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
sequence
start_point
sequence
end_point
sequence
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
Group._reset_tracked_state
(self)
Reset tracked state.
Reset tracked state.
def _reset_tracked_state(self): """Reset tracked state.""" self._on_off = {} self._assumed = {} self._on_states = set() for entity_id in self.trackable: state = self.hass.states.get(entity_id) if state is not None: self._see_state(state)
[ "def", "_reset_tracked_state", "(", "self", ")", ":", "self", ".", "_on_off", "=", "{", "}", "self", ".", "_assumed", "=", "{", "}", "self", ".", "_on_states", "=", "set", "(", ")", "for", "entity_id", "in", "self", ".", "trackable", ":", "state", "=", "self", ".", "hass", ".", "states", ".", "get", "(", "entity_id", ")", "if", "state", "is", "not", "None", ":", "self", ".", "_see_state", "(", "state", ")" ]
[ 674, 4 ]
[ 684, 38 ]
python
en
['en', 'en', 'en']
True
Group._see_state
(self, new_state)
Keep track of the the state.
Keep track of the the state.
def _see_state(self, new_state): """Keep track of the the state.""" entity_id = new_state.entity_id domain = new_state.domain state = new_state.state registry = self.hass.data[REG_KEY] self._assumed[entity_id] = new_state.attributes.get(ATTR_ASSUMED_STATE) if domain not in registry.on_states_by_domain: # Handle the group of a group case if state in registry.on_off_mapping: self._on_states.add(state) elif state in registry.off_on_mapping: self._on_states.add(registry.off_on_mapping[state]) self._on_off[entity_id] = state in registry.on_off_mapping else: entity_on_state = registry.on_states_by_domain[domain] if domain in self.hass.data[REG_KEY].on_states_by_domain: self._on_states.update(entity_on_state) self._on_off[entity_id] = state in entity_on_state
[ "def", "_see_state", "(", "self", ",", "new_state", ")", ":", "entity_id", "=", "new_state", ".", "entity_id", "domain", "=", "new_state", ".", "domain", "state", "=", "new_state", ".", "state", "registry", "=", "self", ".", "hass", ".", "data", "[", "REG_KEY", "]", "self", ".", "_assumed", "[", "entity_id", "]", "=", "new_state", ".", "attributes", ".", "get", "(", "ATTR_ASSUMED_STATE", ")", "if", "domain", "not", "in", "registry", ".", "on_states_by_domain", ":", "# Handle the group of a group case", "if", "state", "in", "registry", ".", "on_off_mapping", ":", "self", ".", "_on_states", ".", "add", "(", "state", ")", "elif", "state", "in", "registry", ".", "off_on_mapping", ":", "self", ".", "_on_states", ".", "add", "(", "registry", ".", "off_on_mapping", "[", "state", "]", ")", "self", ".", "_on_off", "[", "entity_id", "]", "=", "state", "in", "registry", ".", "on_off_mapping", "else", ":", "entity_on_state", "=", "registry", ".", "on_states_by_domain", "[", "domain", "]", "if", "domain", "in", "self", ".", "hass", ".", "data", "[", "REG_KEY", "]", ".", "on_states_by_domain", ":", "self", ".", "_on_states", ".", "update", "(", "entity_on_state", ")", "self", ".", "_on_off", "[", "entity_id", "]", "=", "state", "in", "entity_on_state" ]
[ 686, 4 ]
[ 705, 62 ]
python
en
['en', 'en', 'en']
True
Group._async_update_group_state
(self, tr_state=None)
Update group state. Optionally you can provide the only state changed since last update allowing this method to take shortcuts. This method must be run in the event loop.
Update group state.
def _async_update_group_state(self, tr_state=None): """Update group state. Optionally you can provide the only state changed since last update allowing this method to take shortcuts. This method must be run in the event loop. """ # To store current states of group entities. Might not be needed. if tr_state: self._see_state(tr_state) if not self._on_off: return if ( tr_state is None or self._assumed_state and not tr_state.attributes.get(ATTR_ASSUMED_STATE) ): self._assumed_state = self.mode(self._assumed.values()) elif tr_state.attributes.get(ATTR_ASSUMED_STATE): self._assumed_state = True num_on_states = len(self._on_states) # If all the entity domains we are tracking # have the same on state we use this state # and its hass.data[REG_KEY].on_off_mapping to off if num_on_states == 1: on_state = list(self._on_states)[0] # If we do not have an on state for any domains # we use None (which will be STATE_UNKNOWN) elif num_on_states == 0: self._state = None return # If the entity domains have more than one # on state, we use STATE_ON/STATE_OFF else: on_state = STATE_ON group_is_on = self.mode(self._on_off.values()) if group_is_on: self._state = on_state else: self._state = self.hass.data[REG_KEY].on_off_mapping[on_state]
[ "def", "_async_update_group_state", "(", "self", ",", "tr_state", "=", "None", ")", ":", "# To store current states of group entities. Might not be needed.", "if", "tr_state", ":", "self", ".", "_see_state", "(", "tr_state", ")", "if", "not", "self", ".", "_on_off", ":", "return", "if", "(", "tr_state", "is", "None", "or", "self", ".", "_assumed_state", "and", "not", "tr_state", ".", "attributes", ".", "get", "(", "ATTR_ASSUMED_STATE", ")", ")", ":", "self", ".", "_assumed_state", "=", "self", ".", "mode", "(", "self", ".", "_assumed", ".", "values", "(", ")", ")", "elif", "tr_state", ".", "attributes", ".", "get", "(", "ATTR_ASSUMED_STATE", ")", ":", "self", ".", "_assumed_state", "=", "True", "num_on_states", "=", "len", "(", "self", ".", "_on_states", ")", "# If all the entity domains we are tracking", "# have the same on state we use this state", "# and its hass.data[REG_KEY].on_off_mapping to off", "if", "num_on_states", "==", "1", ":", "on_state", "=", "list", "(", "self", ".", "_on_states", ")", "[", "0", "]", "# If we do not have an on state for any domains", "# we use None (which will be STATE_UNKNOWN)", "elif", "num_on_states", "==", "0", ":", "self", ".", "_state", "=", "None", "return", "# If the entity domains have more than one", "# on state, we use STATE_ON/STATE_OFF", "else", ":", "on_state", "=", "STATE_ON", "group_is_on", "=", "self", ".", "mode", "(", "self", ".", "_on_off", ".", "values", "(", ")", ")", "if", "group_is_on", ":", "self", ".", "_state", "=", "on_state", "else", ":", "self", ".", "_state", "=", "self", ".", "hass", ".", "data", "[", "REG_KEY", "]", ".", "on_off_mapping", "[", "on_state", "]" ]
[ 708, 4 ]
[ 752, 74 ]
python
en
['en', 'en', 'en']
True
async_get_engine
(hass, config, discovery_info=None)
Set up VoiceRSS speech component.
Set up VoiceRSS speech component.
async def async_get_engine(hass, config, discovery_info=None): """Set up VoiceRSS speech component.""" return YandexSpeechKitProvider(hass, config)
[ "async", "def", "async_get_engine", "(", "hass", ",", "config", ",", "discovery_info", "=", "None", ")", ":", "return", "YandexSpeechKitProvider", "(", "hass", ",", "config", ")" ]
[ 81, 0 ]
[ 83, 48 ]
python
en
['en', 'lb', 'en']
True
YandexSpeechKitProvider.__init__
(self, hass, conf)
Init VoiceRSS TTS service.
Init VoiceRSS TTS service.
def __init__(self, hass, conf): """Init VoiceRSS TTS service.""" self.hass = hass self._codec = conf.get(CONF_CODEC) self._key = conf.get(CONF_API_KEY) self._speaker = conf.get(CONF_VOICE) self._language = conf.get(CONF_LANG) self._emotion = conf.get(CONF_EMOTION) self._speed = str(conf.get(CONF_SPEED)) self.name = "YandexTTS"
[ "def", "__init__", "(", "self", ",", "hass", ",", "conf", ")", ":", "self", ".", "hass", "=", "hass", "self", ".", "_codec", "=", "conf", ".", "get", "(", "CONF_CODEC", ")", "self", ".", "_key", "=", "conf", ".", "get", "(", "CONF_API_KEY", ")", "self", ".", "_speaker", "=", "conf", ".", "get", "(", "CONF_VOICE", ")", "self", ".", "_language", "=", "conf", ".", "get", "(", "CONF_LANG", ")", "self", ".", "_emotion", "=", "conf", ".", "get", "(", "CONF_EMOTION", ")", "self", ".", "_speed", "=", "str", "(", "conf", ".", "get", "(", "CONF_SPEED", ")", ")", "self", ".", "name", "=", "\"YandexTTS\"" ]
[ 89, 4 ]
[ 98, 31 ]
python
de
['de', 'fr', 'en']
False
YandexSpeechKitProvider.default_language
(self)
Return the default language.
Return the default language.
def default_language(self): """Return the default language.""" return self._language
[ "def", "default_language", "(", "self", ")", ":", "return", "self", ".", "_language" ]
[ 101, 4 ]
[ 103, 29 ]
python
en
['en', 'et', 'en']
True
YandexSpeechKitProvider.supported_languages
(self)
Return list of supported languages.
Return list of supported languages.
def supported_languages(self): """Return list of supported languages.""" return SUPPORT_LANGUAGES
[ "def", "supported_languages", "(", "self", ")", ":", "return", "SUPPORT_LANGUAGES" ]
[ 106, 4 ]
[ 108, 32 ]
python
en
['en', 'en', 'en']
True
YandexSpeechKitProvider.supported_options
(self)
Return list of supported options.
Return list of supported options.
def supported_options(self): """Return list of supported options.""" return SUPPORTED_OPTIONS
[ "def", "supported_options", "(", "self", ")", ":", "return", "SUPPORTED_OPTIONS" ]
[ 111, 4 ]
[ 113, 32 ]
python
en
['en', 'en', 'en']
True
YandexSpeechKitProvider.async_get_tts_audio
(self, message, language, options=None)
Load TTS from yandex.
Load TTS from yandex.
async def async_get_tts_audio(self, message, language, options=None): """Load TTS from yandex.""" websession = async_get_clientsession(self.hass) actual_language = language options = options or {} try: with async_timeout.timeout(10): url_param = { "text": message, "lang": actual_language, "key": self._key, "speaker": options.get(CONF_VOICE, self._speaker), "format": options.get(CONF_CODEC, self._codec), "emotion": options.get(CONF_EMOTION, self._emotion), "speed": options.get(CONF_SPEED, self._speed), } request = await websession.get(YANDEX_API_URL, params=url_param) if request.status != HTTP_OK: _LOGGER.error( "Error %d on load URL %s", request.status, request.url ) return (None, None) data = await request.read() except (asyncio.TimeoutError, aiohttp.ClientError): _LOGGER.error("Timeout for yandex speech kit API") return (None, None) return (self._codec, data)
[ "async", "def", "async_get_tts_audio", "(", "self", ",", "message", ",", "language", ",", "options", "=", "None", ")", ":", "websession", "=", "async_get_clientsession", "(", "self", ".", "hass", ")", "actual_language", "=", "language", "options", "=", "options", "or", "{", "}", "try", ":", "with", "async_timeout", ".", "timeout", "(", "10", ")", ":", "url_param", "=", "{", "\"text\"", ":", "message", ",", "\"lang\"", ":", "actual_language", ",", "\"key\"", ":", "self", ".", "_key", ",", "\"speaker\"", ":", "options", ".", "get", "(", "CONF_VOICE", ",", "self", ".", "_speaker", ")", ",", "\"format\"", ":", "options", ".", "get", "(", "CONF_CODEC", ",", "self", ".", "_codec", ")", ",", "\"emotion\"", ":", "options", ".", "get", "(", "CONF_EMOTION", ",", "self", ".", "_emotion", ")", ",", "\"speed\"", ":", "options", ".", "get", "(", "CONF_SPEED", ",", "self", ".", "_speed", ")", ",", "}", "request", "=", "await", "websession", ".", "get", "(", "YANDEX_API_URL", ",", "params", "=", "url_param", ")", "if", "request", ".", "status", "!=", "HTTP_OK", ":", "_LOGGER", ".", "error", "(", "\"Error %d on load URL %s\"", ",", "request", ".", "status", ",", "request", ".", "url", ")", "return", "(", "None", ",", "None", ")", "data", "=", "await", "request", ".", "read", "(", ")", "except", "(", "asyncio", ".", "TimeoutError", ",", "aiohttp", ".", "ClientError", ")", ":", "_LOGGER", ".", "error", "(", "\"Timeout for yandex speech kit API\"", ")", "return", "(", "None", ",", "None", ")", "return", "(", "self", ".", "_codec", ",", "data", ")" ]
[ 115, 4 ]
[ 146, 34 ]
python
en
['en', 'en', 'en']
True
setup_bp
(hass)
Fixture to set up the blueprint component.
Fixture to set up the blueprint component.
async def setup_bp(hass): """Fixture to set up the blueprint component.""" assert await async_setup_component(hass, "blueprint", {}) # Trigger registration of automation blueprints await async_setup_component(hass, "automation", {})
[ "async", "def", "setup_bp", "(", "hass", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "\"blueprint\"", ",", "{", "}", ")", "# Trigger registration of automation blueprints", "await", "async_setup_component", "(", "hass", ",", "\"automation\"", ",", "{", "}", ")" ]
[ 11, 0 ]
[ 16, 55 ]
python
en
['en', 'en', 'en']
True
test_list_blueprints
(hass, hass_ws_client)
Test listing blueprints.
Test listing blueprints.
async def test_list_blueprints(hass, hass_ws_client): """Test listing blueprints.""" client = await hass_ws_client(hass) await client.send_json({"id": 5, "type": "blueprint/list", "domain": "automation"}) msg = await client.receive_json() assert msg["id"] == 5 assert msg["success"] blueprints = msg["result"] assert blueprints == { "test_event_service.yaml": { "metadata": { "domain": "automation", "input": {"service_to_call": None, "trigger_event": None}, "name": "Call service based on event", }, }, "in_folder/in_folder_blueprint.yaml": { "metadata": { "domain": "automation", "input": {"action": None, "trigger": None}, "name": "In Folder Blueprint", } }, }
[ "async", "def", "test_list_blueprints", "(", "hass", ",", "hass_ws_client", ")", ":", "client", "=", "await", "hass_ws_client", "(", "hass", ")", "await", "client", ".", "send_json", "(", "{", "\"id\"", ":", "5", ",", "\"type\"", ":", "\"blueprint/list\"", ",", "\"domain\"", ":", "\"automation\"", "}", ")", "msg", "=", "await", "client", ".", "receive_json", "(", ")", "assert", "msg", "[", "\"id\"", "]", "==", "5", "assert", "msg", "[", "\"success\"", "]", "blueprints", "=", "msg", "[", "\"result\"", "]", "assert", "blueprints", "==", "{", "\"test_event_service.yaml\"", ":", "{", "\"metadata\"", ":", "{", "\"domain\"", ":", "\"automation\"", ",", "\"input\"", ":", "{", "\"service_to_call\"", ":", "None", ",", "\"trigger_event\"", ":", "None", "}", ",", "\"name\"", ":", "\"Call service based on event\"", ",", "}", ",", "}", ",", "\"in_folder/in_folder_blueprint.yaml\"", ":", "{", "\"metadata\"", ":", "{", "\"domain\"", ":", "\"automation\"", ",", "\"input\"", ":", "{", "\"action\"", ":", "None", ",", "\"trigger\"", ":", "None", "}", ",", "\"name\"", ":", "\"In Folder Blueprint\"", ",", "}", "}", ",", "}" ]
[ 19, 0 ]
[ 44, 5 ]
python
fr
['fr', 'fr', 'en']
True
test_list_blueprints_non_existing_domain
(hass, hass_ws_client)
Test listing blueprints.
Test listing blueprints.
async def test_list_blueprints_non_existing_domain(hass, hass_ws_client): """Test listing blueprints.""" client = await hass_ws_client(hass) await client.send_json( {"id": 5, "type": "blueprint/list", "domain": "not_existsing"} ) msg = await client.receive_json() assert msg["id"] == 5 assert msg["success"] blueprints = msg["result"] assert blueprints == {}
[ "async", "def", "test_list_blueprints_non_existing_domain", "(", "hass", ",", "hass_ws_client", ")", ":", "client", "=", "await", "hass_ws_client", "(", "hass", ")", "await", "client", ".", "send_json", "(", "{", "\"id\"", ":", "5", ",", "\"type\"", ":", "\"blueprint/list\"", ",", "\"domain\"", ":", "\"not_existsing\"", "}", ")", "msg", "=", "await", "client", ".", "receive_json", "(", ")", "assert", "msg", "[", "\"id\"", "]", "==", "5", "assert", "msg", "[", "\"success\"", "]", "blueprints", "=", "msg", "[", "\"result\"", "]", "assert", "blueprints", "==", "{", "}" ]
[ 47, 0 ]
[ 59, 27 ]
python
fr
['fr', 'fr', 'en']
True
test_import_blueprint
(hass, aioclient_mock, hass_ws_client)
Test importing blueprints.
Test importing blueprints.
async def test_import_blueprint(hass, aioclient_mock, hass_ws_client): """Test importing blueprints.""" raw_data = Path( hass.config.path("blueprints/automation/test_event_service.yaml") ).read_text() aioclient_mock.get( "https://raw.githubusercontent.com/balloob/home-assistant-config/main/blueprints/automation/motion_light.yaml", text=raw_data, ) client = await hass_ws_client(hass) await client.send_json( { "id": 5, "type": "blueprint/import", "url": "https://github.com/balloob/home-assistant-config/blob/main/blueprints/automation/motion_light.yaml", } ) msg = await client.receive_json() assert msg["id"] == 5 assert msg["success"] assert msg["result"] == { "suggested_filename": "balloob-motion_light", "url": "https://github.com/balloob/home-assistant-config/blob/main/blueprints/automation/motion_light.yaml", "raw_data": raw_data, "blueprint": { "metadata": { "domain": "automation", "input": {"service_to_call": None, "trigger_event": None}, "name": "Call service based on event", }, }, "validation_errors": None, }
[ "async", "def", "test_import_blueprint", "(", "hass", ",", "aioclient_mock", ",", "hass_ws_client", ")", ":", "raw_data", "=", "Path", "(", "hass", ".", "config", ".", "path", "(", "\"blueprints/automation/test_event_service.yaml\"", ")", ")", ".", "read_text", "(", ")", "aioclient_mock", ".", "get", "(", "\"https://raw.githubusercontent.com/balloob/home-assistant-config/main/blueprints/automation/motion_light.yaml\"", ",", "text", "=", "raw_data", ",", ")", "client", "=", "await", "hass_ws_client", "(", "hass", ")", "await", "client", ".", "send_json", "(", "{", "\"id\"", ":", "5", ",", "\"type\"", ":", "\"blueprint/import\"", ",", "\"url\"", ":", "\"https://github.com/balloob/home-assistant-config/blob/main/blueprints/automation/motion_light.yaml\"", ",", "}", ")", "msg", "=", "await", "client", ".", "receive_json", "(", ")", "assert", "msg", "[", "\"id\"", "]", "==", "5", "assert", "msg", "[", "\"success\"", "]", "assert", "msg", "[", "\"result\"", "]", "==", "{", "\"suggested_filename\"", ":", "\"balloob-motion_light\"", ",", "\"url\"", ":", "\"https://github.com/balloob/home-assistant-config/blob/main/blueprints/automation/motion_light.yaml\"", ",", "\"raw_data\"", ":", "raw_data", ",", "\"blueprint\"", ":", "{", "\"metadata\"", ":", "{", "\"domain\"", ":", "\"automation\"", ",", "\"input\"", ":", "{", "\"service_to_call\"", ":", "None", ",", "\"trigger_event\"", ":", "None", "}", ",", "\"name\"", ":", "\"Call service based on event\"", ",", "}", ",", "}", ",", "\"validation_errors\"", ":", "None", ",", "}" ]
[ 62, 0 ]
[ 98, 5 ]
python
en
['fr', 'en', 'en']
True
test_save_blueprint
(hass, aioclient_mock, hass_ws_client)
Test saving blueprints.
Test saving blueprints.
async def test_save_blueprint(hass, aioclient_mock, hass_ws_client): """Test saving blueprints.""" raw_data = Path( hass.config.path("blueprints/automation/test_event_service.yaml") ).read_text() with patch("pathlib.Path.write_text") as write_mock: client = await hass_ws_client(hass) await client.send_json( { "id": 6, "type": "blueprint/save", "path": "test_save", "yaml": raw_data, "domain": "automation", "source_url": "https://github.com/balloob/home-assistant-config/blob/main/blueprints/automation/motion_light.yaml", } ) msg = await client.receive_json() assert msg["id"] == 6 assert msg["success"] assert write_mock.mock_calls assert write_mock.call_args[0] == ( "blueprint:\n name: Call service based on event\n domain: automation\n input:\n trigger_event:\n service_to_call:\n source_url: https://github.com/balloob/home-assistant-config/blob/main/blueprints/automation/motion_light.yaml\ntrigger:\n platform: event\n event_type: !placeholder 'trigger_event'\naction:\n service: !placeholder 'service_to_call'\n", )
[ "async", "def", "test_save_blueprint", "(", "hass", ",", "aioclient_mock", ",", "hass_ws_client", ")", ":", "raw_data", "=", "Path", "(", "hass", ".", "config", ".", "path", "(", "\"blueprints/automation/test_event_service.yaml\"", ")", ")", ".", "read_text", "(", ")", "with", "patch", "(", "\"pathlib.Path.write_text\"", ")", "as", "write_mock", ":", "client", "=", "await", "hass_ws_client", "(", "hass", ")", "await", "client", ".", "send_json", "(", "{", "\"id\"", ":", "6", ",", "\"type\"", ":", "\"blueprint/save\"", ",", "\"path\"", ":", "\"test_save\"", ",", "\"yaml\"", ":", "raw_data", ",", "\"domain\"", ":", "\"automation\"", ",", "\"source_url\"", ":", "\"https://github.com/balloob/home-assistant-config/blob/main/blueprints/automation/motion_light.yaml\"", ",", "}", ")", "msg", "=", "await", "client", ".", "receive_json", "(", ")", "assert", "msg", "[", "\"id\"", "]", "==", "6", "assert", "msg", "[", "\"success\"", "]", "assert", "write_mock", ".", "mock_calls", "assert", "write_mock", ".", "call_args", "[", "0", "]", "==", "(", "\"blueprint:\\n name: Call service based on event\\n domain: automation\\n input:\\n trigger_event:\\n service_to_call:\\n source_url: https://github.com/balloob/home-assistant-config/blob/main/blueprints/automation/motion_light.yaml\\ntrigger:\\n platform: event\\n event_type: !placeholder 'trigger_event'\\naction:\\n service: !placeholder 'service_to_call'\\n\"", ",", ")" ]
[ 101, 0 ]
[ 127, 9 ]
python
en
['en', 'hu', 'en']
True
test_save_existing_file
(hass, aioclient_mock, hass_ws_client)
Test saving blueprints.
Test saving blueprints.
async def test_save_existing_file(hass, aioclient_mock, hass_ws_client): """Test saving blueprints.""" client = await hass_ws_client(hass) await client.send_json( { "id": 7, "type": "blueprint/save", "path": "test_event_service", "yaml": 'blueprint: {name: "name", domain: "automation"}', "domain": "automation", "source_url": "https://github.com/balloob/home-assistant-config/blob/main/blueprints/automation/motion_light.yaml", } ) msg = await client.receive_json() assert msg["id"] == 7 assert not msg["success"] assert msg["error"] == {"code": "already_exists", "message": "File already exists"}
[ "async", "def", "test_save_existing_file", "(", "hass", ",", "aioclient_mock", ",", "hass_ws_client", ")", ":", "client", "=", "await", "hass_ws_client", "(", "hass", ")", "await", "client", ".", "send_json", "(", "{", "\"id\"", ":", "7", ",", "\"type\"", ":", "\"blueprint/save\"", ",", "\"path\"", ":", "\"test_event_service\"", ",", "\"yaml\"", ":", "'blueprint: {name: \"name\", domain: \"automation\"}'", ",", "\"domain\"", ":", "\"automation\"", ",", "\"source_url\"", ":", "\"https://github.com/balloob/home-assistant-config/blob/main/blueprints/automation/motion_light.yaml\"", ",", "}", ")", "msg", "=", "await", "client", ".", "receive_json", "(", ")", "assert", "msg", "[", "\"id\"", "]", "==", "7", "assert", "not", "msg", "[", "\"success\"", "]", "assert", "msg", "[", "\"error\"", "]", "==", "{", "\"code\"", ":", "\"already_exists\"", ",", "\"message\"", ":", "\"File already exists\"", "}" ]
[ 130, 0 ]
[ 149, 87 ]
python
en
['en', 'hu', 'en']
True
test_save_file_error
(hass, aioclient_mock, hass_ws_client)
Test saving blueprints with OS error.
Test saving blueprints with OS error.
async def test_save_file_error(hass, aioclient_mock, hass_ws_client): """Test saving blueprints with OS error.""" with patch("pathlib.Path.write_text", side_effect=OSError): client = await hass_ws_client(hass) await client.send_json( { "id": 8, "type": "blueprint/save", "path": "test_save", "yaml": "raw_data", "domain": "automation", "source_url": "https://github.com/balloob/home-assistant-config/blob/main/blueprints/automation/motion_light.yaml", } ) msg = await client.receive_json() assert msg["id"] == 8 assert not msg["success"]
[ "async", "def", "test_save_file_error", "(", "hass", ",", "aioclient_mock", ",", "hass_ws_client", ")", ":", "with", "patch", "(", "\"pathlib.Path.write_text\"", ",", "side_effect", "=", "OSError", ")", ":", "client", "=", "await", "hass_ws_client", "(", "hass", ")", "await", "client", ".", "send_json", "(", "{", "\"id\"", ":", "8", ",", "\"type\"", ":", "\"blueprint/save\"", ",", "\"path\"", ":", "\"test_save\"", ",", "\"yaml\"", ":", "\"raw_data\"", ",", "\"domain\"", ":", "\"automation\"", ",", "\"source_url\"", ":", "\"https://github.com/balloob/home-assistant-config/blob/main/blueprints/automation/motion_light.yaml\"", ",", "}", ")", "msg", "=", "await", "client", ".", "receive_json", "(", ")", "assert", "msg", "[", "\"id\"", "]", "==", "8", "assert", "not", "msg", "[", "\"success\"", "]" ]
[ 152, 0 ]
[ 170, 33 ]
python
en
['en', 'el-Latn', 'en']
True
test_save_invalid_blueprint
(hass, aioclient_mock, hass_ws_client)
Test saving invalid blueprints.
Test saving invalid blueprints.
async def test_save_invalid_blueprint(hass, aioclient_mock, hass_ws_client): """Test saving invalid blueprints.""" client = await hass_ws_client(hass) await client.send_json( { "id": 8, "type": "blueprint/save", "path": "test_wrong", "yaml": "wrong_blueprint", "domain": "automation", "source_url": "https://github.com/balloob/home-assistant-config/blob/main/blueprints/automation/motion_light.yaml", } ) msg = await client.receive_json() assert msg["id"] == 8 assert not msg["success"] assert msg["error"] == { "code": "invalid_format", "message": "Invalid blueprint: expected a dictionary. Got 'wrong_blueprint'", }
[ "async", "def", "test_save_invalid_blueprint", "(", "hass", ",", "aioclient_mock", ",", "hass_ws_client", ")", ":", "client", "=", "await", "hass_ws_client", "(", "hass", ")", "await", "client", ".", "send_json", "(", "{", "\"id\"", ":", "8", ",", "\"type\"", ":", "\"blueprint/save\"", ",", "\"path\"", ":", "\"test_wrong\"", ",", "\"yaml\"", ":", "\"wrong_blueprint\"", ",", "\"domain\"", ":", "\"automation\"", ",", "\"source_url\"", ":", "\"https://github.com/balloob/home-assistant-config/blob/main/blueprints/automation/motion_light.yaml\"", ",", "}", ")", "msg", "=", "await", "client", ".", "receive_json", "(", ")", "assert", "msg", "[", "\"id\"", "]", "==", "8", "assert", "not", "msg", "[", "\"success\"", "]", "assert", "msg", "[", "\"error\"", "]", "==", "{", "\"code\"", ":", "\"invalid_format\"", ",", "\"message\"", ":", "\"Invalid blueprint: expected a dictionary. Got 'wrong_blueprint'\"", ",", "}" ]
[ 173, 0 ]
[ 195, 5 ]
python
en
['en', 'et', 'en']
True
test_delete_blueprint
(hass, aioclient_mock, hass_ws_client)
Test deleting blueprints.
Test deleting blueprints.
async def test_delete_blueprint(hass, aioclient_mock, hass_ws_client): """Test deleting blueprints.""" with patch("pathlib.Path.unlink", return_value=Mock()) as unlink_mock: client = await hass_ws_client(hass) await client.send_json( { "id": 9, "type": "blueprint/delete", "path": "test_delete", "domain": "automation", } ) msg = await client.receive_json() assert unlink_mock.mock_calls assert msg["id"] == 9 assert msg["success"]
[ "async", "def", "test_delete_blueprint", "(", "hass", ",", "aioclient_mock", ",", "hass_ws_client", ")", ":", "with", "patch", "(", "\"pathlib.Path.unlink\"", ",", "return_value", "=", "Mock", "(", ")", ")", "as", "unlink_mock", ":", "client", "=", "await", "hass_ws_client", "(", "hass", ")", "await", "client", ".", "send_json", "(", "{", "\"id\"", ":", "9", ",", "\"type\"", ":", "\"blueprint/delete\"", ",", "\"path\"", ":", "\"test_delete\"", ",", "\"domain\"", ":", "\"automation\"", ",", "}", ")", "msg", "=", "await", "client", ".", "receive_json", "(", ")", "assert", "unlink_mock", ".", "mock_calls", "assert", "msg", "[", "\"id\"", "]", "==", "9", "assert", "msg", "[", "\"success\"", "]" ]
[ 198, 0 ]
[ 216, 29 ]
python
da
['fr', 'da', 'en']
False
test_delete_non_exist_file_blueprint
(hass, aioclient_mock, hass_ws_client)
Test deleting non existing blueprints.
Test deleting non existing blueprints.
async def test_delete_non_exist_file_blueprint(hass, aioclient_mock, hass_ws_client): """Test deleting non existing blueprints.""" client = await hass_ws_client(hass) await client.send_json( { "id": 9, "type": "blueprint/delete", "path": "none_existing", "domain": "automation", } ) msg = await client.receive_json() assert msg["id"] == 9 assert not msg["success"]
[ "async", "def", "test_delete_non_exist_file_blueprint", "(", "hass", ",", "aioclient_mock", ",", "hass_ws_client", ")", ":", "client", "=", "await", "hass_ws_client", "(", "hass", ")", "await", "client", ".", "send_json", "(", "{", "\"id\"", ":", "9", ",", "\"type\"", ":", "\"blueprint/delete\"", ",", "\"path\"", ":", "\"none_existing\"", ",", "\"domain\"", ":", "\"automation\"", ",", "}", ")", "msg", "=", "await", "client", ".", "receive_json", "(", ")", "assert", "msg", "[", "\"id\"", "]", "==", "9", "assert", "not", "msg", "[", "\"success\"", "]" ]
[ 219, 0 ]
[ 235, 29 ]
python
en
['fr', 'en', 'en']
True
get_scanner
(hass, config)
Return a BT Home Hub 5 scanner if successful.
Return a BT Home Hub 5 scanner if successful.
def get_scanner(hass, config): """Return a BT Home Hub 5 scanner if successful.""" scanner = BTHomeHub5DeviceScanner(config[DOMAIN]) return scanner if scanner.success_init else None
[ "def", "get_scanner", "(", "hass", ",", "config", ")", ":", "scanner", "=", "BTHomeHub5DeviceScanner", "(", "config", "[", "DOMAIN", "]", ")", "return", "scanner", "if", "scanner", ".", "success_init", "else", "None" ]
[ 23, 0 ]
[ 27, 52 ]
python
en
['en', 'co', 'en']
True
BTHomeHub5DeviceScanner.__init__
(self, config)
Initialise the scanner.
Initialise the scanner.
def __init__(self, config): """Initialise the scanner.""" _LOGGER.info("Initialising BT Home Hub 5") self.host = config[CONF_HOST] self.last_results = {} # Test the router is accessible data = bthomehub5_devicelist.get_devicelist(self.host) self.success_init = data is not None
[ "def", "__init__", "(", "self", ",", "config", ")", ":", "_LOGGER", ".", "info", "(", "\"Initialising BT Home Hub 5\"", ")", "self", ".", "host", "=", "config", "[", "CONF_HOST", "]", "self", ".", "last_results", "=", "{", "}", "# Test the router is accessible", "data", "=", "bthomehub5_devicelist", ".", "get_devicelist", "(", "self", ".", "host", ")", "self", ".", "success_init", "=", "data", "is", "not", "None" ]
[ 33, 4 ]
[ 42, 44 ]
python
en
['en', 'en', 'en']
True
BTHomeHub5DeviceScanner.scan_devices
(self)
Scan for new devices and return a list with found device IDs.
Scan for new devices and return a list with found device IDs.
def scan_devices(self): """Scan for new devices and return a list with found device IDs.""" self.update_info() return (device for device in self.last_results)
[ "def", "scan_devices", "(", "self", ")", ":", "self", ".", "update_info", "(", ")", "return", "(", "device", "for", "device", "in", "self", ".", "last_results", ")" ]
[ 44, 4 ]
[ 48, 55 ]
python
en
['en', 'en', 'en']
True
BTHomeHub5DeviceScanner.get_device_name
(self, device)
Return the name of the given device or None if we don't know.
Return the name of the given device or None if we don't know.
def get_device_name(self, device): """Return the name of the given device or None if we don't know.""" # If not initialised and not already scanned and not found. if device not in self.last_results: self.update_info() if not self.last_results: return None return self.last_results.get(device)
[ "def", "get_device_name", "(", "self", ",", "device", ")", ":", "# If not initialised and not already scanned and not found.", "if", "device", "not", "in", "self", ".", "last_results", ":", "self", ".", "update_info", "(", ")", "if", "not", "self", ".", "last_results", ":", "return", "None", "return", "self", ".", "last_results", ".", "get", "(", "device", ")" ]
[ 50, 4 ]
[ 59, 44 ]
python
en
['en', 'en', 'en']
True
BTHomeHub5DeviceScanner.update_info
(self)
Ensure the information from the BT Home Hub 5 is up to date.
Ensure the information from the BT Home Hub 5 is up to date.
def update_info(self): """Ensure the information from the BT Home Hub 5 is up to date.""" _LOGGER.info("Scanning") data = bthomehub5_devicelist.get_devicelist(self.host) if not data: _LOGGER.warning("Error scanning devices") return self.last_results = data
[ "def", "update_info", "(", "self", ")", ":", "_LOGGER", ".", "info", "(", "\"Scanning\"", ")", "data", "=", "bthomehub5_devicelist", ".", "get_devicelist", "(", "self", ".", "host", ")", "if", "not", "data", ":", "_LOGGER", ".", "warning", "(", "\"Error scanning devices\"", ")", "return", "self", ".", "last_results", "=", "data" ]
[ 61, 4 ]
[ 72, 32 ]
python
en
['en', 'en', 'en']
True
setup_component
(hass)
Hue component.
Hue component.
async def setup_component(hass): """Hue component.""" with patch.object(hue, "async_setup_entry", return_value=True): assert ( await async_setup_component( hass, hue.DOMAIN, {}, ) is True )
[ "async", "def", "setup_component", "(", "hass", ")", ":", "with", "patch", ".", "object", "(", "hue", ",", "\"async_setup_entry\"", ",", "return_value", "=", "True", ")", ":", "assert", "(", "await", "async_setup_component", "(", "hass", ",", "hue", ".", "DOMAIN", ",", "{", "}", ",", ")", "is", "True", ")" ]
[ 16, 0 ]
[ 26, 9 ]
python
ca
['de', 'ca', 'en']
False
test_hue_activate_scene_both_responds
( hass, mock_bridge1, mock_bridge2, mock_config_entry1, mock_config_entry2 )
Test that makes both bridges successfully activate a scene.
Test that makes both bridges successfully activate a scene.
async def test_hue_activate_scene_both_responds( hass, mock_bridge1, mock_bridge2, mock_config_entry1, mock_config_entry2 ): """Test that makes both bridges successfully activate a scene.""" await setup_component(hass) await setup_bridge(hass, mock_bridge1, mock_config_entry1) await setup_bridge(hass, mock_bridge2, mock_config_entry2) with patch.object( mock_bridge1, "hue_activate_scene", return_value=None ) as mock_hue_activate_scene1, patch.object( mock_bridge2, "hue_activate_scene", return_value=None ) as mock_hue_activate_scene2: await hass.services.async_call( "hue", "hue_activate_scene", {"group_name": "group_2", "scene_name": "my_scene"}, blocking=True, ) mock_hue_activate_scene1.assert_called_once() mock_hue_activate_scene2.assert_called_once()
[ "async", "def", "test_hue_activate_scene_both_responds", "(", "hass", ",", "mock_bridge1", ",", "mock_bridge2", ",", "mock_config_entry1", ",", "mock_config_entry2", ")", ":", "await", "setup_component", "(", "hass", ")", "await", "setup_bridge", "(", "hass", ",", "mock_bridge1", ",", "mock_config_entry1", ")", "await", "setup_bridge", "(", "hass", ",", "mock_bridge2", ",", "mock_config_entry2", ")", "with", "patch", ".", "object", "(", "mock_bridge1", ",", "\"hue_activate_scene\"", ",", "return_value", "=", "None", ")", "as", "mock_hue_activate_scene1", ",", "patch", ".", "object", "(", "mock_bridge2", ",", "\"hue_activate_scene\"", ",", "return_value", "=", "None", ")", "as", "mock_hue_activate_scene2", ":", "await", "hass", ".", "services", ".", "async_call", "(", "\"hue\"", ",", "\"hue_activate_scene\"", ",", "{", "\"group_name\"", ":", "\"group_2\"", ",", "\"scene_name\"", ":", "\"my_scene\"", "}", ",", "blocking", "=", "True", ",", ")", "mock_hue_activate_scene1", ".", "assert_called_once", "(", ")", "mock_hue_activate_scene2", ".", "assert_called_once", "(", ")" ]
[ 29, 0 ]
[ 52, 49 ]
python
en
['en', 'en', 'en']
True
test_hue_activate_scene_one_responds
( hass, mock_bridge1, mock_bridge2, mock_config_entry1, mock_config_entry2 )
Test that makes only one bridge successfully activate a scene.
Test that makes only one bridge successfully activate a scene.
async def test_hue_activate_scene_one_responds( hass, mock_bridge1, mock_bridge2, mock_config_entry1, mock_config_entry2 ): """Test that makes only one bridge successfully activate a scene.""" await setup_component(hass) await setup_bridge(hass, mock_bridge1, mock_config_entry1) await setup_bridge(hass, mock_bridge2, mock_config_entry2) with patch.object( mock_bridge1, "hue_activate_scene", return_value=None ) as mock_hue_activate_scene1, patch.object( mock_bridge2, "hue_activate_scene", return_value=False ) as mock_hue_activate_scene2: await hass.services.async_call( "hue", "hue_activate_scene", {"group_name": "group_2", "scene_name": "my_scene"}, blocking=True, ) mock_hue_activate_scene1.assert_called_once() mock_hue_activate_scene2.assert_called_once()
[ "async", "def", "test_hue_activate_scene_one_responds", "(", "hass", ",", "mock_bridge1", ",", "mock_bridge2", ",", "mock_config_entry1", ",", "mock_config_entry2", ")", ":", "await", "setup_component", "(", "hass", ")", "await", "setup_bridge", "(", "hass", ",", "mock_bridge1", ",", "mock_config_entry1", ")", "await", "setup_bridge", "(", "hass", ",", "mock_bridge2", ",", "mock_config_entry2", ")", "with", "patch", ".", "object", "(", "mock_bridge1", ",", "\"hue_activate_scene\"", ",", "return_value", "=", "None", ")", "as", "mock_hue_activate_scene1", ",", "patch", ".", "object", "(", "mock_bridge2", ",", "\"hue_activate_scene\"", ",", "return_value", "=", "False", ")", "as", "mock_hue_activate_scene2", ":", "await", "hass", ".", "services", ".", "async_call", "(", "\"hue\"", ",", "\"hue_activate_scene\"", ",", "{", "\"group_name\"", ":", "\"group_2\"", ",", "\"scene_name\"", ":", "\"my_scene\"", "}", ",", "blocking", "=", "True", ",", ")", "mock_hue_activate_scene1", ".", "assert_called_once", "(", ")", "mock_hue_activate_scene2", ".", "assert_called_once", "(", ")" ]
[ 55, 0 ]
[ 78, 49 ]
python
en
['en', 'en', 'en']
True
test_hue_activate_scene_zero_responds
( hass, mock_bridge1, mock_bridge2, mock_config_entry1, mock_config_entry2 )
Test that makes no bridge successfully activate a scene.
Test that makes no bridge successfully activate a scene.
async def test_hue_activate_scene_zero_responds( hass, mock_bridge1, mock_bridge2, mock_config_entry1, mock_config_entry2 ): """Test that makes no bridge successfully activate a scene.""" await setup_component(hass) await setup_bridge(hass, mock_bridge1, mock_config_entry1) await setup_bridge(hass, mock_bridge2, mock_config_entry2) with patch.object( mock_bridge1, "hue_activate_scene", return_value=False ) as mock_hue_activate_scene1, patch.object( mock_bridge2, "hue_activate_scene", return_value=False ) as mock_hue_activate_scene2: await hass.services.async_call( "hue", "hue_activate_scene", {"group_name": "group_2", "scene_name": "my_scene"}, blocking=True, ) # both were retried assert mock_hue_activate_scene1.call_count == 2 assert mock_hue_activate_scene2.call_count == 2
[ "async", "def", "test_hue_activate_scene_zero_responds", "(", "hass", ",", "mock_bridge1", ",", "mock_bridge2", ",", "mock_config_entry1", ",", "mock_config_entry2", ")", ":", "await", "setup_component", "(", "hass", ")", "await", "setup_bridge", "(", "hass", ",", "mock_bridge1", ",", "mock_config_entry1", ")", "await", "setup_bridge", "(", "hass", ",", "mock_bridge2", ",", "mock_config_entry2", ")", "with", "patch", ".", "object", "(", "mock_bridge1", ",", "\"hue_activate_scene\"", ",", "return_value", "=", "False", ")", "as", "mock_hue_activate_scene1", ",", "patch", ".", "object", "(", "mock_bridge2", ",", "\"hue_activate_scene\"", ",", "return_value", "=", "False", ")", "as", "mock_hue_activate_scene2", ":", "await", "hass", ".", "services", ".", "async_call", "(", "\"hue\"", ",", "\"hue_activate_scene\"", ",", "{", "\"group_name\"", ":", "\"group_2\"", ",", "\"scene_name\"", ":", "\"my_scene\"", "}", ",", "blocking", "=", "True", ",", ")", "# both were retried", "assert", "mock_hue_activate_scene1", ".", "call_count", "==", "2", "assert", "mock_hue_activate_scene2", ".", "call_count", "==", "2" ]
[ 81, 0 ]
[ 105, 51 ]
python
en
['en', 'en', 'en']
True
setup_bridge
(hass, mock_bridge, config_entry)
Load the Hue light platform with the provided bridge.
Load the Hue light platform with the provided bridge.
async def setup_bridge(hass, mock_bridge, config_entry): """Load the Hue light platform with the provided bridge.""" mock_bridge.config_entry = config_entry hass.data[hue.DOMAIN][config_entry.entry_id] = mock_bridge await hass.config_entries.async_forward_entry_setup(config_entry, "light") # To flush out the service call to update the group await hass.async_block_till_done()
[ "async", "def", "setup_bridge", "(", "hass", ",", "mock_bridge", ",", "config_entry", ")", ":", "mock_bridge", ".", "config_entry", "=", "config_entry", "hass", ".", "data", "[", "hue", ".", "DOMAIN", "]", "[", "config_entry", ".", "entry_id", "]", "=", "mock_bridge", "await", "hass", ".", "config_entries", ".", "async_forward_entry_setup", "(", "config_entry", ",", "\"light\"", ")", "# To flush out the service call to update the group", "await", "hass", ".", "async_block_till_done", "(", ")" ]
[ 108, 0 ]
[ 114, 38 ]
python
en
['en', 'en', 'en']
True
mock_config_entry1
(hass)
Mock a config entry.
Mock a config entry.
def mock_config_entry1(hass): """Mock a config entry.""" return create_config_entry()
[ "def", "mock_config_entry1", "(", "hass", ")", ":", "return", "create_config_entry", "(", ")" ]
[ 118, 0 ]
[ 120, 32 ]
python
en
['en', 'gl', 'en']
True
mock_config_entry2
(hass)
Mock a config entry.
Mock a config entry.
def mock_config_entry2(hass): """Mock a config entry.""" return create_config_entry()
[ "def", "mock_config_entry2", "(", "hass", ")", ":", "return", "create_config_entry", "(", ")" ]
[ 124, 0 ]
[ 126, 32 ]
python
en
['en', 'gl', 'en']
True
create_config_entry
()
Mock a config entry.
Mock a config entry.
def create_config_entry(): """Mock a config entry.""" return config_entries.ConfigEntry( 1, hue.DOMAIN, "Mock Title", {"host": "mock-host"}, "test", config_entries.CONN_CLASS_LOCAL_POLL, system_options={}, )
[ "def", "create_config_entry", "(", ")", ":", "return", "config_entries", ".", "ConfigEntry", "(", "1", ",", "hue", ".", "DOMAIN", ",", "\"Mock Title\"", ",", "{", "\"host\"", ":", "\"mock-host\"", "}", ",", "\"test\"", ",", "config_entries", ".", "CONN_CLASS_LOCAL_POLL", ",", "system_options", "=", "{", "}", ",", ")" ]
[ 129, 0 ]
[ 139, 5 ]
python
en
['en', 'gl', 'en']
True
mock_bridge1
(hass)
Mock a Hue bridge.
Mock a Hue bridge.
def mock_bridge1(hass): """Mock a Hue bridge.""" return create_mock_bridge(hass)
[ "def", "mock_bridge1", "(", "hass", ")", ":", "return", "create_mock_bridge", "(", "hass", ")" ]
[ 143, 0 ]
[ 145, 35 ]
python
en
['en', 'st', 'en']
True
mock_bridge2
(hass)
Mock a Hue bridge.
Mock a Hue bridge.
def mock_bridge2(hass): """Mock a Hue bridge.""" return create_mock_bridge(hass)
[ "def", "mock_bridge2", "(", "hass", ")", ":", "return", "create_mock_bridge", "(", "hass", ")" ]
[ 149, 0 ]
[ 151, 35 ]
python
en
['en', 'st', 'en']
True
create_mock_bridge
(hass)
Create a mock Hue bridge.
Create a mock Hue bridge.
def create_mock_bridge(hass): """Create a mock Hue bridge.""" bridge = Mock( hass=hass, available=True, authorized=True, allow_unreachable=False, allow_groups=False, api=Mock(), reset_jobs=[], spec=hue.HueBridge, ) bridge.sensor_manager = hue_sensor_base.SensorManager(bridge) bridge.mock_requests = [] async def mock_request(method, path, **kwargs): kwargs["method"] = method kwargs["path"] = path bridge.mock_requests.append(kwargs) return {} async def async_request_call(task): await task() bridge.async_request_call = async_request_call bridge.api.config.apiversion = "9.9.9" bridge.api.lights = Lights({}, mock_request) bridge.api.groups = Groups({}, mock_request) bridge.api.sensors = Sensors({}, mock_request) bridge.api.scenes = Scenes({}, mock_request) return bridge
[ "def", "create_mock_bridge", "(", "hass", ")", ":", "bridge", "=", "Mock", "(", "hass", "=", "hass", ",", "available", "=", "True", ",", "authorized", "=", "True", ",", "allow_unreachable", "=", "False", ",", "allow_groups", "=", "False", ",", "api", "=", "Mock", "(", ")", ",", "reset_jobs", "=", "[", "]", ",", "spec", "=", "hue", ".", "HueBridge", ",", ")", "bridge", ".", "sensor_manager", "=", "hue_sensor_base", ".", "SensorManager", "(", "bridge", ")", "bridge", ".", "mock_requests", "=", "[", "]", "async", "def", "mock_request", "(", "method", ",", "path", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "\"method\"", "]", "=", "method", "kwargs", "[", "\"path\"", "]", "=", "path", "bridge", ".", "mock_requests", ".", "append", "(", "kwargs", ")", "return", "{", "}", "async", "def", "async_request_call", "(", "task", ")", ":", "await", "task", "(", ")", "bridge", ".", "async_request_call", "=", "async_request_call", "bridge", ".", "api", ".", "config", ".", "apiversion", "=", "\"9.9.9\"", "bridge", ".", "api", ".", "lights", "=", "Lights", "(", "{", "}", ",", "mock_request", ")", "bridge", ".", "api", ".", "groups", "=", "Groups", "(", "{", "}", ",", "mock_request", ")", "bridge", ".", "api", ".", "sensors", "=", "Sensors", "(", "{", "}", ",", "mock_request", ")", "bridge", ".", "api", ".", "scenes", "=", "Scenes", "(", "{", "}", ",", "mock_request", ")", "return", "bridge" ]
[ 154, 0 ]
[ 184, 17 ]
python
en
['en', 'st', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the Dlib Face detection platform.
Set up the Dlib Face detection platform.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Dlib Face detection platform.""" entities = [] for camera in config[CONF_SOURCE]: entities.append( DlibFaceIdentifyEntity( camera[CONF_ENTITY_ID], config[CONF_FACES], camera.get(CONF_NAME), config[CONF_CONFIDENCE], ) ) add_entities(entities)
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "entities", "=", "[", "]", "for", "camera", "in", "config", "[", "CONF_SOURCE", "]", ":", "entities", ".", "append", "(", "DlibFaceIdentifyEntity", "(", "camera", "[", "CONF_ENTITY_ID", "]", ",", "config", "[", "CONF_FACES", "]", ",", "camera", ".", "get", "(", "CONF_NAME", ")", ",", "config", "[", "CONF_CONFIDENCE", "]", ",", ")", ")", "add_entities", "(", "entities", ")" ]
[ 32, 0 ]
[ 45, 26 ]
python
en
['en', 'da', 'en']
True
DlibFaceIdentifyEntity.__init__
(self, camera_entity, faces, name, tolerance)
Initialize Dlib face identify entry.
Initialize Dlib face identify entry.
def __init__(self, camera_entity, faces, name, tolerance): """Initialize Dlib face identify entry.""" super().__init__() self._camera = camera_entity if name: self._name = name else: self._name = f"Dlib Face {split_entity_id(camera_entity)[1]}" self._faces = {} for face_name, face_file in faces.items(): try: image = face_recognition.load_image_file(face_file) self._faces[face_name] = face_recognition.face_encodings(image)[0] except IndexError as err: _LOGGER.error("Failed to parse %s. Error: %s", face_file, err) self._tolerance = tolerance
[ "def", "__init__", "(", "self", ",", "camera_entity", ",", "faces", ",", "name", ",", "tolerance", ")", ":", "super", "(", ")", ".", "__init__", "(", ")", "self", ".", "_camera", "=", "camera_entity", "if", "name", ":", "self", ".", "_name", "=", "name", "else", ":", "self", ".", "_name", "=", "f\"Dlib Face {split_entity_id(camera_entity)[1]}\"", "self", ".", "_faces", "=", "{", "}", "for", "face_name", ",", "face_file", "in", "faces", ".", "items", "(", ")", ":", "try", ":", "image", "=", "face_recognition", ".", "load_image_file", "(", "face_file", ")", "self", ".", "_faces", "[", "face_name", "]", "=", "face_recognition", ".", "face_encodings", "(", "image", ")", "[", "0", "]", "except", "IndexError", "as", "err", ":", "_LOGGER", ".", "error", "(", "\"Failed to parse %s. Error: %s\"", ",", "face_file", ",", "err", ")", "self", ".", "_tolerance", "=", "tolerance" ]
[ 51, 4 ]
[ 71, 35 ]
python
en
['en', 'en', 'en']
True
DlibFaceIdentifyEntity.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" ]
[ 74, 4 ]
[ 76, 27 ]
python
en
['en', 'en', 'en']
True
DlibFaceIdentifyEntity.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" ]
[ 79, 4 ]
[ 81, 25 ]
python
en
['en', 'en', 'en']
True
DlibFaceIdentifyEntity.process_image
(self, image)
Process image.
Process image.
def process_image(self, image): """Process image.""" fak_file = io.BytesIO(image) fak_file.name = "snapshot.jpg" fak_file.seek(0) image = face_recognition.load_image_file(fak_file) unknowns = face_recognition.face_encodings(image) found = [] for unknown_face in unknowns: for name, face in self._faces.items(): result = face_recognition.compare_faces( [face], unknown_face, tolerance=self._tolerance ) if result[0]: found.append({ATTR_NAME: name}) self.process_faces(found, len(unknowns))
[ "def", "process_image", "(", "self", ",", "image", ")", ":", "fak_file", "=", "io", ".", "BytesIO", "(", "image", ")", "fak_file", ".", "name", "=", "\"snapshot.jpg\"", "fak_file", ".", "seek", "(", "0", ")", "image", "=", "face_recognition", ".", "load_image_file", "(", "fak_file", ")", "unknowns", "=", "face_recognition", ".", "face_encodings", "(", "image", ")", "found", "=", "[", "]", "for", "unknown_face", "in", "unknowns", ":", "for", "name", ",", "face", "in", "self", ".", "_faces", ".", "items", "(", ")", ":", "result", "=", "face_recognition", ".", "compare_faces", "(", "[", "face", "]", ",", "unknown_face", ",", "tolerance", "=", "self", ".", "_tolerance", ")", "if", "result", "[", "0", "]", ":", "found", ".", "append", "(", "{", "ATTR_NAME", ":", "name", "}", ")", "self", ".", "process_faces", "(", "found", ",", "len", "(", "unknowns", ")", ")" ]
[ 83, 4 ]
[ 102, 48 ]
python
en
['en', 'ny', 'en']
False
async_setup
(hass: HomeAssistantType, config: ConfigType)
Set up climate entities.
Set up climate entities.
async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool: """Set up climate entities.""" component = hass.data[DOMAIN] = EntityComponent( _LOGGER, DOMAIN, hass, SCAN_INTERVAL ) await component.async_setup(config) component.async_register_entity_service(SERVICE_TURN_ON, {}, "async_turn_on") component.async_register_entity_service(SERVICE_TURN_OFF, {}, "async_turn_off") component.async_register_entity_service( SERVICE_SET_HVAC_MODE, {vol.Required(ATTR_HVAC_MODE): vol.In(HVAC_MODES)}, "async_set_hvac_mode", ) component.async_register_entity_service( SERVICE_SET_PRESET_MODE, {vol.Required(ATTR_PRESET_MODE): cv.string}, "async_set_preset_mode", [SUPPORT_PRESET_MODE], ) component.async_register_entity_service( SERVICE_SET_AUX_HEAT, {vol.Required(ATTR_AUX_HEAT): cv.boolean}, async_service_aux_heat, [SUPPORT_AUX_HEAT], ) component.async_register_entity_service( SERVICE_SET_TEMPERATURE, SET_TEMPERATURE_SCHEMA, async_service_temperature_set, [SUPPORT_TARGET_TEMPERATURE, SUPPORT_TARGET_TEMPERATURE_RANGE], ) component.async_register_entity_service( SERVICE_SET_HUMIDITY, {vol.Required(ATTR_HUMIDITY): vol.Coerce(float)}, "async_set_humidity", [SUPPORT_TARGET_HUMIDITY], ) component.async_register_entity_service( SERVICE_SET_FAN_MODE, {vol.Required(ATTR_FAN_MODE): cv.string}, "async_set_fan_mode", [SUPPORT_FAN_MODE], ) component.async_register_entity_service( SERVICE_SET_SWING_MODE, {vol.Required(ATTR_SWING_MODE): cv.string}, "async_set_swing_mode", [SUPPORT_SWING_MODE], ) return True
[ "async", "def", "async_setup", "(", "hass", ":", "HomeAssistantType", ",", "config", ":", "ConfigType", ")", "->", "bool", ":", "component", "=", "hass", ".", "data", "[", "DOMAIN", "]", "=", "EntityComponent", "(", "_LOGGER", ",", "DOMAIN", ",", "hass", ",", "SCAN_INTERVAL", ")", "await", "component", ".", "async_setup", "(", "config", ")", "component", ".", "async_register_entity_service", "(", "SERVICE_TURN_ON", ",", "{", "}", ",", "\"async_turn_on\"", ")", "component", ".", "async_register_entity_service", "(", "SERVICE_TURN_OFF", ",", "{", "}", ",", "\"async_turn_off\"", ")", "component", ".", "async_register_entity_service", "(", "SERVICE_SET_HVAC_MODE", ",", "{", "vol", ".", "Required", "(", "ATTR_HVAC_MODE", ")", ":", "vol", ".", "In", "(", "HVAC_MODES", ")", "}", ",", "\"async_set_hvac_mode\"", ",", ")", "component", ".", "async_register_entity_service", "(", "SERVICE_SET_PRESET_MODE", ",", "{", "vol", ".", "Required", "(", "ATTR_PRESET_MODE", ")", ":", "cv", ".", "string", "}", ",", "\"async_set_preset_mode\"", ",", "[", "SUPPORT_PRESET_MODE", "]", ",", ")", "component", ".", "async_register_entity_service", "(", "SERVICE_SET_AUX_HEAT", ",", "{", "vol", ".", "Required", "(", "ATTR_AUX_HEAT", ")", ":", "cv", ".", "boolean", "}", ",", "async_service_aux_heat", ",", "[", "SUPPORT_AUX_HEAT", "]", ",", ")", "component", ".", "async_register_entity_service", "(", "SERVICE_SET_TEMPERATURE", ",", "SET_TEMPERATURE_SCHEMA", ",", "async_service_temperature_set", ",", "[", "SUPPORT_TARGET_TEMPERATURE", ",", "SUPPORT_TARGET_TEMPERATURE_RANGE", "]", ",", ")", "component", ".", "async_register_entity_service", "(", "SERVICE_SET_HUMIDITY", ",", "{", "vol", ".", "Required", "(", "ATTR_HUMIDITY", ")", ":", "vol", ".", "Coerce", "(", "float", ")", "}", ",", "\"async_set_humidity\"", ",", "[", "SUPPORT_TARGET_HUMIDITY", "]", ",", ")", "component", ".", "async_register_entity_service", "(", "SERVICE_SET_FAN_MODE", ",", "{", "vol", ".", "Required", "(", "ATTR_FAN_MODE", ")", ":", "cv", ".", "string", "}", ",", "\"async_set_fan_mode\"", ",", "[", "SUPPORT_FAN_MODE", "]", ",", ")", "component", ".", "async_register_entity_service", "(", "SERVICE_SET_SWING_MODE", ",", "{", "vol", ".", "Required", "(", "ATTR_SWING_MODE", ")", ":", "cv", ".", "string", "}", ",", "\"async_set_swing_mode\"", ",", "[", "SUPPORT_SWING_MODE", "]", ",", ")", "return", "True" ]
[ 102, 0 ]
[ 153, 15 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass: HomeAssistantType, entry)
Set up a config entry.
Set up a config entry.
async def async_setup_entry(hass: HomeAssistantType, entry): """Set up a config entry.""" return await hass.data[DOMAIN].async_setup_entry(entry)
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistantType", ",", "entry", ")", ":", "return", "await", "hass", ".", "data", "[", "DOMAIN", "]", ".", "async_setup_entry", "(", "entry", ")" ]
[ 156, 0 ]
[ 158, 59 ]
python
en
['en', 'en', 'en']
True
async_unload_entry
(hass: HomeAssistantType, entry)
Unload a config entry.
Unload a config entry.
async def async_unload_entry(hass: HomeAssistantType, entry): """Unload a config entry.""" return await hass.data[DOMAIN].async_unload_entry(entry)
[ "async", "def", "async_unload_entry", "(", "hass", ":", "HomeAssistantType", ",", "entry", ")", ":", "return", "await", "hass", ".", "data", "[", "DOMAIN", "]", ".", "async_unload_entry", "(", "entry", ")" ]
[ 161, 0 ]
[ 163, 60 ]
python
en
['en', 'es', 'en']
True
async_service_aux_heat
( entity: ClimateEntity, service: ServiceDataType )
Handle aux heat service.
Handle aux heat service.
async def async_service_aux_heat( entity: ClimateEntity, service: ServiceDataType ) -> None: """Handle aux heat service.""" if service.data[ATTR_AUX_HEAT]: await entity.async_turn_aux_heat_on() else: await entity.async_turn_aux_heat_off()
[ "async", "def", "async_service_aux_heat", "(", "entity", ":", "ClimateEntity", ",", "service", ":", "ServiceDataType", ")", "->", "None", ":", "if", "service", ".", "data", "[", "ATTR_AUX_HEAT", "]", ":", "await", "entity", ".", "async_turn_aux_heat_on", "(", ")", "else", ":", "await", "entity", ".", "async_turn_aux_heat_off", "(", ")" ]
[ 518, 0 ]
[ 525, 46 ]
python
fr
['fr', 'fr', 'fr']
True
async_service_temperature_set
( entity: ClimateEntity, service: ServiceDataType )
Handle set temperature service.
Handle set temperature service.
async def async_service_temperature_set( entity: ClimateEntity, service: ServiceDataType ) -> None: """Handle set temperature service.""" hass = entity.hass kwargs = {} for value, temp in service.data.items(): if value in CONVERTIBLE_ATTRIBUTE: kwargs[value] = convert_temperature( temp, hass.config.units.temperature_unit, entity.temperature_unit ) else: kwargs[value] = temp await entity.async_set_temperature(**kwargs)
[ "async", "def", "async_service_temperature_set", "(", "entity", ":", "ClimateEntity", ",", "service", ":", "ServiceDataType", ")", "->", "None", ":", "hass", "=", "entity", ".", "hass", "kwargs", "=", "{", "}", "for", "value", ",", "temp", "in", "service", ".", "data", ".", "items", "(", ")", ":", "if", "value", "in", "CONVERTIBLE_ATTRIBUTE", ":", "kwargs", "[", "value", "]", "=", "convert_temperature", "(", "temp", ",", "hass", ".", "config", ".", "units", ".", "temperature_unit", ",", "entity", ".", "temperature_unit", ")", "else", ":", "kwargs", "[", "value", "]", "=", "temp", "await", "entity", ".", "async_set_temperature", "(", "*", "*", "kwargs", ")" ]
[ 528, 0 ]
[ 543, 48 ]
python
ca
['es', 'ca', 'en']
False
ClimateEntity.state
(self)
Return the current state.
Return the current state.
def state(self) -> str: """Return the current state.""" return self.hvac_mode
[ "def", "state", "(", "self", ")", "->", "str", ":", "return", "self", ".", "hvac_mode" ]
[ 170, 4 ]
[ 172, 29 ]
python
en
['en', 'en', 'en']
True
ClimateEntity.precision
(self)
Return the precision of the system.
Return the precision of the system.
def precision(self) -> float: """Return the precision of the system.""" if self.hass.config.units.temperature_unit == TEMP_CELSIUS: return PRECISION_TENTHS return PRECISION_WHOLE
[ "def", "precision", "(", "self", ")", "->", "float", ":", "if", "self", ".", "hass", ".", "config", ".", "units", ".", "temperature_unit", "==", "TEMP_CELSIUS", ":", "return", "PRECISION_TENTHS", "return", "PRECISION_WHOLE" ]
[ 175, 4 ]
[ 179, 30 ]
python
en
['en', 'en', 'en']
True
ClimateEntity.capability_attributes
(self)
Return the capability attributes.
Return the capability attributes.
def capability_attributes(self) -> Optional[Dict[str, Any]]: """Return the capability attributes.""" supported_features = self.supported_features data = { ATTR_HVAC_MODES: self.hvac_modes, ATTR_MIN_TEMP: show_temp( self.hass, self.min_temp, self.temperature_unit, self.precision ), ATTR_MAX_TEMP: show_temp( self.hass, self.max_temp, self.temperature_unit, self.precision ), } if self.target_temperature_step: data[ATTR_TARGET_TEMP_STEP] = self.target_temperature_step if supported_features & SUPPORT_TARGET_HUMIDITY: data[ATTR_MIN_HUMIDITY] = self.min_humidity data[ATTR_MAX_HUMIDITY] = self.max_humidity if supported_features & SUPPORT_FAN_MODE: data[ATTR_FAN_MODES] = self.fan_modes if supported_features & SUPPORT_PRESET_MODE: data[ATTR_PRESET_MODES] = self.preset_modes if supported_features & SUPPORT_SWING_MODE: data[ATTR_SWING_MODES] = self.swing_modes return data
[ "def", "capability_attributes", "(", "self", ")", "->", "Optional", "[", "Dict", "[", "str", ",", "Any", "]", "]", ":", "supported_features", "=", "self", ".", "supported_features", "data", "=", "{", "ATTR_HVAC_MODES", ":", "self", ".", "hvac_modes", ",", "ATTR_MIN_TEMP", ":", "show_temp", "(", "self", ".", "hass", ",", "self", ".", "min_temp", ",", "self", ".", "temperature_unit", ",", "self", ".", "precision", ")", ",", "ATTR_MAX_TEMP", ":", "show_temp", "(", "self", ".", "hass", ",", "self", ".", "max_temp", ",", "self", ".", "temperature_unit", ",", "self", ".", "precision", ")", ",", "}", "if", "self", ".", "target_temperature_step", ":", "data", "[", "ATTR_TARGET_TEMP_STEP", "]", "=", "self", ".", "target_temperature_step", "if", "supported_features", "&", "SUPPORT_TARGET_HUMIDITY", ":", "data", "[", "ATTR_MIN_HUMIDITY", "]", "=", "self", ".", "min_humidity", "data", "[", "ATTR_MAX_HUMIDITY", "]", "=", "self", ".", "max_humidity", "if", "supported_features", "&", "SUPPORT_FAN_MODE", ":", "data", "[", "ATTR_FAN_MODES", "]", "=", "self", ".", "fan_modes", "if", "supported_features", "&", "SUPPORT_PRESET_MODE", ":", "data", "[", "ATTR_PRESET_MODES", "]", "=", "self", ".", "preset_modes", "if", "supported_features", "&", "SUPPORT_SWING_MODE", ":", "data", "[", "ATTR_SWING_MODES", "]", "=", "self", ".", "swing_modes", "return", "data" ]
[ 182, 4 ]
[ 211, 19 ]
python
en
['en', 'en', 'en']
True
ClimateEntity.state_attributes
(self)
Return the optional state attributes.
Return the optional state attributes.
def state_attributes(self) -> Dict[str, Any]: """Return the optional state attributes.""" supported_features = self.supported_features data = { ATTR_CURRENT_TEMPERATURE: show_temp( self.hass, self.current_temperature, self.temperature_unit, self.precision, ), } if supported_features & SUPPORT_TARGET_TEMPERATURE: data[ATTR_TEMPERATURE] = show_temp( self.hass, self.target_temperature, self.temperature_unit, self.precision, ) if supported_features & SUPPORT_TARGET_TEMPERATURE_RANGE: data[ATTR_TARGET_TEMP_HIGH] = show_temp( self.hass, self.target_temperature_high, self.temperature_unit, self.precision, ) data[ATTR_TARGET_TEMP_LOW] = show_temp( self.hass, self.target_temperature_low, self.temperature_unit, self.precision, ) if self.current_humidity is not None: data[ATTR_CURRENT_HUMIDITY] = self.current_humidity if supported_features & SUPPORT_TARGET_HUMIDITY: data[ATTR_HUMIDITY] = self.target_humidity if supported_features & SUPPORT_FAN_MODE: data[ATTR_FAN_MODE] = self.fan_mode if self.hvac_action: data[ATTR_HVAC_ACTION] = self.hvac_action if supported_features & SUPPORT_PRESET_MODE: data[ATTR_PRESET_MODE] = self.preset_mode if supported_features & SUPPORT_SWING_MODE: data[ATTR_SWING_MODE] = self.swing_mode if supported_features & SUPPORT_AUX_HEAT: data[ATTR_AUX_HEAT] = STATE_ON if self.is_aux_heat else STATE_OFF return data
[ "def", "state_attributes", "(", "self", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "supported_features", "=", "self", ".", "supported_features", "data", "=", "{", "ATTR_CURRENT_TEMPERATURE", ":", "show_temp", "(", "self", ".", "hass", ",", "self", ".", "current_temperature", ",", "self", ".", "temperature_unit", ",", "self", ".", "precision", ",", ")", ",", "}", "if", "supported_features", "&", "SUPPORT_TARGET_TEMPERATURE", ":", "data", "[", "ATTR_TEMPERATURE", "]", "=", "show_temp", "(", "self", ".", "hass", ",", "self", ".", "target_temperature", ",", "self", ".", "temperature_unit", ",", "self", ".", "precision", ",", ")", "if", "supported_features", "&", "SUPPORT_TARGET_TEMPERATURE_RANGE", ":", "data", "[", "ATTR_TARGET_TEMP_HIGH", "]", "=", "show_temp", "(", "self", ".", "hass", ",", "self", ".", "target_temperature_high", ",", "self", ".", "temperature_unit", ",", "self", ".", "precision", ",", ")", "data", "[", "ATTR_TARGET_TEMP_LOW", "]", "=", "show_temp", "(", "self", ".", "hass", ",", "self", ".", "target_temperature_low", ",", "self", ".", "temperature_unit", ",", "self", ".", "precision", ",", ")", "if", "self", ".", "current_humidity", "is", "not", "None", ":", "data", "[", "ATTR_CURRENT_HUMIDITY", "]", "=", "self", ".", "current_humidity", "if", "supported_features", "&", "SUPPORT_TARGET_HUMIDITY", ":", "data", "[", "ATTR_HUMIDITY", "]", "=", "self", ".", "target_humidity", "if", "supported_features", "&", "SUPPORT_FAN_MODE", ":", "data", "[", "ATTR_FAN_MODE", "]", "=", "self", ".", "fan_mode", "if", "self", ".", "hvac_action", ":", "data", "[", "ATTR_HVAC_ACTION", "]", "=", "self", ".", "hvac_action", "if", "supported_features", "&", "SUPPORT_PRESET_MODE", ":", "data", "[", "ATTR_PRESET_MODE", "]", "=", "self", ".", "preset_mode", "if", "supported_features", "&", "SUPPORT_SWING_MODE", ":", "data", "[", "ATTR_SWING_MODE", "]", "=", "self", ".", "swing_mode", "if", "supported_features", "&", "SUPPORT_AUX_HEAT", ":", "data", "[", "ATTR_AUX_HEAT", "]", "=", "STATE_ON", "if", "self", ".", "is_aux_heat", "else", "STATE_OFF", "return", "data" ]
[ 214, 4 ]
[ 269, 19 ]
python
en
['en', 'en', 'en']
True
ClimateEntity.temperature_unit
(self)
Return the unit of measurement used by the platform.
Return the unit of measurement used by the platform.
def temperature_unit(self) -> str: """Return the unit of measurement used by the platform.""" raise NotImplementedError()
[ "def", "temperature_unit", "(", "self", ")", "->", "str", ":", "raise", "NotImplementedError", "(", ")" ]
[ 272, 4 ]
[ 274, 35 ]
python
en
['en', 'en', 'en']
True
ClimateEntity.current_humidity
(self)
Return the current humidity.
Return the current humidity.
def current_humidity(self) -> Optional[int]: """Return the current humidity.""" return None
[ "def", "current_humidity", "(", "self", ")", "->", "Optional", "[", "int", "]", ":", "return", "None" ]
[ 277, 4 ]
[ 279, 19 ]
python
en
['en', 'en', 'en']
True
ClimateEntity.target_humidity
(self)
Return the humidity we try to reach.
Return the humidity we try to reach.
def target_humidity(self) -> Optional[int]: """Return the humidity we try to reach.""" return None
[ "def", "target_humidity", "(", "self", ")", "->", "Optional", "[", "int", "]", ":", "return", "None" ]
[ 282, 4 ]
[ 284, 19 ]
python
en
['en', 'en', 'en']
True
ClimateEntity.hvac_mode
(self)
Return hvac operation ie. heat, cool mode. Need to be one of HVAC_MODE_*.
Return hvac operation ie. heat, cool mode.
def hvac_mode(self) -> str: """Return hvac operation ie. heat, cool mode. Need to be one of HVAC_MODE_*. """
[ "def", "hvac_mode", "(", "self", ")", "->", "str", ":" ]
[ 288, 4 ]
[ 292, 11 ]
python
bg
['en', 'bg', 'bg']
True
ClimateEntity.hvac_modes
(self)
Return the list of available hvac operation modes. Need to be a subset of HVAC_MODES.
Return the list of available hvac operation modes.
def hvac_modes(self) -> List[str]: """Return the list of available hvac operation modes. Need to be a subset of HVAC_MODES. """
[ "def", "hvac_modes", "(", "self", ")", "->", "List", "[", "str", "]", ":" ]
[ 296, 4 ]
[ 300, 11 ]
python
en
['en', 'en', 'en']
True
ClimateEntity.hvac_action
(self)
Return the current running hvac operation if supported. Need to be one of CURRENT_HVAC_*.
Return the current running hvac operation if supported.
def hvac_action(self) -> Optional[str]: """Return the current running hvac operation if supported. Need to be one of CURRENT_HVAC_*. """ return None
[ "def", "hvac_action", "(", "self", ")", "->", "Optional", "[", "str", "]", ":", "return", "None" ]
[ 303, 4 ]
[ 308, 19 ]
python
en
['en', 'en', 'en']
True
ClimateEntity.current_temperature
(self)
Return the current temperature.
Return the current temperature.
def current_temperature(self) -> Optional[float]: """Return the current temperature.""" return None
[ "def", "current_temperature", "(", "self", ")", "->", "Optional", "[", "float", "]", ":", "return", "None" ]
[ 311, 4 ]
[ 313, 19 ]
python
en
['en', 'la', 'en']
True
ClimateEntity.target_temperature
(self)
Return the temperature we try to reach.
Return the temperature we try to reach.
def target_temperature(self) -> Optional[float]: """Return the temperature we try to reach.""" return None
[ "def", "target_temperature", "(", "self", ")", "->", "Optional", "[", "float", "]", ":", "return", "None" ]
[ 316, 4 ]
[ 318, 19 ]
python
en
['en', 'en', 'en']
True
ClimateEntity.target_temperature_step
(self)
Return the supported step of target temperature.
Return the supported step of target temperature.
def target_temperature_step(self) -> Optional[float]: """Return the supported step of target temperature.""" return None
[ "def", "target_temperature_step", "(", "self", ")", "->", "Optional", "[", "float", "]", ":", "return", "None" ]
[ 321, 4 ]
[ 323, 19 ]
python
en
['en', 'en', 'en']
True
ClimateEntity.target_temperature_high
(self)
Return the highbound target temperature we try to reach. Requires SUPPORT_TARGET_TEMPERATURE_RANGE.
Return the highbound target temperature we try to reach.
def target_temperature_high(self) -> Optional[float]: """Return the highbound target temperature we try to reach. Requires SUPPORT_TARGET_TEMPERATURE_RANGE. """ raise NotImplementedError
[ "def", "target_temperature_high", "(", "self", ")", "->", "Optional", "[", "float", "]", ":", "raise", "NotImplementedError" ]
[ 326, 4 ]
[ 331, 33 ]
python
en
['en', 'en', 'en']
True
ClimateEntity.target_temperature_low
(self)
Return the lowbound target temperature we try to reach. Requires SUPPORT_TARGET_TEMPERATURE_RANGE.
Return the lowbound target temperature we try to reach.
def target_temperature_low(self) -> Optional[float]: """Return the lowbound target temperature we try to reach. Requires SUPPORT_TARGET_TEMPERATURE_RANGE. """ raise NotImplementedError
[ "def", "target_temperature_low", "(", "self", ")", "->", "Optional", "[", "float", "]", ":", "raise", "NotImplementedError" ]
[ 334, 4 ]
[ 339, 33 ]
python
en
['en', 'en', 'en']
True
ClimateEntity.preset_mode
(self)
Return the current preset mode, e.g., home, away, temp. Requires SUPPORT_PRESET_MODE.
Return the current preset mode, e.g., home, away, temp.
def preset_mode(self) -> Optional[str]: """Return the current preset mode, e.g., home, away, temp. Requires SUPPORT_PRESET_MODE. """ raise NotImplementedError
[ "def", "preset_mode", "(", "self", ")", "->", "Optional", "[", "str", "]", ":", "raise", "NotImplementedError" ]
[ 342, 4 ]
[ 347, 33 ]
python
en
['en', 'pt', 'en']
True
ClimateEntity.preset_modes
(self)
Return a list of available preset modes. Requires SUPPORT_PRESET_MODE.
Return a list of available preset modes.
def preset_modes(self) -> Optional[List[str]]: """Return a list of available preset modes. Requires SUPPORT_PRESET_MODE. """ raise NotImplementedError
[ "def", "preset_modes", "(", "self", ")", "->", "Optional", "[", "List", "[", "str", "]", "]", ":", "raise", "NotImplementedError" ]
[ 350, 4 ]
[ 355, 33 ]
python
en
['en', 'en', 'en']
True
ClimateEntity.is_aux_heat
(self)
Return true if aux heater. Requires SUPPORT_AUX_HEAT.
Return true if aux heater.
def is_aux_heat(self) -> Optional[bool]: """Return true if aux heater. Requires SUPPORT_AUX_HEAT. """ raise NotImplementedError
[ "def", "is_aux_heat", "(", "self", ")", "->", "Optional", "[", "bool", "]", ":", "raise", "NotImplementedError" ]
[ 358, 4 ]
[ 363, 33 ]
python
fr
['fr', 'co', 'fr']
True
ClimateEntity.fan_mode
(self)
Return the fan setting. Requires SUPPORT_FAN_MODE.
Return the fan setting.
def fan_mode(self) -> Optional[str]: """Return the fan setting. Requires SUPPORT_FAN_MODE. """ raise NotImplementedError
[ "def", "fan_mode", "(", "self", ")", "->", "Optional", "[", "str", "]", ":", "raise", "NotImplementedError" ]
[ 366, 4 ]
[ 371, 33 ]
python
en
['en', 'fy', 'en']
True
ClimateEntity.fan_modes
(self)
Return the list of available fan modes. Requires SUPPORT_FAN_MODE.
Return the list of available fan modes.
def fan_modes(self) -> Optional[List[str]]: """Return the list of available fan modes. Requires SUPPORT_FAN_MODE. """ raise NotImplementedError
[ "def", "fan_modes", "(", "self", ")", "->", "Optional", "[", "List", "[", "str", "]", "]", ":", "raise", "NotImplementedError" ]
[ 374, 4 ]
[ 379, 33 ]
python
en
['en', 'en', 'en']
True
ClimateEntity.swing_mode
(self)
Return the swing setting. Requires SUPPORT_SWING_MODE.
Return the swing setting.
def swing_mode(self) -> Optional[str]: """Return the swing setting. Requires SUPPORT_SWING_MODE. """ raise NotImplementedError
[ "def", "swing_mode", "(", "self", ")", "->", "Optional", "[", "str", "]", ":", "raise", "NotImplementedError" ]
[ 382, 4 ]
[ 387, 33 ]
python
en
['en', 'ig', 'en']
True
ClimateEntity.swing_modes
(self)
Return the list of available swing modes. Requires SUPPORT_SWING_MODE.
Return the list of available swing modes.
def swing_modes(self) -> Optional[List[str]]: """Return the list of available swing modes. Requires SUPPORT_SWING_MODE. """ raise NotImplementedError
[ "def", "swing_modes", "(", "self", ")", "->", "Optional", "[", "List", "[", "str", "]", "]", ":", "raise", "NotImplementedError" ]
[ 390, 4 ]
[ 395, 33 ]
python
en
['en', 'en', 'en']
True
ClimateEntity.set_temperature
(self, **kwargs)
Set new target temperature.
Set new target temperature.
def set_temperature(self, **kwargs) -> None: """Set new target temperature.""" raise NotImplementedError()
[ "def", "set_temperature", "(", "self", ",", "*", "*", "kwargs", ")", "->", "None", ":", "raise", "NotImplementedError", "(", ")" ]
[ 397, 4 ]
[ 399, 35 ]
python
en
['en', 'ca', 'en']
True
ClimateEntity.async_set_temperature
(self, **kwargs)
Set new target temperature.
Set new target temperature.
async def async_set_temperature(self, **kwargs) -> None: """Set new target temperature.""" await self.hass.async_add_executor_job( ft.partial(self.set_temperature, **kwargs) )
[ "async", "def", "async_set_temperature", "(", "self", ",", "*", "*", "kwargs", ")", "->", "None", ":", "await", "self", ".", "hass", ".", "async_add_executor_job", "(", "ft", ".", "partial", "(", "self", ".", "set_temperature", ",", "*", "*", "kwargs", ")", ")" ]
[ 401, 4 ]
[ 405, 9 ]
python
en
['en', 'ca', 'en']
True
ClimateEntity.set_humidity
(self, humidity: int)
Set new target humidity.
Set new target humidity.
def set_humidity(self, humidity: int) -> None: """Set new target humidity.""" raise NotImplementedError()
[ "def", "set_humidity", "(", "self", ",", "humidity", ":", "int", ")", "->", "None", ":", "raise", "NotImplementedError", "(", ")" ]
[ 407, 4 ]
[ 409, 35 ]
python
en
['en', 'en', 'en']
True
ClimateEntity.async_set_humidity
(self, humidity: int)
Set new target humidity.
Set new target humidity.
async def async_set_humidity(self, humidity: int) -> None: """Set new target humidity.""" await self.hass.async_add_executor_job(self.set_humidity, humidity)
[ "async", "def", "async_set_humidity", "(", "self", ",", "humidity", ":", "int", ")", "->", "None", ":", "await", "self", ".", "hass", ".", "async_add_executor_job", "(", "self", ".", "set_humidity", ",", "humidity", ")" ]
[ 411, 4 ]
[ 413, 75 ]
python
en
['en', 'en', 'en']
True
ClimateEntity.set_fan_mode
(self, fan_mode: str)
Set new target fan mode.
Set new target fan mode.
def set_fan_mode(self, fan_mode: str) -> None: """Set new target fan mode.""" raise NotImplementedError()
[ "def", "set_fan_mode", "(", "self", ",", "fan_mode", ":", "str", ")", "->", "None", ":", "raise", "NotImplementedError", "(", ")" ]
[ 415, 4 ]
[ 417, 35 ]
python
en
['sv', 'fy', 'en']
False
ClimateEntity.async_set_fan_mode
(self, fan_mode: str)
Set new target fan mode.
Set new target fan mode.
async def async_set_fan_mode(self, fan_mode: str) -> None: """Set new target fan mode.""" await self.hass.async_add_executor_job(self.set_fan_mode, fan_mode)
[ "async", "def", "async_set_fan_mode", "(", "self", ",", "fan_mode", ":", "str", ")", "->", "None", ":", "await", "self", ".", "hass", ".", "async_add_executor_job", "(", "self", ".", "set_fan_mode", ",", "fan_mode", ")" ]
[ 419, 4 ]
[ 421, 75 ]
python
en
['sv', 'fy', 'en']
False
ClimateEntity.set_hvac_mode
(self, hvac_mode: str)
Set new target hvac mode.
Set new target hvac mode.
def set_hvac_mode(self, hvac_mode: str) -> None: """Set new target hvac mode.""" raise NotImplementedError()
[ "def", "set_hvac_mode", "(", "self", ",", "hvac_mode", ":", "str", ")", "->", "None", ":", "raise", "NotImplementedError", "(", ")" ]
[ 423, 4 ]
[ 425, 35 ]
python
da
['da', 'su', 'en']
False
ClimateEntity.async_set_hvac_mode
(self, hvac_mode: str)
Set new target hvac mode.
Set new target hvac mode.
async def async_set_hvac_mode(self, hvac_mode: str) -> None: """Set new target hvac mode.""" await self.hass.async_add_executor_job(self.set_hvac_mode, hvac_mode)
[ "async", "def", "async_set_hvac_mode", "(", "self", ",", "hvac_mode", ":", "str", ")", "->", "None", ":", "await", "self", ".", "hass", ".", "async_add_executor_job", "(", "self", ".", "set_hvac_mode", ",", "hvac_mode", ")" ]
[ 427, 4 ]
[ 429, 77 ]
python
da
['da', 'su', 'en']
False
ClimateEntity.set_swing_mode
(self, swing_mode: str)
Set new target swing operation.
Set new target swing operation.
def set_swing_mode(self, swing_mode: str) -> None: """Set new target swing operation.""" raise NotImplementedError()
[ "def", "set_swing_mode", "(", "self", ",", "swing_mode", ":", "str", ")", "->", "None", ":", "raise", "NotImplementedError", "(", ")" ]
[ 431, 4 ]
[ 433, 35 ]
python
en
['en', 'en', 'en']
True
ClimateEntity.async_set_swing_mode
(self, swing_mode: str)
Set new target swing operation.
Set new target swing operation.
async def async_set_swing_mode(self, swing_mode: str) -> None: """Set new target swing operation.""" await self.hass.async_add_executor_job(self.set_swing_mode, swing_mode)
[ "async", "def", "async_set_swing_mode", "(", "self", ",", "swing_mode", ":", "str", ")", "->", "None", ":", "await", "self", ".", "hass", ".", "async_add_executor_job", "(", "self", ".", "set_swing_mode", ",", "swing_mode", ")" ]
[ 435, 4 ]
[ 437, 79 ]
python
en
['en', 'en', 'en']
True
ClimateEntity.set_preset_mode
(self, preset_mode: str)
Set new preset mode.
Set new preset mode.
def set_preset_mode(self, preset_mode: str) -> None: """Set new preset mode.""" raise NotImplementedError()
[ "def", "set_preset_mode", "(", "self", ",", "preset_mode", ":", "str", ")", "->", "None", ":", "raise", "NotImplementedError", "(", ")" ]
[ 439, 4 ]
[ 441, 35 ]
python
en
['en', 'sr', 'en']
True
ClimateEntity.async_set_preset_mode
(self, preset_mode: str)
Set new preset mode.
Set new preset mode.
async def async_set_preset_mode(self, preset_mode: str) -> None: """Set new preset mode.""" await self.hass.async_add_executor_job(self.set_preset_mode, preset_mode)
[ "async", "def", "async_set_preset_mode", "(", "self", ",", "preset_mode", ":", "str", ")", "->", "None", ":", "await", "self", ".", "hass", ".", "async_add_executor_job", "(", "self", ".", "set_preset_mode", ",", "preset_mode", ")" ]
[ 443, 4 ]
[ 445, 81 ]
python
en
['en', 'sr', 'en']
True
ClimateEntity.turn_aux_heat_on
(self)
Turn auxiliary heater on.
Turn auxiliary heater on.
def turn_aux_heat_on(self) -> None: """Turn auxiliary heater on.""" raise NotImplementedError()
[ "def", "turn_aux_heat_on", "(", "self", ")", "->", "None", ":", "raise", "NotImplementedError", "(", ")" ]
[ 447, 4 ]
[ 449, 35 ]
python
en
['fr', 'fi', 'en']
False
ClimateEntity.async_turn_aux_heat_on
(self)
Turn auxiliary heater on.
Turn auxiliary heater on.
async def async_turn_aux_heat_on(self) -> None: """Turn auxiliary heater on.""" await self.hass.async_add_executor_job(self.turn_aux_heat_on)
[ "async", "def", "async_turn_aux_heat_on", "(", "self", ")", "->", "None", ":", "await", "self", ".", "hass", ".", "async_add_executor_job", "(", "self", ".", "turn_aux_heat_on", ")" ]
[ 451, 4 ]
[ 453, 69 ]
python
en
['fr', 'fi', 'en']
False
ClimateEntity.turn_aux_heat_off
(self)
Turn auxiliary heater off.
Turn auxiliary heater off.
def turn_aux_heat_off(self) -> None: """Turn auxiliary heater off.""" raise NotImplementedError()
[ "def", "turn_aux_heat_off", "(", "self", ")", "->", "None", ":", "raise", "NotImplementedError", "(", ")" ]
[ 455, 4 ]
[ 457, 35 ]
python
en
['en', 'en', 'en']
True
ClimateEntity.async_turn_aux_heat_off
(self)
Turn auxiliary heater off.
Turn auxiliary heater off.
async def async_turn_aux_heat_off(self) -> None: """Turn auxiliary heater off.""" await self.hass.async_add_executor_job(self.turn_aux_heat_off)
[ "async", "def", "async_turn_aux_heat_off", "(", "self", ")", "->", "None", ":", "await", "self", ".", "hass", ".", "async_add_executor_job", "(", "self", ".", "turn_aux_heat_off", ")" ]
[ 459, 4 ]
[ 461, 70 ]
python
en
['en', 'en', 'en']
True
ClimateEntity.async_turn_on
(self)
Turn the entity on.
Turn the entity on.
async def async_turn_on(self) -> None: """Turn the entity on.""" if hasattr(self, "turn_on"): # pylint: disable=no-member await self.hass.async_add_executor_job(self.turn_on) return # Fake turn on for mode in (HVAC_MODE_HEAT_COOL, HVAC_MODE_HEAT, HVAC_MODE_COOL): if mode not in self.hvac_modes: continue await self.async_set_hvac_mode(mode) break
[ "async", "def", "async_turn_on", "(", "self", ")", "->", "None", ":", "if", "hasattr", "(", "self", ",", "\"turn_on\"", ")", ":", "# pylint: disable=no-member", "await", "self", ".", "hass", ".", "async_add_executor_job", "(", "self", ".", "turn_on", ")", "return", "# Fake turn on", "for", "mode", "in", "(", "HVAC_MODE_HEAT_COOL", ",", "HVAC_MODE_HEAT", ",", "HVAC_MODE_COOL", ")", ":", "if", "mode", "not", "in", "self", ".", "hvac_modes", ":", "continue", "await", "self", ".", "async_set_hvac_mode", "(", "mode", ")", "break" ]
[ 463, 4 ]
[ 475, 17 ]
python
en
['en', 'en', 'en']
True
ClimateEntity.async_turn_off
(self)
Turn the entity off.
Turn the entity off.
async def async_turn_off(self) -> None: """Turn the entity off.""" if hasattr(self, "turn_off"): # pylint: disable=no-member await self.hass.async_add_executor_job(self.turn_off) return # Fake turn off if HVAC_MODE_OFF in self.hvac_modes: await self.async_set_hvac_mode(HVAC_MODE_OFF)
[ "async", "def", "async_turn_off", "(", "self", ")", "->", "None", ":", "if", "hasattr", "(", "self", ",", "\"turn_off\"", ")", ":", "# pylint: disable=no-member", "await", "self", ".", "hass", ".", "async_add_executor_job", "(", "self", ".", "turn_off", ")", "return", "# Fake turn off", "if", "HVAC_MODE_OFF", "in", "self", ".", "hvac_modes", ":", "await", "self", ".", "async_set_hvac_mode", "(", "HVAC_MODE_OFF", ")" ]
[ 477, 4 ]
[ 486, 57 ]
python
en
['en', 'en', 'en']
True
ClimateEntity.supported_features
(self)
Return the list of supported features.
Return the list of supported features.
def supported_features(self) -> int: """Return the list of supported features.""" raise NotImplementedError()
[ "def", "supported_features", "(", "self", ")", "->", "int", ":", "raise", "NotImplementedError", "(", ")" ]
[ 489, 4 ]
[ 491, 35 ]
python
en
['en', 'en', 'en']
True
ClimateEntity.min_temp
(self)
Return the minimum temperature.
Return the minimum temperature.
def min_temp(self) -> float: """Return the minimum temperature.""" return convert_temperature( DEFAULT_MIN_TEMP, TEMP_CELSIUS, self.temperature_unit )
[ "def", "min_temp", "(", "self", ")", "->", "float", ":", "return", "convert_temperature", "(", "DEFAULT_MIN_TEMP", ",", "TEMP_CELSIUS", ",", "self", ".", "temperature_unit", ")" ]
[ 494, 4 ]
[ 498, 9 ]
python
en
['en', 'la', 'en']
True
ClimateEntity.max_temp
(self)
Return the maximum temperature.
Return the maximum temperature.
def max_temp(self) -> float: """Return the maximum temperature.""" return convert_temperature( DEFAULT_MAX_TEMP, TEMP_CELSIUS, self.temperature_unit )
[ "def", "max_temp", "(", "self", ")", "->", "float", ":", "return", "convert_temperature", "(", "DEFAULT_MAX_TEMP", ",", "TEMP_CELSIUS", ",", "self", ".", "temperature_unit", ")" ]
[ 501, 4 ]
[ 505, 9 ]
python
en
['en', 'la', 'en']
True
ClimateEntity.min_humidity
(self)
Return the minimum humidity.
Return the minimum humidity.
def min_humidity(self) -> int: """Return the minimum humidity.""" return DEFAULT_MIN_HUMIDITY
[ "def", "min_humidity", "(", "self", ")", "->", "int", ":", "return", "DEFAULT_MIN_HUMIDITY" ]
[ 508, 4 ]
[ 510, 35 ]
python
en
['en', 'et', 'en']
True
ClimateEntity.max_humidity
(self)
Return the maximum humidity.
Return the maximum humidity.
def max_humidity(self) -> int: """Return the maximum humidity.""" return DEFAULT_MAX_HUMIDITY
[ "def", "max_humidity", "(", "self", ")", "->", "int", ":", "return", "DEFAULT_MAX_HUMIDITY" ]
[ 513, 4 ]
[ 515, 35 ]
python
en
['en', 'la', 'en']
True
ClimateDevice.__init_subclass__
(cls, **kwargs)
Print deprecation warning.
Print deprecation warning.
def __init_subclass__(cls, **kwargs): """Print deprecation warning.""" super().__init_subclass__(**kwargs) _LOGGER.warning( "ClimateDevice is deprecated, modify %s to extend ClimateEntity", cls.__name__, )
[ "def", "__init_subclass__", "(", "cls", ",", "*", "*", "kwargs", ")", ":", "super", "(", ")", ".", "__init_subclass__", "(", "*", "*", "kwargs", ")", "_LOGGER", ".", "warning", "(", "\"ClimateDevice is deprecated, modify %s to extend ClimateEntity\"", ",", "cls", ".", "__name__", ",", ")" ]
[ 549, 4 ]
[ 555, 9 ]
python
de
['de', 'sv', 'en']
False
async_setup
(hass, config)
Set up the Plex component.
Set up the Plex component.
async def async_setup(hass, config): """Set up the Plex component.""" hass.data.setdefault( PLEX_DOMAIN, {SERVERS: {}, DISPATCHERS: {}, WEBSOCKETS: {}, PLATFORMS_COMPLETED: {}}, ) await async_setup_services(hass) gdm = hass.data[PLEX_DOMAIN][GDM_SCANNER] = GDM() hass.data[PLEX_DOMAIN][GDM_DEBOUNCER] = Debouncer( hass, _LOGGER, cooldown=10, immediate=True, function=partial(gdm.scan, scan_for_clients=True), ).async_call return True
[ "async", "def", "async_setup", "(", "hass", ",", "config", ")", ":", "hass", ".", "data", ".", "setdefault", "(", "PLEX_DOMAIN", ",", "{", "SERVERS", ":", "{", "}", ",", "DISPATCHERS", ":", "{", "}", ",", "WEBSOCKETS", ":", "{", "}", ",", "PLATFORMS_COMPLETED", ":", "{", "}", "}", ",", ")", "await", "async_setup_services", "(", "hass", ")", "gdm", "=", "hass", ".", "data", "[", "PLEX_DOMAIN", "]", "[", "GDM_SCANNER", "]", "=", "GDM", "(", ")", "hass", ".", "data", "[", "PLEX_DOMAIN", "]", "[", "GDM_DEBOUNCER", "]", "=", "Debouncer", "(", "hass", ",", "_LOGGER", ",", "cooldown", "=", "10", ",", "immediate", "=", "True", ",", "function", "=", "partial", "(", "gdm", ".", "scan", ",", "scan_for_clients", "=", "True", ")", ",", ")", ".", "async_call", "return", "True" ]
[ 64, 0 ]
[ 83, 15 ]
python
en
['en', 'fr', 'en']
True
async_setup_entry
(hass, entry)
Set up Plex from a config entry.
Set up Plex from a config entry.
async def async_setup_entry(hass, entry): """Set up Plex from a config entry.""" server_config = entry.data[PLEX_SERVER_CONFIG] if entry.unique_id is None: hass.config_entries.async_update_entry( entry, unique_id=entry.data[CONF_SERVER_IDENTIFIER] ) if MP_DOMAIN not in entry.options: options = dict(entry.options) options.setdefault(MP_DOMAIN, {}) hass.config_entries.async_update_entry(entry, options=options) plex_server = PlexServer( hass, server_config, entry.data[CONF_SERVER_IDENTIFIER], entry.options, entry.entry_id, ) try: await hass.async_add_executor_job(plex_server.connect) except ShouldUpdateConfigEntry: new_server_data = { **entry.data[PLEX_SERVER_CONFIG], CONF_URL: plex_server.url_in_use, CONF_SERVER: plex_server.friendly_name, } hass.config_entries.async_update_entry( entry, data={**entry.data, PLEX_SERVER_CONFIG: new_server_data} ) except requests.exceptions.ConnectionError as error: if entry.state != ENTRY_STATE_SETUP_RETRY: _LOGGER.error( "Plex server (%s) could not be reached: [%s]", server_config[CONF_URL], error, ) raise ConfigEntryNotReady from error except plexapi.exceptions.Unauthorized: hass.async_create_task( hass.config_entries.flow.async_init( PLEX_DOMAIN, context={CONF_SOURCE: SOURCE_REAUTH}, data=entry.data, ) ) _LOGGER.error( "Token not accepted, please reauthenticate Plex server '%s'", entry.data[CONF_SERVER], ) return False except ( plexapi.exceptions.BadRequest, plexapi.exceptions.NotFound, ) as error: _LOGGER.error( "Login to %s failed, verify token and SSL settings: [%s]", entry.data[CONF_SERVER], error, ) return False _LOGGER.debug( "Connected to: %s (%s)", plex_server.friendly_name, plex_server.url_in_use ) server_id = plex_server.machine_identifier hass.data[PLEX_DOMAIN][SERVERS][server_id] = plex_server hass.data[PLEX_DOMAIN][PLATFORMS_COMPLETED][server_id] = set() entry.add_update_listener(async_options_updated) async def async_update_plex(): await hass.data[PLEX_DOMAIN][GDM_DEBOUNCER]() await plex_server.async_update_platforms() unsub = async_dispatcher_connect( hass, PLEX_UPDATE_PLATFORMS_SIGNAL.format(server_id), async_update_plex, ) hass.data[PLEX_DOMAIN][DISPATCHERS].setdefault(server_id, []) hass.data[PLEX_DOMAIN][DISPATCHERS][server_id].append(unsub) @callback def plex_websocket_callback(signal, data, error): """Handle callbacks from plexwebsocket library.""" if signal == SIGNAL_CONNECTION_STATE: if data == STATE_CONNECTED: _LOGGER.debug("Websocket to %s successful", entry.data[CONF_SERVER]) elif data == STATE_DISCONNECTED: _LOGGER.debug( "Websocket to %s disconnected, retrying", entry.data[CONF_SERVER] ) # Stopped websockets without errors are expected during shutdown and ignored elif data == STATE_STOPPED and error: _LOGGER.error( "Websocket to %s failed, aborting [Error: %s]", entry.data[CONF_SERVER], error, ) hass.async_create_task(hass.config_entries.async_reload(entry.entry_id)) elif signal == SIGNAL_DATA: async_dispatcher_send(hass, PLEX_UPDATE_PLATFORMS_SIGNAL.format(server_id)) session = async_get_clientsession(hass) verify_ssl = server_config.get(CONF_VERIFY_SSL) websocket = PlexWebsocket( plex_server.plex_server, plex_websocket_callback, session=session, verify_ssl=verify_ssl, ) hass.data[PLEX_DOMAIN][WEBSOCKETS][server_id] = websocket def start_websocket_session(platform, _): hass.data[PLEX_DOMAIN][PLATFORMS_COMPLETED][server_id].add(platform) if hass.data[PLEX_DOMAIN][PLATFORMS_COMPLETED][server_id] == PLATFORMS: hass.loop.create_task(websocket.listen()) def close_websocket_session(_): websocket.close() unsub = hass.bus.async_listen_once( EVENT_HOMEASSISTANT_STOP, close_websocket_session ) hass.data[PLEX_DOMAIN][DISPATCHERS][server_id].append(unsub) for platform in PLATFORMS: task = hass.async_create_task( hass.config_entries.async_forward_entry_setup(entry, platform) ) task.add_done_callback(functools.partial(start_websocket_session, platform)) async def async_play_on_sonos_service(service_call): await hass.async_add_executor_job(play_on_sonos, hass, service_call) play_on_sonos_schema = vol.Schema( { vol.Required(ATTR_ENTITY_ID): cv.entity_id, vol.Required(ATTR_MEDIA_CONTENT_ID): str, vol.Optional(ATTR_MEDIA_CONTENT_TYPE): vol.In("music"), } ) def get_plex_account(plex_server): try: return plex_server.account except (plexapi.exceptions.BadRequest, plexapi.exceptions.Unauthorized): return None plex_account = await hass.async_add_executor_job(get_plex_account, plex_server) if plex_account: hass.services.async_register( PLEX_DOMAIN, SERVICE_PLAY_ON_SONOS, async_play_on_sonos_service, schema=play_on_sonos_schema, ) return True
[ "async", "def", "async_setup_entry", "(", "hass", ",", "entry", ")", ":", "server_config", "=", "entry", ".", "data", "[", "PLEX_SERVER_CONFIG", "]", "if", "entry", ".", "unique_id", "is", "None", ":", "hass", ".", "config_entries", ".", "async_update_entry", "(", "entry", ",", "unique_id", "=", "entry", ".", "data", "[", "CONF_SERVER_IDENTIFIER", "]", ")", "if", "MP_DOMAIN", "not", "in", "entry", ".", "options", ":", "options", "=", "dict", "(", "entry", ".", "options", ")", "options", ".", "setdefault", "(", "MP_DOMAIN", ",", "{", "}", ")", "hass", ".", "config_entries", ".", "async_update_entry", "(", "entry", ",", "options", "=", "options", ")", "plex_server", "=", "PlexServer", "(", "hass", ",", "server_config", ",", "entry", ".", "data", "[", "CONF_SERVER_IDENTIFIER", "]", ",", "entry", ".", "options", ",", "entry", ".", "entry_id", ",", ")", "try", ":", "await", "hass", ".", "async_add_executor_job", "(", "plex_server", ".", "connect", ")", "except", "ShouldUpdateConfigEntry", ":", "new_server_data", "=", "{", "*", "*", "entry", ".", "data", "[", "PLEX_SERVER_CONFIG", "]", ",", "CONF_URL", ":", "plex_server", ".", "url_in_use", ",", "CONF_SERVER", ":", "plex_server", ".", "friendly_name", ",", "}", "hass", ".", "config_entries", ".", "async_update_entry", "(", "entry", ",", "data", "=", "{", "*", "*", "entry", ".", "data", ",", "PLEX_SERVER_CONFIG", ":", "new_server_data", "}", ")", "except", "requests", ".", "exceptions", ".", "ConnectionError", "as", "error", ":", "if", "entry", ".", "state", "!=", "ENTRY_STATE_SETUP_RETRY", ":", "_LOGGER", ".", "error", "(", "\"Plex server (%s) could not be reached: [%s]\"", ",", "server_config", "[", "CONF_URL", "]", ",", "error", ",", ")", "raise", "ConfigEntryNotReady", "from", "error", "except", "plexapi", ".", "exceptions", ".", "Unauthorized", ":", "hass", ".", "async_create_task", "(", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "PLEX_DOMAIN", ",", "context", "=", "{", "CONF_SOURCE", ":", "SOURCE_REAUTH", "}", ",", "data", "=", "entry", ".", "data", ",", ")", ")", "_LOGGER", ".", "error", "(", "\"Token not accepted, please reauthenticate Plex server '%s'\"", ",", "entry", ".", "data", "[", "CONF_SERVER", "]", ",", ")", "return", "False", "except", "(", "plexapi", ".", "exceptions", ".", "BadRequest", ",", "plexapi", ".", "exceptions", ".", "NotFound", ",", ")", "as", "error", ":", "_LOGGER", ".", "error", "(", "\"Login to %s failed, verify token and SSL settings: [%s]\"", ",", "entry", ".", "data", "[", "CONF_SERVER", "]", ",", "error", ",", ")", "return", "False", "_LOGGER", ".", "debug", "(", "\"Connected to: %s (%s)\"", ",", "plex_server", ".", "friendly_name", ",", "plex_server", ".", "url_in_use", ")", "server_id", "=", "plex_server", ".", "machine_identifier", "hass", ".", "data", "[", "PLEX_DOMAIN", "]", "[", "SERVERS", "]", "[", "server_id", "]", "=", "plex_server", "hass", ".", "data", "[", "PLEX_DOMAIN", "]", "[", "PLATFORMS_COMPLETED", "]", "[", "server_id", "]", "=", "set", "(", ")", "entry", ".", "add_update_listener", "(", "async_options_updated", ")", "async", "def", "async_update_plex", "(", ")", ":", "await", "hass", ".", "data", "[", "PLEX_DOMAIN", "]", "[", "GDM_DEBOUNCER", "]", "(", ")", "await", "plex_server", ".", "async_update_platforms", "(", ")", "unsub", "=", "async_dispatcher_connect", "(", "hass", ",", "PLEX_UPDATE_PLATFORMS_SIGNAL", ".", "format", "(", "server_id", ")", ",", "async_update_plex", ",", ")", "hass", ".", "data", "[", "PLEX_DOMAIN", "]", "[", "DISPATCHERS", "]", ".", "setdefault", "(", "server_id", ",", "[", "]", ")", "hass", ".", "data", "[", "PLEX_DOMAIN", "]", "[", "DISPATCHERS", "]", "[", "server_id", "]", ".", "append", "(", "unsub", ")", "@", "callback", "def", "plex_websocket_callback", "(", "signal", ",", "data", ",", "error", ")", ":", "\"\"\"Handle callbacks from plexwebsocket library.\"\"\"", "if", "signal", "==", "SIGNAL_CONNECTION_STATE", ":", "if", "data", "==", "STATE_CONNECTED", ":", "_LOGGER", ".", "debug", "(", "\"Websocket to %s successful\"", ",", "entry", ".", "data", "[", "CONF_SERVER", "]", ")", "elif", "data", "==", "STATE_DISCONNECTED", ":", "_LOGGER", ".", "debug", "(", "\"Websocket to %s disconnected, retrying\"", ",", "entry", ".", "data", "[", "CONF_SERVER", "]", ")", "# Stopped websockets without errors are expected during shutdown and ignored", "elif", "data", "==", "STATE_STOPPED", "and", "error", ":", "_LOGGER", ".", "error", "(", "\"Websocket to %s failed, aborting [Error: %s]\"", ",", "entry", ".", "data", "[", "CONF_SERVER", "]", ",", "error", ",", ")", "hass", ".", "async_create_task", "(", "hass", ".", "config_entries", ".", "async_reload", "(", "entry", ".", "entry_id", ")", ")", "elif", "signal", "==", "SIGNAL_DATA", ":", "async_dispatcher_send", "(", "hass", ",", "PLEX_UPDATE_PLATFORMS_SIGNAL", ".", "format", "(", "server_id", ")", ")", "session", "=", "async_get_clientsession", "(", "hass", ")", "verify_ssl", "=", "server_config", ".", "get", "(", "CONF_VERIFY_SSL", ")", "websocket", "=", "PlexWebsocket", "(", "plex_server", ".", "plex_server", ",", "plex_websocket_callback", ",", "session", "=", "session", ",", "verify_ssl", "=", "verify_ssl", ",", ")", "hass", ".", "data", "[", "PLEX_DOMAIN", "]", "[", "WEBSOCKETS", "]", "[", "server_id", "]", "=", "websocket", "def", "start_websocket_session", "(", "platform", ",", "_", ")", ":", "hass", ".", "data", "[", "PLEX_DOMAIN", "]", "[", "PLATFORMS_COMPLETED", "]", "[", "server_id", "]", ".", "add", "(", "platform", ")", "if", "hass", ".", "data", "[", "PLEX_DOMAIN", "]", "[", "PLATFORMS_COMPLETED", "]", "[", "server_id", "]", "==", "PLATFORMS", ":", "hass", ".", "loop", ".", "create_task", "(", "websocket", ".", "listen", "(", ")", ")", "def", "close_websocket_session", "(", "_", ")", ":", "websocket", ".", "close", "(", ")", "unsub", "=", "hass", ".", "bus", ".", "async_listen_once", "(", "EVENT_HOMEASSISTANT_STOP", ",", "close_websocket_session", ")", "hass", ".", "data", "[", "PLEX_DOMAIN", "]", "[", "DISPATCHERS", "]", "[", "server_id", "]", ".", "append", "(", "unsub", ")", "for", "platform", "in", "PLATFORMS", ":", "task", "=", "hass", ".", "async_create_task", "(", "hass", ".", "config_entries", ".", "async_forward_entry_setup", "(", "entry", ",", "platform", ")", ")", "task", ".", "add_done_callback", "(", "functools", ".", "partial", "(", "start_websocket_session", ",", "platform", ")", ")", "async", "def", "async_play_on_sonos_service", "(", "service_call", ")", ":", "await", "hass", ".", "async_add_executor_job", "(", "play_on_sonos", ",", "hass", ",", "service_call", ")", "play_on_sonos_schema", "=", "vol", ".", "Schema", "(", "{", "vol", ".", "Required", "(", "ATTR_ENTITY_ID", ")", ":", "cv", ".", "entity_id", ",", "vol", ".", "Required", "(", "ATTR_MEDIA_CONTENT_ID", ")", ":", "str", ",", "vol", ".", "Optional", "(", "ATTR_MEDIA_CONTENT_TYPE", ")", ":", "vol", ".", "In", "(", "\"music\"", ")", ",", "}", ")", "def", "get_plex_account", "(", "plex_server", ")", ":", "try", ":", "return", "plex_server", ".", "account", "except", "(", "plexapi", ".", "exceptions", ".", "BadRequest", ",", "plexapi", ".", "exceptions", ".", "Unauthorized", ")", ":", "return", "None", "plex_account", "=", "await", "hass", ".", "async_add_executor_job", "(", "get_plex_account", ",", "plex_server", ")", "if", "plex_account", ":", "hass", ".", "services", ".", "async_register", "(", "PLEX_DOMAIN", ",", "SERVICE_PLAY_ON_SONOS", ",", "async_play_on_sonos_service", ",", "schema", "=", "play_on_sonos_schema", ",", ")", "return", "True" ]
[ 86, 0 ]
[ 249, 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.""" server_id = entry.data[CONF_SERVER_IDENTIFIER] websocket = hass.data[PLEX_DOMAIN][WEBSOCKETS].pop(server_id) websocket.close() dispatchers = hass.data[PLEX_DOMAIN][DISPATCHERS].pop(server_id) for unsub in dispatchers: unsub() tasks = [ hass.config_entries.async_forward_entry_unload(entry, platform) for platform in PLATFORMS ] await asyncio.gather(*tasks) hass.data[PLEX_DOMAIN][SERVERS].pop(server_id) return True
[ "async", "def", "async_unload_entry", "(", "hass", ",", "entry", ")", ":", "server_id", "=", "entry", ".", "data", "[", "CONF_SERVER_IDENTIFIER", "]", "websocket", "=", "hass", ".", "data", "[", "PLEX_DOMAIN", "]", "[", "WEBSOCKETS", "]", ".", "pop", "(", "server_id", ")", "websocket", ".", "close", "(", ")", "dispatchers", "=", "hass", ".", "data", "[", "PLEX_DOMAIN", "]", "[", "DISPATCHERS", "]", ".", "pop", "(", "server_id", ")", "for", "unsub", "in", "dispatchers", ":", "unsub", "(", ")", "tasks", "=", "[", "hass", ".", "config_entries", ".", "async_forward_entry_unload", "(", "entry", ",", "platform", ")", "for", "platform", "in", "PLATFORMS", "]", "await", "asyncio", ".", "gather", "(", "*", "tasks", ")", "hass", ".", "data", "[", "PLEX_DOMAIN", "]", "[", "SERVERS", "]", ".", "pop", "(", "server_id", ")", "return", "True" ]
[ 252, 0 ]
[ 271, 15 ]
python
en
['en', 'es', 'en']
True
async_options_updated
(hass, entry)
Triggered by config entry options updates.
Triggered by config entry options updates.
async def async_options_updated(hass, entry): """Triggered by config entry options updates.""" server_id = entry.data[CONF_SERVER_IDENTIFIER] # Guard incomplete setup during reauth flows if server_id in hass.data[PLEX_DOMAIN][SERVERS]: hass.data[PLEX_DOMAIN][SERVERS][server_id].options = entry.options
[ "async", "def", "async_options_updated", "(", "hass", ",", "entry", ")", ":", "server_id", "=", "entry", ".", "data", "[", "CONF_SERVER_IDENTIFIER", "]", "# Guard incomplete setup during reauth flows", "if", "server_id", "in", "hass", ".", "data", "[", "PLEX_DOMAIN", "]", "[", "SERVERS", "]", ":", "hass", ".", "data", "[", "PLEX_DOMAIN", "]", "[", "SERVERS", "]", "[", "server_id", "]", ".", "options", "=", "entry", ".", "options" ]
[ 274, 0 ]
[ 280, 74 ]
python
en
['en', 'en', 'en']
True
play_on_sonos
(hass, service_call)
Play Plex media on a linked Sonos device.
Play Plex media on a linked Sonos device.
def play_on_sonos(hass, service_call): """Play Plex media on a linked Sonos device.""" entity_id = service_call.data[ATTR_ENTITY_ID] content_id = service_call.data[ATTR_MEDIA_CONTENT_ID] content_type = service_call.data.get(ATTR_MEDIA_CONTENT_TYPE) sonos = hass.components.sonos try: sonos_name = sonos.get_coordinator_name(entity_id) except HomeAssistantError as err: _LOGGER.error("Cannot get Sonos device: %s", err) return media, plex_server = lookup_plex_media(hass, content_type, content_id) if media is None: return sonos_speaker = plex_server.account.sonos_speaker(sonos_name) if sonos_speaker is None: _LOGGER.error( "Sonos speaker '%s' could not be found on this Plex account", sonos_name ) return sonos_speaker.playMedia(media)
[ "def", "play_on_sonos", "(", "hass", ",", "service_call", ")", ":", "entity_id", "=", "service_call", ".", "data", "[", "ATTR_ENTITY_ID", "]", "content_id", "=", "service_call", ".", "data", "[", "ATTR_MEDIA_CONTENT_ID", "]", "content_type", "=", "service_call", ".", "data", ".", "get", "(", "ATTR_MEDIA_CONTENT_TYPE", ")", "sonos", "=", "hass", ".", "components", ".", "sonos", "try", ":", "sonos_name", "=", "sonos", ".", "get_coordinator_name", "(", "entity_id", ")", "except", "HomeAssistantError", "as", "err", ":", "_LOGGER", ".", "error", "(", "\"Cannot get Sonos device: %s\"", ",", "err", ")", "return", "media", ",", "plex_server", "=", "lookup_plex_media", "(", "hass", ",", "content_type", ",", "content_id", ")", "if", "media", "is", "None", ":", "return", "sonos_speaker", "=", "plex_server", ".", "account", ".", "sonos_speaker", "(", "sonos_name", ")", "if", "sonos_speaker", "is", "None", ":", "_LOGGER", ".", "error", "(", "\"Sonos speaker '%s' could not be found on this Plex account\"", ",", "sonos_name", ")", "return", "sonos_speaker", ".", "playMedia", "(", "media", ")" ]
[ 283, 0 ]
[ 307, 34 ]
python
en
['es', 'sk', 'en']
False
setup_comp
(hass, mqtt_mock)
Set up mqtt component.
Set up mqtt component.
def setup_comp(hass, mqtt_mock): """Set up mqtt component.""" pass
[ "def", "setup_comp", "(", "hass", ",", "mqtt_mock", ")", ":", "pass" ]
[ 12, 0 ]
[ 14, 8 ]
python
en
['en', 'lb', 'it']
False
test_ensure_device_tracker_platform_validation
(hass)
Test if platform validation was done.
Test if platform validation was done.
async def test_ensure_device_tracker_platform_validation(hass): """Test if platform validation was done.""" async def mock_setup_scanner(hass, config, see, discovery_info=None): """Check that Qos was added by validation.""" assert "qos" in config with patch( "homeassistant.components.mqtt.device_tracker.async_setup_scanner", autospec=True, side_effect=mock_setup_scanner, ) as mock_sp: dev_id = "paulus" topic = "/location/paulus" assert await async_setup_component( hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "mqtt", "devices": {dev_id: topic}}} ) assert mock_sp.call_count == 1
[ "async", "def", "test_ensure_device_tracker_platform_validation", "(", "hass", ")", ":", "async", "def", "mock_setup_scanner", "(", "hass", ",", "config", ",", "see", ",", "discovery_info", "=", "None", ")", ":", "\"\"\"Check that Qos was added by validation.\"\"\"", "assert", "\"qos\"", "in", "config", "with", "patch", "(", "\"homeassistant.components.mqtt.device_tracker.async_setup_scanner\"", ",", "autospec", "=", "True", ",", "side_effect", "=", "mock_setup_scanner", ",", ")", "as", "mock_sp", ":", "dev_id", "=", "\"paulus\"", "topic", "=", "\"/location/paulus\"", "assert", "await", "async_setup_component", "(", "hass", ",", "DOMAIN", ",", "{", "DOMAIN", ":", "{", "CONF_PLATFORM", ":", "\"mqtt\"", ",", "\"devices\"", ":", "{", "dev_id", ":", "topic", "}", "}", "}", ")", "assert", "mock_sp", ".", "call_count", "==", "1" ]
[ 17, 0 ]
[ 35, 38 ]
python
en
['en', 'de', 'en']
True
test_new_message
(hass, mock_device_tracker_conf)
Test new message.
Test new message.
async def test_new_message(hass, mock_device_tracker_conf): """Test new message.""" dev_id = "paulus" entity_id = f"{DOMAIN}.{dev_id}" topic = "/location/paulus" location = "work" hass.config.components = {"mqtt", "zone"} assert await async_setup_component( hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "mqtt", "devices": {dev_id: topic}}} ) async_fire_mqtt_message(hass, topic, location) await hass.async_block_till_done() assert hass.states.get(entity_id).state == location
[ "async", "def", "test_new_message", "(", "hass", ",", "mock_device_tracker_conf", ")", ":", "dev_id", "=", "\"paulus\"", "entity_id", "=", "f\"{DOMAIN}.{dev_id}\"", "topic", "=", "\"/location/paulus\"", "location", "=", "\"work\"", "hass", ".", "config", ".", "components", "=", "{", "\"mqtt\"", ",", "\"zone\"", "}", "assert", "await", "async_setup_component", "(", "hass", ",", "DOMAIN", ",", "{", "DOMAIN", ":", "{", "CONF_PLATFORM", ":", "\"mqtt\"", ",", "\"devices\"", ":", "{", "dev_id", ":", "topic", "}", "}", "}", ")", "async_fire_mqtt_message", "(", "hass", ",", "topic", ",", "location", ")", "await", "hass", ".", "async_block_till_done", "(", ")", "assert", "hass", ".", "states", ".", "get", "(", "entity_id", ")", ".", "state", "==", "location" ]
[ 38, 0 ]
[ 51, 55 ]
python
en
['en', 'en', 'en']
True
test_single_level_wildcard_topic
(hass, mock_device_tracker_conf)
Test single level wildcard topic.
Test single level wildcard topic.
async def test_single_level_wildcard_topic(hass, mock_device_tracker_conf): """Test single level wildcard topic.""" dev_id = "paulus" entity_id = f"{DOMAIN}.{dev_id}" subscription = "/location/+/paulus" topic = "/location/room/paulus" location = "work" hass.config.components = {"mqtt", "zone"} assert await async_setup_component( hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "mqtt", "devices": {dev_id: subscription}}}, ) async_fire_mqtt_message(hass, topic, location) await hass.async_block_till_done() assert hass.states.get(entity_id).state == location
[ "async", "def", "test_single_level_wildcard_topic", "(", "hass", ",", "mock_device_tracker_conf", ")", ":", "dev_id", "=", "\"paulus\"", "entity_id", "=", "f\"{DOMAIN}.{dev_id}\"", "subscription", "=", "\"/location/+/paulus\"", "topic", "=", "\"/location/room/paulus\"", "location", "=", "\"work\"", "hass", ".", "config", ".", "components", "=", "{", "\"mqtt\"", ",", "\"zone\"", "}", "assert", "await", "async_setup_component", "(", "hass", ",", "DOMAIN", ",", "{", "DOMAIN", ":", "{", "CONF_PLATFORM", ":", "\"mqtt\"", ",", "\"devices\"", ":", "{", "dev_id", ":", "subscription", "}", "}", "}", ",", ")", "async_fire_mqtt_message", "(", "hass", ",", "topic", ",", "location", ")", "await", "hass", ".", "async_block_till_done", "(", ")", "assert", "hass", ".", "states", ".", "get", "(", "entity_id", ")", ".", "state", "==", "location" ]
[ 54, 0 ]
[ 70, 55 ]
python
en
['en', 'en', 'en']
True