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
SharkVacuumEntity.async_set_fan_speed
(self, fan_speed: str, **kwargs)
Set the fan speed.
Set the fan speed.
async def async_set_fan_speed(self, fan_speed: str, **kwargs): """Set the fan speed.""" await self.sharkiq.async_set_property_value( Properties.POWER_MODE, FAN_SPEEDS_MAP.get(fan_speed.capitalize()) ) await self.coordinator.async_refresh()
[ "async", "def", "async_set_fan_speed", "(", "self", ",", "fan_speed", ":", "str", ",", "*", "*", "kwargs", ")", ":", "await", "self", ".", "sharkiq", ".", "async_set_property_value", "(", "Properties", ".", "POWER_MODE", ",", "FAN_SPEEDS_MAP", ".", "get", "(...
[ 228, 4 ]
[ 233, 46 ]
python
en
['en', 'fy', 'en']
True
SharkVacuumEntity.fan_speed_list
(self)
Get the list of available fan speed steps of the vacuum cleaner.
Get the list of available fan speed steps of the vacuum cleaner.
def fan_speed_list(self): """Get the list of available fan speed steps of the vacuum cleaner.""" return list(FAN_SPEEDS_MAP)
[ "def", "fan_speed_list", "(", "self", ")", ":", "return", "list", "(", "FAN_SPEEDS_MAP", ")" ]
[ 236, 4 ]
[ 238, 35 ]
python
en
['en', 'en', 'en']
True
SharkVacuumEntity.recharge_resume
(self)
Recharge and resume mode active.
Recharge and resume mode active.
def recharge_resume(self) -> Optional[bool]: """Recharge and resume mode active.""" return self.sharkiq.get_property_value(Properties.RECHARGE_RESUME)
[ "def", "recharge_resume", "(", "self", ")", "->", "Optional", "[", "bool", "]", ":", "return", "self", ".", "sharkiq", ".", "get_property_value", "(", "Properties", ".", "RECHARGE_RESUME", ")" ]
[ 242, 4 ]
[ 244, 74 ]
python
en
['en', 'en', 'en']
True
SharkVacuumEntity.rssi
(self)
Get the WiFi RSSI.
Get the WiFi RSSI.
def rssi(self) -> Optional[int]: """Get the WiFi RSSI.""" return self.sharkiq.get_property_value(Properties.RSSI)
[ "def", "rssi", "(", "self", ")", "->", "Optional", "[", "int", "]", ":", "return", "self", ".", "sharkiq", ".", "get_property_value", "(", "Properties", ".", "RSSI", ")" ]
[ 247, 4 ]
[ 249, 63 ]
python
en
['en', 'en', 'en']
True
SharkVacuumEntity.low_light
(self)
Let us know if the robot is operating in low-light mode.
Let us know if the robot is operating in low-light mode.
def low_light(self): """Let us know if the robot is operating in low-light mode.""" return self.sharkiq.get_property_value(Properties.LOW_LIGHT_MISSION)
[ "def", "low_light", "(", "self", ")", ":", "return", "self", ".", "sharkiq", ".", "get_property_value", "(", "Properties", ".", "LOW_LIGHT_MISSION", ")" ]
[ 252, 4 ]
[ 254, 76 ]
python
en
['en', 'en', 'en']
True
SharkVacuumEntity.device_state_attributes
(self)
Return a dictionary of device state attributes specific to sharkiq.
Return a dictionary of device state attributes specific to sharkiq.
def device_state_attributes(self) -> Dict: """Return a dictionary of device state attributes specific to sharkiq.""" data = { ATTR_ERROR_CODE: self.error_code, ATTR_ERROR_MSG: self.sharkiq.error_text, ATTR_LOW_LIGHT: self.low_light, ATTR_RECHARGE_RESUME: s...
[ "def", "device_state_attributes", "(", "self", ")", "->", "Dict", ":", "data", "=", "{", "ATTR_ERROR_CODE", ":", "self", ".", "error_code", ",", "ATTR_ERROR_MSG", ":", "self", ".", "sharkiq", ".", "error_text", ",", "ATTR_LOW_LIGHT", ":", "self", ".", "low_l...
[ 257, 4 ]
[ 265, 19 ]
python
en
['en', 'en', 'en']
True
async_setup_events
(gateway)
Set up the deCONZ events.
Set up the deCONZ events.
async def async_setup_events(gateway) -> None: """Set up the deCONZ events.""" @callback def async_add_sensor(sensors): """Create DeconzEvent.""" for sensor in sensors: if not gateway.option_allow_clip_sensor and sensor.type.startswith("CLIP"): continue ...
[ "async", "def", "async_setup_events", "(", "gateway", ")", "->", "None", ":", "@", "callback", "def", "async_add_sensor", "(", "sensors", ")", ":", "\"\"\"Create DeconzEvent.\"\"\"", "for", "sensor", "in", "sensors", ":", "if", "not", "gateway", ".", "option_all...
[ 14, 0 ]
[ 42, 5 ]
python
en
['en', 'fr', 'en']
True
async_unload_events
(gateway)
Unload all deCONZ events.
Unload all deCONZ events.
def async_unload_events(gateway) -> None: """Unload all deCONZ events.""" for event in gateway.events: event.async_will_remove_from_hass() gateway.events.clear()
[ "def", "async_unload_events", "(", "gateway", ")", "->", "None", ":", "for", "event", "in", "gateway", ".", "events", ":", "event", ".", "async_will_remove_from_hass", "(", ")", "gateway", ".", "events", ".", "clear", "(", ")" ]
[ 46, 0 ]
[ 51, 26 ]
python
ca
['sv', 'ca', 'pt']
False
DeconzEvent.__init__
(self, device, gateway)
Register callback that will be used for signals.
Register callback that will be used for signals.
def __init__(self, device, gateway): """Register callback that will be used for signals.""" super().__init__(device, gateway) self._device.register_callback(self.async_update_callback) self.device_id = None self.event_id = slugify(self._device.name) LOGGER.debug("deCONZ...
[ "def", "__init__", "(", "self", ",", "device", ",", "gateway", ")", ":", "super", "(", ")", ".", "__init__", "(", "device", ",", "gateway", ")", "self", ".", "_device", ".", "register_callback", "(", "self", ".", "async_update_callback", ")", "self", "."...
[ 61, 4 ]
[ 69, 63 ]
python
en
['en', 'en', 'en']
True
DeconzEvent.device
(self)
Return Event device.
Return Event device.
def device(self): """Return Event device.""" return self._device
[ "def", "device", "(", "self", ")", ":", "return", "self", ".", "_device" ]
[ 72, 4 ]
[ 74, 27 ]
python
en
['fr', 'hr', 'en']
False
DeconzEvent.async_will_remove_from_hass
(self)
Disconnect event object when removed.
Disconnect event object when removed.
def async_will_remove_from_hass(self) -> None: """Disconnect event object when removed.""" self._device.remove_callback(self.async_update_callback)
[ "def", "async_will_remove_from_hass", "(", "self", ")", "->", "None", ":", "self", ".", "_device", ".", "remove_callback", "(", "self", ".", "async_update_callback", ")" ]
[ 77, 4 ]
[ 79, 64 ]
python
en
['en', 'en', 'en']
True
DeconzEvent.async_update_callback
(self, force_update=False)
Fire the event if reason is that state is updated.
Fire the event if reason is that state is updated.
def async_update_callback(self, force_update=False): """Fire the event if reason is that state is updated.""" if ( self.gateway.ignore_state_updates or "state" not in self._device.changed_keys ): return data = { CONF_ID: self.event_id, ...
[ "def", "async_update_callback", "(", "self", ",", "force_update", "=", "False", ")", ":", "if", "(", "self", ".", "gateway", ".", "ignore_state_updates", "or", "\"state\"", "not", "in", "self", ".", "_device", ".", "changed_keys", ")", ":", "return", "data",...
[ 82, 4 ]
[ 105, 65 ]
python
en
['en', 'en', 'en']
True
DeconzEvent.async_update_device_registry
(self)
Update device registry.
Update device registry.
async def async_update_device_registry(self): """Update device registry.""" device_registry = ( await self.gateway.hass.helpers.device_registry.async_get_registry() ) entry = device_registry.async_get_or_create( config_entry_id=self.gateway.config_entry.entry_id,...
[ "async", "def", "async_update_device_registry", "(", "self", ")", ":", "device_registry", "=", "(", "await", "self", ".", "gateway", ".", "hass", ".", "helpers", ".", "device_registry", ".", "async_get_registry", "(", ")", ")", "entry", "=", "device_registry", ...
[ 107, 4 ]
[ 116, 33 ]
python
en
['fr', 'fy', 'en']
False
accuracy
(output, target, topk=(1,))
Computes the precision@k for the specified values of k
Computes the precision
def accuracy(output, target, topk=(1,)): """ Computes the precision@k for the specified values of k """ maxk = max(topk) batch_size = target.size(0) _, pred = output.topk(maxk, 1, True, True) pred = pred.t() # one-hot case if target.ndimension() > 1: target = target.max(1)[1] c...
[ "def", "accuracy", "(", "output", ",", "target", ",", "topk", "=", "(", "1", ",", ")", ")", ":", "maxk", "=", "max", "(", "topk", ")", "batch_size", "=", "target", ".", "size", "(", "0", ")", "_", ",", "pred", "=", "output", ".", "topk", "(", ...
[ 45, 0 ]
[ 62, 14 ]
python
en
['en', 'en', 'en']
True
CorpusLoader.n_folds
(self)
Returns the number of folds if it exists; 0 otherwise.
Returns the number of folds if it exists; 0 otherwise.
def n_folds(self): """ Returns the number of folds if it exists; 0 otherwise. """ if self.folds is None: return 0 return self.folds.n_folds
[ "def", "n_folds", "(", "self", ")", ":", "if", "self", ".", "folds", "is", "None", ":", "return", "0", "return", "self", ".", "folds", ".", "n_folds" ]
[ 14, 4 ]
[ 19, 33 ]
python
en
['en', 'error', 'th']
False
test_datetime
()
Test datetime encoding.
Test datetime encoding.
async def test_datetime(): """Test datetime encoding.""" time = datetime(2019, 1, 13, 12, 30, 5) assert victim().encode(time) == '"2019-01-13T12:30:05"'
[ "async", "def", "test_datetime", "(", ")", ":", "time", "=", "datetime", "(", "2019", ",", "1", ",", "13", ",", "12", ",", "30", ",", "5", ")", "assert", "victim", "(", ")", ".", "encode", "(", "time", ")", "==", "'\"2019-01-13T12:30:05\"'" ]
[ 25, 0 ]
[ 28, 59 ]
python
da
['fr', 'da', 'en']
False
test_no_datetime
()
Test integer encoding.
Test integer encoding.
async def test_no_datetime(): """Test integer encoding.""" assert victim().encode(42) == "42"
[ "async", "def", "test_no_datetime", "(", ")", ":", "assert", "victim", "(", ")", ".", "encode", "(", "42", ")", "==", "\"42\"" ]
[ 31, 0 ]
[ 33, 38 ]
python
da
['da', 'da', 'en']
True
test_nested
()
Test dictionary encoding.
Test dictionary encoding.
async def test_nested(): """Test dictionary encoding.""" assert victim().encode({"foo": "bar"}) == '{"foo": "bar"}'
[ "async", "def", "test_nested", "(", ")", ":", "assert", "victim", "(", ")", ".", "encode", "(", "{", "\"foo\"", ":", "\"bar\"", "}", ")", "==", "'{\"foo\": \"bar\"}'" ]
[ 36, 0 ]
[ 38, 62 ]
python
en
['en', 'en', 'it']
True
mock_client_fixture
()
Mock the pubsub client.
Mock the pubsub client.
def mock_client_fixture(): """Mock the pubsub client.""" with mock.patch(f"{GOOGLE_PUBSUB_PATH}.pubsub_v1") as client: client.PublisherClient = mock.MagicMock() setattr( client.PublisherClient, "from_service_account_json", mock.MagicMock(return_value=mock.Magi...
[ "def", "mock_client_fixture", "(", ")", ":", "with", "mock", ".", "patch", "(", "f\"{GOOGLE_PUBSUB_PATH}.pubsub_v1\"", ")", "as", "client", ":", "client", ".", "PublisherClient", "=", "mock", ".", "MagicMock", "(", ")", "setattr", "(", "client", ".", "Publishe...
[ 42, 0 ]
[ 51, 20 ]
python
en
['en', 'fr', 'en']
True
mock_os_fixture
()
Mock the OS cli.
Mock the OS cli.
def mock_os_fixture(): """Mock the OS cli.""" with mock.patch(f"{GOOGLE_PUBSUB_PATH}.os") as os_cli: os_cli.path = mock.MagicMock() setattr(os_cli.path, "join", mock.MagicMock(return_value="path")) yield os_cli
[ "def", "mock_os_fixture", "(", ")", ":", "with", "mock", ".", "patch", "(", "f\"{GOOGLE_PUBSUB_PATH}.os\"", ")", "as", "os_cli", ":", "os_cli", ".", "path", "=", "mock", ".", "MagicMock", "(", ")", "setattr", "(", "os_cli", ".", "path", ",", "\"join\"", ...
[ 55, 0 ]
[ 60, 20 ]
python
en
['en', 'sm', 'en']
True
mock_bus_and_json
(hass, monkeypatch)
Mock the event bus listener and os component.
Mock the event bus listener and os component.
def mock_bus_and_json(hass, monkeypatch): """Mock the event bus listener and os component.""" hass.bus.listen = mock.MagicMock() monkeypatch.setattr( f"{GOOGLE_PUBSUB_PATH}.json.dumps", mock.Mock(return_value=mock.MagicMock()) )
[ "def", "mock_bus_and_json", "(", "hass", ",", "monkeypatch", ")", ":", "hass", ".", "bus", ".", "listen", "=", "mock", ".", "MagicMock", "(", ")", "monkeypatch", ".", "setattr", "(", "f\"{GOOGLE_PUBSUB_PATH}.json.dumps\"", ",", "mock", ".", "Mock", "(", "ret...
[ 64, 0 ]
[ 69, 5 ]
python
en
['en', 'en', 'en']
True
test_minimal_config
(hass, mock_client)
Test the minimal config and defaults of component.
Test the minimal config and defaults of component.
async def test_minimal_config(hass, mock_client): """Test the minimal config and defaults of component.""" config = { google_pubsub.DOMAIN: { "project_id": "proj", "topic_name": "topic", "credentials_json": "creds", "filter": {}, } } assert...
[ "async", "def", "test_minimal_config", "(", "hass", ",", "mock_client", ")", ":", "config", "=", "{", "google_pubsub", ".", "DOMAIN", ":", "{", "\"project_id\"", ":", "\"proj\"", ",", "\"topic_name\"", ":", "\"topic\"", ",", "\"credentials_json\"", ":", "\"creds...
[ 72, 0 ]
[ 89, 5 ]
python
en
['en', 'en', 'en']
True
test_full_config
(hass, mock_client)
Test the full config of the component.
Test the full config of the component.
async def test_full_config(hass, mock_client): """Test the full config of the component.""" config = { google_pubsub.DOMAIN: { "project_id": "proj", "topic_name": "topic", "credentials_json": "creds", "filter": { "include_domains": ["light"...
[ "async", "def", "test_full_config", "(", "hass", ",", "mock_client", ")", ":", "config", "=", "{", "google_pubsub", ".", "DOMAIN", ":", "{", "\"project_id\"", ":", "\"proj\"", ",", "\"topic_name\"", ":", "\"topic\"", ",", "\"credentials_json\"", ":", "\"creds\""...
[ 92, 0 ]
[ 116, 5 ]
python
en
['en', 'en', 'en']
True
make_event
(entity_id)
Make a mock event for test.
Make a mock event for test.
def make_event(entity_id): """Make a mock event for test.""" domain = split_entity_id(entity_id)[0] state = mock.MagicMock( state="not blank", domain=domain, entity_id=entity_id, object_id="entity", attributes={}, ) return mock.MagicMock(data={"new_state": sta...
[ "def", "make_event", "(", "entity_id", ")", ":", "domain", "=", "split_entity_id", "(", "entity_id", ")", "[", "0", "]", "state", "=", "mock", ".", "MagicMock", "(", "state", "=", "\"not blank\"", ",", "domain", "=", "domain", ",", "entity_id", "=", "ent...
[ 119, 0 ]
[ 129, 70 ]
python
en
['en', 'da', 'en']
True
_setup
(hass, filter_config)
Shared set up for filtering tests.
Shared set up for filtering tests.
async def _setup(hass, filter_config): """Shared set up for filtering tests.""" config = { google_pubsub.DOMAIN: { "project_id": "proj", "topic_name": "topic", "credentials_json": "creds", "filter": filter_config, } } assert await async_set...
[ "async", "def", "_setup", "(", "hass", ",", "filter_config", ")", ":", "config", "=", "{", "google_pubsub", ".", "DOMAIN", ":", "{", "\"project_id\"", ":", "\"proj\"", ",", "\"topic_name\"", ":", "\"topic\"", ",", "\"credentials_json\"", ":", "\"creds\"", ",",...
[ 132, 0 ]
[ 144, 50 ]
python
en
['en', 'da', 'en']
True
test_allowlist
(hass, mock_client)
Test an allowlist only config.
Test an allowlist only config.
async def test_allowlist(hass, mock_client): """Test an allowlist only config.""" handler_method = await _setup( hass, { "include_domains": ["light"], "include_entity_globs": ["sensor.included_*"], "include_entities": ["binary_sensor.included"], }, ...
[ "async", "def", "test_allowlist", "(", "hass", ",", "mock_client", ")", ":", "handler_method", "=", "await", "_setup", "(", "hass", ",", "{", "\"include_domains\"", ":", "[", "\"light\"", "]", ",", "\"include_entity_globs\"", ":", "[", "\"sensor.included_*\"", "...
[ 147, 0 ]
[ 174, 43 ]
python
en
['en', 'lb', 'en']
True
test_denylist
(hass, mock_client)
Test a denylist only config.
Test a denylist only config.
async def test_denylist(hass, mock_client): """Test a denylist only config.""" handler_method = await _setup( hass, { "exclude_domains": ["climate"], "exclude_entity_globs": ["sensor.excluded_*"], "exclude_entities": ["binary_sensor.excluded"], }, ...
[ "async", "def", "test_denylist", "(", "hass", ",", "mock_client", ")", ":", "handler_method", "=", "await", "_setup", "(", "hass", ",", "{", "\"exclude_domains\"", ":", "[", "\"climate\"", "]", ",", "\"exclude_entity_globs\"", ":", "[", "\"sensor.excluded_*\"", ...
[ 177, 0 ]
[ 204, 43 ]
python
en
['en', 'en', 'en']
True
test_filtered_allowlist
(hass, mock_client)
Test an allowlist config with a filtering denylist.
Test an allowlist config with a filtering denylist.
async def test_filtered_allowlist(hass, mock_client): """Test an allowlist config with a filtering denylist.""" handler_method = await _setup( hass, { "include_domains": ["light"], "include_entity_globs": ["*.included_*"], "exclude_domains": ["climate"], ...
[ "async", "def", "test_filtered_allowlist", "(", "hass", ",", "mock_client", ")", ":", "handler_method", "=", "await", "_setup", "(", "hass", ",", "{", "\"include_domains\"", ":", "[", "\"light\"", "]", ",", "\"include_entity_globs\"", ":", "[", "\"*.included_*\"",...
[ 207, 0 ]
[ 235, 43 ]
python
en
['en', 'en', 'en']
True
test_filtered_denylist
(hass, mock_client)
Test a denylist config with a filtering allowlist.
Test a denylist config with a filtering allowlist.
async def test_filtered_denylist(hass, mock_client): """Test a denylist config with a filtering allowlist.""" handler_method = await _setup( hass, { "include_entities": ["climate.included", "sensor.excluded_test"], "exclude_domains": ["climate"], "exclude_enti...
[ "async", "def", "test_filtered_denylist", "(", "hass", ",", "mock_client", ")", ":", "handler_method", "=", "await", "_setup", "(", "hass", ",", "{", "\"include_entities\"", ":", "[", "\"climate.included\"", ",", "\"sensor.excluded_test\"", "]", ",", "\"exclude_doma...
[ 238, 0 ]
[ 266, 43 ]
python
en
['en', 'en', 'en']
True
supported
(event)
Return whether an event supports switch.
Return whether an event supports switch.
def supported(event): """Return whether an event supports switch.""" return ( isinstance(event.device, rfxtrxmod.LightingDevice) and not event.device.known_to_be_dimmable and not event.device.known_to_be_rollershutter or isinstance(event.device, rfxtrxmod.RfyDevice) )
[ "def", "supported", "(", "event", ")", ":", "return", "(", "isinstance", "(", "event", ".", "device", ",", "rfxtrxmod", ".", "LightingDevice", ")", "and", "not", "event", ".", "device", ".", "known_to_be_dimmable", "and", "not", "event", ".", "device", "."...
[ 26, 0 ]
[ 33, 5 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
( hass, config_entry, async_add_entities, )
Set up config entry.
Set up config entry.
async def async_setup_entry( hass, config_entry, async_add_entities, ): """Set up config entry.""" discovery_info = config_entry.data device_ids = set() # Add switch from config file entities = [] for packet_id, entity_info in discovery_info[CONF_DEVICES].items(): event = ge...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ",", ")", ":", "discovery_info", "=", "config_entry", ".", "data", "device_ids", "=", "set", "(", ")", "# Add switch from config file", "entities", "=", "[", "]", "...
[ 36, 0 ]
[ 93, 57 ]
python
en
['en', 'en', 'en']
True
RfxtrxSwitch.async_added_to_hass
(self)
Restore device state.
Restore device state.
async def async_added_to_hass(self): """Restore device state.""" await super().async_added_to_hass() if self._event is None: old_state = await self.async_get_last_state() if old_state is not None: self._state = old_state.state == STATE_ON
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "await", "super", "(", ")", ".", "async_added_to_hass", "(", ")", "if", "self", ".", "_event", "is", "None", ":", "old_state", "=", "await", "self", ".", "async_get_last_state", "(", ")", "if", ...
[ 99, 4 ]
[ 106, 57 ]
python
it
['it', 'it', 'en']
True
RfxtrxSwitch._apply_event
(self, event)
Apply command from rfxtrx.
Apply command from rfxtrx.
def _apply_event(self, event): """Apply command from rfxtrx.""" super()._apply_event(event) if event.values["Command"] in COMMAND_ON_LIST: self._state = True elif event.values["Command"] in COMMAND_OFF_LIST: self._state = False
[ "def", "_apply_event", "(", "self", ",", "event", ")", ":", "super", "(", ")", ".", "_apply_event", "(", "event", ")", "if", "event", ".", "values", "[", "\"Command\"", "]", "in", "COMMAND_ON_LIST", ":", "self", ".", "_state", "=", "True", "elif", "eve...
[ 108, 4 ]
[ 114, 31 ]
python
en
['en', 'en', 'en']
True
RfxtrxSwitch._handle_event
(self, event, device_id)
Check if event applies to me and update.
Check if event applies to me and update.
def _handle_event(self, event, device_id): """Check if event applies to me and update.""" if device_id != self._device_id: return self._apply_event(event) self.async_write_ha_state()
[ "def", "_handle_event", "(", "self", ",", "event", ",", "device_id", ")", ":", "if", "device_id", "!=", "self", ".", "_device_id", ":", "return", "self", ".", "_apply_event", "(", "event", ")", "self", ".", "async_write_ha_state", "(", ")" ]
[ 117, 4 ]
[ 124, 35 ]
python
en
['en', 'en', 'en']
True
RfxtrxSwitch.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" ]
[ 127, 4 ]
[ 129, 26 ]
python
en
['en', 'fy', 'en']
True
RfxtrxSwitch.async_turn_on
(self, **kwargs)
Turn the device on.
Turn the device on.
async def async_turn_on(self, **kwargs): """Turn the device on.""" await self._async_send(self._device.send_on) self._state = True self.async_write_ha_state()
[ "async", "def", "async_turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "await", "self", ".", "_async_send", "(", "self", ".", "_device", ".", "send_on", ")", "self", ".", "_state", "=", "True", "self", ".", "async_write_ha_state", "(", ")" ]
[ 131, 4 ]
[ 135, 35 ]
python
en
['en', 'en', 'en']
True
RfxtrxSwitch.async_turn_off
(self, **kwargs)
Turn the device off.
Turn the device off.
async def async_turn_off(self, **kwargs): """Turn the device off.""" await self._async_send(self._device.send_off) self._state = False self.async_write_ha_state()
[ "async", "def", "async_turn_off", "(", "self", ",", "*", "*", "kwargs", ")", ":", "await", "self", ".", "_async_send", "(", "self", ".", "_device", ".", "send_off", ")", "self", ".", "_state", "=", "False", "self", ".", "async_write_ha_state", "(", ")" ]
[ 137, 4 ]
[ 141, 35 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Perform the setup for Fibaro controller devices.
Perform the setup for Fibaro controller devices.
def setup_platform(hass, config, add_entities, discovery_info=None): """Perform the setup for Fibaro controller devices.""" if discovery_info is None: return add_entities( [ FibaroBinarySensor(device) for device in hass.data[FIBARO_DEVICES]["binary_sensor"] ]...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "if", "discovery_info", "is", "None", ":", "return", "add_entities", "(", "[", "FibaroBinarySensor", "(", "device", ")", "for", "device", ...
[ 24, 0 ]
[ 35, 5 ]
python
en
['en', 'en', 'en']
True
FibaroBinarySensor.__init__
(self, fibaro_device)
Initialize the binary_sensor.
Initialize the binary_sensor.
def __init__(self, fibaro_device): """Initialize the binary_sensor.""" self._state = None super().__init__(fibaro_device) self.entity_id = f"{DOMAIN}.{self.ha_id}" stype = None devconf = fibaro_device.device_config if fibaro_device.type in SENSOR_TYPES: ...
[ "def", "__init__", "(", "self", ",", "fibaro_device", ")", ":", "self", ".", "_state", "=", "None", "super", "(", ")", ".", "__init__", "(", "fibaro_device", ")", "self", ".", "entity_id", "=", "f\"{DOMAIN}.{self.ha_id}\"", "stype", "=", "None", "devconf", ...
[ 41, 4 ]
[ 60, 55 ]
python
en
['en', 'haw', 'en']
True
FibaroBinarySensor.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" ]
[ 63, 4 ]
[ 65, 25 ]
python
en
['en', 'en', 'en']
True
FibaroBinarySensor.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" ]
[ 68, 4 ]
[ 70, 33 ]
python
en
['en', 'en', 'en']
True
FibaroBinarySensor.is_on
(self)
Return true if sensor is on.
Return true if sensor is on.
def is_on(self): """Return true if sensor is on.""" return self._state
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 73, 4 ]
[ 75, 26 ]
python
en
['en', 'et', 'en']
True
FibaroBinarySensor.update
(self)
Get the latest data and update the state.
Get the latest data and update the state.
def update(self): """Get the latest data and update the state.""" self._state = self.current_binary_state
[ "def", "update", "(", "self", ")", ":", "self", ".", "_state", "=", "self", ".", "current_binary_state" ]
[ 77, 4 ]
[ 79, 47 ]
python
en
['en', 'en', 'en']
True
async_setup
(hass, config)
Get all devices and add them to hass.
Get all devices and add them to hass.
async def async_setup(hass, config): """Get all devices and add them to hass.""" return True
[ "async", "def", "async_setup", "(", "hass", ",", "config", ")", ":", "return", "True" ]
[ 17, 0 ]
[ 19, 15 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass: HomeAssistantType, entry: ConfigEntry)
Set up the devolo account from a config entry.
Set up the devolo account from a config entry.
async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool: """Set up the devolo account from a config entry.""" conf = entry.data hass.data.setdefault(DOMAIN, {}) mydevolo = Mydevolo() mydevolo.user = conf[CONF_USERNAME] mydevolo.password = conf[CONF_PASSWORD] mydevol...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistantType", ",", "entry", ":", "ConfigEntry", ")", "->", "bool", ":", "conf", "=", "entry", ".", "data", "hass", ".", "data", ".", "setdefault", "(", "DOMAIN", ",", "{", "}", ")", "mydevolo"...
[ 22, 0 ]
[ 75, 15 ]
python
en
['en', 'en', 'en']
True
async_unload_entry
(hass: HomeAssistantType, entry: ConfigEntry)
Unload a config entry.
Unload a config entry.
async def async_unload_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool: """Unload a config entry.""" unload = all( await asyncio.gather( *[ hass.config_entries.async_forward_entry_unload(entry, platform) for platform in PLATFORMS ] ...
[ "async", "def", "async_unload_entry", "(", "hass", ":", "HomeAssistantType", ",", "entry", ":", "ConfigEntry", ")", "->", "bool", ":", "unload", "=", "all", "(", "await", "asyncio", ".", "gather", "(", "*", "[", "hass", ".", "config_entries", ".", "async_f...
[ 78, 0 ]
[ 96, 17 ]
python
en
['en', 'es', 'en']
True
convert_to_unicode
(text)
Converts `text` to Unicode (if it's not already), assuming UTF-8 input.
Converts `text` to Unicode (if it's not already), assuming UTF-8 input.
def convert_to_unicode(text): """ Converts `text` to Unicode (if it's not already), assuming UTF-8 input. """ # six_ensure_text is copied from https://github.com/benjaminp/six def six_ensure_text(s, encoding="utf-8", errors="strict"): if isinstance(s, six.binary_type): return s.d...
[ "def", "convert_to_unicode", "(", "text", ")", ":", "# six_ensure_text is copied from https://github.com/benjaminp/six", "def", "six_ensure_text", "(", "s", ",", "encoding", "=", "\"utf-8\"", ",", "errors", "=", "\"strict\"", ")", ":", "if", "isinstance", "(", "s", ...
[ 62, 0 ]
[ 75, 67 ]
python
en
['en', 'error', 'th']
False
FlaubertTokenizer._tokenize
(self, text, bypass_tokenizer=False)
Tokenize a string given language code using Moses. Details of tokenization: - [sacremoses](https://github.com/alvations/sacremoses): port of Moses - Install with `pip install sacremoses` Args: - bypass_tokenizer: Allow users to preprocess and tokenize the...
Tokenize a string given language code using Moses.
def _tokenize(self, text, bypass_tokenizer=False): """ Tokenize a string given language code using Moses. Details of tokenization: - [sacremoses](https://github.com/alvations/sacremoses): port of Moses - Install with `pip install sacremoses` Args: ...
[ "def", "_tokenize", "(", "self", ",", "text", ",", "bypass_tokenizer", "=", "False", ")", ":", "lang", "=", "\"fr\"", "if", "lang", "and", "self", ".", "lang2id", "and", "lang", "not", "in", "self", ".", "lang2id", ":", "logger", ".", "error", "(", "...
[ 112, 4 ]
[ 147, 27 ]
python
en
['en', 'error', 'th']
False
due_in_minutes
(timestamp)
Get the time in minutes from a timestamp. The timestamp should be in the format day/month/year hour/minute/second
Get the time in minutes from a timestamp.
def due_in_minutes(timestamp): """Get the time in minutes from a timestamp. The timestamp should be in the format day/month/year hour/minute/second """ diff = datetime.strptime(timestamp, "%d/%m/%Y %H:%M:%S") - dt_util.now().replace( tzinfo=None ) return str(int(diff.total_seconds() / ...
[ "def", "due_in_minutes", "(", "timestamp", ")", ":", "diff", "=", "datetime", ".", "strptime", "(", "timestamp", ",", "\"%d/%m/%Y %H:%M:%S\"", ")", "-", "dt_util", ".", "now", "(", ")", ".", "replace", "(", "tzinfo", "=", "None", ")", "return", "str", "(...
[ 45, 0 ]
[ 54, 46 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the Dublin public transport sensor.
Set up the Dublin public transport sensor.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Dublin public transport sensor.""" name = config[CONF_NAME] stop = config[CONF_STOP_ID] route = config[CONF_ROUTE] data = PublicTransportData(stop, route) add_entities([DublinPublicTransportSensor(data, stop, rou...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "name", "=", "config", "[", "CONF_NAME", "]", "stop", "=", "config", "[", "CONF_STOP_ID", "]", "route", "=", "config", "[", "CONF_ROUTE"...
[ 57, 0 ]
[ 64, 78 ]
python
en
['en', 'sq', 'en']
True
DublinPublicTransportSensor.__init__
(self, data, stop, route, name)
Initialize the sensor.
Initialize the sensor.
def __init__(self, data, stop, route, name): """Initialize the sensor.""" self.data = data self._name = name self._stop = stop self._route = route self._times = self._state = None
[ "def", "__init__", "(", "self", ",", "data", ",", "stop", ",", "route", ",", "name", ")", ":", "self", ".", "data", "=", "data", "self", ".", "_name", "=", "name", "self", ".", "_stop", "=", "stop", "self", ".", "_route", "=", "route", "self", "....
[ 70, 4 ]
[ 76, 40 ]
python
en
['en', 'en', 'en']
True
DublinPublicTransportSensor.name
(self)
Return the name of the sensor.
Return the name of the sensor.
def name(self): """Return the name of the sensor.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 79, 4 ]
[ 81, 25 ]
python
en
['en', 'mi', 'en']
True
DublinPublicTransportSensor.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._state
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 84, 4 ]
[ 86, 26 ]
python
en
['en', 'en', 'en']
True
DublinPublicTransportSensor.device_state_attributes
(self)
Return the state attributes.
Return the state attributes.
def device_state_attributes(self): """Return the state attributes.""" if self._times is not None: next_up = "None" if len(self._times) > 1: next_up = f"{self._times[1][ATTR_ROUTE]} in " next_up += self._times[1][ATTR_DUE_IN] return { ...
[ "def", "device_state_attributes", "(", "self", ")", ":", "if", "self", ".", "_times", "is", "not", "None", ":", "next_up", "=", "\"None\"", "if", "len", "(", "self", ".", "_times", ")", ">", "1", ":", "next_up", "=", "f\"{self._times[1][ATTR_ROUTE]} in \"", ...
[ 89, 4 ]
[ 104, 13 ]
python
en
['en', 'en', 'en']
True
DublinPublicTransportSensor.unit_of_measurement
(self)
Return the unit this state is expressed in.
Return the unit this state is expressed in.
def unit_of_measurement(self): """Return the unit this state is expressed in.""" return TIME_MINUTES
[ "def", "unit_of_measurement", "(", "self", ")", ":", "return", "TIME_MINUTES" ]
[ 107, 4 ]
[ 109, 27 ]
python
en
['en', 'en', 'en']
True
DublinPublicTransportSensor.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 ICON
[ "def", "icon", "(", "self", ")", ":", "return", "ICON" ]
[ 112, 4 ]
[ 114, 19 ]
python
en
['en', 'en', 'en']
True
DublinPublicTransportSensor.update
(self)
Get the latest data from opendata.ch and update the states.
Get the latest data from opendata.ch and update the states.
def update(self): """Get the latest data from opendata.ch and update the states.""" self.data.update() self._times = self.data.info try: self._state = self._times[0][ATTR_DUE_IN] except TypeError: pass
[ "def", "update", "(", "self", ")", ":", "self", ".", "data", ".", "update", "(", ")", "self", ".", "_times", "=", "self", ".", "data", ".", "info", "try", ":", "self", ".", "_state", "=", "self", ".", "_times", "[", "0", "]", "[", "ATTR_DUE_IN", ...
[ 116, 4 ]
[ 123, 16 ]
python
en
['en', 'en', 'en']
True
PublicTransportData.__init__
(self, stop, route)
Initialize the data object.
Initialize the data object.
def __init__(self, stop, route): """Initialize the data object.""" self.stop = stop self.route = route self.info = [{ATTR_DUE_AT: "n/a", ATTR_ROUTE: self.route, ATTR_DUE_IN: "n/a"}]
[ "def", "__init__", "(", "self", ",", "stop", ",", "route", ")", ":", "self", ".", "stop", "=", "stop", "self", ".", "route", "=", "route", "self", ".", "info", "=", "[", "{", "ATTR_DUE_AT", ":", "\"n/a\"", ",", "ATTR_ROUTE", ":", "self", ".", "rout...
[ 129, 4 ]
[ 133, 86 ]
python
en
['en', 'en', 'en']
True
PublicTransportData.update
(self)
Get the latest data from opendata.ch.
Get the latest data from opendata.ch.
def update(self): """Get the latest data from opendata.ch.""" params = {} params["stopid"] = self.stop if self.route: params["routeid"] = self.route params["maxresults"] = 2 params["format"] = "json" response = requests.get(_RESOURCE, params, timeou...
[ "def", "update", "(", "self", ")", ":", "params", "=", "{", "}", "params", "[", "\"stopid\"", "]", "=", "self", ".", "stop", "if", "self", ".", "route", ":", "params", "[", "\"routeid\"", "]", "=", "self", ".", "route", "params", "[", "\"maxresults\"...
[ 135, 4 ]
[ 177, 13 ]
python
en
['en', 'en', 'en']
True
BaseZhaEntity.__init__
(self, unique_id: str, zha_device: ZhaDeviceType, **kwargs)
Init ZHA entity.
Init ZHA entity.
def __init__(self, unique_id: str, zha_device: ZhaDeviceType, **kwargs): """Init ZHA entity.""" self._name: str = "" self._force_update: bool = False self._should_poll: bool = False self._unique_id: str = unique_id self._state: Any = None self._device_state_attrib...
[ "def", "__init__", "(", "self", ",", "unique_id", ":", "str", ",", "zha_device", ":", "ZhaDeviceType", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_name", ":", "str", "=", "\"\"", "self", ".", "_force_update", ":", "bool", "=", "False", "self", ...
[ 38, 4 ]
[ 48, 50 ]
python
en
['en', 'pl', 'it']
False
BaseZhaEntity.name
(self)
Return Entity's default name.
Return Entity's default name.
def name(self) -> str: """Return Entity's default name.""" return self._name
[ "def", "name", "(", "self", ")", "->", "str", ":", "return", "self", ".", "_name" ]
[ 51, 4 ]
[ 53, 25 ]
python
en
['es', 'fr', 'en']
False
BaseZhaEntity.unique_id
(self)
Return a unique ID.
Return a unique ID.
def unique_id(self) -> str: """Return a unique ID.""" return self._unique_id
[ "def", "unique_id", "(", "self", ")", "->", "str", ":", "return", "self", ".", "_unique_id" ]
[ 56, 4 ]
[ 58, 30 ]
python
ca
['fr', 'ca', 'en']
False
BaseZhaEntity.zha_device
(self)
Return the zha device this entity is attached to.
Return the zha device this entity is attached to.
def zha_device(self) -> ZhaDeviceType: """Return the zha device this entity is attached to.""" return self._zha_device
[ "def", "zha_device", "(", "self", ")", "->", "ZhaDeviceType", ":", "return", "self", ".", "_zha_device" ]
[ 61, 4 ]
[ 63, 31 ]
python
en
['en', 'en', 'en']
True
BaseZhaEntity.device_state_attributes
(self)
Return device specific state attributes.
Return device specific state attributes.
def device_state_attributes(self) -> Dict[str, Any]: """Return device specific state attributes.""" return self._device_state_attributes
[ "def", "device_state_attributes", "(", "self", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "return", "self", ".", "_device_state_attributes" ]
[ 66, 4 ]
[ 68, 44 ]
python
en
['fr', 'en', 'en']
True
BaseZhaEntity.force_update
(self)
Force update this entity.
Force update this entity.
def force_update(self) -> bool: """Force update this entity.""" return self._force_update
[ "def", "force_update", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "_force_update" ]
[ 71, 4 ]
[ 73, 33 ]
python
en
['en', 'en', 'en']
True
BaseZhaEntity.should_poll
(self)
Poll state from device.
Poll state from device.
def should_poll(self) -> bool: """Poll state from device.""" return self._should_poll
[ "def", "should_poll", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "_should_poll" ]
[ 76, 4 ]
[ 78, 32 ]
python
en
['en', 'en', 'en']
True
BaseZhaEntity.device_info
(self)
Return a device description for device registry.
Return a device description for device registry.
def device_info(self) -> Dict[str, Any]: """Return a device description for device registry.""" zha_device_info = self._zha_device.device_info ieee = zha_device_info["ieee"] return { "connections": {(CONNECTION_ZIGBEE, ieee)}, "identifiers": {(DOMAIN, ieee)}, ...
[ "def", "device_info", "(", "self", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "zha_device_info", "=", "self", ".", "_zha_device", ".", "device_info", "ieee", "=", "zha_device_info", "[", "\"ieee\"", "]", "return", "{", "\"connections\"", ":", "{"...
[ 81, 4 ]
[ 92, 9 ]
python
en
['ro', 'fr', 'en']
False
BaseZhaEntity.async_state_changed
(self)
Entity state changed.
Entity state changed.
def async_state_changed(self) -> None: """Entity state changed.""" self.async_write_ha_state()
[ "def", "async_state_changed", "(", "self", ")", "->", "None", ":", "self", ".", "async_write_ha_state", "(", ")" ]
[ 95, 4 ]
[ 97, 35 ]
python
en
['en', 'en', 'en']
True
BaseZhaEntity.async_update_state_attribute
(self, key: str, value: Any)
Update a single device state attribute.
Update a single device state attribute.
def async_update_state_attribute(self, key: str, value: Any) -> None: """Update a single device state attribute.""" self._device_state_attributes.update({key: value}) self.async_write_ha_state()
[ "def", "async_update_state_attribute", "(", "self", ",", "key", ":", "str", ",", "value", ":", "Any", ")", "->", "None", ":", "self", ".", "_device_state_attributes", ".", "update", "(", "{", "key", ":", "value", "}", ")", "self", ".", "async_write_ha_stat...
[ 100, 4 ]
[ 103, 35 ]
python
co
['ro', 'co', 'en']
False
BaseZhaEntity.async_set_state
(self, attr_id: int, attr_name: str, value: Any)
Set the entity state.
Set the entity state.
def async_set_state(self, attr_id: int, attr_name: str, value: Any) -> None: """Set the entity state."""
[ "def", "async_set_state", "(", "self", ",", "attr_id", ":", "int", ",", "attr_name", ":", "str", ",", "value", ":", "Any", ")", "->", "None", ":" ]
[ 106, 4 ]
[ 107, 35 ]
python
en
['en', 'en', 'en']
True
BaseZhaEntity.async_will_remove_from_hass
(self)
Disconnect entity object when removed.
Disconnect entity object when removed.
async def async_will_remove_from_hass(self) -> None: """Disconnect entity object when removed.""" for unsub in self._unsubs[:]: unsub() self._unsubs.remove(unsub)
[ "async", "def", "async_will_remove_from_hass", "(", "self", ")", "->", "None", ":", "for", "unsub", "in", "self", ".", "_unsubs", "[", ":", "]", ":", "unsub", "(", ")", "self", ".", "_unsubs", ".", "remove", "(", "unsub", ")" ]
[ 109, 4 ]
[ 113, 38 ]
python
en
['en', 'en', 'en']
True
BaseZhaEntity.async_accept_signal
( self, channel: ChannelType, signal: str, func: CALLABLE_T, signal_override=False )
Accept a signal from a channel.
Accept a signal from a channel.
def async_accept_signal( self, channel: ChannelType, signal: str, func: CALLABLE_T, signal_override=False ): """Accept a signal from a channel.""" unsub = None if signal_override: unsub = async_dispatcher_connect(self.hass, signal, func) else: unsub = ...
[ "def", "async_accept_signal", "(", "self", ",", "channel", ":", "ChannelType", ",", "signal", ":", "str", ",", "func", ":", "CALLABLE_T", ",", "signal_override", "=", "False", ")", ":", "unsub", "=", "None", "if", "signal_override", ":", "unsub", "=", "asy...
[ 116, 4 ]
[ 127, 34 ]
python
en
['en', 'en', 'en']
True
BaseZhaEntity.log
(self, level: int, msg: str, *args)
Log a message.
Log a message.
def log(self, level: int, msg: str, *args): """Log a message.""" msg = f"%s: {msg}" args = (self.entity_id,) + args _LOGGER.log(level, msg, *args)
[ "def", "log", "(", "self", ",", "level", ":", "int", ",", "msg", ":", "str", ",", "*", "args", ")", ":", "msg", "=", "f\"%s: {msg}\"", "args", "=", "(", "self", ".", "entity_id", ",", ")", "+", "args", "_LOGGER", ".", "log", "(", "level", ",", ...
[ 129, 4 ]
[ 133, 38 ]
python
en
['en', 'lb', 'en']
True
ZhaEntity.__init__
( self, unique_id: str, zha_device: ZhaDeviceType, channels: List[ChannelType], **kwargs, )
Init ZHA entity.
Init ZHA entity.
def __init__( self, unique_id: str, zha_device: ZhaDeviceType, channels: List[ChannelType], **kwargs, ): """Init ZHA entity.""" super().__init__(unique_id, zha_device, **kwargs) ieeetail = "".join([f"{o:02x}" for o in zha_device.ieee[:4]]) ch_n...
[ "def", "__init__", "(", "self", ",", "unique_id", ":", "str", ",", "zha_device", ":", "ZhaDeviceType", ",", "channels", ":", "List", "[", "ChannelType", "]", ",", "*", "*", "kwargs", ",", ")", ":", "super", "(", ")", ".", "__init__", "(", "unique_id", ...
[ 139, 4 ]
[ 154, 57 ]
python
en
['en', 'pl', 'it']
False
ZhaEntity.available
(self)
Return entity availability.
Return entity availability.
def available(self) -> bool: """Return entity availability.""" return self._zha_device.available
[ "def", "available", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "_zha_device", ".", "available" ]
[ 157, 4 ]
[ 159, 41 ]
python
en
['en', 'ga', 'en']
True
ZhaEntity.async_added_to_hass
(self)
Run when about to be added to hass.
Run when about to be added to hass.
async def async_added_to_hass(self) -> None: """Run when about to be added to hass.""" self.remove_future = asyncio.Future() self.async_accept_signal( None, f"{SIGNAL_REMOVE}_{self.zha_device.ieee}", self.async_remove, signal_override=True, ...
[ "async", "def", "async_added_to_hass", "(", "self", ")", "->", "None", ":", "self", ".", "remove_future", "=", "asyncio", ".", "Future", "(", ")", "self", ".", "async_accept_signal", "(", "None", ",", "f\"{SIGNAL_REMOVE}_{self.zha_device.ieee}\"", ",", "self", "...
[ 161, 4 ]
[ 190, 9 ]
python
en
['en', 'en', 'en']
True
ZhaEntity.async_will_remove_from_hass
(self)
Disconnect entity object when removed.
Disconnect entity object when removed.
async def async_will_remove_from_hass(self) -> None: """Disconnect entity object when removed.""" await super().async_will_remove_from_hass() self.zha_device.gateway.remove_entity_reference(self) self.remove_future.set_result(True)
[ "async", "def", "async_will_remove_from_hass", "(", "self", ")", "->", "None", ":", "await", "super", "(", ")", ".", "async_will_remove_from_hass", "(", ")", "self", ".", "zha_device", ".", "gateway", ".", "remove_entity_reference", "(", "self", ")", "self", "...
[ 192, 4 ]
[ 196, 43 ]
python
en
['en', 'en', 'en']
True
ZhaEntity.async_restore_last_state
(self, last_state)
Restore previous state.
Restore previous state.
def async_restore_last_state(self, last_state) -> None: """Restore previous state."""
[ "def", "async_restore_last_state", "(", "self", ",", "last_state", ")", "->", "None", ":" ]
[ 199, 4 ]
[ 200, 37 ]
python
it
['it', 'it', 'en']
True
ZhaEntity.async_update
(self)
Retrieve latest state.
Retrieve latest state.
async def async_update(self) -> None: """Retrieve latest state.""" tasks = [ channel.async_update() for channel in self.cluster_channels.values() if hasattr(channel, "async_update") ] if tasks: await asyncio.gather(*tasks)
[ "async", "def", "async_update", "(", "self", ")", "->", "None", ":", "tasks", "=", "[", "channel", ".", "async_update", "(", ")", "for", "channel", "in", "self", ".", "cluster_channels", ".", "values", "(", ")", "if", "hasattr", "(", "channel", ",", "\...
[ 202, 4 ]
[ 210, 40 ]
python
en
['es', 'sk', 'en']
False
ZhaGroupEntity.__init__
( self, entity_ids: List[str], unique_id: str, group_id: int, zha_device, **kwargs )
Initialize a light group.
Initialize a light group.
def __init__( self, entity_ids: List[str], unique_id: str, group_id: int, zha_device, **kwargs ) -> None: """Initialize a light group.""" super().__init__(unique_id, zha_device, **kwargs) self._available = False self._group = zha_device.gateway.groups.get(group_id) se...
[ "def", "__init__", "(", "self", ",", "entity_ids", ":", "List", "[", "str", "]", ",", "unique_id", ":", "str", ",", "group_id", ":", "int", ",", "zha_device", ",", "*", "*", "kwargs", ")", "->", "None", ":", "super", "(", ")", ".", "__init__", "(",...
[ 216, 4 ]
[ 227, 46 ]
python
en
['en', 'en', 'en']
True
ZhaGroupEntity.available
(self)
Return entity availability.
Return entity availability.
def available(self) -> bool: """Return entity availability.""" return self._available
[ "def", "available", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "_available" ]
[ 230, 4 ]
[ 232, 30 ]
python
en
['en', 'ga', 'en']
True
ZhaGroupEntity._handle_group_membership_changed
(self)
Handle group membership changed.
Handle group membership changed.
async def _handle_group_membership_changed(self): """Handle group membership changed.""" # Make sure we don't call remove twice as members are removed if self._handled_group_membership: return self._handled_group_membership = True await self.async_remove()
[ "async", "def", "_handle_group_membership_changed", "(", "self", ")", ":", "# Make sure we don't call remove twice as members are removed", "if", "self", ".", "_handled_group_membership", ":", "return", "self", ".", "_handled_group_membership", "=", "True", "await", "self", ...
[ 234, 4 ]
[ 241, 33 ]
python
af
['fr', 'af', 'en']
False
ZhaGroupEntity.async_added_to_hass
(self)
Register callbacks.
Register callbacks.
async def async_added_to_hass(self) -> None: """Register callbacks.""" await super().async_added_to_hass() self.async_accept_signal( None, f"{SIGNAL_GROUP_MEMBERSHIP_CHANGE}_0x{self._group_id:04x}", self._handle_group_membership_changed, signal_ov...
[ "async", "def", "async_added_to_hass", "(", "self", ")", "->", "None", ":", "await", "super", "(", ")", ".", "async_added_to_hass", "(", ")", "self", ".", "async_accept_signal", "(", "None", ",", "f\"{SIGNAL_GROUP_MEMBERSHIP_CHANGE}_0x{self._group_id:04x}\"", ",", "...
[ 243, 4 ]
[ 263, 49 ]
python
en
['en', 'no', 'en']
False
ZhaGroupEntity.async_state_changed_listener
(self, event: Event)
Handle child updates.
Handle child updates.
def async_state_changed_listener(self, event: Event): """Handle child updates.""" self.async_schedule_update_ha_state(True)
[ "def", "async_state_changed_listener", "(", "self", ",", "event", ":", "Event", ")", ":", "self", ".", "async_schedule_update_ha_state", "(", "True", ")" ]
[ 266, 4 ]
[ 268, 49 ]
python
en
['en', 'la', 'en']
True
ZhaGroupEntity.async_will_remove_from_hass
(self)
Handle removal from Home Assistant.
Handle removal from Home Assistant.
async def async_will_remove_from_hass(self) -> None: """Handle removal from Home Assistant.""" await super().async_will_remove_from_hass() if self._async_unsub_state_changed is not None: self._async_unsub_state_changed() self._async_unsub_state_changed = None
[ "async", "def", "async_will_remove_from_hass", "(", "self", ")", "->", "None", ":", "await", "super", "(", ")", ".", "async_will_remove_from_hass", "(", ")", "if", "self", ".", "_async_unsub_state_changed", "is", "not", "None", ":", "self", ".", "_async_unsub_st...
[ 270, 4 ]
[ 275, 50 ]
python
en
['en', 'en', 'en']
True
ZhaGroupEntity.async_update
(self)
Update the state of the group entity.
Update the state of the group entity.
async def async_update(self) -> None: """Update the state of the group entity."""
[ "async", "def", "async_update", "(", "self", ")", "->", "None", ":" ]
[ 277, 4 ]
[ 278, 51 ]
python
en
['en', 'en', 'en']
True
async_setup
(hass: HomeAssistant, config: dict)
Set up the Gree Climate component.
Set up the Gree Climate component.
async def async_setup(hass: HomeAssistant, config: dict): """Set up the Gree Climate component.""" hass.data[DOMAIN] = {} return True
[ "async", "def", "async_setup", "(", "hass", ":", "HomeAssistant", ",", "config", ":", "dict", ")", ":", "hass", ".", "data", "[", "DOMAIN", "]", "=", "{", "}", "return", "True" ]
[ 13, 0 ]
[ 16, 15 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass: HomeAssistant, entry: ConfigEntry)
Set up Gree Climate from a config entry.
Set up Gree Climate from a config entry.
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): """Set up Gree Climate from a config entry.""" devices = [] # First we'll grab as many devices as we can find on the network # it's necessary to bind static devices anyway _LOGGER.debug("Scanning network for Gree devices") f...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ")", ":", "devices", "=", "[", "]", "# First we'll grab as many devices as we can find on the network", "# it's necessary to bind static devices anyway", "_LOGGER", ".", ...
[ 19, 0 ]
[ 48, 15 ]
python
en
['en', 'en', 'en']
True
async_unload_entry
(hass: HomeAssistant, entry: ConfigEntry)
Unload a config entry.
Unload a config entry.
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry): """Unload a config entry.""" unload_ok = await hass.config_entries.async_forward_entry_unload( entry, CLIMATE_DOMAIN ) if unload_ok: hass.data[DOMAIN].pop("devices", None) hass.data[DOMAIN].pop("pending", Non...
[ "async", "def", "async_unload_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ")", ":", "unload_ok", "=", "await", "hass", ".", "config_entries", ".", "async_forward_entry_unload", "(", "entry", ",", "CLIMATE_DOMAIN", ")", "if", "unl...
[ 51, 0 ]
[ 61, 20 ]
python
en
['en', 'es', 'en']
True
floats_tensor
(shape, scale=1.0, rng=None, name=None)
Creates a random float32 tensor
Creates a random float32 tensor
def floats_tensor(shape, scale=1.0, rng=None, name=None): """Creates a random float32 tensor""" if rng is None: rng = global_rng total_dims = 1 for dim in shape: total_dims *= dim values = [] for _ in range(total_dims): values.append(rng.random() * scale) return to...
[ "def", "floats_tensor", "(", "shape", ",", "scale", "=", "1.0", ",", "rng", "=", "None", ",", "name", "=", "None", ")", ":", "if", "rng", "is", "None", ":", "rng", "=", "global_rng", "total_dims", "=", "1", "for", "dim", "in", "shape", ":", "total_...
[ 1250, 0 ]
[ 1263, 101 ]
python
en
['en', 'ca', 'en']
True
ClientMock.__init__
(self)
Create a mocked client.
Create a mocked client.
def __init__(self) -> None: """Create a mocked client.""" self.is_offline = False self.is_on = True self.brightness = 10 self.id = str(uuid4()) self.device_info = { "uuid": self.id, "device_name": self.id, # we make sure that entity id is differe...
[ "def", "__init__", "(", "self", ")", "->", "None", ":", "self", ".", "is_offline", "=", "False", "self", ".", "is_on", "=", "True", "self", ".", "brightness", "=", "10", "self", ".", "id", "=", "str", "(", "uuid4", "(", ")", ")", "self", ".", "de...
[ 18, 4 ]
[ 29, 9 ]
python
en
['en', 'en', 'en']
True
ClientMock.host
(self)
Get the mocked host.
Get the mocked host.
def host(self) -> str: """Get the mocked host.""" return TEST_HOST
[ "def", "host", "(", "self", ")", "->", "str", ":", "return", "TEST_HOST" ]
[ 32, 4 ]
[ 34, 24 ]
python
en
['en', 'da', 'en']
True
ClientMock.get_device_info
(self)
Get the mocked device info.
Get the mocked device info.
async def get_device_info(self): """Get the mocked device info.""" if self.is_offline: raise ClientConnectionError() return self.device_info
[ "async", "def", "get_device_info", "(", "self", ")", ":", "if", "self", ".", "is_offline", ":", "raise", "ClientConnectionError", "(", ")", "return", "self", ".", "device_info" ]
[ 36, 4 ]
[ 40, 31 ]
python
en
['en', 'en', 'en']
True
ClientMock.get_is_on
(self)
Get the mocked on/off state.
Get the mocked on/off state.
async def get_is_on(self) -> bool: """Get the mocked on/off state.""" if self.is_offline: raise ClientConnectionError() return self.is_on
[ "async", "def", "get_is_on", "(", "self", ")", "->", "bool", ":", "if", "self", ".", "is_offline", ":", "raise", "ClientConnectionError", "(", ")", "return", "self", ".", "is_on" ]
[ 42, 4 ]
[ 46, 25 ]
python
en
['en', 'en', 'en']
True
ClientMock.set_is_on
(self, is_on: bool)
Set the mocked on/off state.
Set the mocked on/off state.
async def set_is_on(self, is_on: bool) -> None: """Set the mocked on/off state.""" if self.is_offline: raise ClientConnectionError() self.is_on = is_on
[ "async", "def", "set_is_on", "(", "self", ",", "is_on", ":", "bool", ")", "->", "None", ":", "if", "self", ".", "is_offline", ":", "raise", "ClientConnectionError", "(", ")", "self", ".", "is_on", "=", "is_on" ]
[ 48, 4 ]
[ 52, 26 ]
python
en
['en', 'en', 'en']
True
ClientMock.get_brightness
(self)
Get the mocked brightness.
Get the mocked brightness.
async def get_brightness(self) -> int: """Get the mocked brightness.""" if self.is_offline: raise ClientConnectionError() return self.brightness
[ "async", "def", "get_brightness", "(", "self", ")", "->", "int", ":", "if", "self", ".", "is_offline", ":", "raise", "ClientConnectionError", "(", ")", "return", "self", ".", "brightness" ]
[ 54, 4 ]
[ 58, 30 ]
python
en
['en', 'da', 'en']
True
ClientMock.set_brightness
(self, brightness: int)
Set the mocked brightness.
Set the mocked brightness.
async def set_brightness(self, brightness: int) -> None: """Set the mocked brightness.""" if self.is_offline: raise ClientConnectionError() self.brightness = brightness
[ "async", "def", "set_brightness", "(", "self", ",", "brightness", ":", "int", ")", "->", "None", ":", "if", "self", ".", "is_offline", ":", "raise", "ClientConnectionError", "(", ")", "self", ".", "brightness", "=", "brightness" ]
[ 60, 4 ]
[ 64, 36 ]
python
en
['en', 'zu', 'en']
True
ClientMock.change_name
(self, new_name: str)
Change the name of this virtual device.
Change the name of this virtual device.
def change_name(self, new_name: str) -> None: """Change the name of this virtual device.""" self.device_info[DEV_NAME] = new_name
[ "def", "change_name", "(", "self", ",", "new_name", ":", "str", ")", "->", "None", ":", "self", ".", "device_info", "[", "DEV_NAME", "]", "=", "new_name" ]
[ 66, 4 ]
[ 68, 45 ]
python
en
['en', 'en', 'en']
True
test_state
(hass)
Test derivative sensor state.
Test derivative sensor state.
async def test_state(hass): """Test derivative sensor state.""" config = { "sensor": { "platform": "derivative", "name": "derivative", "source": "sensor.energy", "unit": "kW", "round": 2, } } assert await async_setup_component(...
[ "async", "def", "test_state", "(", "hass", ")", ":", "config", "=", "{", "\"sensor\"", ":", "{", "\"platform\"", ":", "\"derivative\"", ",", "\"name\"", ":", "\"derivative\"", ",", "\"source\"", ":", "\"sensor.energy\"", ",", "\"unit\"", ":", "\"kW\"", ",", ...
[ 10, 0 ]
[ 39, 62 ]
python
bs
['fr', 'bs', 'en']
False
setup_tests
(hass, config, times, values, expected_state)
Test derivative sensor state.
Test derivative sensor state.
async def setup_tests(hass, config, times, values, expected_state): """Test derivative sensor state.""" config, entity_id = await _setup_sensor(hass, config) # Testing a energy sensor with non-monotonic intervals and values for time, value in zip(times, values): now = dt_util.utcnow() + timedel...
[ "async", "def", "setup_tests", "(", "hass", ",", "config", ",", "times", ",", "values", ",", "expected_state", ")", ":", "config", ",", "entity_id", "=", "await", "_setup_sensor", "(", "hass", ",", "config", ")", "# Testing a energy sensor with non-monotonic inter...
[ 60, 0 ]
[ 76, 16 ]
python
bs
['fr', 'bs', 'en']
False