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
DemoImageProcessingAlpr.confidence
(self)
Return minimum confidence for send events.
Return minimum confidence for send events.
def confidence(self): """Return minimum confidence for send events.""" return 80
[ "def", "confidence", "(", "self", ")", ":", "return", "80" ]
[ 39, 4 ]
[ 41, 17 ]
python
en
['en', 'la', 'en']
True
DemoImageProcessingAlpr.name
(self)
Return the name of the entity.
Return the name of the entity.
def name(self): """Return the name of the entity.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 44, 4 ]
[ 46, 25 ]
python
en
['en', 'en', 'en']
True
DemoImageProcessingAlpr.process_image
(self, image)
Process image.
Process image.
def process_image(self, image): """Process image.""" demo_data = { "AC3829": 98.3, "BE392034": 95.5, "CD02394": 93.4, "DF923043": 90.8, } self.process_plates(demo_data, 1)
[ "def", "process_image", "(", "self", ",", "image", ")", ":", "demo_data", "=", "{", "\"AC3829\"", ":", "98.3", ",", "\"BE392034\"", ":", "95.5", ",", "\"CD02394\"", ":", "93.4", ",", "\"DF923043\"", ":", "90.8", ",", "}", "self", ".", "process_plates", "...
[ 48, 4 ]
[ 57, 41 ]
python
en
['en', 'ny', 'en']
False
DemoImageProcessingFace.__init__
(self, camera_entity, name)
Initialize demo face image processing entity.
Initialize demo face image processing entity.
def __init__(self, camera_entity, name): """Initialize demo face image processing entity.""" super().__init__() self._name = name self._camera = camera_entity
[ "def", "__init__", "(", "self", ",", "camera_entity", ",", "name", ")", ":", "super", "(", ")", ".", "__init__", "(", ")", "self", ".", "_name", "=", "name", "self", ".", "_camera", "=", "camera_entity" ]
[ 63, 4 ]
[ 68, 36 ]
python
en
['es', 'en', 'en']
True
DemoImageProcessingFace.camera_entity
(self)
Return camera entity id from process pictures.
Return camera entity id from process pictures.
def camera_entity(self): """Return camera entity id from process pictures.""" return self._camera
[ "def", "camera_entity", "(", "self", ")", ":", "return", "self", ".", "_camera" ]
[ 71, 4 ]
[ 73, 27 ]
python
en
['en', 'en', 'en']
True
DemoImageProcessingFace.confidence
(self)
Return minimum confidence for send events.
Return minimum confidence for send events.
def confidence(self): """Return minimum confidence for send events.""" return 80
[ "def", "confidence", "(", "self", ")", ":", "return", "80" ]
[ 76, 4 ]
[ 78, 17 ]
python
en
['en', 'la', 'en']
True
DemoImageProcessingFace.name
(self)
Return the name of the entity.
Return the name of the entity.
def name(self): """Return the name of the entity.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 81, 4 ]
[ 83, 25 ]
python
en
['en', 'en', 'en']
True
DemoImageProcessingFace.process_image
(self, image)
Process image.
Process image.
def process_image(self, image): """Process image.""" demo_data = [ { ATTR_CONFIDENCE: 98.34, ATTR_NAME: "Hans", ATTR_AGE: 16.0, ATTR_GENDER: "male", }, {ATTR_NAME: "Helena", ATTR_AGE: 28.0, ATTR_GENDER: "...
[ "def", "process_image", "(", "self", ",", "image", ")", ":", "demo_data", "=", "[", "{", "ATTR_CONFIDENCE", ":", "98.34", ",", "ATTR_NAME", ":", "\"Hans\"", ",", "ATTR_AGE", ":", "16.0", ",", "ATTR_GENDER", ":", "\"male\"", ",", "}", ",", "{", "ATTR_NAME...
[ 85, 4 ]
[ 98, 40 ]
python
en
['en', 'ny', 'en']
False
test_purge_old_states
(hass, hass_recorder)
Test deleting old states.
Test deleting old states.
def test_purge_old_states(hass, hass_recorder): """Test deleting old states.""" hass = hass_recorder() _add_test_states(hass) # make sure we start with 6 states with session_scope(hass=hass) as session: states = session.query(States) assert states.count() == 6 # run purge_o...
[ "def", "test_purge_old_states", "(", "hass", ",", "hass_recorder", ")", ":", "hass", "=", "hass_recorder", "(", ")", "_add_test_states", "(", "hass", ")", "# make sure we start with 6 states", "with", "session_scope", "(", "hass", "=", "hass", ")", "as", "session"...
[ 16, 0 ]
[ 37, 34 ]
python
en
['nl', 'en', 'en']
True
test_purge_old_events
(hass, hass_recorder)
Test deleting old events.
Test deleting old events.
def test_purge_old_events(hass, hass_recorder): """Test deleting old events.""" hass = hass_recorder() _add_test_events(hass) with session_scope(hass=hass) as session: events = session.query(Events).filter(Events.event_type.like("EVENT_TEST%")) assert events.count() == 6 # run ...
[ "def", "test_purge_old_events", "(", "hass", ",", "hass_recorder", ")", ":", "hass", "=", "hass_recorder", "(", ")", "_add_test_events", "(", "hass", ")", "with", "session_scope", "(", "hass", "=", "hass", ")", "as", "session", ":", "events", "=", "session",...
[ 40, 0 ]
[ 61, 34 ]
python
en
['nl', 'en', 'en']
True
test_purge_method
(hass, hass_recorder)
Test purge method.
Test purge method.
def test_purge_method(hass, hass_recorder): """Test purge method.""" hass = hass_recorder() service_data = {"keep_days": 4} _add_test_events(hass) _add_test_states(hass) _add_test_recorder_runs(hass) # make sure we start with 6 states with session_scope(hass=hass) as session: st...
[ "def", "test_purge_method", "(", "hass", ",", "hass_recorder", ")", ":", "hass", "=", "hass_recorder", "(", ")", "service_data", "=", "{", "\"keep_days\"", ":", "4", "}", "_add_test_events", "(", "hass", ")", "_add_test_states", "(", "hass", ")", "_add_test_re...
[ 64, 0 ]
[ 127, 13 ]
python
en
['en', 'et', 'en']
True
_add_test_states
(hass)
Add multiple states to the db for testing.
Add multiple states to the db for testing.
def _add_test_states(hass): """Add multiple states to the db for testing.""" now = datetime.now() five_days_ago = now - timedelta(days=5) eleven_days_ago = now - timedelta(days=11) attributes = {"test_attr": 5, "test_attr_10": "nice"} hass.block_till_done() hass.data[DATA_INSTANCE].block_ti...
[ "def", "_add_test_states", "(", "hass", ")", ":", "now", "=", "datetime", ".", "now", "(", ")", "five_days_ago", "=", "now", "-", "timedelta", "(", "days", "=", "5", ")", "eleven_days_ago", "=", "now", "-", "timedelta", "(", "days", "=", "11", ")", "...
[ 130, 0 ]
[ 164, 13 ]
python
en
['en', 'en', 'en']
True
_add_test_events
(hass)
Add a few events for testing.
Add a few events for testing.
def _add_test_events(hass): """Add a few events for testing.""" now = datetime.now() five_days_ago = now - timedelta(days=5) eleven_days_ago = now - timedelta(days=11) event_data = {"test_attr": 5, "test_attr_10": "nice"} hass.block_till_done() hass.data[DATA_INSTANCE].block_till_done() ...
[ "def", "_add_test_events", "(", "hass", ")", ":", "now", "=", "datetime", ".", "now", "(", ")", "five_days_ago", "=", "now", "-", "timedelta", "(", "days", "=", "5", ")", "eleven_days_ago", "=", "now", "-", "timedelta", "(", "days", "=", "11", ")", "...
[ 167, 0 ]
[ 198, 13 ]
python
en
['en', 'en', 'en']
True
_add_test_recorder_runs
(hass)
Add a few recorder_runs for testing.
Add a few recorder_runs for testing.
def _add_test_recorder_runs(hass): """Add a few recorder_runs for testing.""" now = datetime.now() five_days_ago = now - timedelta(days=5) eleven_days_ago = now - timedelta(days=11) hass.block_till_done() hass.data[DATA_INSTANCE].block_till_done() wait_recording_done(hass) with recorde...
[ "def", "_add_test_recorder_runs", "(", "hass", ")", ":", "now", "=", "datetime", ".", "now", "(", ")", "five_days_ago", "=", "now", "-", "timedelta", "(", "days", "=", "5", ")", "eleven_days_ago", "=", "now", "-", "timedelta", "(", "days", "=", "11", "...
[ 201, 0 ]
[ 226, 13 ]
python
en
['en', 'cy', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the PiFace Digital Output devices.
Set up the PiFace Digital Output devices.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the PiFace Digital Output devices.""" switches = [] ports = config.get(CONF_PORTS) for port, port_entity in ports.items(): name = port_entity.get(ATTR_NAME) invert_logic = port_entity[ATTR_INVERT_LOGIC] ...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "switches", "=", "[", "]", "ports", "=", "config", ".", "get", "(", "CONF_PORTS", ")", "for", "port", ",", "port_entity", "in", "ports...
[ 27, 0 ]
[ 36, 26 ]
python
en
['en', 'en', 'en']
True
RPiPFIOSwitch.__init__
(self, port, name, invert_logic)
Initialize the pin.
Initialize the pin.
def __init__(self, port, name, invert_logic): """Initialize the pin.""" self._port = port self._name = name or DEVICE_DEFAULT_NAME self._invert_logic = invert_logic self._state = False rpi_pfio.write_output(self._port, 1 if self._invert_logic else 0)
[ "def", "__init__", "(", "self", ",", "port", ",", "name", ",", "invert_logic", ")", ":", "self", ".", "_port", "=", "port", "self", ".", "_name", "=", "name", "or", "DEVICE_DEFAULT_NAME", "self", ".", "_invert_logic", "=", "invert_logic", "self", ".", "_...
[ 42, 4 ]
[ 48, 73 ]
python
en
['en', 'en', 'en']
True
RPiPFIOSwitch.name
(self)
Return the name of the switch.
Return the name of the switch.
def name(self): """Return the name of the switch.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 51, 4 ]
[ 53, 25 ]
python
en
['en', 'en', 'en']
True
RPiPFIOSwitch.should_poll
(self)
Return the polling state.
Return the polling state.
def should_poll(self): """Return the polling state.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 56, 4 ]
[ 58, 20 ]
python
en
['en', 'en', 'en']
True
RPiPFIOSwitch.is_on
(self)
Return true if device is on.
Return true if device is on.
def is_on(self): """Return true if device is on.""" return self._state
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 61, 4 ]
[ 63, 26 ]
python
en
['en', 'fy', 'en']
True
RPiPFIOSwitch.turn_on
(self, **kwargs)
Turn the device on.
Turn the device on.
def turn_on(self, **kwargs): """Turn the device on.""" rpi_pfio.write_output(self._port, 0 if self._invert_logic else 1) self._state = True self.schedule_update_ha_state()
[ "def", "turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "rpi_pfio", ".", "write_output", "(", "self", ".", "_port", ",", "0", "if", "self", ".", "_invert_logic", "else", "1", ")", "self", ".", "_state", "=", "True", "self", ".", "schedule_u...
[ 65, 4 ]
[ 69, 39 ]
python
en
['en', 'en', 'en']
True
RPiPFIOSwitch.turn_off
(self, **kwargs)
Turn the device off.
Turn the device off.
def turn_off(self, **kwargs): """Turn the device off.""" rpi_pfio.write_output(self._port, 1 if self._invert_logic else 0) self._state = False self.schedule_update_ha_state()
[ "def", "turn_off", "(", "self", ",", "*", "*", "kwargs", ")", ":", "rpi_pfio", ".", "write_output", "(", "self", ".", "_port", ",", "1", "if", "self", ".", "_invert_logic", "else", "0", ")", "self", ".", "_state", "=", "False", "self", ".", "schedule...
[ 71, 4 ]
[ 75, 39 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, config_entry, async_add_entities)
Set up Z-Wave binary_sensor from config entry.
Set up Z-Wave binary_sensor from config entry.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up Z-Wave binary_sensor from config entry.""" @callback def async_add_binary_sensor(values): """Add Z-Wave Binary Sensor(s).""" async_add_entities(VALUE_TYPE_SENSORS[values.primary.type](values)) hass.data[DOMA...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "@", "callback", "def", "async_add_binary_sensor", "(", "values", ")", ":", "\"\"\"Add Z-Wave Binary Sensor(s).\"\"\"", "async_add_entities", "(", "VALUE_TYPE_SENSO...
[ 252, 0 ]
[ 264, 5 ]
python
en
['en', 'en', 'en']
True
async_get_legacy_binary_sensors
(values)
Add Legacy/classic Z-Wave Binary Sensor.
Add Legacy/classic Z-Wave Binary Sensor.
def async_get_legacy_binary_sensors(values): """Add Legacy/classic Z-Wave Binary Sensor.""" return [ZWaveBinarySensor(values)]
[ "def", "async_get_legacy_binary_sensors", "(", "values", ")", ":", "return", "[", "ZWaveBinarySensor", "(", "values", ")", "]" ]
[ 268, 0 ]
[ 270, 38 ]
python
en
['en', 'pl', 'en']
True
async_get_notification_sensors
(values)
Convert Notification values into binary sensors.
Convert Notification values into binary sensors.
def async_get_notification_sensors(values): """Convert Notification values into binary sensors.""" sensors_to_add = [] for list_value in values.primary.value["List"]: # check if we have a mapping for this value for item in NOTIFICATION_SENSORS: if item[NOTIFICATION_TYPE] != value...
[ "def", "async_get_notification_sensors", "(", "values", ")", ":", "sensors_to_add", "=", "[", "]", "for", "list_value", "in", "values", ".", "primary", ".", "value", "[", "\"List\"", "]", ":", "# check if we have a mapping for this value", "for", "item", "in", "NO...
[ 274, 0 ]
[ 295, 25 ]
python
en
['en', 'mg', 'en']
True
ZWaveBinarySensor.is_on
(self)
Return if the sensor is on or off.
Return if the sensor is on or off.
def is_on(self): """Return if the sensor is on or off.""" return self.values.primary.value
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "values", ".", "primary", ".", "value" ]
[ 308, 4 ]
[ 310, 40 ]
python
en
['en', 'en', 'en']
True
ZWaveBinarySensor.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) -> bool: """Return if the entity should be enabled when first added to the entity registry.""" # Legacy binary sensors are phased out (replaced by notification sensors) # Disable by default to not confuse users for item in self.values.primary.nod...
[ "def", "entity_registry_enabled_default", "(", "self", ")", "->", "bool", ":", "# Legacy binary sensors are phased out (replaced by notification sensors)", "# Disable by default to not confuse users", "for", "item", "in", "self", ".", "values", ".", "primary", ".", "node", "....
[ 313, 4 ]
[ 321, 19 ]
python
en
['en', 'en', 'en']
True
ZWaveListValueSensor.__init__
( self, values, on_value, device_class=None, default_enabled=True, off_value=NOTIFICATION_VALUE_CLEAR, )
Initialize a ZWaveListValueSensor entity.
Initialize a ZWaveListValueSensor entity.
def __init__( self, values, on_value, device_class=None, default_enabled=True, off_value=NOTIFICATION_VALUE_CLEAR, ): """Initialize a ZWaveListValueSensor entity.""" super().__init__(values) self._on_value = on_value self._device_class ...
[ "def", "__init__", "(", "self", ",", "values", ",", "on_value", ",", "device_class", "=", "None", ",", "default_enabled", "=", "True", ",", "off_value", "=", "NOTIFICATION_VALUE_CLEAR", ",", ")", ":", "super", "(", ")", ".", "__init__", "(", "values", ")",...
[ 327, 4 ]
[ 343, 30 ]
python
en
['es', 'pl', 'en']
False
ZWaveListValueSensor.on_value_update
(self)
Call when a value is added/updated in the underlying EntityValues Collection.
Call when a value is added/updated in the underlying EntityValues Collection.
def on_value_update(self): """Call when a value is added/updated in the underlying EntityValues Collection.""" if self.values.primary.value["Selected_id"] == self._on_value: # Only when the active ID exactly matches our watched ON value, set sensor state to ON self._state = True ...
[ "def", "on_value_update", "(", "self", ")", ":", "if", "self", ".", "values", ".", "primary", ".", "value", "[", "\"Selected_id\"", "]", "==", "self", ".", "_on_value", ":", "# Only when the active ID exactly matches our watched ON value, set sensor state to ON", "self"...
[ 346, 4 ]
[ 361, 31 ]
python
en
['en', 'en', 'en']
True
ZWaveListValueSensor.name
(self)
Return the name of the entity.
Return the name of the entity.
def name(self): """Return the name of the entity.""" # Append value label to base name base_name = super().name value_label = "" for item in self.values.primary.value["List"]: if item["Value"] == self._on_value: value_label = item["Label"] ...
[ "def", "name", "(", "self", ")", ":", "# Append value label to base name", "base_name", "=", "super", "(", ")", ".", "name", "value_label", "=", "\"\"", "for", "item", "in", "self", ".", "values", ".", "primary", ".", "value", "[", "\"List\"", "]", ":", ...
[ 364, 4 ]
[ 377, 44 ]
python
en
['en', 'en', 'en']
True
ZWaveListValueSensor.unique_id
(self)
Return the unique_id of the entity.
Return the unique_id of the entity.
def unique_id(self): """Return the unique_id of the entity.""" unique_id = super().unique_id return f"{unique_id}.{self._on_value}"
[ "def", "unique_id", "(", "self", ")", ":", "unique_id", "=", "super", "(", ")", ".", "unique_id", "return", "f\"{unique_id}.{self._on_value}\"" ]
[ 380, 4 ]
[ 383, 46 ]
python
en
['en', 'en', 'en']
True
ZWaveListValueSensor.is_on
(self)
Return if the sensor is on or off.
Return if the sensor is on or off.
def is_on(self): """Return if the sensor is on or off.""" return self._state
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 386, 4 ]
[ 388, 26 ]
python
en
['en', 'en', 'en']
True
ZWaveListValueSensor.device_class
(self)
Return the class of this device, from component DEVICE_CLASSES.
Return the class of this device, from component DEVICE_CLASSES.
def device_class(self): """Return the class of this device, from component DEVICE_CLASSES.""" return self._device_class
[ "def", "device_class", "(", "self", ")", ":", "return", "self", ".", "_device_class" ]
[ 391, 4 ]
[ 393, 33 ]
python
en
['en', 'en', 'en']
True
ZWaveListValueSensor.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) -> bool: """Return if the entity should be enabled when first added to the entity registry.""" # We hide the more advanced sensors by default to not overwhelm users return self._default_enabled
[ "def", "entity_registry_enabled_default", "(", "self", ")", "->", "bool", ":", "# We hide the more advanced sensors by default to not overwhelm users", "return", "self", ".", "_default_enabled" ]
[ 396, 4 ]
[ 399, 36 ]
python
en
['en', 'en', 'en']
True
async_setup
(hass, config)
Component setup, do nothing.
Component setup, do nothing.
async def async_setup(hass, config): """Component setup, do nothing.""" if DOMAIN not in config: return True for device_id in config[DOMAIN]: conf = config[DOMAIN][device_id] hass.async_create_task( hass.config_entries.flow.async_init( DOMAIN, ...
[ "async", "def", "async_setup", "(", "hass", ",", "config", ")", ":", "if", "DOMAIN", "not", "in", "config", ":", "return", "True", "for", "device_id", "in", "config", "[", "DOMAIN", "]", ":", "conf", "=", "config", "[", "DOMAIN", "]", "[", "device_id",...
[ 55, 0 ]
[ 69, 15 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, entry)
Set up the HLK-SW16 switch.
Set up the HLK-SW16 switch.
async def async_setup_entry(hass, entry): """Set up the HLK-SW16 switch.""" hass.data.setdefault(DOMAIN, {}) host = entry.data[CONF_HOST] port = entry.data[CONF_PORT] address = f"{host}:{port}" hass.data[DOMAIN][entry.entry_id] = {} @callback def disconnected(): """Schedule rec...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "entry", ")", ":", "hass", ".", "data", ".", "setdefault", "(", "DOMAIN", ",", "{", "}", ")", "host", "=", "entry", ".", "data", "[", "CONF_HOST", "]", "port", "=", "entry", ".", "data", "[", "...
[ 72, 0 ]
[ 121, 15 ]
python
en
['en', 'en', 'en']
True
async_unload_entry
(hass, entry)
Unload a config entry.
Unload a config entry.
async def async_unload_entry(hass, entry): """Unload a config entry.""" client = hass.data[DOMAIN][entry.entry_id].pop(DATA_DEVICE_REGISTER) client.stop() unload_ok = await hass.config_entries.async_forward_entry_unload(entry, "switch") if unload_ok: if hass.data[DOMAIN][entry.entry_id]: ...
[ "async", "def", "async_unload_entry", "(", "hass", ",", "entry", ")", ":", "client", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "entry", ".", "entry_id", "]", ".", "pop", "(", "DATA_DEVICE_REGISTER", ")", "client", ".", "stop", "(", ")", "unloa...
[ 124, 0 ]
[ 135, 20 ]
python
en
['en', 'es', 'en']
True
SW16Device.__init__
(self, device_port, entry_id, client)
Initialize the device.
Initialize the device.
def __init__(self, device_port, entry_id, client): """Initialize the device.""" # HLK-SW16 specific attributes for every component type self._entry_id = entry_id self._device_port = device_port self._is_on = None self._client = client self._name = device_port
[ "def", "__init__", "(", "self", ",", "device_port", ",", "entry_id", ",", "client", ")", ":", "# HLK-SW16 specific attributes for every component type", "self", ".", "_entry_id", "=", "entry_id", "self", ".", "_device_port", "=", "device_port", "self", ".", "_is_on"...
[ 144, 4 ]
[ 151, 32 ]
python
en
['en', 'en', 'en']
True
SW16Device.unique_id
(self)
Return a unique ID.
Return a unique ID.
def unique_id(self): """Return a unique ID.""" return f"{self._entry_id}_{self._device_port}"
[ "def", "unique_id", "(", "self", ")", ":", "return", "f\"{self._entry_id}_{self._device_port}\"" ]
[ 154, 4 ]
[ 156, 54 ]
python
ca
['fr', 'ca', 'en']
False
SW16Device.handle_event_callback
(self, event)
Propagate changes through ha.
Propagate changes through ha.
def handle_event_callback(self, event): """Propagate changes through ha.""" _LOGGER.debug("Relay %s new state callback: %r", self.unique_id, event) self._is_on = event self.async_write_ha_state()
[ "def", "handle_event_callback", "(", "self", ",", "event", ")", ":", "_LOGGER", ".", "debug", "(", "\"Relay %s new state callback: %r\"", ",", "self", ".", "unique_id", ",", "event", ")", "self", ".", "_is_on", "=", "event", "self", ".", "async_write_ha_state", ...
[ 159, 4 ]
[ 163, 35 ]
python
en
['en', 'gd', 'en']
True
SW16Device.should_poll
(self)
No polling needed.
No polling needed.
def should_poll(self): """No polling needed.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 166, 4 ]
[ 168, 20 ]
python
en
['en', 'en', 'en']
True
SW16Device.name
(self)
Return a name for the device.
Return a name for the device.
def name(self): """Return a name for the device.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 171, 4 ]
[ 173, 25 ]
python
en
['en', 'en', 'en']
True
SW16Device.available
(self)
Return True if entity is available.
Return True if entity is available.
def available(self): """Return True if entity is available.""" return bool(self._client.is_connected)
[ "def", "available", "(", "self", ")", ":", "return", "bool", "(", "self", ".", "_client", ".", "is_connected", ")" ]
[ 176, 4 ]
[ 178, 46 ]
python
en
['en', 'en', 'en']
True
SW16Device._availability_callback
(self, availability)
Update availability state.
Update availability state.
def _availability_callback(self, availability): """Update availability state.""" self.async_write_ha_state()
[ "def", "_availability_callback", "(", "self", ",", "availability", ")", ":", "self", ".", "async_write_ha_state", "(", ")" ]
[ 181, 4 ]
[ 183, 35 ]
python
en
['en', 'en', 'en']
True
SW16Device.async_added_to_hass
(self)
Register update callback.
Register update callback.
async def async_added_to_hass(self): """Register update callback.""" self._client.register_status_callback( self.handle_event_callback, self._device_port ) self._is_on = await self._client.status(self._device_port) self.async_on_remove( async_dispatcher_co...
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "self", ".", "_client", ".", "register_status_callback", "(", "self", ".", "handle_event_callback", ",", "self", ".", "_device_port", ")", "self", ".", "_is_on", "=", "await", "self", ".", "_client"...
[ 185, 4 ]
[ 197, 9 ]
python
en
['fr', 'no', 'en']
False
device_reg
(hass)
Return an empty, loaded, registry.
Return an empty, loaded, registry.
def device_reg(hass): """Return an empty, loaded, registry.""" return mock_device_registry(hass)
[ "def", "device_reg", "(", "hass", ")", ":", "return", "mock_device_registry", "(", "hass", ")" ]
[ 21, 0 ]
[ 23, 37 ]
python
en
['en', 'fy', 'en']
True
entity_reg
(hass)
Return an empty, loaded, registry.
Return an empty, loaded, registry.
def entity_reg(hass): """Return an empty, loaded, registry.""" return mock_registry(hass)
[ "def", "entity_reg", "(", "hass", ")", ":", "return", "mock_registry", "(", "hass", ")" ]
[ 27, 0 ]
[ 29, 30 ]
python
en
['en', 'fy', 'en']
True
test_get_actions
(hass, device_reg, entity_reg)
Test we get the expected actions from a humidifier.
Test we get the expected actions from a humidifier.
async def test_get_actions(hass, device_reg, entity_reg): """Test we get the expected actions from a humidifier.""" config_entry = MockConfigEntry(domain="test", data={}) config_entry.add_to_hass(hass) device_entry = device_reg.async_get_or_create( config_entry_id=config_entry.entry_id, ...
[ "async", "def", "test_get_actions", "(", "hass", ",", "device_reg", ",", "entity_reg", ")", ":", "config_entry", "=", "MockConfigEntry", "(", "domain", "=", "\"test\"", ",", "data", "=", "{", "}", ")", "config_entry", ".", "add_to_hass", "(", "hass", ")", ...
[ 32, 0 ]
[ 78, 48 ]
python
en
['en', 'en', 'en']
True
test_get_action_no_modes
(hass, device_reg, entity_reg)
Test we get the expected actions from a humidifier.
Test we get the expected actions from a humidifier.
async def test_get_action_no_modes(hass, device_reg, entity_reg): """Test we get the expected actions from a humidifier.""" config_entry = MockConfigEntry(domain="test", data={}) config_entry.add_to_hass(hass) device_entry = device_reg.async_get_or_create( config_entry_id=config_entry.entry_id, ...
[ "async", "def", "test_get_action_no_modes", "(", "hass", ",", "device_reg", ",", "entity_reg", ")", ":", "config_entry", "=", "MockConfigEntry", "(", "domain", "=", "\"test\"", ",", "data", "=", "{", "}", ")", "config_entry", ".", "add_to_hass", "(", "hass", ...
[ 81, 0 ]
[ 121, 48 ]
python
en
['en', 'en', 'en']
True
test_get_action_no_state
(hass, device_reg, entity_reg)
Test we get the expected actions from a humidifier.
Test we get the expected actions from a humidifier.
async def test_get_action_no_state(hass, device_reg, entity_reg): """Test we get the expected actions from a humidifier.""" config_entry = MockConfigEntry(domain="test", data={}) config_entry.add_to_hass(hass) device_entry = device_reg.async_get_or_create( config_entry_id=config_entry.entry_id, ...
[ "async", "def", "test_get_action_no_state", "(", "hass", ",", "device_reg", ",", "entity_reg", ")", ":", "config_entry", "=", "MockConfigEntry", "(", "domain", "=", "\"test\"", ",", "data", "=", "{", "}", ")", "config_entry", ".", "add_to_hass", "(", "hass", ...
[ 124, 0 ]
[ 160, 48 ]
python
en
['en', 'en', 'en']
True
test_action
(hass)
Test for actions.
Test for actions.
async def test_action(hass): """Test for actions.""" hass.states.async_set( "humidifier.entity", STATE_ON, {const.ATTR_AVAILABLE_MODES: [const.MODE_HOME, const.MODE_AWAY]}, ) assert await async_setup_component( hass, automation.DOMAIN, { autom...
[ "async", "def", "test_action", "(", "hass", ")", ":", "hass", ".", "states", ".", "async_set", "(", "\"humidifier.entity\"", ",", "STATE_ON", ",", "{", "const", ".", "ATTR_AVAILABLE_MODES", ":", "[", "const", ".", "MODE_HOME", ",", "const", ".", "MODE_AWAY",...
[ 163, 0 ]
[ 289, 33 ]
python
en
['en', 'en', 'en']
True
test_capabilities
(hass)
Test getting capabilities.
Test getting capabilities.
async def test_capabilities(hass): """Test getting capabilities.""" # Test capabililities without state capabilities = await device_action.async_get_action_capabilities( hass, { "domain": DOMAIN, "device_id": "abcdefgh", "entity_id": "humidifier.entity", ...
[ "async", "def", "test_capabilities", "(", "hass", ")", ":", "# Test capabililities without state", "capabilities", "=", "await", "device_action", ".", "async_get_action_capabilities", "(", "hass", ",", "{", "\"domain\"", ":", "DOMAIN", ",", "\"device_id\"", ":", "\"ab...
[ 292, 0 ]
[ 357, 5 ]
python
en
['nl', 'en', 'en']
True
test_import_fail
(gogogate2api_mock, hass: HomeAssistant)
Test the failure to import.
Test the failure to import.
async def test_import_fail(gogogate2api_mock, hass: HomeAssistant) -> None: """Test the failure to import.""" api = MagicMock(spec=GogoGate2Api) api.info.side_effect = ApiError(22, "Error") gogogate2api_mock.return_value = api hass_config = { HA_DOMAIN: {CONF_UNIT_SYSTEM: CONF_UNIT_SYSTEM_M...
[ "async", "def", "test_import_fail", "(", "gogogate2api_mock", ",", "hass", ":", "HomeAssistant", ")", "->", "None", ":", "api", "=", "MagicMock", "(", "spec", "=", "GogoGate2Api", ")", "api", ".", "info", ".", "side_effect", "=", "ApiError", "(", "22", ","...
[ 182, 0 ]
[ 208, 25 ]
python
en
['en', 'en', 'en']
True
test_import
( ismartgateapi_mock, gogogate2api_mock, hass: HomeAssistant )
Test importing of file based config.
Test importing of file based config.
async def test_import( ismartgateapi_mock, gogogate2api_mock, hass: HomeAssistant ) -> None: """Test importing of file based config.""" api0 = MagicMock(spec=GogoGate2Api) api0.info.return_value = _mocked_gogogate_open_door_response() gogogate2api_mock.return_value = api0 api1 = MagicMock(spec=...
[ "async", "def", "test_import", "(", "ismartgateapi_mock", ",", "gogogate2api_mock", ",", "hass", ":", "HomeAssistant", ")", "->", "None", ":", "api0", "=", "MagicMock", "(", "spec", "=", "GogoGate2Api", ")", "api0", ".", "info", ".", "return_value", "=", "_m...
[ 213, 0 ]
[ 257, 38 ]
python
en
['en', 'en', 'en']
True
test_open_close_update
(gogogate2api_mock, hass: HomeAssistant)
Test open and close and data update.
Test open and close and data update.
async def test_open_close_update(gogogate2api_mock, hass: HomeAssistant) -> None: """Test open and close and data update.""" def info_response(door_status: DoorStatus) -> GogoGate2InfoResponse: return GogoGate2InfoResponse( user="user1", gogogatename="gogogatename0", ...
[ "async", "def", "test_open_close_update", "(", "gogogate2api_mock", ",", "hass", ":", "HomeAssistant", ")", "->", "None", ":", "def", "info_response", "(", "door_status", ":", "DoorStatus", ")", "->", "GogoGate2InfoResponse", ":", "return", "GogoGate2InfoResponse", ...
[ 261, 0 ]
[ 370, 51 ]
python
en
['en', 'en', 'en']
True
test_availability
(ismartgateapi_mock, hass: HomeAssistant)
Test availability.
Test availability.
async def test_availability(ismartgateapi_mock, hass: HomeAssistant) -> None: """Test availability.""" closed_door_response = _mocked_ismartgate_closed_door_response() api = MagicMock(ISmartGateApi) api.info.return_value = closed_door_response ismartgateapi_mock.return_value = api config_entry...
[ "async", "def", "test_availability", "(", "ismartgateapi_mock", ",", "hass", ":", "HomeAssistant", ")", "->", "None", ":", "closed_door_response", "=", "_mocked_ismartgate_closed_door_response", "(", ")", "api", "=", "MagicMock", "(", "ISmartGateApi", ")", "api", "....
[ 374, 0 ]
[ 417, 63 ]
python
en
['fr', 'ga', 'en']
False
test_device_info_ismartgate
(ismartgateapi_mock, hass: HomeAssistant)
Test device info.
Test device info.
async def test_device_info_ismartgate(ismartgateapi_mock, hass: HomeAssistant) -> None: """Test device info.""" device_registry = mock_device_registry(hass) closed_door_response = _mocked_ismartgate_closed_door_response() api = MagicMock(ISmartGateApi) api.info.return_value = closed_door_response ...
[ "async", "def", "test_device_info_ismartgate", "(", "ismartgateapi_mock", ",", "hass", ":", "HomeAssistant", ")", "->", "None", ":", "device_registry", "=", "mock_device_registry", "(", "hass", ")", "closed_door_response", "=", "_mocked_ismartgate_closed_door_response", "...
[ 421, 0 ]
[ 452, 37 ]
python
en
['fr', 'pl', 'en']
False
test_device_info_gogogate2
(gogogate2api_mock, hass: HomeAssistant)
Test device info.
Test device info.
async def test_device_info_gogogate2(gogogate2api_mock, hass: HomeAssistant) -> None: """Test device info.""" device_registry = mock_device_registry(hass) closed_door_response = _mocked_gogogate_open_door_response() api = MagicMock(GogoGate2Api) api.info.return_value = closed_door_response gog...
[ "async", "def", "test_device_info_gogogate2", "(", "gogogate2api_mock", ",", "hass", ":", "HomeAssistant", ")", "->", "None", ":", "device_registry", "=", "mock_device_registry", "(", "hass", ")", "closed_door_response", "=", "_mocked_gogogate_open_door_response", "(", ...
[ 456, 0 ]
[ 487, 37 ]
python
en
['fr', 'pl', 'en']
False
retry
(ExceptionToCheck: Any, tries: int = 4, delay: float = 3, backoff: float = 2)
Retry calling the decorated function using an exponential backoff. http://www.saltycrane.com/blog/2009/11/trying-out-retry-decorator-python/ original from: http://wiki.python.org/moin/PythonDecoratorLibrary#Retry (BSD licensed) :param ExceptionToCheck: the exception on which to retry :param tries: n...
Retry calling the decorated function using an exponential backoff. http://www.saltycrane.com/blog/2009/11/trying-out-retry-decorator-python/ original from: http://wiki.python.org/moin/PythonDecoratorLibrary#Retry (BSD licensed) :param ExceptionToCheck: the exception on which to retry :param tries: n...
def retry(ExceptionToCheck: Any, tries: int = 4, delay: float = 3, backoff: float = 2): """Retry calling the decorated function using an exponential backoff. http://www.saltycrane.com/blog/2009/11/trying-out-retry-decorator-python/ original from: http://wiki.python.org/moin/PythonDecoratorLibrary#Retry ...
[ "def", "retry", "(", "ExceptionToCheck", ":", "Any", ",", "tries", ":", "int", "=", "4", ",", "delay", ":", "float", "=", "3", ",", "backoff", ":", "float", "=", "2", ")", ":", "def", "deco_retry", "(", "f", ":", "Callable", ")", "->", "Callable", ...
[ 46, 0 ]
[ 74, 21 ]
python
en
['en', 'en', 'en']
True
update_plugins
(editor: Editor)
The main entry function of this module. All input arguments are grouped in the `Editor`.
The main entry function of this module. All input arguments are grouped in the `Editor`.
def update_plugins(editor: Editor): """The main entry function of this module. All input arguments are grouped in the `Editor`.""" args = parse_args(editor) log.setLevel(LOG_LEVELS[args.debug]) log.info("Start updating plugins") nixpkgs_repo = git.Repo(editor.root, search_parent_directories=True) ...
[ "def", "update_plugins", "(", "editor", ":", "Editor", ")", ":", "args", "=", "parse_args", "(", "editor", ")", "log", ".", "setLevel", "(", "LOG_LEVELS", "[", "args", ".", "debug", "]", ")", "log", ".", "info", "(", "\"Start updating plugins\"", ")", "n...
[ 516, 0 ]
[ 554, 13 ]
python
en
['en', 'en', 'en']
True
test_failing_setups_no_entities
(hass, numato_fixture, monkeypatch)
When port setup fails, no entity shall be created.
When port setup fails, no entity shall be created.
async def test_failing_setups_no_entities(hass, numato_fixture, monkeypatch): """When port setup fails, no entity shall be created.""" monkeypatch.setattr(numato_fixture.NumatoDeviceMock, "setup", mockup_raise) assert await async_setup_component(hass, "numato", NUMATO_CFG) await hass.async_block_till_do...
[ "async", "def", "test_failing_setups_no_entities", "(", "hass", ",", "numato_fixture", ",", "monkeypatch", ")", ":", "monkeypatch", ".", "setattr", "(", "numato_fixture", ".", "NumatoDeviceMock", ",", "\"setup\"", ",", "mockup_raise", ")", "assert", "await", "async_...
[ 14, 0 ]
[ 20, 62 ]
python
en
['en', 'haw', 'en']
True
test_regular_hass_operations
(hass, numato_fixture)
Test regular operations from within Home Assistant.
Test regular operations from within Home Assistant.
async def test_regular_hass_operations(hass, numato_fixture): """Test regular operations from within Home Assistant.""" assert await async_setup_component(hass, "numato", NUMATO_CFG) await hass.async_block_till_done() # wait until services are registered await hass.services.async_call( switch.D...
[ "async", "def", "test_regular_hass_operations", "(", "hass", ",", "numato_fixture", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "\"numato\"", ",", "NUMATO_CFG", ")", "await", "hass", ".", "async_block_till_done", "(", ")", "# wait until s...
[ 23, 0 ]
[ 58, 51 ]
python
en
['en', 'en', 'en']
True
test_failing_hass_operations
(hass, numato_fixture, monkeypatch)
Test failing operations called from within Home Assistant. Switches remain in their initial 'off' state when the device can't be written to.
Test failing operations called from within Home Assistant.
async def test_failing_hass_operations(hass, numato_fixture, monkeypatch): """Test failing operations called from within Home Assistant. Switches remain in their initial 'off' state when the device can't be written to. """ assert await async_setup_component(hass, "numato", NUMATO_CFG) await ha...
[ "async", "def", "test_failing_hass_operations", "(", "hass", ",", "numato_fixture", ",", "monkeypatch", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "\"numato\"", ",", "NUMATO_CFG", ")", "await", "hass", ".", "async_block_till_done", "(", ...
[ 61, 0 ]
[ 102, 50 ]
python
en
['en', 'en', 'en']
True
test_switch_setup_without_discovery_info
(hass, config, numato_fixture)
Test handling of empty discovery_info.
Test handling of empty discovery_info.
async def test_switch_setup_without_discovery_info(hass, config, numato_fixture): """Test handling of empty discovery_info.""" numato_fixture.discover() await discovery.async_load_platform(hass, "switch", "numato", None, config) for entity_id in MOCKUP_ENTITY_IDS: assert entity_id not in hass.st...
[ "async", "def", "test_switch_setup_without_discovery_info", "(", "hass", ",", "config", ",", "numato_fixture", ")", ":", "numato_fixture", ".", "discover", "(", ")", "await", "discovery", ".", "async_load_platform", "(", "hass", ",", "\"switch\"", ",", "\"numato\"",...
[ 105, 0 ]
[ 113, 58 ]
python
en
['en', 'en', 'en']
True
test_sensor
(hass, generic_data)
Test setting up config entry.
Test setting up config entry.
async def test_sensor(hass, generic_data): """Test setting up config entry.""" await setup_ozw(hass, fixture=generic_data) # Test standard sensor state = hass.states.get("sensor.smart_plug_electric_v") assert state is not None assert state.state == "123.9" assert state.attributes["unit_of_m...
[ "async", "def", "test_sensor", "(", "hass", ",", "generic_data", ")", ":", "await", "setup_ozw", "(", "hass", ",", "fixture", "=", "generic_data", ")", "# Test standard sensor", "state", "=", "hass", ".", "states", ".", "get", "(", "\"sensor.smart_plug_electric_...
[ 13, 0 ]
[ 51, 42 ]
python
en
['en', 'en', 'en']
True
test_sensor_enabled
(hass, generic_data, sensor_msg)
Test enabling an advanced sensor.
Test enabling an advanced sensor.
async def test_sensor_enabled(hass, generic_data, sensor_msg): """Test enabling an advanced sensor.""" registry = await hass.helpers.entity_registry.async_get_registry() entry = registry.async_get_or_create( SENSOR_DOMAIN, DOMAIN, "1-36-1407375493578772", suggested_object_i...
[ "async", "def", "test_sensor_enabled", "(", "hass", ",", "generic_data", ",", "sensor_msg", ")", ":", "registry", "=", "await", "hass", ".", "helpers", ".", "entity_registry", ".", "async_get_registry", "(", ")", "entry", "=", "registry", ".", "async_get_or_crea...
[ 54, 0 ]
[ 75, 47 ]
python
en
['en', 'ht', 'en']
True
test_string_sensor
(hass, string_sensor_data)
Test so the returned type is a string sensor.
Test so the returned type is a string sensor.
async def test_string_sensor(hass, string_sensor_data): """Test so the returned type is a string sensor.""" registry = await hass.helpers.entity_registry.async_get_registry() entry = registry.async_get_or_create( SENSOR_DOMAIN, DOMAIN, "1-49-73464969749610519", suggested_ob...
[ "async", "def", "test_string_sensor", "(", "hass", ",", "string_sensor_data", ")", ":", "registry", "=", "await", "hass", ".", "helpers", ".", "entity_registry", ".", "async_get_registry", "(", ")", "entry", "=", "registry", ".", "async_get_or_create", "(", "SEN...
[ 78, 0 ]
[ 96, 34 ]
python
en
['en', 'en', 'en']
True
MikrotikFlowHandler.async_get_options_flow
(config_entry)
Get the options flow for this handler.
Get the options flow for this handler.
def async_get_options_flow(config_entry): """Get the options flow for this handler.""" return MikrotikOptionsFlowHandler(config_entry)
[ "def", "async_get_options_flow", "(", "config_entry", ")", ":", "return", "MikrotikOptionsFlowHandler", "(", "config_entry", ")" ]
[ 35, 4 ]
[ 37, 55 ]
python
en
['en', 'en', 'en']
True
MikrotikFlowHandler.async_step_user
(self, user_input=None)
Handle a flow initialized by the user.
Handle a flow initialized by the user.
async def async_step_user(self, user_input=None): """Handle a flow initialized by the user.""" errors = {} if user_input is not None: for entry in self.hass.config_entries.async_entries(DOMAIN): if entry.data[CONF_HOST] == user_input[CONF_HOST]: re...
[ "async", "def", "async_step_user", "(", "self", ",", "user_input", "=", "None", ")", ":", "errors", "=", "{", "}", "if", "user_input", "is", "not", "None", ":", "for", "entry", "in", "self", ".", "hass", ".", "config_entries", ".", "async_entries", "(", ...
[ 39, 4 ]
[ 75, 9 ]
python
en
['en', 'en', 'en']
True
MikrotikFlowHandler.async_step_import
(self, import_config)
Import Miktortik from config.
Import Miktortik from config.
async def async_step_import(self, import_config): """Import Miktortik from config.""" import_config[CONF_DETECTION_TIME] = import_config[CONF_DETECTION_TIME].seconds return await self.async_step_user(user_input=import_config)
[ "async", "def", "async_step_import", "(", "self", ",", "import_config", ")", ":", "import_config", "[", "CONF_DETECTION_TIME", "]", "=", "import_config", "[", "CONF_DETECTION_TIME", "]", ".", "seconds", "return", "await", "self", ".", "async_step_user", "(", "user...
[ 77, 4 ]
[ 81, 67 ]
python
en
['en', 'sv', 'en']
True
MikrotikOptionsFlowHandler.__init__
(self, config_entry)
Initialize Mikrotik options flow.
Initialize Mikrotik options flow.
def __init__(self, config_entry): """Initialize Mikrotik options flow.""" self.config_entry = config_entry
[ "def", "__init__", "(", "self", ",", "config_entry", ")", ":", "self", ".", "config_entry", "=", "config_entry" ]
[ 87, 4 ]
[ 89, 40 ]
python
da
['da', 'fr', 'nl']
False
MikrotikOptionsFlowHandler.async_step_init
(self, user_input=None)
Manage the Mikrotik options.
Manage the Mikrotik options.
async def async_step_init(self, user_input=None): """Manage the Mikrotik options.""" return await self.async_step_device_tracker()
[ "async", "def", "async_step_init", "(", "self", ",", "user_input", "=", "None", ")", ":", "return", "await", "self", ".", "async_step_device_tracker", "(", ")" ]
[ 91, 4 ]
[ 93, 53 ]
python
en
['en', 'sq', 'en']
True
MikrotikOptionsFlowHandler.async_step_device_tracker
(self, user_input=None)
Manage the device tracker options.
Manage the device tracker options.
async def async_step_device_tracker(self, user_input=None): """Manage the device tracker options.""" if user_input is not None: return self.async_create_entry(title="", data=user_input) options = { vol.Optional( CONF_FORCE_DHCP, default=se...
[ "async", "def", "async_step_device_tracker", "(", "self", ",", "user_input", "=", "None", ")", ":", "if", "user_input", "is", "not", "None", ":", "return", "self", ".", "async_create_entry", "(", "title", "=", "\"\"", ",", "data", "=", "user_input", ")", "...
[ 95, 4 ]
[ 119, 9 ]
python
en
['en', 'en', 'en']
True
async_setup
(hass, config)
Set up the Luftdaten component.
Set up the Luftdaten component.
async def async_setup(hass, config): """Set up the Luftdaten component.""" hass.data[DOMAIN] = {} hass.data[DOMAIN][DATA_LUFTDATEN_CLIENT] = {} hass.data[DOMAIN][DATA_LUFTDATEN_LISTENER] = {} if DOMAIN not in config: return True conf = config[DOMAIN] station_id = conf[CONF_SENSOR_I...
[ "async", "def", "async_setup", "(", "hass", ",", "config", ")", ":", "hass", ".", "data", "[", "DOMAIN", "]", "=", "{", "}", "hass", ".", "data", "[", "DOMAIN", "]", "[", "DATA_LUFTDATEN_CLIENT", "]", "=", "{", "}", "hass", ".", "data", "[", "DOMAI...
[ 93, 0 ]
[ 120, 15 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, config_entry)
Set up Luftdaten as config entry.
Set up Luftdaten as config entry.
async def async_setup_entry(hass, config_entry): """Set up Luftdaten as config entry.""" if not isinstance(config_entry.data[CONF_SENSOR_ID], int): _async_fixup_sensor_id(hass, config_entry, config_entry.data[CONF_SENSOR_ID]) if ( config_entry.data[CONF_SENSOR_ID] in duplicate_stations(has...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ")", ":", "if", "not", "isinstance", "(", "config_entry", ".", "data", "[", "CONF_SENSOR_ID", "]", ",", "int", ")", ":", "_async_fixup_sensor_id", "(", "hass", ",", "config_entry", ",", "...
[ 123, 0 ]
[ 171, 15 ]
python
en
['en', 'en', 'de']
True
async_unload_entry
(hass, config_entry)
Unload an Luftdaten config entry.
Unload an Luftdaten config entry.
async def async_unload_entry(hass, config_entry): """Unload an Luftdaten config entry.""" remove_listener = hass.data[DOMAIN][DATA_LUFTDATEN_LISTENER].pop( config_entry.entry_id ) remove_listener() hass.data[DOMAIN][DATA_LUFTDATEN_CLIENT].pop(config_entry.entry_id) return await hass.co...
[ "async", "def", "async_unload_entry", "(", "hass", ",", "config_entry", ")", ":", "remove_listener", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "DATA_LUFTDATEN_LISTENER", "]", ".", "pop", "(", "config_entry", ".", "entry_id", ")", "remove_listener", "(...
[ 174, 0 ]
[ 183, 87 ]
python
de
['de', 'en', 'nl']
False
LuftDatenData.__init__
(self, client, sensor_conditions)
Initialize the Luftdata object.
Initialize the Luftdata object.
def __init__(self, client, sensor_conditions): """Initialize the Luftdata object.""" self.client = client self.data = {} self.sensor_conditions = sensor_conditions
[ "def", "__init__", "(", "self", ",", "client", ",", "sensor_conditions", ")", ":", "self", ".", "client", "=", "client", "self", ".", "data", "=", "{", "}", "self", ".", "sensor_conditions", "=", "sensor_conditions" ]
[ 189, 4 ]
[ 193, 50 ]
python
en
['en', 'en', 'en']
True
LuftDatenData.async_update
(self)
Update sensor/binary sensor data.
Update sensor/binary sensor data.
async def async_update(self): """Update sensor/binary sensor data.""" try: await self.client.get_data() self.data[DATA_LUFTDATEN] = self.client.values self.data[DATA_LUFTDATEN].update(self.client.meta) except LuftdatenError: _LOGGER.error("Unable...
[ "async", "def", "async_update", "(", "self", ")", ":", "try", ":", "await", "self", ".", "client", ".", "get_data", "(", ")", "self", ".", "data", "[", "DATA_LUFTDATEN", "]", "=", "self", ".", "client", ".", "values", "self", ".", "data", "[", "DATA_...
[ 195, 4 ]
[ 204, 72 ]
python
en
['en', 'bs', 'en']
True
test_debounce
(hass)
Test add_timeout decorator function.
Test add_timeout decorator function.
async def test_debounce(hass): """Test add_timeout decorator function.""" def demo_func(*args): nonlocal arguments, counter counter += 1 arguments = args arguments = None counter = 0 mock = Mock(hass=hass, debounce={}) debounce_demo = debounce(demo_func) assert deb...
[ "async", "def", "test_debounce", "(", "hass", ")", ":", "def", "demo_func", "(", "*", "args", ")", ":", "nonlocal", "arguments", ",", "counter", "counter", "+=", "1", "arguments", "=", "args", "arguments", "=", "None", "counter", "=", "0", "mock", "=", ...
[ 52, 0 ]
[ 81, 23 ]
python
en
['fr', 'en', 'en']
True
test_accessory_cancels_track_state_change_on_stop
(hass, hk_driver)
Ensure homekit state changed listeners are unsubscribed on reload.
Ensure homekit state changed listeners are unsubscribed on reload.
async def test_accessory_cancels_track_state_change_on_stop(hass, hk_driver): """Ensure homekit state changed listeners are unsubscribed on reload.""" entity_id = "sensor.accessory" hass.states.async_set(entity_id, None) acc = HomeAccessory( hass, hk_driver, "Home Accessory", entity_id, 2, {"pla...
[ "async", "def", "test_accessory_cancels_track_state_change_on_stop", "(", "hass", ",", "hk_driver", ")", ":", "entity_id", "=", "\"sensor.accessory\"", "hass", ".", "states", ".", "async_set", "(", "entity_id", ",", "None", ")", "acc", "=", "HomeAccessory", "(", "...
[ 84, 0 ]
[ 97, 67 ]
python
en
['en', 'en', 'en']
True
test_home_accessory
(hass, hk_driver)
Test HomeAccessory class.
Test HomeAccessory class.
async def test_home_accessory(hass, hk_driver): """Test HomeAccessory class.""" entity_id = "sensor.accessory" entity_id2 = "light.accessory" hass.states.async_set(entity_id, None) hass.states.async_set(entity_id2, STATE_UNAVAILABLE) await hass.async_block_till_done() acc = HomeAccessory(...
[ "async", "def", "test_home_accessory", "(", "hass", ",", "hk_driver", ")", ":", "entity_id", "=", "\"sensor.accessory\"", "entity_id2", "=", "\"light.accessory\"", "hass", ".", "states", ".", "async_set", "(", "entity_id", ",", "None", ")", "hass", ".", "states"...
[ 100, 0 ]
[ 176, 68 ]
python
en
['en', 'en', 'en']
True
test_battery_service
(hass, hk_driver, caplog)
Test battery service.
Test battery service.
async def test_battery_service(hass, hk_driver, caplog): """Test battery service.""" entity_id = "homekit.accessory" hass.states.async_set(entity_id, None, {ATTR_BATTERY_LEVEL: 50}) await hass.async_block_till_done() acc = HomeAccessory(hass, hk_driver, "Battery Service", entity_id, 2, None) as...
[ "async", "def", "test_battery_service", "(", "hass", ",", "hk_driver", ",", "caplog", ")", ":", "entity_id", "=", "\"homekit.accessory\"", "hass", ".", "states", ".", "async_set", "(", "entity_id", ",", "None", ",", "{", "ATTR_BATTERY_LEVEL", ":", "50", "}", ...
[ 179, 0 ]
[ 266, 40 ]
python
en
['en', 'cs', 'en']
True
test_linked_battery_sensor
(hass, hk_driver, caplog)
Test battery service with linked_battery_sensor.
Test battery service with linked_battery_sensor.
async def test_linked_battery_sensor(hass, hk_driver, caplog): """Test battery service with linked_battery_sensor.""" entity_id = "homekit.accessory" linked_battery = "sensor.battery" hass.states.async_set(entity_id, "open", {ATTR_BATTERY_LEVEL: 100}) hass.states.async_set(linked_battery, 50, None) ...
[ "async", "def", "test_linked_battery_sensor", "(", "hass", ",", "hk_driver", ",", "caplog", ")", ":", "entity_id", "=", "\"homekit.accessory\"", "linked_battery", "=", "\"sensor.battery\"", "hass", ".", "states", ".", "async_set", "(", "entity_id", ",", "\"open\"", ...
[ 269, 0 ]
[ 353, 40 ]
python
en
['en', 'en', 'en']
True
test_linked_battery_charging_sensor
(hass, hk_driver, caplog)
Test battery service with linked_battery_charging_sensor.
Test battery service with linked_battery_charging_sensor.
async def test_linked_battery_charging_sensor(hass, hk_driver, caplog): """Test battery service with linked_battery_charging_sensor.""" entity_id = "homekit.accessory" linked_battery_charging_sensor = "binary_sensor.battery_charging" hass.states.async_set(entity_id, "open", {ATTR_BATTERY_LEVEL: 100}) ...
[ "async", "def", "test_linked_battery_charging_sensor", "(", "hass", ",", "hk_driver", ",", "caplog", ")", ":", "entity_id", "=", "\"homekit.accessory\"", "linked_battery_charging_sensor", "=", "\"binary_sensor.battery_charging\"", "hass", ".", "states", ".", "async_set", ...
[ 356, 0 ]
[ 411, 40 ]
python
en
['en', 'en', 'en']
True
test_linked_battery_sensor_and_linked_battery_charging_sensor
( hass, hk_driver, caplog )
Test battery service with linked_battery_sensor and a linked_battery_charging_sensor.
Test battery service with linked_battery_sensor and a linked_battery_charging_sensor.
async def test_linked_battery_sensor_and_linked_battery_charging_sensor( hass, hk_driver, caplog ): """Test battery service with linked_battery_sensor and a linked_battery_charging_sensor.""" entity_id = "homekit.accessory" linked_battery = "sensor.battery" linked_battery_charging_sensor = "binary_s...
[ "async", "def", "test_linked_battery_sensor_and_linked_battery_charging_sensor", "(", "hass", ",", "hk_driver", ",", "caplog", ")", ":", "entity_id", "=", "\"homekit.accessory\"", "linked_battery", "=", "\"sensor.battery\"", "linked_battery_charging_sensor", "=", "\"binary_sens...
[ 414, 0 ]
[ 460, 40 ]
python
en
['en', 'en', 'en']
True
test_missing_linked_battery_charging_sensor
(hass, hk_driver, caplog)
Test battery service with linked_battery_charging_sensor that is mapping to a missing entity.
Test battery service with linked_battery_charging_sensor that is mapping to a missing entity.
async def test_missing_linked_battery_charging_sensor(hass, hk_driver, caplog): """Test battery service with linked_battery_charging_sensor that is mapping to a missing entity.""" entity_id = "homekit.accessory" linked_battery_charging_sensor = "binary_sensor.battery_charging" hass.states.async_set(enti...
[ "async", "def", "test_missing_linked_battery_charging_sensor", "(", "hass", ",", "hk_driver", ",", "caplog", ")", ":", "entity_id", "=", "\"homekit.accessory\"", "linked_battery_charging_sensor", "=", "\"binary_sensor.battery_charging\"", "hass", ".", "states", ".", "async_...
[ 463, 0 ]
[ 496, 42 ]
python
en
['en', 'en', 'en']
True
test_missing_linked_battery_sensor
(hass, hk_driver, caplog)
Test battery service with missing linked_battery_sensor.
Test battery service with missing linked_battery_sensor.
async def test_missing_linked_battery_sensor(hass, hk_driver, caplog): """Test battery service with missing linked_battery_sensor.""" entity_id = "homekit.accessory" linked_battery = "sensor.battery" hass.states.async_set(entity_id, "open") await hass.async_block_till_done() acc = HomeAccessory...
[ "async", "def", "test_missing_linked_battery_sensor", "(", "hass", ",", "hk_driver", ",", "caplog", ")", ":", "entity_id", "=", "\"homekit.accessory\"", "linked_battery", "=", "\"sensor.battery\"", "hass", ".", "states", ".", "async_set", "(", "entity_id", ",", "\"o...
[ 499, 0 ]
[ 539, 37 ]
python
en
['en', 'en', 'en']
True
test_battery_appears_after_startup
(hass, hk_driver, caplog)
Test battery level appears after homekit is started.
Test battery level appears after homekit is started.
async def test_battery_appears_after_startup(hass, hk_driver, caplog): """Test battery level appears after homekit is started.""" entity_id = "homekit.accessory" hass.states.async_set(entity_id, None, {}) await hass.async_block_till_done() acc = HomeAccessory(hass, hk_driver, "Accessory without bat...
[ "async", "def", "test_battery_appears_after_startup", "(", "hass", ",", "hk_driver", ",", "caplog", ")", ":", "entity_id", "=", "\"homekit.accessory\"", "hass", ".", "states", ".", "async_set", "(", "entity_id", ",", "None", ",", "{", "}", ")", "await", "hass"...
[ 542, 0 ]
[ 572, 36 ]
python
en
['en', 'en', 'en']
True
test_call_service
(hass, hk_driver, events)
Test call_service method.
Test call_service method.
async def test_call_service(hass, hk_driver, events): """Test call_service method.""" entity_id = "homekit.accessory" hass.states.async_set(entity_id, None) await hass.async_block_till_done() acc = HomeAccessory(hass, hk_driver, "Home Accessory", entity_id, 2, {}) call_service = async_mock_serv...
[ "async", "def", "test_call_service", "(", "hass", ",", "hk_driver", ",", "events", ")", ":", "entity_id", "=", "\"homekit.accessory\"", "hass", ".", "states", ".", "async_set", "(", "entity_id", ",", "None", ")", "await", "hass", ".", "async_block_till_done", ...
[ 575, 0 ]
[ 604, 62 ]
python
en
['en', 'en', 'en']
True
test_home_bridge
(hk_driver)
Test HomeBridge class.
Test HomeBridge class.
def test_home_bridge(hk_driver): """Test HomeBridge class.""" bridge = HomeBridge("hass", hk_driver, BRIDGE_NAME) assert bridge.hass == "hass" assert bridge.display_name == BRIDGE_NAME assert bridge.category == 2 # Category.BRIDGE assert len(bridge.services) == 1 serv = bridge.services[0] ...
[ "def", "test_home_bridge", "(", "hk_driver", ")", ":", "bridge", "=", "HomeBridge", "(", "\"hass\"", ",", "hk_driver", ",", "BRIDGE_NAME", ")", "assert", "bridge", ".", "hass", "==", "\"hass\"", "assert", "bridge", ".", "display_name", "==", "BRIDGE_NAME", "as...
[ 607, 0 ]
[ 628, 26 ]
python
en
['en', 'zh', 'en']
True
test_home_driver
()
Test HomeDriver class.
Test HomeDriver class.
def test_home_driver(): """Test HomeDriver class.""" ip_address = "127.0.0.1" port = 51826 path = ".homekit.state" pin = b"123-45-678" with patch("pyhap.accessory_driver.AccessoryDriver.__init__") as mock_driver: driver = HomeDriver( "hass", "entry_id", "name", address=ip_ad...
[ "def", "test_home_driver", "(", ")", ":", "ip_address", "=", "\"127.0.0.1\"", "port", "=", "51826", "path", "=", "\".homekit.state\"", "pin", "=", "b\"123-45-678\"", "with", "patch", "(", "\"pyhap.accessory_driver.AccessoryDriver.__init__\"", ")", "as", "mock_driver", ...
[ 631, 0 ]
[ 664, 81 ]
python
en
['en', 'lb', 'en']
True
async_setup_entry
(hass, config_entry, async_add_entities)
Set up the Flo switches from config entry.
Set up the Flo switches from config entry.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up the Flo switches from config entry.""" devices: List[FloDeviceDataUpdateCoordinator] = hass.data[FLO_DOMAIN][ config_entry.entry_id ]["devices"] async_add_entities([FloSwitch(device) for device in devices]) platf...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "devices", ":", "List", "[", "FloDeviceDataUpdateCoordinator", "]", "=", "hass", ".", "data", "[", "FLO_DOMAIN", "]", "[", "config_entry", ".", "entry_id"...
[ 23, 0 ]
[ 50, 5 ]
python
en
['en', 'en', 'en']
True
FloSwitch.__init__
(self, device: FloDeviceDataUpdateCoordinator)
Initialize the Flo switch.
Initialize the Flo switch.
def __init__(self, device: FloDeviceDataUpdateCoordinator): """Initialize the Flo switch.""" super().__init__("shutoff_valve", "Shutoff Valve", device) self._state = self._device.last_known_valve_state == "open"
[ "def", "__init__", "(", "self", ",", "device", ":", "FloDeviceDataUpdateCoordinator", ")", ":", "super", "(", ")", ".", "__init__", "(", "\"shutoff_valve\"", ",", "\"Shutoff Valve\"", ",", "device", ")", "self", ".", "_state", "=", "self", ".", "_device", "....
[ 56, 4 ]
[ 59, 67 ]
python
en
['en', 'en', 'en']
True
FloSwitch.is_on
(self)
Return True if the valve is open.
Return True if the valve is open.
def is_on(self) -> bool: """Return True if the valve is open.""" return self._state
[ "def", "is_on", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "_state" ]
[ 62, 4 ]
[ 64, 26 ]
python
en
['en', 'nl', 'en']
True
FloSwitch.icon
(self)
Return the icon to use for the valve.
Return the icon to use for the valve.
def icon(self): """Return the icon to use for the valve.""" if self.is_on: return "mdi:valve-open" return "mdi:valve-closed"
[ "def", "icon", "(", "self", ")", ":", "if", "self", ".", "is_on", ":", "return", "\"mdi:valve-open\"", "return", "\"mdi:valve-closed\"" ]
[ 67, 4 ]
[ 71, 33 ]
python
en
['en', 'en', 'en']
True
FloSwitch.async_turn_on
(self, **kwargs)
Open the valve.
Open the valve.
async def async_turn_on(self, **kwargs) -> None: """Open the valve.""" await self._device.api_client.device.open_valve(self._device.id) self._state = True self.async_write_ha_state()
[ "async", "def", "async_turn_on", "(", "self", ",", "*", "*", "kwargs", ")", "->", "None", ":", "await", "self", ".", "_device", ".", "api_client", ".", "device", ".", "open_valve", "(", "self", ".", "_device", ".", "id", ")", "self", ".", "_state", "...
[ 73, 4 ]
[ 77, 35 ]
python
en
['en', 'fi', 'en']
True
FloSwitch.async_turn_off
(self, **kwargs)
Close the valve.
Close the valve.
async def async_turn_off(self, **kwargs) -> None: """Close the valve.""" await self._device.api_client.device.close_valve(self._device.id) self._state = False self.async_write_ha_state()
[ "async", "def", "async_turn_off", "(", "self", ",", "*", "*", "kwargs", ")", "->", "None", ":", "await", "self", ".", "_device", ".", "api_client", ".", "device", ".", "close_valve", "(", "self", ".", "_device", ".", "id", ")", "self", ".", "_state", ...
[ 79, 4 ]
[ 83, 35 ]
python
en
['en', 'sd', 'en']
True
FloSwitch.async_update_state
(self)
Retrieve the latest valve state and update the state machine.
Retrieve the latest valve state and update the state machine.
def async_update_state(self) -> None: """Retrieve the latest valve state and update the state machine.""" self._state = self._device.last_known_valve_state == "open" self.async_write_ha_state()
[ "def", "async_update_state", "(", "self", ")", "->", "None", ":", "self", ".", "_state", "=", "self", ".", "_device", ".", "last_known_valve_state", "==", "\"open\"", "self", ".", "async_write_ha_state", "(", ")" ]
[ 86, 4 ]
[ 89, 35 ]
python
en
['en', 'en', 'en']
True
FloSwitch.async_added_to_hass
(self)
When entity is added to hass.
When entity is added to hass.
async def async_added_to_hass(self): """When entity is added to hass.""" self.async_on_remove(self._device.async_add_listener(self.async_update_state))
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "self", ".", "async_on_remove", "(", "self", ".", "_device", ".", "async_add_listener", "(", "self", ".", "async_update_state", ")", ")" ]
[ 91, 4 ]
[ 93, 86 ]
python
en
['en', 'en', 'en']
True
FloSwitch.async_set_mode_home
(self)
Set the Flo location to home mode.
Set the Flo location to home mode.
async def async_set_mode_home(self): """Set the Flo location to home mode.""" await self._device.async_set_mode_home()
[ "async", "def", "async_set_mode_home", "(", "self", ")", ":", "await", "self", ".", "_device", ".", "async_set_mode_home", "(", ")" ]
[ 95, 4 ]
[ 97, 48 ]
python
en
['en', 'pt', 'en']
True
FloSwitch.async_set_mode_away
(self)
Set the Flo location to away mode.
Set the Flo location to away mode.
async def async_set_mode_away(self): """Set the Flo location to away mode.""" await self._device.async_set_mode_away()
[ "async", "def", "async_set_mode_away", "(", "self", ")", ":", "await", "self", ".", "_device", ".", "async_set_mode_away", "(", ")" ]
[ 99, 4 ]
[ 101, 48 ]
python
en
['en', 'en', 'en']
True