Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
list
start_point
list
end_point
list
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
test_restoring_devices
(hass)
Test restoring existing device_tracker entities if not detected on startup.
Test restoring existing device_tracker entities if not detected on startup.
async def test_restoring_devices(hass): """Test restoring existing device_tracker entities if not detected on startup.""" config_entry = MockConfigEntry( domain=mikrotik.DOMAIN, data=MOCK_DATA, options=MOCK_OPTIONS ) config_entry.add_to_hass(hass) registry = await entity_registry.async_get_...
[ "async", "def", "test_restoring_devices", "(", "hass", ")", ":", "config_entry", "=", "MockConfigEntry", "(", "domain", "=", "mikrotik", ".", "DOMAIN", ",", "data", "=", "MOCK_DATA", ",", "options", "=", "MOCK_OPTIONS", ")", "config_entry", ".", "add_to_hass", ...
[ 86, 0 ]
[ 117, 39 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the Fibaro controller devices.
Set up the Fibaro controller devices.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Fibaro controller devices.""" if discovery_info is None: return add_entities( [FibaroSensor(device) for device in hass.data[FIBARO_DEVICES]["sensor"]], True )
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "if", "discovery_info", "is", "None", ":", "return", "add_entities", "(", "[", "FibaroSensor", "(", "device", ")", "for", "device", "in", ...
[ 40, 0 ]
[ 47, 5 ]
python
en
['en', 'en', 'en']
True
FibaroSensor.__init__
(self, fibaro_device)
Initialize the sensor.
Initialize the sensor.
def __init__(self, fibaro_device): """Initialize the sensor.""" self.current_value = None self.last_changed_time = None super().__init__(fibaro_device) self.entity_id = f"{DOMAIN}.{self.ha_id}" if fibaro_device.type in SENSOR_TYPES: self._unit = SENSOR_TYPES[f...
[ "def", "__init__", "(", "self", ",", "fibaro_device", ")", ":", "self", ".", "current_value", "=", "None", "self", ".", "last_changed_time", "=", "None", "super", "(", ")", ".", "__init__", "(", "fibaro_device", ")", "self", ".", "entity_id", "=", "f\"{DOM...
[ 53, 4 ]
[ 78, 16 ]
python
en
['en', 'en', 'en']
True
FibaroSensor.state
(self)
Return the state of the sensor.
Return the state of the sensor.
def state(self): """Return the state of the sensor.""" return self.current_value
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "current_value" ]
[ 81, 4 ]
[ 83, 33 ]
python
en
['en', 'en', 'en']
True
FibaroSensor.unit_of_measurement
(self)
Return the unit of measurement of this entity, if any.
Return the unit of measurement of this entity, if any.
def unit_of_measurement(self): """Return the unit of measurement of this entity, if any.""" return self._unit
[ "def", "unit_of_measurement", "(", "self", ")", ":", "return", "self", ".", "_unit" ]
[ 86, 4 ]
[ 88, 25 ]
python
en
['en', 'en', 'en']
True
FibaroSensor.icon
(self)
Icon to use in the frontend, if any.
Icon to use in the frontend, if any.
def icon(self): """Icon to use in the frontend, if any.""" return self._icon
[ "def", "icon", "(", "self", ")", ":", "return", "self", ".", "_icon" ]
[ 91, 4 ]
[ 93, 25 ]
python
en
['en', 'en', 'en']
True
FibaroSensor.device_class
(self)
Return the device class of the sensor.
Return the device class of the sensor.
def device_class(self): """Return the device class of the sensor.""" return self._device_class
[ "def", "device_class", "(", "self", ")", ":", "return", "self", ".", "_device_class" ]
[ 96, 4 ]
[ 98, 33 ]
python
en
['en', 'en', 'en']
True
FibaroSensor.update
(self)
Update the state.
Update the state.
def update(self): """Update the state.""" try: self.current_value = float(self.fibaro_device.properties.value) except (KeyError, ValueError): pass
[ "def", "update", "(", "self", ")", ":", "try", ":", "self", ".", "current_value", "=", "float", "(", "self", ".", "fibaro_device", ".", "properties", ".", "value", ")", "except", "(", "KeyError", ",", "ValueError", ")", ":", "pass" ]
[ 100, 4 ]
[ 105, 16 ]
python
en
['en', 'en', 'en']
True
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Set up the mysensors platform for binary sensors.
Set up the mysensors platform for binary sensors.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the mysensors platform for binary sensors.""" mysensors.setup_mysensors_platform( hass, DOMAIN, discovery_info, MySensorsBinarySensor, async_add_entities=async_add_entities, ...
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "mysensors", ".", "setup_mysensors_platform", "(", "hass", ",", "DOMAIN", ",", "discovery_info", ",", "MySensorsBinarySensor"...
[ 26, 0 ]
[ 34, 5 ]
python
en
['en', 'da', 'en']
True
MySensorsBinarySensor.is_on
(self)
Return True if the binary sensor is on.
Return True if the binary sensor is on.
def is_on(self): """Return True if the binary sensor is on.""" return self._values.get(self.value_type) == STATE_ON
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_values", ".", "get", "(", "self", ".", "value_type", ")", "==", "STATE_ON" ]
[ 41, 4 ]
[ 43, 60 ]
python
en
['en', 'fy', 'en']
True
MySensorsBinarySensor.device_class
(self)
Return the class of this sensor, from DEVICE_CLASSES.
Return the class of this sensor, from DEVICE_CLASSES.
def device_class(self): """Return the class of this sensor, from DEVICE_CLASSES.""" pres = self.gateway.const.Presentation device_class = SENSORS.get(pres(self.child_type).name) if device_class in DEVICE_CLASSES: return device_class return None
[ "def", "device_class", "(", "self", ")", ":", "pres", "=", "self", ".", "gateway", ".", "const", ".", "Presentation", "device_class", "=", "SENSORS", ".", "get", "(", "pres", "(", "self", ".", "child_type", ")", ".", "name", ")", "if", "device_class", ...
[ 46, 4 ]
[ 52, 19 ]
python
en
['en', 'en', 'en']
True
test_bridge_import_flow
(hass)
Test a bridge entry gets created and set up during the import flow.
Test a bridge entry gets created and set up during the import flow.
async def test_bridge_import_flow(hass): """Test a bridge entry gets created and set up during the import flow.""" entry_mock_data = { CONF_HOST: "1.1.1.1", CONF_KEYFILE: "", CONF_CERTFILE: "", CONF_CA_CERTS: "", } with patch( "homeassistant.components.lutron_ca...
[ "async", "def", "test_bridge_import_flow", "(", "hass", ")", ":", "entry_mock_data", "=", "{", "CONF_HOST", ":", "\"1.1.1.1\"", ",", "CONF_KEYFILE", ":", "\"\"", ",", "CONF_CERTFILE", ":", "\"\"", ",", "CONF_CA_CERTS", ":", "\"\"", ",", "}", "with", "patch", ...
[ 41, 0 ]
[ 71, 48 ]
python
en
['en', 'en', 'en']
True
test_bridge_cannot_connect
(hass)
Test checking for connection and cannot_connect error.
Test checking for connection and cannot_connect error.
async def test_bridge_cannot_connect(hass): """Test checking for connection and cannot_connect error.""" entry_mock_data = { CONF_HOST: "not.a.valid.host", CONF_KEYFILE: "", CONF_CERTFILE: "", CONF_CA_CERTS: "", } with patch.object(Smartbridge, "create_tls") as create_t...
[ "async", "def", "test_bridge_cannot_connect", "(", "hass", ")", ":", "entry_mock_data", "=", "{", "CONF_HOST", ":", "\"not.a.valid.host\"", ",", "CONF_KEYFILE", ":", "\"\"", ",", "CONF_CERTFILE", ":", "\"\"", ",", "CONF_CA_CERTS", ":", "\"\"", ",", "}", "with", ...
[ 74, 0 ]
[ 100, 75 ]
python
en
['en', 'en', 'en']
True
test_bridge_cannot_connect_unknown_error
(hass)
Test checking for connection and encountering an unknown error.
Test checking for connection and encountering an unknown error.
async def test_bridge_cannot_connect_unknown_error(hass): """Test checking for connection and encountering an unknown error.""" entry_mock_data = { CONF_HOST: "", CONF_KEYFILE: "", CONF_CERTFILE: "", CONF_CA_CERTS: "", } with patch.object(Smartbridge, "create_tls") as c...
[ "async", "def", "test_bridge_cannot_connect_unknown_error", "(", "hass", ")", ":", "entry_mock_data", "=", "{", "CONF_HOST", ":", "\"\"", ",", "CONF_KEYFILE", ":", "\"\"", ",", "CONF_CERTFILE", ":", "\"\"", ",", "CONF_CA_CERTS", ":", "\"\"", ",", "}", "with", ...
[ 103, 0 ]
[ 130, 75 ]
python
en
['en', 'en', 'en']
True
test_duplicate_bridge_import
(hass)
Test that creating a bridge entry with a duplicate host errors.
Test that creating a bridge entry with a duplicate host errors.
async def test_duplicate_bridge_import(hass): """Test that creating a bridge entry with a duplicate host errors.""" entry_mock_data = { CONF_HOST: "1.1.1.1", CONF_KEYFILE: "", CONF_CERTFILE: "", CONF_CA_CERTS: "", } mock_entry = MockConfigEntry(domain=DOMAIN, data=entry_...
[ "async", "def", "test_duplicate_bridge_import", "(", "hass", ")", ":", "entry_mock_data", "=", "{", "CONF_HOST", ":", "\"1.1.1.1\"", ",", "CONF_KEYFILE", ":", "\"\"", ",", "CONF_CERTFILE", ":", "\"\"", ",", "CONF_CA_CERTS", ":", "\"\"", ",", "}", "mock_entry", ...
[ 133, 0 ]
[ 158, 48 ]
python
en
['en', 'en', 'en']
True
MockBridge.__init__
(self, can_connect=True)
Initialize MockBridge instance with configured mock connectivity.
Initialize MockBridge instance with configured mock connectivity.
def __init__(self, can_connect=True): """Initialize MockBridge instance with configured mock connectivity.""" self.can_connect = can_connect self.is_currently_connected = False
[ "def", "__init__", "(", "self", ",", "can_connect", "=", "True", ")", ":", "self", ".", "can_connect", "=", "can_connect", "self", ".", "is_currently_connected", "=", "False" ]
[ 22, 4 ]
[ 25, 43 ]
python
en
['en', 'zu', 'en']
True
MockBridge.connect
(self)
Connect the mock bridge.
Connect the mock bridge.
async def connect(self): """Connect the mock bridge.""" if self.can_connect: self.is_currently_connected = True
[ "async", "def", "connect", "(", "self", ")", ":", "if", "self", ".", "can_connect", ":", "self", ".", "is_currently_connected", "=", "True" ]
[ 27, 4 ]
[ 30, 46 ]
python
en
['en', 'fr', 'en']
True
MockBridge.is_connected
(self)
Return whether the mock bridge is connected.
Return whether the mock bridge is connected.
def is_connected(self): """Return whether the mock bridge is connected.""" return self.is_currently_connected
[ "def", "is_connected", "(", "self", ")", ":", "return", "self", ".", "is_currently_connected" ]
[ 32, 4 ]
[ 34, 42 ]
python
en
['en', 'en', 'en']
True
MockBridge.close
(self)
Close the mock bridge connection.
Close the mock bridge connection.
async def close(self): """Close the mock bridge connection.""" self.is_currently_connected = False
[ "async", "def", "close", "(", "self", ")", ":", "self", ".", "is_currently_connected", "=", "False" ]
[ 36, 4 ]
[ 38, 43 ]
python
en
['en', 'fr', 'en']
True
HDEntity.__init__
(self, coordinator, device_info, unique_id)
Initialize the entity.
Initialize the entity.
def __init__(self, coordinator, device_info, unique_id): """Initialize the entity.""" super().__init__(coordinator) self._unique_id = unique_id self._device_info = device_info
[ "def", "__init__", "(", "self", ",", "coordinator", ",", "device_info", ",", "unique_id", ")", ":", "super", "(", ")", ".", "__init__", "(", "coordinator", ")", "self", ".", "_unique_id", "=", "unique_id", "self", ".", "_device_info", "=", "device_info" ]
[ 25, 4 ]
[ 29, 39 ]
python
en
['en', 'en', 'en']
True
HDEntity.unique_id
(self)
Return the unique id.
Return the unique id.
def unique_id(self): """Return the unique id.""" return self._unique_id
[ "def", "unique_id", "(", "self", ")", ":", "return", "self", ".", "_unique_id" ]
[ 32, 4 ]
[ 34, 30 ]
python
en
['en', 'la', 'en']
True
HDEntity.device_info
(self)
Return the device_info of the device.
Return the device_info of the device.
def device_info(self): """Return the device_info of the device.""" firmware = self._device_info[DEVICE_FIRMWARE] sw_version = f"{firmware[FIRMWARE_REVISION]}.{firmware[FIRMWARE_SUB_REVISION]}.{firmware[FIRMWARE_BUILD]}" return { "identifiers": {(DOMAIN, self._device_info[DEVI...
[ "def", "device_info", "(", "self", ")", ":", "firmware", "=", "self", ".", "_device_info", "[", "DEVICE_FIRMWARE", "]", "sw_version", "=", "f\"{firmware[FIRMWARE_REVISION]}.{firmware[FIRMWARE_SUB_REVISION]}.{firmware[FIRMWARE_BUILD]}\"", "return", "{", "\"identifiers\"", ":",...
[ 37, 4 ]
[ 50, 9 ]
python
en
['en', 'en', 'en']
True
ShadeEntity.__init__
(self, coordinator, device_info, shade, shade_name)
Initialize the shade.
Initialize the shade.
def __init__(self, coordinator, device_info, shade, shade_name): """Initialize the shade.""" super().__init__(coordinator, device_info, shade.id) self._shade_name = shade_name self._shade = shade
[ "def", "__init__", "(", "self", ",", "coordinator", ",", "device_info", ",", "shade", ",", "shade_name", ")", ":", "super", "(", ")", ".", "__init__", "(", "coordinator", ",", "device_info", ",", "shade", ".", "id", ")", "self", ".", "_shade_name", "=", ...
[ 56, 4 ]
[ 60, 27 ]
python
en
['en', 'en', 'en']
True
ShadeEntity.device_info
(self)
Return the device_info of the device.
Return the device_info of the device.
def device_info(self): """Return the device_info of the device.""" device_info = { "identifiers": {(DOMAIN, self._shade.id)}, "name": self._shade_name, "manufacturer": MANUFACTURER, "via_device": (DOMAIN, self._device_info[DEVICE_SERIAL_NUMBER]), ...
[ "def", "device_info", "(", "self", ")", ":", "device_info", "=", "{", "\"identifiers\"", ":", "{", "(", "DOMAIN", ",", "self", ".", "_shade", ".", "id", ")", "}", ",", "\"name\"", ":", "self", ".", "_shade_name", ",", "\"manufacturer\"", ":", "MANUFACTUR...
[ 63, 4 ]
[ 86, 26 ]
python
en
['en', 'en', 'en']
True
test_component_unload_config_entry
(hass, config_entry)
Test that loading and unloading of a config entry works.
Test that loading and unloading of a config entry works.
async def test_component_unload_config_entry(hass, config_entry): """Test that loading and unloading of a config entry works.""" config_entry.add_to_hass(hass) with patch( "aio_geojson_geonetnz_volcano.GeonetnzVolcanoFeedManager.update", new_callable=AsyncMock, ) as mock_feed_manager_upd...
[ "async", "def", "test_component_unload_config_entry", "(", "hass", ",", "config_entry", ")", ":", "config_entry", ".", "add_to_hass", "(", "hass", ")", "with", "patch", "(", "\"aio_geojson_geonetnz_volcano.GeonetnzVolcanoFeedManager.update\"", ",", "new_callable", "=", "A...
[ 6, 0 ]
[ 21, 73 ]
python
en
['en', 'en', 'en']
True
test_valid_state
(hass, requests_mock)
Test for operational london_air sensor with proper attributes.
Test for operational london_air sensor with proper attributes.
async def test_valid_state(hass, requests_mock): """Test for operational london_air sensor with proper attributes.""" requests_mock.get(URL, text=load_fixture("london_air.json"), status_code=HTTP_OK) assert await async_setup_component(hass, "sensor", VALID_CONFIG) await hass.async_block_till_done() ...
[ "async", "def", "test_valid_state", "(", "hass", ",", "requests_mock", ")", ":", "requests_mock", ".", "get", "(", "URL", ",", "text", "=", "load_fixture", "(", "\"london_air.json\"", ")", ",", "status_code", "=", "HTTP_OK", ")", "assert", "await", "async_setu...
[ 10, 0 ]
[ 38, 52 ]
python
en
['en', 'en', 'en']
True
test_api_failure
(hass, requests_mock)
Test for failure in the API.
Test for failure in the API.
async def test_api_failure(hass, requests_mock): """Test for failure in the API.""" requests_mock.get(URL, status_code=HTTP_SERVICE_UNAVAILABLE) assert await async_setup_component(hass, "sensor", VALID_CONFIG) await hass.async_block_till_done() state = hass.states.get("sensor.merton") assert st...
[ "async", "def", "test_api_failure", "(", "hass", ",", "requests_mock", ")", ":", "requests_mock", ".", "get", "(", "URL", ",", "status_code", "=", "HTTP_SERVICE_UNAVAILABLE", ")", "assert", "await", "async_setup_component", "(", "hass", ",", "\"sensor\"", ",", "...
[ 41, 0 ]
[ 50, 41 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, config_entry, async_add_entities)
Set up a BleBox climate entity.
Set up a BleBox climate entity.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up a BleBox climate entity.""" create_blebox_entities( hass, config_entry, async_add_entities, BleBoxClimateEntity, "climates" )
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "create_blebox_entities", "(", "hass", ",", "config_entry", ",", "async_add_entities", ",", "BleBoxClimateEntity", ",", "\"climates\"", ")" ]
[ 16, 0 ]
[ 21, 5 ]
python
en
['en', 'hu', 'en']
True
BleBoxClimateEntity.supported_features
(self)
Return the supported climate features.
Return the supported climate features.
def supported_features(self): """Return the supported climate features.""" return SUPPORT_TARGET_TEMPERATURE
[ "def", "supported_features", "(", "self", ")", ":", "return", "SUPPORT_TARGET_TEMPERATURE" ]
[ 28, 4 ]
[ 30, 41 ]
python
en
['en', 'en', 'en']
True
BleBoxClimateEntity.hvac_mode
(self)
Return the desired HVAC mode.
Return the desired HVAC mode.
def hvac_mode(self): """Return the desired HVAC mode.""" if self._feature.is_on is None: return None return HVAC_MODE_HEAT if self._feature.is_on else HVAC_MODE_OFF
[ "def", "hvac_mode", "(", "self", ")", ":", "if", "self", ".", "_feature", ".", "is_on", "is", "None", ":", "return", "None", "return", "HVAC_MODE_HEAT", "if", "self", ".", "_feature", ".", "is_on", "else", "HVAC_MODE_OFF" ]
[ 33, 4 ]
[ 38, 71 ]
python
en
['en', 'no', 'en']
True
BleBoxClimateEntity.hvac_action
(self)
Return the actual current HVAC action.
Return the actual current HVAC action.
def hvac_action(self): """Return the actual current HVAC action.""" is_on = self._feature.is_on if not is_on: return None if is_on is None else CURRENT_HVAC_OFF # NOTE: In practice, there's no need to handle case when is_heating is None return CURRENT_HVAC_HEAT if se...
[ "def", "hvac_action", "(", "self", ")", ":", "is_on", "=", "self", ".", "_feature", ".", "is_on", "if", "not", "is_on", ":", "return", "None", "if", "is_on", "is", "None", "else", "CURRENT_HVAC_OFF", "# NOTE: In practice, there's no need to handle case when is_heati...
[ 41, 4 ]
[ 48, 83 ]
python
en
['en', 'en', 'en']
True
BleBoxClimateEntity.hvac_modes
(self)
Return a list of possible HVAC modes.
Return a list of possible HVAC modes.
def hvac_modes(self): """Return a list of possible HVAC modes.""" return [HVAC_MODE_OFF, HVAC_MODE_HEAT]
[ "def", "hvac_modes", "(", "self", ")", ":", "return", "[", "HVAC_MODE_OFF", ",", "HVAC_MODE_HEAT", "]" ]
[ 51, 4 ]
[ 53, 46 ]
python
en
['en', 'en', 'en']
True
BleBoxClimateEntity.temperature_unit
(self)
Return the temperature unit.
Return the temperature unit.
def temperature_unit(self): """Return the temperature unit.""" return TEMP_CELSIUS
[ "def", "temperature_unit", "(", "self", ")", ":", "return", "TEMP_CELSIUS" ]
[ 56, 4 ]
[ 58, 27 ]
python
en
['en', 'la', 'en']
True
BleBoxClimateEntity.max_temp
(self)
Return the maximum temperature supported.
Return the maximum temperature supported.
def max_temp(self): """Return the maximum temperature supported.""" return self._feature.max_temp
[ "def", "max_temp", "(", "self", ")", ":", "return", "self", ".", "_feature", ".", "max_temp" ]
[ 61, 4 ]
[ 63, 37 ]
python
en
['en', 'la', 'en']
True
BleBoxClimateEntity.min_temp
(self)
Return the maximum temperature supported.
Return the maximum temperature supported.
def min_temp(self): """Return the maximum temperature supported.""" return self._feature.min_temp
[ "def", "min_temp", "(", "self", ")", ":", "return", "self", ".", "_feature", ".", "min_temp" ]
[ 66, 4 ]
[ 68, 37 ]
python
en
['en', 'la', 'en']
True
BleBoxClimateEntity.current_temperature
(self)
Return the current temperature.
Return the current temperature.
def current_temperature(self): """Return the current temperature.""" return self._feature.current
[ "def", "current_temperature", "(", "self", ")", ":", "return", "self", ".", "_feature", ".", "current" ]
[ 71, 4 ]
[ 73, 36 ]
python
en
['en', 'la', 'en']
True
BleBoxClimateEntity.target_temperature
(self)
Return the desired thermostat temperature.
Return the desired thermostat temperature.
def target_temperature(self): """Return the desired thermostat temperature.""" return self._feature.desired
[ "def", "target_temperature", "(", "self", ")", ":", "return", "self", ".", "_feature", ".", "desired" ]
[ 76, 4 ]
[ 78, 36 ]
python
en
['en', 'en', 'en']
True
BleBoxClimateEntity.async_set_hvac_mode
(self, hvac_mode)
Set the climate entity mode.
Set the climate entity mode.
async def async_set_hvac_mode(self, hvac_mode): """Set the climate entity mode.""" if hvac_mode == HVAC_MODE_HEAT: await self._feature.async_on() return await self._feature.async_off()
[ "async", "def", "async_set_hvac_mode", "(", "self", ",", "hvac_mode", ")", ":", "if", "hvac_mode", "==", "HVAC_MODE_HEAT", ":", "await", "self", ".", "_feature", ".", "async_on", "(", ")", "return", "await", "self", ".", "_feature", ".", "async_off", "(", ...
[ 80, 4 ]
[ 86, 39 ]
python
en
['en', 'en', 'en']
True
BleBoxClimateEntity.async_set_temperature
(self, **kwargs)
Set the thermostat temperature.
Set the thermostat temperature.
async def async_set_temperature(self, **kwargs): """Set the thermostat temperature.""" value = kwargs[ATTR_TEMPERATURE] await self._feature.async_set_temperature(value)
[ "async", "def", "async_set_temperature", "(", "self", ",", "*", "*", "kwargs", ")", ":", "value", "=", "kwargs", "[", "ATTR_TEMPERATURE", "]", "await", "self", ".", "_feature", ".", "async_set_temperature", "(", "value", ")" ]
[ 88, 4 ]
[ 91, 56 ]
python
en
['en', 'la', 'en']
True
update_vocabulary
(vocab, file_name, is_dict=False)
Read text and return dictionary that encodes vocabulary
Read text and return dictionary that encodes vocabulary
def update_vocabulary(vocab, file_name, is_dict=False): """Read text and return dictionary that encodes vocabulary """ #vocab = Counter() with codecs.open(file_name, encoding='utf-8') as fobj: for i, line in enumerate(fobj): if is_dict: try: word,...
[ "def", "update_vocabulary", "(", "vocab", ",", "file_name", ",", "is_dict", "=", "False", ")", ":", "#vocab = Counter()", "with", "codecs", ".", "open", "(", "file_name", ",", "encoding", "=", "'utf-8'", ")", "as", "fobj", ":", "for", "i", ",", "line", "...
[ 25, 0 ]
[ 43, 16 ]
python
en
['en', 'en', 'en']
True
update_pair_statistics
(pair, changed, stats, indices)
Minimally update the indices and frequency of symbol pairs if we merge a pair of symbols, only pairs that overlap with occurrences of this pair are affected, and need to be updated.
Minimally update the indices and frequency of symbol pairs
def update_pair_statistics(pair, changed, stats, indices): """Minimally update the indices and frequency of symbol pairs if we merge a pair of symbols, only pairs that overlap with occurrences of this pair are affected, and need to be updated. """ stats[pair] = 0 indices[pair] = defaultdict(int...
[ "def", "update_pair_statistics", "(", "pair", ",", "changed", ",", "stats", ",", "indices", ")", ":", "stats", "[", "pair", "]", "=", "0", "indices", "[", "pair", "]", "=", "defaultdict", "(", "int", ")", "first", ",", "second", "=", "pair", "new_pair"...
[ 46, 0 ]
[ 102, 18 ]
python
en
['en', 'en', 'en']
True
get_pair_statistics
(vocab)
Count frequency of all symbol pairs, and create index
Count frequency of all symbol pairs, and create index
def get_pair_statistics(vocab): """Count frequency of all symbol pairs, and create index""" # data structure of pair frequencies stats = defaultdict(int) #index from pairs to words indices = defaultdict(lambda: defaultdict(int)) for i, (word, freq) in enumerate(vocab): prev_char = wor...
[ "def", "get_pair_statistics", "(", "vocab", ")", ":", "# data structure of pair frequencies", "stats", "=", "defaultdict", "(", "int", ")", "#index from pairs to words", "indices", "=", "defaultdict", "(", "lambda", ":", "defaultdict", "(", "int", ")", ")", "for", ...
[ 105, 0 ]
[ 121, 25 ]
python
en
['en', 'en', 'en']
True
replace_pair
(pair, vocab, indices)
Replace all occurrences of a symbol pair ('A', 'B') with a new symbol 'AB
Replace all occurrences of a symbol pair ('A', 'B') with a new symbol 'AB
def replace_pair(pair, vocab, indices): """Replace all occurrences of a symbol pair ('A', 'B') with a new symbol 'AB'""" first, second = pair pair_str = ''.join(pair) pair_str = pair_str.replace('\\','\\\\') changes = [] pattern = re.compile(r'(?<!\S)' + re.escape(first + ' ' + second) + r'(?!\S...
[ "def", "replace_pair", "(", "pair", ",", "vocab", ",", "indices", ")", ":", "first", ",", "second", "=", "pair", "pair_str", "=", "''", ".", "join", "(", "pair", ")", "pair_str", "=", "pair_str", ".", "replace", "(", "'\\\\'", ",", "'\\\\\\\\'", ")", ...
[ 124, 0 ]
[ 146, 18 ]
python
en
['en', 'en', 'en']
True
prune_stats
(stats, big_stats, threshold)
Prune statistics dict for efficiency of max() The frequency of a symbol pair never increases, so pruning is generally safe (until we the most frequent pair is less frequent than a pair we previously pruned) big_stats keeps full statistics for when we need to access pruned items
Prune statistics dict for efficiency of max()
def prune_stats(stats, big_stats, threshold): """Prune statistics dict for efficiency of max() The frequency of a symbol pair never increases, so pruning is generally safe (until we the most frequent pair is less frequent than a pair we previously pruned) big_stats keeps full statistics for when we nee...
[ "def", "prune_stats", "(", "stats", ",", "big_stats", ",", "threshold", ")", ":", "for", "item", ",", "freq", "in", "list", "(", "stats", ".", "items", "(", ")", ")", ":", "if", "freq", "<", "threshold", ":", "del", "stats", "[", "item", "]", "if",...
[ 148, 0 ]
[ 161, 38 ]
python
en
['en', 'en', 'en']
True
learn_bpe
(infile_names, outfile_name, num_symbols, min_frequency=2, verbose=False, is_dict=False, total_symbols=False)
Learn num_symbols BPE operations from vocabulary, and write to outfile.
Learn num_symbols BPE operations from vocabulary, and write to outfile.
def learn_bpe(infile_names, outfile_name, num_symbols, min_frequency=2, verbose=False, is_dict=False, total_symbols=False): """Learn num_symbols BPE operations from vocabulary, and write to outfile. """ sys.stderr = codecs.getwriter('UTF-8')(sys.stderr.buffer) sys.stdout = codecs.getwriter('UTF-8')(sys....
[ "def", "learn_bpe", "(", "infile_names", ",", "outfile_name", ",", "num_symbols", ",", "min_frequency", "=", "2", ",", "verbose", "=", "False", ",", "is_dict", "=", "False", ",", "total_symbols", "=", "False", ")", ":", "sys", ".", "stderr", "=", "codecs",...
[ 164, 0 ]
[ 229, 56 ]
python
en
['en', 'en', 'en']
True
test_load_from_storage
(hass, hass_storage)
Test that entity map can be correctly loaded from cache.
Test that entity map can be correctly loaded from cache.
async def test_load_from_storage(hass, hass_storage): """Test that entity map can be correctly loaded from cache.""" hkid = "00:00:00:00:00:00" hass_storage["homekit_controller-entity-map"] = { "version": 1, "data": {"pairings": {hkid: {"c#": 1, "accessories": []}}}, } await setup_...
[ "async", "def", "test_load_from_storage", "(", "hass", ",", "hass_storage", ")", ":", "hkid", "=", "\"00:00:00:00:00:00\"", "hass_storage", "[", "\"homekit_controller-entity-map\"", "]", "=", "{", "\"version\"", ":", "1", ",", "\"data\"", ":", "{", "\"pairings\"", ...
[ 15, 0 ]
[ 25, 53 ]
python
en
['en', 'en', 'en']
True
test_storage_is_removed
(hass, hass_storage)
Test entity map storage removal is idempotent.
Test entity map storage removal is idempotent.
async def test_storage_is_removed(hass, hass_storage): """Test entity map storage removal is idempotent.""" await setup_platform(hass) entity_map = hass.data[ENTITY_MAP] hkid = "00:00:00:00:00:01" entity_map.async_create_or_update_map(hkid, 1, []) assert hkid in entity_map.storage_data awa...
[ "async", "def", "test_storage_is_removed", "(", "hass", ",", "hass_storage", ")", ":", "await", "setup_platform", "(", "hass", ")", "entity_map", "=", "hass", ".", "data", "[", "ENTITY_MAP", "]", "hkid", "=", "\"00:00:00:00:00:01\"", "entity_map", ".", "async_cr...
[ 28, 0 ]
[ 44, 61 ]
python
en
['en', 'en', 'en']
True
test_storage_is_removed_idempotent
(hass)
Test entity map storage removal is idempotent.
Test entity map storage removal is idempotent.
async def test_storage_is_removed_idempotent(hass): """Test entity map storage removal is idempotent.""" await setup_platform(hass) entity_map = hass.data[ENTITY_MAP] hkid = "00:00:00:00:00:01" assert hkid not in entity_map.storage_data entity_map.async_delete_map(hkid) assert hkid not i...
[ "async", "def", "test_storage_is_removed_idempotent", "(", "hass", ")", ":", "await", "setup_platform", "(", "hass", ")", "entity_map", "=", "hass", ".", "data", "[", "ENTITY_MAP", "]", "hkid", "=", "\"00:00:00:00:00:01\"", "assert", "hkid", "not", "in", "entity...
[ 47, 0 ]
[ 58, 46 ]
python
en
['en', 'en', 'en']
True
create_lightbulb_service
(accessory)
Define lightbulb characteristics.
Define lightbulb characteristics.
def create_lightbulb_service(accessory): """Define lightbulb characteristics.""" service = accessory.add_service(ServicesTypes.LIGHTBULB) on_char = service.add_char(CharacteristicsTypes.ON) on_char.value = 0
[ "def", "create_lightbulb_service", "(", "accessory", ")", ":", "service", "=", "accessory", ".", "add_service", "(", "ServicesTypes", ".", "LIGHTBULB", ")", "on_char", "=", "service", ".", "add_char", "(", "CharacteristicsTypes", ".", "ON", ")", "on_char", ".", ...
[ 61, 0 ]
[ 65, 21 ]
python
en
['en', 'bg', 'en']
True
test_storage_is_updated_on_add
(hass, hass_storage, utcnow)
Test entity map storage is cleaned up on adding an accessory.
Test entity map storage is cleaned up on adding an accessory.
async def test_storage_is_updated_on_add(hass, hass_storage, utcnow): """Test entity map storage is cleaned up on adding an accessory.""" await setup_test_component(hass, create_lightbulb_service) entity_map = hass.data[ENTITY_MAP] hkid = "00:00:00:00:00:00" # Is in memory store updated? asser...
[ "async", "def", "test_storage_is_updated_on_add", "(", "hass", ",", "hass_storage", ",", "utcnow", ")", ":", "await", "setup_test_component", "(", "hass", ",", "create_lightbulb_service", ")", "entity_map", "=", "hass", ".", "data", "[", "ENTITY_MAP", "]", "hkid",...
[ 68, 0 ]
[ 80, 63 ]
python
en
['en', 'en', 'en']
True
test_storage_is_removed_on_config_entry_removal
(hass, utcnow)
Test entity map storage is cleaned up on config entry removal.
Test entity map storage is cleaned up on config entry removal.
async def test_storage_is_removed_on_config_entry_removal(hass, utcnow): """Test entity map storage is cleaned up on config entry removal.""" await setup_test_component(hass, create_lightbulb_service) hkid = "00:00:00:00:00:00" pairing_data = {"AccessoryPairingID": hkid} entry = config_entries.Co...
[ "async", "def", "test_storage_is_removed_on_config_entry_removal", "(", "hass", ",", "utcnow", ")", ":", "await", "setup_test_component", "(", "hass", ",", "create_lightbulb_service", ")", "hkid", "=", "\"00:00:00:00:00:00\"", "pairing_data", "=", "{", "\"AccessoryPairing...
[ 83, 0 ]
[ 105, 57 ]
python
en
['en', 'en', 'en']
True
test_form_source_user
(hass)
Test we get config flow setup form as a user.
Test we get config flow setup form as a user.
async def test_form_source_user(hass): """Test we get config flow setup form as a user.""" await setup.async_setup_component(hass, "persistent_notification", {}) result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) assert result["type"]...
[ "async", "def", "test_form_source_user", "(", "hass", ")", ":", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"persistent_notification\"", ",", "{", "}", ")", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async...
[ 13, 0 ]
[ 43, 48 ]
python
en
['en', 'da', 'en']
True
test_form_source_import
(hass)
Test we setup the config entry via import.
Test we setup the config entry via import.
async def test_form_source_import(hass): """Test we setup the config entry via import.""" await setup.async_setup_component(hass, "persistent_notification", {}) mock_powerwall = await _mock_powerwall_site_name(hass, "Imported site") with patch( "homeassistant.components.powerwall.config_flow.Po...
[ "async", "def", "test_form_source_import", "(", "hass", ")", ":", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"persistent_notification\"", ",", "{", "}", ")", "mock_powerwall", "=", "await", "_mock_powerwall_site_name", "(", "hass", ",", "\...
[ 46, 0 ]
[ 71, 48 ]
python
en
['en', 'pt', 'en']
True
test_form_cannot_connect
(hass)
Test we handle cannot connect error.
Test we handle cannot connect error.
async def test_form_cannot_connect(hass): """Test we handle cannot connect error.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) mock_powerwall = _mock_powerwall_side_effect(site_info=PowerwallUnreachableError) with patch( ...
[ "async", "def", "test_form_cannot_connect", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "config_entries", ".", "SOURCE_USER", "}", "...
[ 74, 0 ]
[ 92, 58 ]
python
en
['en', 'en', 'en']
True
test_form_wrong_version
(hass)
Test we can handle wrong version error.
Test we can handle wrong version error.
async def test_form_wrong_version(hass): """Test we can handle wrong version error.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) mock_powerwall = _mock_powerwall_side_effect( site_info=MissingAttributeError({}, "") )...
[ "async", "def", "test_form_wrong_version", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "config_entries", ".", "SOURCE_USER", "}", ")...
[ 95, 0 ]
[ 115, 57 ]
python
en
['nl', 'en', 'en']
True
test_battery_icon
()
Test icon generator for battery sensor.
Test icon generator for battery sensor.
def test_battery_icon(): """Test icon generator for battery sensor.""" from homeassistant.helpers.icon import icon_for_battery_level assert icon_for_battery_level(None, True) == "mdi:battery-unknown" assert icon_for_battery_level(None, False) == "mdi:battery-unknown" assert icon_for_battery_level(...
[ "def", "test_battery_icon", "(", ")", ":", "from", "homeassistant", ".", "helpers", ".", "icon", "import", "icon_for_battery_level", "assert", "icon_for_battery_level", "(", "None", ",", "True", ")", "==", "\"mdi:battery-unknown\"", "assert", "icon_for_battery_level", ...
[ 3, 0 ]
[ 45, 81 ]
python
en
['en', 'no', 'en']
True
test_signal_icon
()
Test icon generator for signal sensor.
Test icon generator for signal sensor.
def test_signal_icon(): """Test icon generator for signal sensor.""" from homeassistant.helpers.icon import icon_for_signal_level assert icon_for_signal_level(None) == "mdi:signal-cellular-outline" assert icon_for_signal_level(0) == "mdi:signal-cellular-outline" assert icon_for_signal_level(5) == "...
[ "def", "test_signal_icon", "(", ")", ":", "from", "homeassistant", ".", "helpers", ".", "icon", "import", "icon_for_signal_level", "assert", "icon_for_signal_level", "(", "None", ")", "==", "\"mdi:signal-cellular-outline\"", "assert", "icon_for_signal_level", "(", "0", ...
[ 48, 0 ]
[ 57, 64 ]
python
en
['en', 'ja', 'en']
True
test_platform_manually_configured
(hass)
Test that we do not discover anything or try to set up a gateway.
Test that we do not discover anything or try to set up a gateway.
async def test_platform_manually_configured(hass): """Test that we do not discover anything or try to set up a gateway.""" assert ( await async_setup_component( hass, SWITCH_DOMAIN, {"switch": {"platform": DECONZ_DOMAIN}} ) is True ) assert DECONZ_DOMAIN not in hass.d...
[ "async", "def", "test_platform_manually_configured", "(", "hass", ")", ":", "assert", "(", "await", "async_setup_component", "(", "hass", ",", "SWITCH_DOMAIN", ",", "{", "\"switch\"", ":", "{", "\"platform\"", ":", "DECONZ_DOMAIN", "}", "}", ")", "is", "True", ...
[ 67, 0 ]
[ 75, 41 ]
python
en
['en', 'en', 'en']
True
test_no_switches
(hass)
Test that no switch entities are created.
Test that no switch entities are created.
async def test_no_switches(hass): """Test that no switch entities are created.""" await setup_deconz_integration(hass) assert len(hass.states.async_all()) == 0
[ "async", "def", "test_no_switches", "(", "hass", ")", ":", "await", "setup_deconz_integration", "(", "hass", ")", "assert", "len", "(", "hass", ".", "states", ".", "async_all", "(", ")", ")", "==", "0" ]
[ 78, 0 ]
[ 81, 44 ]
python
en
['en', 'en', 'en']
True
test_power_plugs
(hass)
Test that all supported switch entities are created.
Test that all supported switch entities are created.
async def test_power_plugs(hass): """Test that all supported switch entities are created.""" data = deepcopy(DECONZ_WEB_REQUEST) data["lights"] = deepcopy(POWER_PLUGS) config_entry = await setup_deconz_integration(hass, get_state_response=data) gateway = get_gateway_from_config_entry(hass, config_en...
[ "async", "def", "test_power_plugs", "(", "hass", ")", ":", "data", "=", "deepcopy", "(", "DECONZ_WEB_REQUEST", ")", "data", "[", "\"lights\"", "]", "=", "deepcopy", "(", "POWER_PLUGS", ")", "config_entry", "=", "await", "setup_deconz_integration", "(", "hass", ...
[ 84, 0 ]
[ 142, 44 ]
python
en
['en', 'en', 'en']
True
test_sirens
(hass)
Test that siren entities are created.
Test that siren entities are created.
async def test_sirens(hass): """Test that siren entities are created.""" data = deepcopy(DECONZ_WEB_REQUEST) data["lights"] = deepcopy(SIRENS) config_entry = await setup_deconz_integration(hass, get_state_response=data) gateway = get_gateway_from_config_entry(hass, config_entry) assert len(hass...
[ "async", "def", "test_sirens", "(", "hass", ")", ":", "data", "=", "deepcopy", "(", "DECONZ_WEB_REQUEST", ")", "data", "[", "\"lights\"", "]", "=", "deepcopy", "(", "SIRENS", ")", "config_entry", "=", "await", "setup_deconz_integration", "(", "hass", ",", "g...
[ 145, 0 ]
[ 205, 44 ]
python
en
['en', 'en', 'en']
True
test_set_username
(hass)
Test we clear config if we set different username.
Test we clear config if we set different username.
async def test_set_username(hass): """Test we clear config if we set different username.""" prefs = CloudPreferences(hass) await prefs.async_initialize() assert prefs.google_enabled await prefs.async_update(google_enabled=False) assert not prefs.google_enabled await prefs.async_set_usern...
[ "async", "def", "test_set_username", "(", "hass", ")", ":", "prefs", "=", "CloudPreferences", "(", "hass", ")", "await", "prefs", ".", "async_initialize", "(", ")", "assert", "prefs", ".", "google_enabled", "await", "prefs", ".", "async_update", "(", "google_e...
[ 7, 0 ]
[ 20, 31 ]
python
en
['nl', 'en', 'en']
True
test_set_username_migration
(hass)
Test we not clear config if we had no username.
Test we not clear config if we had no username.
async def test_set_username_migration(hass): """Test we not clear config if we had no username.""" prefs = CloudPreferences(hass) with patch.object(prefs, "_empty_config", return_value=prefs._empty_config(None)): await prefs.async_initialize() assert prefs.google_enabled await prefs.async...
[ "async", "def", "test_set_username_migration", "(", "hass", ")", ":", "prefs", "=", "CloudPreferences", "(", "hass", ")", "with", "patch", ".", "object", "(", "prefs", ",", "\"_empty_config\"", ",", "return_value", "=", "prefs", ".", "_empty_config", "(", "Non...
[ 23, 0 ]
[ 38, 35 ]
python
en
['en', 'en', 'en']
True
test_load_invalid_cloud_user
(hass, hass_storage)
Test loading cloud user with invalid storage.
Test loading cloud user with invalid storage.
async def test_load_invalid_cloud_user(hass, hass_storage): """Test loading cloud user with invalid storage.""" hass_storage[STORAGE_KEY] = {"version": 1, "data": {"cloud_user": "non-existing"}} prefs = CloudPreferences(hass) await prefs.async_initialize() cloud_user_id = await prefs.get_cloud_use...
[ "async", "def", "test_load_invalid_cloud_user", "(", "hass", ",", "hass_storage", ")", ":", "hass_storage", "[", "STORAGE_KEY", "]", "=", "{", "\"version\"", ":", "1", ",", "\"data\"", ":", "{", "\"cloud_user\"", ":", "\"non-existing\"", "}", "}", "prefs", "="...
[ 41, 0 ]
[ 57, 52 ]
python
en
['en', 'en', 'en']
True
test_setup_remove_cloud_user
(hass, hass_storage)
Test creating and removing cloud user.
Test creating and removing cloud user.
async def test_setup_remove_cloud_user(hass, hass_storage): """Test creating and removing cloud user.""" hass_storage[STORAGE_KEY] = {"version": 1, "data": {"cloud_user": None}} prefs = CloudPreferences(hass) await prefs.async_initialize() await prefs.async_set_username("user1") cloud_user = a...
[ "async", "def", "test_setup_remove_cloud_user", "(", "hass", ",", "hass_storage", ")", ":", "hass_storage", "[", "STORAGE_KEY", "]", "=", "{", "\"version\"", ":", "1", ",", "\"data\"", ":", "{", "\"cloud_user\"", ":", "None", "}", "}", "prefs", "=", "CloudPr...
[ 60, 0 ]
[ 79, 42 ]
python
en
['en', 'en', 'en']
True
test_outlet_set_state
(hass, hk_driver, events)
Test if Outlet accessory and HA are updated accordingly.
Test if Outlet accessory and HA are updated accordingly.
async def test_outlet_set_state(hass, hk_driver, events): """Test if Outlet accessory and HA are updated accordingly.""" entity_id = "switch.outlet_test" hass.states.async_set(entity_id, None) await hass.async_block_till_done() acc = Outlet(hass, hk_driver, "Outlet", entity_id, 2, None) await a...
[ "async", "def", "test_outlet_set_state", "(", "hass", ",", "hk_driver", ",", "events", ")", ":", "entity_id", "=", "\"switch.outlet_test\"", "hass", ".", "states", ".", "async_set", "(", "entity_id", ",", "None", ")", "await", "hass", ".", "async_block_till_done...
[ 32, 0 ]
[ 72, 46 ]
python
en
['en', 'en', 'en']
True
test_switch_set_state
(hass, hk_driver, entity_id, attrs, events)
Test if accessory and HA are updated accordingly.
Test if accessory and HA are updated accordingly.
async def test_switch_set_state(hass, hk_driver, entity_id, attrs, events): """Test if accessory and HA are updated accordingly.""" domain = split_entity_id(entity_id)[0] hass.states.async_set(entity_id, None, attrs) await hass.async_block_till_done() acc = Switch(hass, hk_driver, "Switch", entity_...
[ "async", "def", "test_switch_set_state", "(", "hass", ",", "hk_driver", ",", "entity_id", ",", "attrs", ",", "events", ")", ":", "domain", "=", "split_entity_id", "(", "entity_id", ")", "[", "0", "]", "hass", ".", "states", ".", "async_set", "(", "entity_i...
[ 85, 0 ]
[ 125, 46 ]
python
en
['en', 'en', 'en']
True
test_valve_set_state
(hass, hk_driver, events)
Test if Valve accessory and HA are updated accordingly.
Test if Valve accessory and HA are updated accordingly.
async def test_valve_set_state(hass, hk_driver, events): """Test if Valve accessory and HA are updated accordingly.""" entity_id = "switch.valve_test" hass.states.async_set(entity_id, None) await hass.async_block_till_done() acc = Valve(hass, hk_driver, "Valve", entity_id, 2, {CONF_TYPE: TYPE_FAUC...
[ "async", "def", "test_valve_set_state", "(", "hass", ",", "hk_driver", ",", "events", ")", ":", "entity_id", "=", "\"switch.valve_test\"", "hass", ".", "states", ".", "async_set", "(", "entity_id", ",", "None", ")", "await", "hass", ".", "async_block_till_done",...
[ 128, 0 ]
[ 192, 46 ]
python
en
['en', 'en', 'en']
True
test_vacuum_set_state
(hass, hk_driver, events)
Test if Vacuum accessory and HA are updated accordingly.
Test if Vacuum accessory and HA are updated accordingly.
async def test_vacuum_set_state(hass, hk_driver, events): """Test if Vacuum accessory and HA are updated accordingly.""" entity_id = "vacuum.roomba" hass.states.async_set(entity_id, None) await hass.async_block_till_done() acc = DockVacuum(hass, hk_driver, "DockVacuum", entity_id, 2, None) awa...
[ "async", "def", "test_vacuum_set_state", "(", "hass", ",", "hk_driver", ",", "events", ")", ":", "entity_id", "=", "\"vacuum.roomba\"", "hass", ".", "states", ".", "async_set", "(", "entity_id", ",", "None", ")", "await", "hass", ".", "async_block_till_done", ...
[ 195, 0 ]
[ 238, 46 ]
python
en
['en', 'en', 'en']
True
test_reset_switch
(hass, hk_driver, events)
Test if switch accessory is reset correctly.
Test if switch accessory is reset correctly.
async def test_reset_switch(hass, hk_driver, events): """Test if switch accessory is reset correctly.""" domain = "scene" entity_id = "scene.test" hass.states.async_set(entity_id, None) await hass.async_block_till_done() acc = Switch(hass, hk_driver, "Switch", entity_id, 2, None) await acc....
[ "async", "def", "test_reset_switch", "(", "hass", ",", "hk_driver", ",", "events", ")", ":", "domain", "=", "\"scene\"", "entity_id", "=", "\"scene.test\"", "hass", ".", "states", ".", "async_set", "(", "entity_id", ",", "None", ")", "await", "hass", ".", ...
[ 241, 0 ]
[ 276, 27 ]
python
en
['en', 'en', 'en']
True
test_reset_switch_reload
(hass, hk_driver, events)
Test reset switch after script reload.
Test reset switch after script reload.
async def test_reset_switch_reload(hass, hk_driver, events): """Test reset switch after script reload.""" entity_id = "script.test" hass.states.async_set(entity_id, None) await hass.async_block_till_done() acc = Switch(hass, hk_driver, "Switch", entity_id, 2, None) await acc.run_handler() a...
[ "async", "def", "test_reset_switch_reload", "(", "hass", ",", "hk_driver", ",", "events", ")", ":", "entity_id", "=", "\"script.test\"", "hass", ".", "states", ".", "async_set", "(", "entity_id", ",", "None", ")", "await", "hass", ".", "async_block_till_done", ...
[ 279, 0 ]
[ 293, 37 ]
python
en
['en', 'en', 'en']
True
config_schema_validate
(withings_config)
Assert a schema config succeeds.
Assert a schema config succeeds.
def config_schema_validate(withings_config) -> dict: """Assert a schema config succeeds.""" hass_config = {const.DOMAIN: withings_config} return CONFIG_SCHEMA(hass_config)
[ "def", "config_schema_validate", "(", "withings_config", ")", "->", "dict", ":", "hass_config", "=", "{", "const", ".", "DOMAIN", ":", "withings_config", "}", "return", "CONFIG_SCHEMA", "(", "hass_config", ")" ]
[ 31, 0 ]
[ 35, 37 ]
python
en
['it', 'lb', 'en']
False
config_schema_assert_fail
(withings_config)
Assert a schema config will fail.
Assert a schema config will fail.
def config_schema_assert_fail(withings_config) -> None: """Assert a schema config will fail.""" try: config_schema_validate(withings_config) assert False, "This line should not have run." except vol.error.MultipleInvalid: assert True
[ "def", "config_schema_assert_fail", "(", "withings_config", ")", "->", "None", ":", "try", ":", "config_schema_validate", "(", "withings_config", ")", "assert", "False", ",", "\"This line should not have run.\"", "except", "vol", ".", "error", ".", "MultipleInvalid", ...
[ 38, 0 ]
[ 44, 19 ]
python
en
['en', 'lb', 'en']
True
test_config_schema_basic_config
()
Test schema.
Test schema.
def test_config_schema_basic_config() -> None: """Test schema.""" config_schema_validate( { CONF_CLIENT_ID: "my_client_id", CONF_CLIENT_SECRET: "my_client_secret", const.CONF_USE_WEBHOOK: True, } )
[ "def", "test_config_schema_basic_config", "(", ")", "->", "None", ":", "config_schema_validate", "(", "{", "CONF_CLIENT_ID", ":", "\"my_client_id\"", ",", "CONF_CLIENT_SECRET", ":", "\"my_client_secret\"", ",", "const", ".", "CONF_USE_WEBHOOK", ":", "True", ",", "}", ...
[ 47, 0 ]
[ 55, 5 ]
python
de
['de', 'de', 'it']
False
test_config_schema_client_id
()
Test schema.
Test schema.
def test_config_schema_client_id() -> None: """Test schema.""" config_schema_assert_fail({CONF_CLIENT_SECRET: "my_client_secret"}) config_schema_assert_fail( {CONF_CLIENT_SECRET: "my_client_secret", CONF_CLIENT_ID: ""} ) config_schema_validate( {CONF_CLIENT_SECRET: "my_client_secret"...
[ "def", "test_config_schema_client_id", "(", ")", "->", "None", ":", "config_schema_assert_fail", "(", "{", "CONF_CLIENT_SECRET", ":", "\"my_client_secret\"", "}", ")", "config_schema_assert_fail", "(", "{", "CONF_CLIENT_SECRET", ":", "\"my_client_secret\"", ",", "CONF_CLI...
[ 58, 0 ]
[ 66, 5 ]
python
de
['de', 'de', 'it']
False
test_config_schema_client_secret
()
Test schema.
Test schema.
def test_config_schema_client_secret() -> None: """Test schema.""" config_schema_assert_fail({CONF_CLIENT_ID: "my_client_id"}) config_schema_assert_fail({CONF_CLIENT_ID: "my_client_id", CONF_CLIENT_SECRET: ""}) config_schema_validate( {CONF_CLIENT_ID: "my_client_id", CONF_CLIENT_SECRET: "my_clie...
[ "def", "test_config_schema_client_secret", "(", ")", "->", "None", ":", "config_schema_assert_fail", "(", "{", "CONF_CLIENT_ID", ":", "\"my_client_id\"", "}", ")", "config_schema_assert_fail", "(", "{", "CONF_CLIENT_ID", ":", "\"my_client_id\"", ",", "CONF_CLIENT_SECRET",...
[ 69, 0 ]
[ 75, 5 ]
python
de
['de', 'de', 'it']
False
test_config_schema_use_webhook
()
Test schema.
Test schema.
def test_config_schema_use_webhook() -> None: """Test schema.""" config_schema_validate( {CONF_CLIENT_ID: "my_client_id", CONF_CLIENT_SECRET: "my_client_secret"} ) config = config_schema_validate( { CONF_CLIENT_ID: "my_client_id", CONF_CLIENT_SECRET: "my_client_se...
[ "def", "test_config_schema_use_webhook", "(", ")", "->", "None", ":", "config_schema_validate", "(", "{", "CONF_CLIENT_ID", ":", "\"my_client_id\"", ",", "CONF_CLIENT_SECRET", ":", "\"my_client_secret\"", "}", ")", "config", "=", "config_schema_validate", "(", "{", "C...
[ 78, 0 ]
[ 105, 5 ]
python
de
['de', 'de', 'it']
False
test_async_setup_no_config
(hass: HomeAssistant)
Test method.
Test method.
async def test_async_setup_no_config(hass: HomeAssistant) -> None: """Test method.""" hass.async_create_task = MagicMock() await async_setup(hass, {}) hass.async_create_task.assert_not_called()
[ "async", "def", "test_async_setup_no_config", "(", "hass", ":", "HomeAssistant", ")", "->", "None", ":", "hass", ".", "async_create_task", "=", "MagicMock", "(", ")", "await", "async_setup", "(", "hass", ",", "{", "}", ")", "hass", ".", "async_create_task", ...
[ 108, 0 ]
[ 114, 46 ]
python
en
['en', 'et', 'en']
False
test_auth_failure
( hass: HomeAssistant, component_factory: ComponentFactory, exception: Exception )
Test auth failure.
Test auth failure.
async def test_auth_failure( hass: HomeAssistant, component_factory: ComponentFactory, exception: Exception ) -> None: """Test auth failure.""" person0 = new_profile_config( "person0", 0, api_response_user_get_device=exception, api_response_measure_get_meas=exception, ...
[ "async", "def", "test_auth_failure", "(", "hass", ":", "HomeAssistant", ",", "component_factory", ":", "ComponentFactory", ",", "exception", ":", "Exception", ")", "->", "None", ":", "person0", "=", "new_profile_config", "(", "\"person0\"", ",", "0", ",", "api_r...
[ 125, 0 ]
[ 161, 43 ]
python
en
['fr', 'gd', 'en']
False
test_set_config_unique_id
( hass: HomeAssistant, component_factory: ComponentFactory )
Test upgrading configs to use a unique id.
Test upgrading configs to use a unique id.
async def test_set_config_unique_id( hass: HomeAssistant, component_factory: ComponentFactory ) -> None: """Test upgrading configs to use a unique id.""" person0 = new_profile_config("person0", 0) await component_factory.configure_component(profile_configs=(person0,)) config_entry = MockConfigEntr...
[ "async", "def", "test_set_config_unique_id", "(", "hass", ":", "HomeAssistant", ",", "component_factory", ":", "ComponentFactory", ")", "->", "None", ":", "person0", "=", "new_profile_config", "(", "\"person0\"", ",", "0", ")", "await", "component_factory", ".", "...
[ 164, 0 ]
[ 187, 53 ]
python
en
['en', 'en', 'en']
True
test_set_convert_unique_id_to_string
(hass: HomeAssistant)
Test upgrading configs to use a unique id.
Test upgrading configs to use a unique id.
async def test_set_convert_unique_id_to_string(hass: HomeAssistant) -> None: """Test upgrading configs to use a unique id.""" config_entry = MockConfigEntry( domain=DOMAIN, data={ "token": {"userid": 1234}, "auth_implementation": "withings", "profile": "person...
[ "async", "def", "test_set_convert_unique_id_to_string", "(", "hass", ":", "HomeAssistant", ")", "->", "None", ":", "config_entry", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", "data", "=", "{", "\"token\"", ":", "{", "\"userid\"", ":", "1234", "}...
[ 190, 0 ]
[ 224, 47 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, config_entry, async_add_entities)
Add AccuWeather entities from a config_entry.
Add AccuWeather entities from a config_entry.
async def async_setup_entry(hass, config_entry, async_add_entities): """Add AccuWeather entities from a config_entry.""" name = config_entry.data[CONF_NAME] coordinator = hass.data[DOMAIN][config_entry.entry_id][COORDINATOR] sensors = [] for sensor in SENSOR_TYPES: sensors.append(AccuWeath...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "name", "=", "config_entry", ".", "data", "[", "CONF_NAME", "]", "coordinator", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "config_entry", "."...
[ 27, 0 ]
[ 47, 38 ]
python
en
['en', 'en', 'en']
True
AccuWeatherSensor.__init__
(self, name, kind, coordinator, forecast_day=None)
Initialize.
Initialize.
def __init__(self, name, kind, coordinator, forecast_day=None): """Initialize.""" super().__init__(coordinator) self._name = name self.kind = kind self._device_class = None self._attrs = {ATTR_ATTRIBUTION: ATTRIBUTION} self._unit_system = "Metric" if self.coordina...
[ "def", "__init__", "(", "self", ",", "name", ",", "kind", ",", "coordinator", ",", "forecast_day", "=", "None", ")", ":", "super", "(", ")", ".", "__init__", "(", "coordinator", ")", "self", ".", "_name", "=", "name", "self", ".", "kind", "=", "kind"...
[ 53, 4 ]
[ 61, 40 ]
python
en
['en', 'en', 'it']
False
AccuWeatherSensor.name
(self)
Return the name.
Return the name.
def name(self): """Return the name.""" if self.forecast_day is not None: return f"{self._name} {FORECAST_SENSOR_TYPES[self.kind][ATTR_LABEL]} {self.forecast_day}d" return f"{self._name} {SENSOR_TYPES[self.kind][ATTR_LABEL]}"
[ "def", "name", "(", "self", ")", ":", "if", "self", ".", "forecast_day", "is", "not", "None", ":", "return", "f\"{self._name} {FORECAST_SENSOR_TYPES[self.kind][ATTR_LABEL]} {self.forecast_day}d\"", "return", "f\"{self._name} {SENSOR_TYPES[self.kind][ATTR_LABEL]}\"" ]
[ 64, 4 ]
[ 68, 68 ]
python
en
['en', 'ig', 'en']
True
AccuWeatherSensor.unique_id
(self)
Return a unique_id for this entity.
Return a unique_id for this entity.
def unique_id(self): """Return a unique_id for this entity.""" if self.forecast_day is not None: return f"{self.coordinator.location_key}-{self.kind}-{self.forecast_day}".lower() return f"{self.coordinator.location_key}-{self.kind}".lower()
[ "def", "unique_id", "(", "self", ")", ":", "if", "self", ".", "forecast_day", "is", "not", "None", ":", "return", "f\"{self.coordinator.location_key}-{self.kind}-{self.forecast_day}\"", ".", "lower", "(", ")", "return", "f\"{self.coordinator.location_key}-{self.kind}\"", ...
[ 71, 4 ]
[ 75, 69 ]
python
en
['en', 'en', 'en']
True
AccuWeatherSensor.device_info
(self)
Return the device info.
Return the device info.
def device_info(self): """Return the device info.""" return { "identifiers": {(DOMAIN, self.coordinator.location_key)}, "name": NAME, "manufacturer": MANUFACTURER, "entry_type": "service", }
[ "def", "device_info", "(", "self", ")", ":", "return", "{", "\"identifiers\"", ":", "{", "(", "DOMAIN", ",", "self", ".", "coordinator", ".", "location_key", ")", "}", ",", "\"name\"", ":", "NAME", ",", "\"manufacturer\"", ":", "MANUFACTURER", ",", "\"entr...
[ 78, 4 ]
[ 85, 9 ]
python
en
['en', 'en', 'en']
True
AccuWeatherSensor.state
(self)
Return the state.
Return the state.
def state(self): """Return the state.""" if self.forecast_day is not None: if ( FORECAST_SENSOR_TYPES[self.kind][ATTR_DEVICE_CLASS] == DEVICE_CLASS_TEMPERATURE ): return self.coordinator.data[ATTR_FORECAST][self.forecast_day][ ...
[ "def", "state", "(", "self", ")", ":", "if", "self", ".", "forecast_day", "is", "not", "None", ":", "if", "(", "FORECAST_SENSOR_TYPES", "[", "self", ".", "kind", "]", "[", "ATTR_DEVICE_CLASS", "]", "==", "DEVICE_CLASS_TEMPERATURE", ")", ":", "return", "sel...
[ 88, 4 ]
[ 119, 47 ]
python
en
['en', 'en', 'en']
True
AccuWeatherSensor.icon
(self)
Return the icon.
Return the icon.
def icon(self): """Return the icon.""" if self.forecast_day is not None: return FORECAST_SENSOR_TYPES[self.kind][ATTR_ICON] return SENSOR_TYPES[self.kind][ATTR_ICON]
[ "def", "icon", "(", "self", ")", ":", "if", "self", ".", "forecast_day", "is", "not", "None", ":", "return", "FORECAST_SENSOR_TYPES", "[", "self", ".", "kind", "]", "[", "ATTR_ICON", "]", "return", "SENSOR_TYPES", "[", "self", ".", "kind", "]", "[", "A...
[ 122, 4 ]
[ 126, 49 ]
python
en
['en', 'sr', 'en']
True
AccuWeatherSensor.device_class
(self)
Return the device_class.
Return the device_class.
def device_class(self): """Return the device_class.""" if self.forecast_day is not None: return FORECAST_SENSOR_TYPES[self.kind][ATTR_DEVICE_CLASS] return SENSOR_TYPES[self.kind][ATTR_DEVICE_CLASS]
[ "def", "device_class", "(", "self", ")", ":", "if", "self", ".", "forecast_day", "is", "not", "None", ":", "return", "FORECAST_SENSOR_TYPES", "[", "self", ".", "kind", "]", "[", "ATTR_DEVICE_CLASS", "]", "return", "SENSOR_TYPES", "[", "self", ".", "kind", ...
[ 129, 4 ]
[ 133, 57 ]
python
en
['en', 'en', 'en']
True
AccuWeatherSensor.unit_of_measurement
(self)
Return the unit the value is expressed in.
Return the unit the value is expressed in.
def unit_of_measurement(self): """Return the unit the value is expressed in.""" if self.forecast_day is not None: return FORECAST_SENSOR_TYPES[self.kind][self._unit_system] return SENSOR_TYPES[self.kind][self._unit_system]
[ "def", "unit_of_measurement", "(", "self", ")", ":", "if", "self", ".", "forecast_day", "is", "not", "None", ":", "return", "FORECAST_SENSOR_TYPES", "[", "self", ".", "kind", "]", "[", "self", ".", "_unit_system", "]", "return", "SENSOR_TYPES", "[", "self", ...
[ 136, 4 ]
[ 140, 57 ]
python
en
['en', 'en', 'en']
True
AccuWeatherSensor.device_state_attributes
(self)
Return the state attributes.
Return the state attributes.
def device_state_attributes(self): """Return the state attributes.""" if self.forecast_day is not None: if self.kind in ["WindGustDay", "WindGustNight"]: self._attrs["direction"] = self.coordinator.data[ATTR_FORECAST][ self.forecast_day ][s...
[ "def", "device_state_attributes", "(", "self", ")", ":", "if", "self", ".", "forecast_day", "is", "not", "None", ":", "if", "self", ".", "kind", "in", "[", "\"WindGustDay\"", ",", "\"WindGustNight\"", "]", ":", "self", ".", "_attrs", "[", "\"direction\"", ...
[ 143, 4 ]
[ 159, 26 ]
python
en
['en', 'en', 'en']
True
AccuWeatherSensor.entity_registry_enabled_default
(self)
Return if the entity should be enabled when first added to the entity registry.
Return if the entity should be enabled when first added to the entity registry.
def entity_registry_enabled_default(self): """Return if the entity should be enabled when first added to the entity registry.""" return bool(self.kind not in OPTIONAL_SENSORS)
[ "def", "entity_registry_enabled_default", "(", "self", ")", ":", "return", "bool", "(", "self", ".", "kind", "not", "in", "OPTIONAL_SENSORS", ")" ]
[ 162, 4 ]
[ 164, 54 ]
python
en
['en', 'en', 'en']
True
mock_device
()
Mock a Dynalite device.
Mock a Dynalite device.
def mock_device(): """Mock a Dynalite device.""" mock_dev = create_mock_device("cover", DynaliteTimeCoverWithTiltDevice) mock_dev.device_class = "blind" return mock_dev
[ "def", "mock_device", "(", ")", ":", "mock_dev", "=", "create_mock_device", "(", "\"cover\"", ",", "DynaliteTimeCoverWithTiltDevice", ")", "mock_dev", ".", "device_class", "=", "\"blind\"", "return", "mock_dev" ]
[ 17, 0 ]
[ 21, 19 ]
python
en
['ro', 'ht', 'en']
False
test_cover_setup
(hass, mock_device)
Test a successful setup.
Test a successful setup.
async def test_cover_setup(hass, mock_device): """Test a successful setup.""" await create_entity_from_device(hass, mock_device) entity_state = hass.states.get("cover.name") assert entity_state.attributes[ATTR_FRIENDLY_NAME] == mock_device.name assert ( entity_state.attributes["current_posit...
[ "async", "def", "test_cover_setup", "(", "hass", ",", "mock_device", ")", ":", "await", "create_entity_from_device", "(", "hass", ",", "mock_device", ")", "entity_state", "=", "hass", ".", "states", ".", "get", "(", "\"cover.name\"", ")", "assert", "entity_state...
[ 24, 0 ]
[ 60, 5 ]
python
en
['en', 'co', 'en']
True
test_cover_without_tilt
(hass, mock_device)
Test a cover with no tilt.
Test a cover with no tilt.
async def test_cover_without_tilt(hass, mock_device): """Test a cover with no tilt.""" mock_device.has_tilt = False await create_entity_from_device(hass, mock_device) await hass.services.async_call( "cover", "open_cover_tilt", {"entity_id": "cover.name"}, blocking=True ) await hass.async...
[ "async", "def", "test_cover_without_tilt", "(", "hass", ",", "mock_device", ")", ":", "mock_device", ".", "has_tilt", "=", "False", "await", "create_entity_from_device", "(", "hass", ",", "mock_device", ")", "await", "hass", ".", "services", ".", "async_call", "...
[ 63, 0 ]
[ 71, 57 ]
python
en
['en', 'en', 'en']
True
check_cover_position
( hass, update_func, device, closing, opening, closed, expected )
Check that a given position behaves correctly.
Check that a given position behaves correctly.
async def check_cover_position( hass, update_func, device, closing, opening, closed, expected ): """Check that a given position behaves correctly.""" device.is_closing = closing device.is_opening = opening device.is_closed = closed update_func(device) await hass.async_block_till_done() e...
[ "async", "def", "check_cover_position", "(", "hass", ",", "update_func", ",", "device", ",", "closing", ",", "opening", ",", "closed", ",", "expected", ")", ":", "device", ".", "is_closing", "=", "closing", "device", ".", "is_opening", "=", "opening", "devic...
[ 74, 0 ]
[ 84, 41 ]
python
en
['en', 'en', 'en']
True
test_cover_positions
(hass, mock_device)
Test that the state updates in the various positions.
Test that the state updates in the various positions.
async def test_cover_positions(hass, mock_device): """Test that the state updates in the various positions.""" update_func = await create_entity_from_device(hass, mock_device) await check_cover_position( hass, update_func, mock_device, True, False, False, "closing" ) await check_cover_positi...
[ "async", "def", "test_cover_positions", "(", "hass", ",", "mock_device", ")", ":", "update_func", "=", "await", "create_entity_from_device", "(", "hass", ",", "mock_device", ")", "await", "check_cover_position", "(", "hass", ",", "update_func", ",", "mock_device", ...
[ 87, 0 ]
[ 101, 5 ]
python
en
['en', 'en', 'en']
True
BatchTuner.is_valid
(self, search_space)
Check the search space is valid: only contains 'choice' type Parameters ---------- search_space : dict Returns ------- None or list If valid, return candidate values; else return None.
Check the search space is valid: only contains 'choice' type
def is_valid(self, search_space): """ Check the search space is valid: only contains 'choice' type Parameters ---------- search_space : dict Returns ------- None or list If valid, return candidate values; else return None. """ ...
[ "def", "is_valid", "(", "self", ",", "search_space", ")", ":", "if", "not", "len", "(", "search_space", ")", "==", "1", ":", "raise", "RuntimeError", "(", "'BatchTuner only supprt one combined-paramreters key.'", ")", "for", "param", "in", "search_space", ":", "...
[ 41, 4 ]
[ 68, 19 ]
python
en
['en', 'error', 'th']
False
BatchTuner.update_search_space
(self, search_space)
Update the search space Parameters ---------- search_space : dict
Update the search space
def update_search_space(self, search_space): """Update the search space Parameters ---------- search_space : dict """ self._values = self.is_valid(search_space)
[ "def", "update_search_space", "(", "self", ",", "search_space", ")", ":", "self", ".", "_values", "=", "self", ".", "is_valid", "(", "search_space", ")" ]
[ 70, 4 ]
[ 77, 50 ]
python
en
['en', 'en', 'en']
True
BatchTuner.generate_parameters
(self, parameter_id, **kwargs)
Returns a dict of trial (hyper-)parameters, as a serializable object. Parameters ---------- parameter_id : int Returns ------- dict A candidate parameter group.
Returns a dict of trial (hyper-)parameters, as a serializable object.
def generate_parameters(self, parameter_id, **kwargs): """Returns a dict of trial (hyper-)parameters, as a serializable object. Parameters ---------- parameter_id : int Returns ------- dict A candidate parameter group. """ self._count...
[ "def", "generate_parameters", "(", "self", ",", "parameter_id", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_count", "+=", "1", "if", "self", ".", "_count", ">", "len", "(", "self", ".", "_values", ")", "-", "1", ":", "raise", "nni", ".", "NoM...
[ 79, 4 ]
[ 94, 40 ]
python
en
['en', 'en', 'en']
True