Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
list
start_point
list
end_point
list
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
GoogleCalendarEventDevice.update
(self)
Update event data.
Update event data.
def update(self): """Update event data.""" self.data.update() event = copy.deepcopy(self.data.event) if event is None: self._event = event return event = calculate_offset(event, self._offset) self._offset_reached = is_offset_reached(event) ...
[ "def", "update", "(", "self", ")", ":", "self", ".", "data", ".", "update", "(", ")", "event", "=", "copy", ".", "deepcopy", "(", "self", ".", "data", ".", "event", ")", "if", "event", "is", "None", ":", "self", ".", "_event", "=", "event", "retu...
[ 103, 4 ]
[ 112, 27 ]
python
co
['fr', 'co', 'en']
False
GoogleCalendarData.__init__
( self, calendar_service, calendar_id, search, ignore_availability, max_results )
Set up how we are going to search the google calendar.
Set up how we are going to search the google calendar.
def __init__( self, calendar_service, calendar_id, search, ignore_availability, max_results ): """Set up how we are going to search the google calendar.""" self.calendar_service = calendar_service self.calendar_id = calendar_id self.search = search self.ignore_availab...
[ "def", "__init__", "(", "self", ",", "calendar_service", ",", "calendar_id", ",", "search", ",", "ignore_availability", ",", "max_results", ")", ":", "self", ".", "calendar_service", "=", "calendar_service", "self", ".", "calendar_id", "=", "calendar_id", "self", ...
[ 118, 4 ]
[ 127, 25 ]
python
en
['en', 'en', 'en']
True
GoogleCalendarData.async_get_events
(self, hass, start_date, end_date)
Get all events in a specific time frame.
Get all events in a specific time frame.
async def async_get_events(self, hass, start_date, end_date): """Get all events in a specific time frame.""" service, params = await hass.async_add_executor_job(self._prepare_query) if service is None: return [] params["timeMin"] = start_date.isoformat("T") params["ti...
[ "async", "def", "async_get_events", "(", "self", ",", "hass", ",", "start_date", ",", "end_date", ")", ":", "service", ",", "params", "=", "await", "hass", ".", "async_add_executor_job", "(", "self", ".", "_prepare_query", ")", "if", "service", "is", "None",...
[ 144, 4 ]
[ 163, 25 ]
python
en
['en', 'en', 'en']
True
GoogleCalendarData.update
(self)
Get the latest data.
Get the latest data.
def update(self): """Get the latest data.""" service, params = self._prepare_query() if service is None: return params["timeMin"] = dt.now().isoformat("T") events = service.events() result = events.list(**params).execute() items = result.get("items",...
[ "def", "update", "(", "self", ")", ":", "service", ",", "params", "=", "self", ".", "_prepare_query", "(", ")", "if", "service", "is", "None", ":", "return", "params", "[", "\"timeMin\"", "]", "=", "dt", ".", "now", "(", ")", ".", "isoformat", "(", ...
[ 166, 4 ]
[ 188, 30 ]
python
en
['en', 'en', 'en']
True
test_bad_posting
(hass, aiohttp_client)
Test that posting to wrong api endpoint fails.
Test that posting to wrong api endpoint fails.
async def test_bad_posting(hass, aiohttp_client): """Test that posting to wrong api endpoint fails.""" await async_process_ha_core_config( hass, {"external_url": "http://example.com"}, ) await async_setup_component( hass, "camera", { "camera": { ...
[ "async", "def", "test_bad_posting", "(", "hass", ",", "aiohttp_client", ")", ":", "await", "async_process_ha_core_config", "(", "hass", ",", "{", "\"external_url\"", ":", "\"http://example.com\"", "}", ",", ")", "await", "async_setup_component", "(", "hass", ",", ...
[ 11, 0 ]
[ 39, 39 ]
python
en
['en', 'en', 'en']
True
test_posting_url
(hass, aiohttp_client)
Test that posting to api endpoint works.
Test that posting to api endpoint works.
async def test_posting_url(hass, aiohttp_client): """Test that posting to api endpoint works.""" await async_process_ha_core_config( hass, {"external_url": "http://example.com"}, ) await async_setup_component( hass, "camera", { "camera": { ...
[ "async", "def", "test_posting_url", "(", "hass", ",", "aiohttp_client", ")", ":", "await", "async_process_ha_core_config", "(", "hass", ",", "{", "\"external_url\"", ":", "\"http://example.com\"", "}", ",", ")", "await", "async_setup_component", "(", "hass", ",", ...
[ 42, 0 ]
[ 84, 39 ]
python
en
['en', 'en', 'en']
True
make_script_schema
(schema, default_script_mode, extra=vol.PREVENT_EXTRA)
Make a schema for a component that uses the script helper.
Make a schema for a component that uses the script helper.
def make_script_schema(schema, default_script_mode, extra=vol.PREVENT_EXTRA): """Make a schema for a component that uses the script helper.""" return vol.Schema( { **schema, vol.Optional(CONF_MODE, default=default_script_mode): vol.In( SCRIPT_MODE_CHOICES ...
[ "def", "make_script_schema", "(", "schema", ",", "default_script_mode", ",", "extra", "=", "vol", ".", "PREVENT_EXTRA", ")", ":", "return", "vol", ".", "Schema", "(", "{", "*", "*", "schema", ",", "vol", ".", "Optional", "(", "CONF_MODE", ",", "default", ...
[ 112, 0 ]
[ 128, 5 ]
python
en
['en', 'en', 'en']
True
async_validate_actions_config
( hass: HomeAssistant, actions: List[ConfigType] )
Validate a list of actions.
Validate a list of actions.
async def async_validate_actions_config( hass: HomeAssistant, actions: List[ConfigType] ) -> List[ConfigType]: """Validate a list of actions.""" return await asyncio.gather( *[async_validate_action_config(hass, action) for action in actions] )
[ "async", "def", "async_validate_actions_config", "(", "hass", ":", "HomeAssistant", ",", "actions", ":", "List", "[", "ConfigType", "]", ")", "->", "List", "[", "ConfigType", "]", ":", "return", "await", "asyncio", ".", "gather", "(", "*", "[", "async_valida...
[ 141, 0 ]
[ 147, 5 ]
python
en
['en', 'en', 'en']
True
async_validate_action_config
( hass: HomeAssistant, config: ConfigType )
Validate config.
Validate config.
async def async_validate_action_config( hass: HomeAssistant, config: ConfigType ) -> ConfigType: """Validate config.""" action_type = cv.determine_script_action(config) if action_type in STATIC_VALIDATION_ACTION_TYPES: pass elif action_type == cv.SCRIPT_ACTION_DEVICE_AUTOMATION: pl...
[ "async", "def", "async_validate_action_config", "(", "hass", ":", "HomeAssistant", ",", "config", ":", "ConfigType", ")", "->", "ConfigType", ":", "action_type", "=", "cv", ".", "determine_script_action", "(", "config", ")", "if", "action_type", "in", "STATIC_VALI...
[ 150, 0 ]
[ 196, 17 ]
python
en
['en', 'la', 'it']
False
_async_stop_scripts_after_shutdown
(hass, point_in_time)
Stop running Script objects started after shutdown.
Stop running Script objects started after shutdown.
async def _async_stop_scripts_after_shutdown(hass, point_in_time): """Stop running Script objects started after shutdown.""" running_scripts = [ script for script in hass.data[DATA_SCRIPTS] if script["instance"].is_running ] if running_scripts: names = ", ".join([script["instance"].name ...
[ "async", "def", "_async_stop_scripts_after_shutdown", "(", "hass", ",", "point_in_time", ")", ":", "running_scripts", "=", "[", "script", "for", "script", "in", "hass", ".", "data", "[", "DATA_SCRIPTS", "]", "if", "script", "[", "\"instance\"", "]", ".", "is_r...
[ 719, 0 ]
[ 732, 9 ]
python
en
['da', 'en', 'en']
True
_async_stop_scripts_at_shutdown
(hass, event)
Stop running Script objects started before shutdown.
Stop running Script objects started before shutdown.
async def _async_stop_scripts_at_shutdown(hass, event): """Stop running Script objects started before shutdown.""" async_call_later( hass, _SHUTDOWN_MAX_WAIT, partial(_async_stop_scripts_after_shutdown, hass) ) running_scripts = [ script for script in hass.data[DATA_SCRIPTS] ...
[ "async", "def", "_async_stop_scripts_at_shutdown", "(", "hass", ",", "event", ")", ":", "async_call_later", "(", "hass", ",", "_SHUTDOWN_MAX_WAIT", ",", "partial", "(", "_async_stop_scripts_after_shutdown", ",", "hass", ")", ")", "running_scripts", "=", "[", "script...
[ 735, 0 ]
[ 751, 9 ]
python
en
['en', 'en', 'en']
True
_ScriptRun.async_run
(self)
Run script.
Run script.
async def async_run(self) -> None: """Run script.""" try: if self._stop.is_set(): return self._log("Running %s", self._script.running_description) for self._step, self._action in enumerate(self._script.sequence): if self._stop.is_set():...
[ "async", "def", "async_run", "(", "self", ")", "->", "None", ":", "try", ":", "if", "self", ".", "_stop", ".", "is_set", "(", ")", ":", "return", "self", ".", "_log", "(", "\"Running %s\"", ",", "self", ".", "_script", ".", "running_description", ")", ...
[ 235, 4 ]
[ 248, 26 ]
python
en
['ro', 'ms', 'en']
False
_ScriptRun.async_stop
(self)
Stop script run.
Stop script run.
async def async_stop(self) -> None: """Stop script run.""" self._stop.set() await self._stopped.wait()
[ "async", "def", "async_stop", "(", "self", ")", "->", "None", ":", "self", ".", "_stop", ".", "set", "(", ")", "await", "self", ".", "_stopped", ".", "wait", "(", ")" ]
[ 269, 4 ]
[ 272, 34 ]
python
de
['de', 'ms', 'en']
False
_ScriptRun._async_delay_step
(self)
Handle delay.
Handle delay.
async def _async_delay_step(self): """Handle delay.""" delay = self._get_pos_time_period_template(CONF_DELAY) self._script.last_action = self._action.get(CONF_ALIAS, f"delay {delay}") self._log("Executing step %s", self._script.last_action) delay = delay.total_seconds() ...
[ "async", "def", "_async_delay_step", "(", "self", ")", ":", "delay", "=", "self", ".", "_get_pos_time_period_template", "(", "CONF_DELAY", ")", "self", ".", "_script", ".", "last_action", "=", "self", ".", "_action", ".", "get", "(", "CONF_ALIAS", ",", "f\"d...
[ 320, 4 ]
[ 333, 16 ]
python
en
['it', 'es', 'en']
False
_ScriptRun._async_wait_template_step
(self)
Handle a wait template.
Handle a wait template.
async def _async_wait_template_step(self): """Handle a wait template.""" if CONF_TIMEOUT in self._action: delay = self._get_pos_time_period_template(CONF_TIMEOUT).total_seconds() else: delay = None self._script.last_action = self._action.get(CONF_ALIAS, "wait tem...
[ "async", "def", "_async_wait_template_step", "(", "self", ")", ":", "if", "CONF_TIMEOUT", "in", "self", ".", "_action", ":", "delay", "=", "self", ".", "_get_pos_time_period_template", "(", "CONF_TIMEOUT", ")", ".", "total_seconds", "(", ")", "else", ":", "del...
[ 335, 4 ]
[ 389, 19 ]
python
en
['en', 'fr', 'en']
True
_ScriptRun._async_run_long_action
(self, long_task)
Run a long task while monitoring for stop request.
Run a long task while monitoring for stop request.
async def _async_run_long_action(self, long_task): """Run a long task while monitoring for stop request.""" async def async_cancel_long_task(): # Stop long task and wait for it to finish. long_task.cancel() try: await long_task except Exce...
[ "async", "def", "_async_run_long_action", "(", "self", ",", "long_task", ")", ":", "async", "def", "async_cancel_long_task", "(", ")", ":", "# Stop long task and wait for it to finish.", "long_task", ".", "cancel", "(", ")", "try", ":", "await", "long_task", "except...
[ 391, 4 ]
[ 424, 42 ]
python
en
['en', 'en', 'en']
True
_ScriptRun._async_call_service_step
(self)
Call the service specified in the action.
Call the service specified in the action.
async def _async_call_service_step(self): """Call the service specified in the action.""" self._script.last_action = self._action.get(CONF_ALIAS, "call service") self._log("Executing step %s", self._script.last_action) domain, service, service_data = async_prepare_call_from_config( ...
[ "async", "def", "_async_call_service_step", "(", "self", ")", ":", "self", ".", "_script", ".", "last_action", "=", "self", ".", "_action", ".", "get", "(", "CONF_ALIAS", ",", "\"call service\"", ")", "self", ".", "_log", "(", "\"Executing step %s\"", ",", "...
[ 426, 4 ]
[ 462, 55 ]
python
en
['en', 'en', 'en']
True
_ScriptRun._async_device_step
(self)
Perform the device automation specified in the action.
Perform the device automation specified in the action.
async def _async_device_step(self): """Perform the device automation specified in the action.""" self._script.last_action = self._action.get(CONF_ALIAS, "device automation") self._log("Executing step %s", self._script.last_action) platform = await device_automation.async_get_device_autom...
[ "async", "def", "_async_device_step", "(", "self", ")", ":", "self", ".", "_script", ".", "last_action", "=", "self", ".", "_action", ".", "get", "(", "CONF_ALIAS", ",", "\"device automation\"", ")", "self", ".", "_log", "(", "\"Executing step %s\"", ",", "s...
[ 464, 4 ]
[ 473, 9 ]
python
en
['en', 'en', 'en']
True
_ScriptRun._async_scene_step
(self)
Activate the scene specified in the action.
Activate the scene specified in the action.
async def _async_scene_step(self): """Activate the scene specified in the action.""" self._script.last_action = self._action.get(CONF_ALIAS, "activate scene") self._log("Executing step %s", self._script.last_action) await self._hass.services.async_call( scene.DOMAIN, ...
[ "async", "def", "_async_scene_step", "(", "self", ")", ":", "self", ".", "_script", ".", "last_action", "=", "self", ".", "_action", ".", "get", "(", "CONF_ALIAS", ",", "\"activate scene\"", ")", "self", ".", "_log", "(", "\"Executing step %s\"", ",", "self"...
[ 475, 4 ]
[ 485, 9 ]
python
en
['en', 'en', 'en']
True
_ScriptRun._async_event_step
(self)
Fire an event.
Fire an event.
async def _async_event_step(self): """Fire an event.""" self._script.last_action = self._action.get( CONF_ALIAS, self._action[CONF_EVENT] ) self._log("Executing step %s", self._script.last_action) event_data = {} for conf in [CONF_EVENT_DATA, CONF_EVENT_DATA_T...
[ "async", "def", "_async_event_step", "(", "self", ")", ":", "self", ".", "_script", ".", "last_action", "=", "self", ".", "_action", ".", "get", "(", "CONF_ALIAS", ",", "self", ".", "_action", "[", "CONF_EVENT", "]", ")", "self", ".", "_log", "(", "\"E...
[ 487, 4 ]
[ 509, 9 ]
python
en
['en', 'lb', 'en']
True
_ScriptRun._async_condition_step
(self)
Test if condition is matching.
Test if condition is matching.
async def _async_condition_step(self): """Test if condition is matching.""" self._script.last_action = self._action.get( CONF_ALIAS, self._action[CONF_CONDITION] ) cond = await self._async_get_condition(self._action) check = cond(self._hass, self._variables) s...
[ "async", "def", "_async_condition_step", "(", "self", ")", ":", "self", ".", "_script", ".", "last_action", "=", "self", ".", "_action", ".", "get", "(", "CONF_ALIAS", ",", "self", ".", "_action", "[", "CONF_CONDITION", "]", ")", "cond", "=", "await", "s...
[ 511, 4 ]
[ 520, 29 ]
python
en
['en', 'en', 'en']
True
_ScriptRun._async_repeat_step
(self)
Repeat a sequence.
Repeat a sequence.
async def _async_repeat_step(self): """Repeat a sequence.""" description = self._action.get(CONF_ALIAS, "sequence") repeat = self._action[CONF_REPEAT] saved_repeat_vars = self._variables.get("repeat") def set_repeat_var(iteration, count=None): repeat_vars = {"first"...
[ "async", "def", "_async_repeat_step", "(", "self", ")", ":", "description", "=", "self", ".", "_action", ".", "get", "(", "CONF_ALIAS", ",", "\"sequence\"", ")", "repeat", "=", "self", ".", "_action", "[", "CONF_REPEAT", "]", "saved_repeat_vars", "=", "self"...
[ 522, 4 ]
[ 589, 41 ]
python
en
['en', 'en', 'it']
True
_ScriptRun._async_choose_step
(self)
Choose a sequence.
Choose a sequence.
async def _async_choose_step(self): """Choose a sequence.""" # pylint: disable=protected-access choose_data = await self._script._async_get_choose_data(self._step) for conditions, script in choose_data["choices"]: if all(condition(self._hass, self._variables) for condition i...
[ "async", "def", "_async_choose_step", "(", "self", ")", ":", "# pylint: disable=protected-access", "choose_data", "=", "await", "self", ".", "_script", ".", "_async_get_choose_data", "(", "self", ".", "_step", ")", "for", "conditions", ",", "script", "in", "choose...
[ 591, 4 ]
[ 602, 64 ]
python
en
['en', 'en', 'en']
True
_ScriptRun._async_wait_for_trigger_step
(self)
Wait for a trigger event.
Wait for a trigger event.
async def _async_wait_for_trigger_step(self): """Wait for a trigger event.""" if CONF_TIMEOUT in self._action: delay = self._get_pos_time_period_template(CONF_TIMEOUT).total_seconds() else: delay = None self._script.last_action = self._action.get(CONF_ALIAS, "wai...
[ "async", "def", "_async_wait_for_trigger_step", "(", "self", ")", ":", "if", "CONF_TIMEOUT", "in", "self", ".", "_action", ":", "delay", "=", "self", ".", "_get_pos_time_period_template", "(", "CONF_TIMEOUT", ")", ".", "total_seconds", "(", ")", "else", ":", "...
[ 604, 4 ]
[ 660, 29 ]
python
en
['en', 'en', 'en']
True
_ScriptRun._async_variables_step
(self)
Set a variable value.
Set a variable value.
async def _async_variables_step(self): """Set a variable value.""" self._script.last_action = self._action.get(CONF_ALIAS, "setting variables") self._log("Executing step %s", self._script.last_action) self._variables = self._action[CONF_VARIABLES].async_render( self._hass, se...
[ "async", "def", "_async_variables_step", "(", "self", ")", ":", "self", ".", "_script", ".", "last_action", "=", "self", ".", "_action", ".", "get", "(", "CONF_ALIAS", ",", "\"setting variables\"", ")", "self", ".", "_log", "(", "\"Executing step %s\"", ",", ...
[ 662, 4 ]
[ 668, 9 ]
python
en
['en', 'en', 'en']
True
_ScriptRun._async_run_script
(self, script)
Execute a script.
Execute a script.
async def _async_run_script(self, script): """Execute a script.""" await self._async_run_long_action( self._hass.async_create_task( script.async_run(self._variables, self._context) ) )
[ "async", "def", "_async_run_script", "(", "self", ",", "script", ")", ":", "await", "self", ".", "_async_run_long_action", "(", "self", ".", "_hass", ".", "async_create_task", "(", "script", ".", "async_run", "(", "self", ".", "_variables", ",", "self", ".",...
[ 670, 4 ]
[ 676, 9 ]
python
en
['en', 'ca', 'en']
True
_QueuedScriptRun.async_run
(self)
Run script.
Run script.
async def async_run(self) -> None: """Run script.""" # Wait for previous run, if any, to finish by attempting to acquire the script's # shared lock. At the same time monitor if we've been told to stop. lock_task = self._hass.async_create_task( self._script._queue_lck.acquire(...
[ "async", "def", "async_run", "(", "self", ")", "->", "None", ":", "# Wait for previous run, if any, to finish by attempting to acquire the script's", "# shared lock. At the same time monitor if we've been told to stop.", "lock_task", "=", "self", ".", "_hass", ".", "async_create_ta...
[ 684, 4 ]
[ 709, 37 ]
python
en
['ro', 'ms', 'en']
False
Script.__init__
( self, hass: HomeAssistant, sequence: Sequence[Dict[str, Any]], name: str, domain: str, *, # Used in "Running <running_description>" log message running_description: Optional[str] = None, change_listener: Optional[Callable[..., Any]] = None, ...
Initialize the script.
Initialize the script.
def __init__( self, hass: HomeAssistant, sequence: Sequence[Dict[str, Any]], name: str, domain: str, *, # Used in "Running <running_description>" log message running_description: Optional[str] = None, change_listener: Optional[Callable[..., Any]] =...
[ "def", "__init__", "(", "self", ",", "hass", ":", "HomeAssistant", ",", "sequence", ":", "Sequence", "[", "Dict", "[", "str", ",", "Any", "]", "]", ",", "name", ":", "str", ",", "domain", ":", "str", ",", "*", ",", "# Used in \"Running <running_descripti...
[ 760, 4 ]
[ 822, 44 ]
python
en
['en', 'co', 'en']
True
Script.change_listener
(self)
Return the change_listener.
Return the change_listener.
def change_listener(self) -> Optional[Callable[..., Any]]: """Return the change_listener.""" return self._change_listener
[ "def", "change_listener", "(", "self", ")", "->", "Optional", "[", "Callable", "[", "...", ",", "Any", "]", "]", ":", "return", "self", ".", "_change_listener" ]
[ 825, 4 ]
[ 827, 36 ]
python
en
['en', 'no', 'en']
True
Script.change_listener
(self, change_listener: Callable[..., Any])
Update the change_listener.
Update the change_listener.
def change_listener(self, change_listener: Callable[..., Any]) -> None: """Update the change_listener.""" self._change_listener = change_listener if ( self._change_listener_job is None or change_listener != self._change_listener_job.target ): self._cha...
[ "def", "change_listener", "(", "self", ",", "change_listener", ":", "Callable", "[", "...", ",", "Any", "]", ")", "->", "None", ":", "self", ".", "_change_listener", "=", "change_listener", "if", "(", "self", ".", "_change_listener_job", "is", "None", "or", ...
[ 830, 4 ]
[ 837, 64 ]
python
en
['en', 'de', 'en']
True
Script.update_logger
(self, logger: Optional[logging.Logger] = None)
Update logger.
Update logger.
def update_logger(self, logger: Optional[logging.Logger] = None) -> None: """Update logger.""" self._set_logger(logger) for script in self._repeat_script.values(): script.update_logger(self._logger) for choose_data in self._choose_data.values(): for _, script in c...
[ "def", "update_logger", "(", "self", ",", "logger", ":", "Optional", "[", "logging", ".", "Logger", "]", "=", "None", ")", "->", "None", ":", "self", ".", "_set_logger", "(", "logger", ")", "for", "script", "in", "self", ".", "_repeat_script", ".", "va...
[ 845, 4 ]
[ 854, 66 ]
python
en
['es', 'en', 'en']
False
Script.is_running
(self)
Return true if script is on.
Return true if script is on.
def is_running(self) -> bool: """Return true if script is on.""" return len(self._runs) > 0
[ "def", "is_running", "(", "self", ")", "->", "bool", ":", "return", "len", "(", "self", ".", "_runs", ")", ">", "0" ]
[ 866, 4 ]
[ 868, 34 ]
python
en
['en', 'fy', 'en']
True
Script.runs
(self)
Return the number of current runs.
Return the number of current runs.
def runs(self) -> int: """Return the number of current runs.""" return len(self._runs)
[ "def", "runs", "(", "self", ")", "->", "int", ":", "return", "len", "(", "self", ".", "_runs", ")" ]
[ 871, 4 ]
[ 873, 30 ]
python
en
['en', 'en', 'en']
True
Script.supports_max
(self)
Return true if the current mode support max.
Return true if the current mode support max.
def supports_max(self) -> bool: """Return true if the current mode support max.""" return self.script_mode in (SCRIPT_MODE_PARALLEL, SCRIPT_MODE_QUEUED)
[ "def", "supports_max", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "script_mode", "in", "(", "SCRIPT_MODE_PARALLEL", ",", "SCRIPT_MODE_QUEUED", ")" ]
[ 876, 4 ]
[ 878, 77 ]
python
en
['en', 'en', 'en']
True
Script.referenced_devices
(self)
Return a set of referenced devices.
Return a set of referenced devices.
def referenced_devices(self): """Return a set of referenced devices.""" if self._referenced_devices is not None: return self._referenced_devices referenced = set() for step in self.sequence: action = cv.determine_script_action(step) if action == cv....
[ "def", "referenced_devices", "(", "self", ")", ":", "if", "self", ".", "_referenced_devices", "is", "not", "None", ":", "return", "self", ".", "_referenced_devices", "referenced", "=", "set", "(", ")", "for", "step", "in", "self", ".", "sequence", ":", "ac...
[ 881, 4 ]
[ 898, 25 ]
python
en
['en', 'en', 'en']
True
Script.referenced_entities
(self)
Return a set of referenced entities.
Return a set of referenced entities.
def referenced_entities(self): """Return a set of referenced entities.""" if self._referenced_entities is not None: return self._referenced_entities referenced = set() for step in self.sequence: action = cv.determine_script_action(step) if action ==...
[ "def", "referenced_entities", "(", "self", ")", ":", "if", "self", ".", "_referenced_entities", "is", "not", "None", ":", "return", "self", ".", "_referenced_entities", "referenced", "=", "set", "(", ")", "for", "step", "in", "self", ".", "sequence", ":", ...
[ 901, 4 ]
[ 934, 25 ]
python
en
['en', 'en', 'en']
True
Script.run
( self, variables: Optional[_VarsType] = None, context: Optional[Context] = None )
Run script.
Run script.
def run( self, variables: Optional[_VarsType] = None, context: Optional[Context] = None ) -> None: """Run script.""" asyncio.run_coroutine_threadsafe( self.async_run(variables, context), self._hass.loop ).result()
[ "def", "run", "(", "self", ",", "variables", ":", "Optional", "[", "_VarsType", "]", "=", "None", ",", "context", ":", "Optional", "[", "Context", "]", "=", "None", ")", "->", "None", ":", "asyncio", ".", "run_coroutine_threadsafe", "(", "self", ".", "...
[ 936, 4 ]
[ 942, 18 ]
python
en
['ro', 'ms', 'en']
False
Script.async_run
( self, run_variables: Optional[_VarsType] = None, context: Optional[Context] = None, started_action: Optional[Callable[..., Any]] = None, )
Run script.
Run script.
async def async_run( self, run_variables: Optional[_VarsType] = None, context: Optional[Context] = None, started_action: Optional[Callable[..., Any]] = None, ) -> None: """Run script.""" if context is None: self._log( "Running script requir...
[ "async", "def", "async_run", "(", "self", ",", "run_variables", ":", "Optional", "[", "_VarsType", "]", "=", "None", ",", "context", ":", "Optional", "[", "Context", "]", "=", "None", ",", "started_action", ":", "Optional", "[", "Callable", "[", "...", "...
[ 944, 4 ]
[ 1013, 17 ]
python
en
['ro', 'ms', 'en']
False
Script.async_stop
(self, update_state: bool = True)
Stop running script.
Stop running script.
async def async_stop(self, update_state: bool = True) -> None: """Stop running script.""" await asyncio.shield(self._async_stop(update_state))
[ "async", "def", "async_stop", "(", "self", ",", "update_state", ":", "bool", "=", "True", ")", "->", "None", ":", "await", "asyncio", ".", "shield", "(", "self", ".", "_async_stop", "(", "update_state", ")", ")" ]
[ 1023, 4 ]
[ 1025, 60 ]
python
en
['en', 'sv', 'en']
True
async_setup_entry
( hass: HomeAssistantType, entry: ConfigEntry, async_add_entities: Callable[[List, bool], None], )
Load DirecTV remote based on a config entry.
Load DirecTV remote based on a config entry.
async def async_setup_entry( hass: HomeAssistantType, entry: ConfigEntry, async_add_entities: Callable[[List, bool], None], ) -> bool: """Load DirecTV remote based on a config entry.""" dtv = hass.data[DOMAIN][entry.entry_id] entities = [] for location in dtv.device.locations: entit...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistantType", ",", "entry", ":", "ConfigEntry", ",", "async_add_entities", ":", "Callable", "[", "[", "List", ",", "bool", "]", ",", "None", "]", ",", ")", "->", "bool", ":", "dtv", "=", "hass...
[ 19, 0 ]
[ 37, 38 ]
python
en
['en', 'en', 'en']
True
DIRECTVRemote.__init__
(self, *, dtv: DIRECTV, name: str, address: str = "0")
Initialize DirecTV remote.
Initialize DirecTV remote.
def __init__(self, *, dtv: DIRECTV, name: str, address: str = "0") -> None: """Initialize DirecTV remote.""" super().__init__( dtv=dtv, name=name, address=address, ) self._available = False self._is_on = True
[ "def", "__init__", "(", "self", ",", "*", ",", "dtv", ":", "DIRECTV", ",", "name", ":", "str", ",", "address", ":", "str", "=", "\"0\"", ")", "->", "None", ":", "super", "(", ")", ".", "__init__", "(", "dtv", "=", "dtv", ",", "name", "=", "name...
[ 43, 4 ]
[ 52, 26 ]
python
it
['en', 'it', 'it']
True
DIRECTVRemote.available
(self)
Return if able to retrieve information from device or not.
Return if able to retrieve information from device or not.
def available(self): """Return if able to retrieve information from device or not.""" return self._available
[ "def", "available", "(", "self", ")", ":", "return", "self", ".", "_available" ]
[ 55, 4 ]
[ 57, 30 ]
python
en
['en', 'en', 'en']
True
DIRECTVRemote.unique_id
(self)
Return a unique ID.
Return a unique ID.
def unique_id(self): """Return a unique ID.""" if self._address == "0": return self.dtv.device.info.receiver_id return self._address
[ "def", "unique_id", "(", "self", ")", ":", "if", "self", ".", "_address", "==", "\"0\"", ":", "return", "self", ".", "dtv", ".", "device", ".", "info", ".", "receiver_id", "return", "self", ".", "_address" ]
[ 60, 4 ]
[ 65, 28 ]
python
ca
['fr', 'ca', 'en']
False
DIRECTVRemote.is_on
(self)
Return True if entity is on.
Return True if entity is on.
def is_on(self) -> bool: """Return True if entity is on.""" return self._is_on
[ "def", "is_on", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "_is_on" ]
[ 68, 4 ]
[ 70, 26 ]
python
en
['en', 'cy', 'en']
True
DIRECTVRemote.async_update
(self)
Update device state.
Update device state.
async def async_update(self) -> None: """Update device state.""" status = await self.dtv.status(self._address) if status in ("active", "standby"): self._available = True self._is_on = status == "active" else: self._available = False self._...
[ "async", "def", "async_update", "(", "self", ")", "->", "None", ":", "status", "=", "await", "self", ".", "dtv", ".", "status", "(", "self", ".", "_address", ")", "if", "status", "in", "(", "\"active\"", ",", "\"standby\"", ")", ":", "self", ".", "_a...
[ 72, 4 ]
[ 81, 31 ]
python
en
['fr', 'en', 'en']
True
DIRECTVRemote.async_turn_on
(self, **kwargs: Any)
Turn the device on.
Turn the device on.
async def async_turn_on(self, **kwargs: Any) -> None: """Turn the device on.""" await self.dtv.remote("poweron", self._address)
[ "async", "def", "async_turn_on", "(", "self", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "None", ":", "await", "self", ".", "dtv", ".", "remote", "(", "\"poweron\"", ",", "self", ".", "_address", ")" ]
[ 83, 4 ]
[ 85, 55 ]
python
en
['en', 'en', 'en']
True
DIRECTVRemote.async_turn_off
(self, **kwargs: Any)
Turn the device off.
Turn the device off.
async def async_turn_off(self, **kwargs: Any) -> None: """Turn the device off.""" await self.dtv.remote("poweroff", self._address)
[ "async", "def", "async_turn_off", "(", "self", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "None", ":", "await", "self", ".", "dtv", ".", "remote", "(", "\"poweroff\"", ",", "self", ".", "_address", ")" ]
[ 87, 4 ]
[ 89, 56 ]
python
en
['en', 'en', 'en']
True
DIRECTVRemote.async_send_command
(self, command: Iterable[str], **kwargs: Any)
Send a command to a device. Supported keys: power, poweron, poweroff, format, pause, rew, replay, stop, advance, ffwd, record, play, guide, active, list, exit, back, menu, info, up, down, left, right, select, red, green, yellow, blue, chanup, chandown, prev, 0, 1, 2, 3, 4, 5, ...
Send a command to a device.
async def async_send_command(self, command: Iterable[str], **kwargs: Any) -> None: """Send a command to a device. Supported keys: power, poweron, poweroff, format, pause, rew, replay, stop, advance, ffwd, record, play, guide, active, list, exit, back, menu, info, up, down, left,...
[ "async", "def", "async_send_command", "(", "self", ",", "command", ":", "Iterable", "[", "str", "]", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "None", ":", "num_repeats", "=", "kwargs", "[", "ATTR_NUM_REPEATS", "]", "for", "_", "in", "range", "("...
[ 91, 4 ]
[ 112, 21 ]
python
en
['en', 'en', 'en']
True
get_masks
(slen, lengths, causal, padding_mask=None)
Generate hidden states mask, and optionally an attention mask.
Generate hidden states mask, and optionally an attention mask.
def get_masks(slen, lengths, causal, padding_mask=None): """ Generate hidden states mask, and optionally an attention mask. """ bs = shape_list(lengths)[0] if padding_mask is not None: mask = padding_mask else: # assert lengths.max().item() <= slen alen = tf.range(slen) ...
[ "def", "get_masks", "(", "slen", ",", "lengths", ",", "causal", ",", "padding_mask", "=", "None", ")", ":", "bs", "=", "shape_list", "(", "lengths", ")", "[", "0", "]", "if", "padding_mask", "is", "not", "None", ":", "mask", "=", "padding_mask", "else"...
[ 174, 0 ]
[ 200, 26 ]
python
en
['en', 'error', 'th']
False
TFFlaubertMultiHeadAttention.call
(self, input, mask, kv, cache, head_mask, output_attentions, training=False)
Self-attention (if kv is None) or attention over source sentence (provided by kv).
Self-attention (if kv is None) or attention over source sentence (provided by kv).
def call(self, input, mask, kv, cache, head_mask, output_attentions, training=False): """ Self-attention (if kv is None) or attention over source sentence (provided by kv). """ # Input is (bs, qlen, dim) # Mask is (bs, klen) (non-causal) or (bs, klen, klen) bs, qlen, dim ...
[ "def", "call", "(", "self", ",", "input", ",", "mask", ",", "kv", ",", "cache", ",", "head_mask", ",", "output_attentions", ",", "training", "=", "False", ")", ":", "# Input is (bs, qlen, dim)", "# Mask is (bs, klen) (non-causal) or (bs, klen, klen)", "bs", ",", "...
[ 326, 4 ]
[ 394, 22 ]
python
en
['en', 'error', 'th']
False
async_get_addon_info
(hass: HomeAssistantType, slug: str)
Return add-on info. The caller of the function should handle HassioAPIError.
Return add-on info.
async def async_get_addon_info(hass: HomeAssistantType, slug: str) -> dict: """Return add-on info. The caller of the function should handle HassioAPIError. """ hassio = hass.data[DOMAIN] return await hassio.get_addon_info(slug)
[ "async", "def", "async_get_addon_info", "(", "hass", ":", "HomeAssistantType", ",", "slug", ":", "str", ")", "->", "dict", ":", "hassio", "=", "hass", ".", "data", "[", "DOMAIN", "]", "return", "await", "hassio", ".", "get_addon_info", "(", "slug", ")" ]
[ 131, 0 ]
[ 137, 44 ]
python
en
['en', 'cy', 'en']
True
async_install_addon
(hass: HomeAssistantType, slug: str)
Install add-on. The caller of the function should handle HassioAPIError.
Install add-on.
async def async_install_addon(hass: HomeAssistantType, slug: str) -> dict: """Install add-on. The caller of the function should handle HassioAPIError. """ hassio = hass.data[DOMAIN] command = f"/addons/{slug}/install" return await hassio.send_command(command, timeout=None)
[ "async", "def", "async_install_addon", "(", "hass", ":", "HomeAssistantType", ",", "slug", ":", "str", ")", "->", "dict", ":", "hassio", "=", "hass", ".", "data", "[", "DOMAIN", "]", "command", "=", "f\"/addons/{slug}/install\"", "return", "await", "hassio", ...
[ 142, 0 ]
[ 149, 59 ]
python
en
['en', 'cy', 'en']
False
async_uninstall_addon
(hass: HomeAssistantType, slug: str)
Uninstall add-on. The caller of the function should handle HassioAPIError.
Uninstall add-on.
async def async_uninstall_addon(hass: HomeAssistantType, slug: str) -> dict: """Uninstall add-on. The caller of the function should handle HassioAPIError. """ hassio = hass.data[DOMAIN] command = f"/addons/{slug}/uninstall" return await hassio.send_command(command)
[ "async", "def", "async_uninstall_addon", "(", "hass", ":", "HomeAssistantType", ",", "slug", ":", "str", ")", "->", "dict", ":", "hassio", "=", "hass", ".", "data", "[", "DOMAIN", "]", "command", "=", "f\"/addons/{slug}/uninstall\"", "return", "await", "hassio...
[ 154, 0 ]
[ 161, 45 ]
python
en
['en', 'cy', 'en']
False
async_start_addon
(hass: HomeAssistantType, slug: str)
Start add-on. The caller of the function should handle HassioAPIError.
Start add-on.
async def async_start_addon(hass: HomeAssistantType, slug: str) -> dict: """Start add-on. The caller of the function should handle HassioAPIError. """ hassio = hass.data[DOMAIN] command = f"/addons/{slug}/start" return await hassio.send_command(command, timeout=60)
[ "async", "def", "async_start_addon", "(", "hass", ":", "HomeAssistantType", ",", "slug", ":", "str", ")", "->", "dict", ":", "hassio", "=", "hass", ".", "data", "[", "DOMAIN", "]", "command", "=", "f\"/addons/{slug}/start\"", "return", "await", "hassio", "."...
[ 166, 0 ]
[ 173, 57 ]
python
en
['en', 'de', 'en']
False
async_stop_addon
(hass: HomeAssistantType, slug: str)
Stop add-on. The caller of the function should handle HassioAPIError.
Stop add-on.
async def async_stop_addon(hass: HomeAssistantType, slug: str) -> dict: """Stop add-on. The caller of the function should handle HassioAPIError. """ hassio = hass.data[DOMAIN] command = f"/addons/{slug}/stop" return await hassio.send_command(command)
[ "async", "def", "async_stop_addon", "(", "hass", ":", "HomeAssistantType", ",", "slug", ":", "str", ")", "->", "dict", ":", "hassio", "=", "hass", ".", "data", "[", "DOMAIN", "]", "command", "=", "f\"/addons/{slug}/stop\"", "return", "await", "hassio", ".", ...
[ 178, 0 ]
[ 185, 45 ]
python
en
['en', 'en', 'en']
False
async_set_addon_options
( hass: HomeAssistantType, slug: str, options: dict )
Set add-on options. The caller of the function should handle HassioAPIError.
Set add-on options.
async def async_set_addon_options( hass: HomeAssistantType, slug: str, options: dict ) -> dict: """Set add-on options. The caller of the function should handle HassioAPIError. """ hassio = hass.data[DOMAIN] command = f"/addons/{slug}/options" return await hassio.send_command(command, payloa...
[ "async", "def", "async_set_addon_options", "(", "hass", ":", "HomeAssistantType", ",", "slug", ":", "str", ",", "options", ":", "dict", ")", "->", "dict", ":", "hassio", "=", "hass", ".", "data", "[", "DOMAIN", "]", "command", "=", "f\"/addons/{slug}/options...
[ 190, 0 ]
[ 199, 62 ]
python
en
['en', 'bg', 'en']
True
get_info
(hass)
Return generic information from Supervisor. Async friendly.
Return generic information from Supervisor.
def get_info(hass): """Return generic information from Supervisor. Async friendly. """ return hass.data.get(DATA_INFO)
[ "def", "get_info", "(", "hass", ")", ":", "return", "hass", ".", "data", ".", "get", "(", "DATA_INFO", ")" ]
[ 204, 0 ]
[ 209, 35 ]
python
en
['en', 'no', 'en']
True
get_host_info
(hass)
Return generic host information. Async friendly.
Return generic host information.
def get_host_info(hass): """Return generic host information. Async friendly. """ return hass.data.get(DATA_HOST_INFO)
[ "def", "get_host_info", "(", "hass", ")", ":", "return", "hass", ".", "data", ".", "get", "(", "DATA_HOST_INFO", ")" ]
[ 214, 0 ]
[ 219, 40 ]
python
da
['nl', 'da', 'en']
False
get_supervisor_info
(hass)
Return Supervisor information. Async friendly.
Return Supervisor information.
def get_supervisor_info(hass): """Return Supervisor information. Async friendly. """ return hass.data.get(DATA_SUPERVISOR_INFO)
[ "def", "get_supervisor_info", "(", "hass", ")", ":", "return", "hass", ".", "data", ".", "get", "(", "DATA_SUPERVISOR_INFO", ")" ]
[ 224, 0 ]
[ 229, 46 ]
python
en
['es', 'no', 'en']
False
get_os_info
(hass)
Return OS information. Async friendly.
Return OS information.
def get_os_info(hass): """Return OS information. Async friendly. """ return hass.data.get(DATA_OS_INFO)
[ "def", "get_os_info", "(", "hass", ")", ":", "return", "hass", ".", "data", ".", "get", "(", "DATA_OS_INFO", ")" ]
[ 234, 0 ]
[ 239, 38 ]
python
da
['es', 'da', 'en']
False
get_core_info
(hass)
Return Home Assistant Core information from Supervisor. Async friendly.
Return Home Assistant Core information from Supervisor.
def get_core_info(hass): """Return Home Assistant Core information from Supervisor. Async friendly. """ return hass.data.get(DATA_CORE_INFO)
[ "def", "get_core_info", "(", "hass", ")", ":", "return", "hass", ".", "data", ".", "get", "(", "DATA_CORE_INFO", ")" ]
[ 244, 0 ]
[ 249, 40 ]
python
en
['en', 'en', 'en']
True
is_hassio
(hass)
Return true if Hass.io is loaded. Async friendly.
Return true if Hass.io is loaded.
def is_hassio(hass): """Return true if Hass.io is loaded. Async friendly. """ return DOMAIN in hass.config.components
[ "def", "is_hassio", "(", "hass", ")", ":", "return", "DOMAIN", "in", "hass", ".", "config", ".", "components" ]
[ 254, 0 ]
[ 259, 43 ]
python
en
['en', 'en', 'en']
True
get_supervisor_ip
()
Return the supervisor ip address.
Return the supervisor ip address.
def get_supervisor_ip(): """Return the supervisor ip address.""" if "SUPERVISOR" not in os.environ: return None return os.environ["SUPERVISOR"].partition(":")[0]
[ "def", "get_supervisor_ip", "(", ")", ":", "if", "\"SUPERVISOR\"", "not", "in", "os", ".", "environ", ":", "return", "None", "return", "os", ".", "environ", "[", "\"SUPERVISOR\"", "]", ".", "partition", "(", "\":\"", ")", "[", "0", "]" ]
[ 263, 0 ]
[ 267, 53 ]
python
en
['en', 'no', 'en']
True
async_setup
(hass, config)
Set up the Hass.io component.
Set up the Hass.io component.
async def async_setup(hass, config): """Set up the Hass.io component.""" # Check local setup for env in ("HASSIO", "HASSIO_TOKEN"): if os.environ.get(env): continue _LOGGER.error("Missing %s environment variable", env) return False host = os.environ["HASSIO"] web...
[ "async", "def", "async_setup", "(", "hass", ",", "config", ")", ":", "# Check local setup", "for", "env", "in", "(", "\"HASSIO\"", ",", "\"HASSIO_TOKEN\"", ")", ":", "if", "os", ".", "environ", ".", "get", "(", "env", ")", ":", "continue", "_LOGGER", "."...
[ 270, 0 ]
[ 437, 15 ]
python
en
['en', 'en', 'en']
True
_generate_mock_feed_entry
( external_id, title, distance_to_home, coordinates, attribution=None, alert_level=None, country=None, duration_in_week=None, event_name=None, event_type_short=None, event_type=None, from_date=None, to_date=None, population=None, severity=None, vulnerabili...
Construct a mock feed entry for testing purposes.
Construct a mock feed entry for testing purposes.
def _generate_mock_feed_entry( external_id, title, distance_to_home, coordinates, attribution=None, alert_level=None, country=None, duration_in_week=None, event_name=None, event_type_short=None, event_type=None, from_date=None, to_date=None, population=None, s...
[ "def", "_generate_mock_feed_entry", "(", "external_id", ",", "title", ",", "distance_to_home", ",", "coordinates", ",", "attribution", "=", "None", ",", "alert_level", "=", "None", ",", "country", "=", "None", ",", "duration_in_week", "=", "None", ",", "event_na...
[ 4, 0 ]
[ 40, 21 ]
python
en
['en', 'en', 'en']
True
check_binary_sensors
(value)
Validate binary sensor configurations.
Validate binary sensor configurations.
def check_binary_sensors(value): """Validate binary sensor configurations.""" for exclusive_options in _EXCLUSIVE_OPTIONS: if len(set(value) & exclusive_options) > 1: raise vol.Invalid( f"must contain at most one of {', '.join(exclusive_options)}." ) return va...
[ "def", "check_binary_sensors", "(", "value", ")", ":", "for", "exclusive_options", "in", "_EXCLUSIVE_OPTIONS", ":", "if", "len", "(", "set", "(", "value", ")", "&", "exclusive_options", ")", ">", "1", ":", "raise", "vol", ".", "Invalid", "(", "f\"must contai...
[ 65, 0 ]
[ 72, 16 ]
python
en
['en', 'ky', 'en']
True
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Set up a binary sensor for an Amcrest IP Camera.
Set up a binary sensor for an Amcrest IP Camera.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up a binary sensor for an Amcrest IP Camera.""" if discovery_info is None: return name = discovery_info[CONF_NAME] device = hass.data[DATA_AMCREST][DEVICES][name] async_add_entities( [ ...
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "if", "discovery_info", "is", "None", ":", "return", "name", "=", "discovery_info", "[", "CONF_NAME", "]", "device", "=...
[ 75, 0 ]
[ 88, 5 ]
python
en
['en', 'pt', 'en']
True
AmcrestBinarySensor.__init__
(self, name, device, sensor_type)
Initialize entity.
Initialize entity.
def __init__(self, name, device, sensor_type): """Initialize entity.""" self._name = f"{name} {BINARY_SENSORS[sensor_type][SENSOR_NAME]}" self._signal_name = name self._api = device.api self._sensor_type = sensor_type self._state = None self._device_class = BINARY...
[ "def", "__init__", "(", "self", ",", "name", ",", "device", ",", "sensor_type", ")", ":", "self", ".", "_name", "=", "f\"{name} {BINARY_SENSORS[sensor_type][SENSOR_NAME]}\"", "self", ".", "_signal_name", "=", "name", "self", ".", "_api", "=", "device", ".", "a...
[ 94, 4 ]
[ 103, 35 ]
python
es
['es', 'pl', 'it']
False
AmcrestBinarySensor.should_poll
(self)
Return True if entity has to be polled for state.
Return True if entity has to be polled for state.
def should_poll(self): """Return True if entity has to be polled for state.""" return self._sensor_type in BINARY_POLLED_SENSORS
[ "def", "should_poll", "(", "self", ")", ":", "return", "self", ".", "_sensor_type", "in", "BINARY_POLLED_SENSORS" ]
[ 106, 4 ]
[ 108, 57 ]
python
en
['en', 'en', 'en']
True
AmcrestBinarySensor.name
(self)
Return entity name.
Return entity name.
def name(self): """Return entity name.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 111, 4 ]
[ 113, 25 ]
python
en
['en', 'ig', 'en']
True
AmcrestBinarySensor.is_on
(self)
Return if entity is on.
Return if entity is on.
def is_on(self): """Return if entity is on.""" return self._state
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 116, 4 ]
[ 118, 26 ]
python
en
['en', 'en', 'en']
True
AmcrestBinarySensor.device_class
(self)
Return device class.
Return device class.
def device_class(self): """Return device class.""" return self._device_class
[ "def", "device_class", "(", "self", ")", ":", "return", "self", ".", "_device_class" ]
[ 121, 4 ]
[ 123, 33 ]
python
en
['es', 'zh', 'en']
False
AmcrestBinarySensor.available
(self)
Return True if entity is available.
Return True if entity is available.
def available(self): """Return True if entity is available.""" return self._sensor_type == BINARY_SENSOR_ONLINE or self._api.available
[ "def", "available", "(", "self", ")", ":", "return", "self", ".", "_sensor_type", "==", "BINARY_SENSOR_ONLINE", "or", "self", ".", "_api", ".", "available" ]
[ 126, 4 ]
[ 128, 79 ]
python
en
['en', 'en', 'en']
True
AmcrestBinarySensor.update
(self)
Update entity.
Update entity.
def update(self): """Update entity.""" if self._sensor_type == BINARY_SENSOR_ONLINE: self._update_online() else: self._update_others()
[ "def", "update", "(", "self", ")", ":", "if", "self", ".", "_sensor_type", "==", "BINARY_SENSOR_ONLINE", ":", "self", ".", "_update_online", "(", ")", "else", ":", "self", ".", "_update_others", "(", ")" ]
[ 130, 4 ]
[ 135, 33 ]
python
en
['es', 'en', 'en']
False
AmcrestBinarySensor.async_on_demand_update
(self)
Update state.
Update state.
async def async_on_demand_update(self): """Update state.""" if self._sensor_type == BINARY_SENSOR_ONLINE: _LOGGER.debug(_UPDATE_MSG, self._name) self._state = self._api.available self.async_write_ha_state() return self.async_schedule_update_ha_stat...
[ "async", "def", "async_on_demand_update", "(", "self", ")", ":", "if", "self", ".", "_sensor_type", "==", "BINARY_SENSOR_ONLINE", ":", "_LOGGER", ".", "debug", "(", "_UPDATE_MSG", ",", "self", ".", "_name", ")", "self", ".", "_state", "=", "self", ".", "_a...
[ 164, 4 ]
[ 171, 49 ]
python
en
['en', 'co', 'en']
False
AmcrestBinarySensor.async_event_received
(self, start)
Update state from received event.
Update state from received event.
def async_event_received(self, start): """Update state from received event.""" _LOGGER.debug(_UPDATE_MSG, self._name) self._state = start self.async_write_ha_state()
[ "def", "async_event_received", "(", "self", ",", "start", ")", ":", "_LOGGER", ".", "debug", "(", "_UPDATE_MSG", ",", "self", ".", "_name", ")", "self", ".", "_state", "=", "start", "self", ".", "async_write_ha_state", "(", ")" ]
[ 174, 4 ]
[ 178, 35 ]
python
en
['en', 'en', 'en']
True
AmcrestBinarySensor.async_added_to_hass
(self)
Subscribe to signals.
Subscribe to signals.
async def async_added_to_hass(self): """Subscribe to signals.""" self._unsub_dispatcher.append( async_dispatcher_connect( self.hass, service_signal(SERVICE_UPDATE, self._signal_name), self.async_on_demand_update, ) ) ...
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "self", ".", "_unsub_dispatcher", ".", "append", "(", "async_dispatcher_connect", "(", "self", ".", "hass", ",", "service_signal", "(", "SERVICE_UPDATE", ",", "self", ".", "_signal_name", ")", ",", ...
[ 180, 4 ]
[ 196, 13 ]
python
en
['en', 'en', 'en']
True
AmcrestBinarySensor.async_will_remove_from_hass
(self)
Disconnect from update signal.
Disconnect from update signal.
async def async_will_remove_from_hass(self): """Disconnect from update signal.""" for unsub_dispatcher in self._unsub_dispatcher: unsub_dispatcher()
[ "async", "def", "async_will_remove_from_hass", "(", "self", ")", ":", "for", "unsub_dispatcher", "in", "self", ".", "_unsub_dispatcher", ":", "unsub_dispatcher", "(", ")" ]
[ 198, 4 ]
[ 201, 30 ]
python
en
['en', 'en', 'en']
True
_async_reproduce_states
( hass: HomeAssistantType, state: State, *, context: Optional[Context] = None, reproduce_options: Optional[Dict[str, Any]] = None, )
Reproduce component states.
Reproduce component states.
async def _async_reproduce_states( hass: HomeAssistantType, state: State, *, context: Optional[Context] = None, reproduce_options: Optional[Dict[str, Any]] = None, ) -> None: """Reproduce component states.""" async def call_service(service: str, keys: Iterable) -> None: """Call serv...
[ "async", "def", "_async_reproduce_states", "(", "hass", ":", "HomeAssistantType", ",", "state", ":", "State", ",", "*", ",", "context", ":", "Optional", "[", "Context", "]", "=", "None", ",", "reproduce_options", ":", "Optional", "[", "Dict", "[", "str", "...
[ 38, 0 ]
[ 99, 51 ]
python
en
['de', 'en', 'en']
True
async_reproduce_states
( hass: HomeAssistantType, states: Iterable[State], *, context: Optional[Context] = None, reproduce_options: Optional[Dict[str, Any]] = None, )
Reproduce component states.
Reproduce component states.
async def async_reproduce_states( hass: HomeAssistantType, states: Iterable[State], *, context: Optional[Context] = None, reproduce_options: Optional[Dict[str, Any]] = None, ) -> None: """Reproduce component states.""" await asyncio.gather( *( _async_reproduce_states( ...
[ "async", "def", "async_reproduce_states", "(", "hass", ":", "HomeAssistantType", ",", "states", ":", "Iterable", "[", "State", "]", ",", "*", ",", "context", ":", "Optional", "[", "Context", "]", "=", "None", ",", "reproduce_options", ":", "Optional", "[", ...
[ 102, 0 ]
[ 117, 5 ]
python
en
['de', 'en', 'en']
True
async_setup
(hass, config)
Set up the Tuya integration.
Set up the Tuya integration.
async def async_setup(hass, config): """Set up the Tuya integration.""" conf = config.get(DOMAIN) if conf is not None: hass.async_create_task( hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_IMPORT}, data=conf ) ) return Tr...
[ "async", "def", "async_setup", "(", "hass", ",", "config", ")", ":", "conf", "=", "config", ".", "get", "(", "DOMAIN", ")", "if", "conf", "is", "not", "None", ":", "hass", ".", "async_create_task", "(", "hass", ".", "config_entries", ".", "flow", ".", ...
[ 105, 0 ]
[ 116, 15 ]
python
en
['en', 'ceb', 'en']
True
async_setup_entry
(hass: HomeAssistant, entry: ConfigEntry)
Set up Tuya platform.
Set up Tuya platform.
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): """Set up Tuya platform.""" tuya = TuyaApi() username = entry.data[CONF_USERNAME] password = entry.data[CONF_PASSWORD] country_code = entry.data[CONF_COUNTRYCODE] platform = entry.data[CONF_PLATFORM] try: await h...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ")", ":", "tuya", "=", "TuyaApi", "(", ")", "username", "=", "entry", ".", "data", "[", "CONF_USERNAME", "]", "password", "=", "entry", ".", "data", ...
[ 119, 0 ]
[ 228, 15 ]
python
en
['en', 'ru', 'en']
True
async_unload_entry
(hass: HomeAssistant, entry: ConfigEntry)
Unloading the Tuya platforms.
Unloading the Tuya platforms.
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry): """Unloading the Tuya platforms.""" unload_ok = all( await asyncio.gather( *[ hass.config_entries.async_forward_entry_unload( entry, component.split(".", 1)[0] ) ...
[ "async", "def", "async_unload_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ")", ":", "unload_ok", "=", "all", "(", "await", "asyncio", ".", "gather", "(", "*", "[", "hass", ".", "config_entries", ".", "async_forward_entry_unload...
[ 231, 0 ]
[ 250, 20 ]
python
en
['en', 'jv', 'en']
True
update_listener
(hass: HomeAssistant, entry: ConfigEntry)
Update when config_entry options update.
Update when config_entry options update.
async def update_listener(hass: HomeAssistant, entry: ConfigEntry): """Update when config_entry options update.""" hass.data[DOMAIN][TUYA_DEVICES_CONF] = entry.options.copy() _update_discovery_interval( hass, entry.options.get(CONF_DISCOVERY_INTERVAL, DEFAULT_DISCOVERY_INTERVAL) ) _update_qu...
[ "async", "def", "update_listener", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ")", ":", "hass", ".", "data", "[", "DOMAIN", "]", "[", "TUYA_DEVICES_CONF", "]", "=", "entry", ".", "options", ".", "copy", "(", ")", "_update_discover...
[ 253, 0 ]
[ 262, 53 ]
python
en
['en', 'en', 'en']
True
cleanup_device_registry
(hass: HomeAssistant, device_id)
Remove device registry entry if there are no remaining entities.
Remove device registry entry if there are no remaining entities.
async def cleanup_device_registry(hass: HomeAssistant, device_id): """Remove device registry entry if there are no remaining entities.""" device_registry = await hass.helpers.device_registry.async_get_registry() entity_registry = await hass.helpers.entity_registry.async_get_registry() if device_id and ...
[ "async", "def", "cleanup_device_registry", "(", "hass", ":", "HomeAssistant", ",", "device_id", ")", ":", "device_registry", "=", "await", "hass", ".", "helpers", ".", "device_registry", ".", "async_get_registry", "(", ")", "entity_registry", "=", "await", "hass",...
[ 265, 0 ]
[ 273, 54 ]
python
en
['en', 'en', 'en']
True
TuyaDevice.__init__
(self, tuya, platform)
Init Tuya devices.
Init Tuya devices.
def __init__(self, tuya, platform): """Init Tuya devices.""" self._tuya = tuya self._tuya_platform = platform
[ "def", "__init__", "(", "self", ",", "tuya", ",", "platform", ")", ":", "self", ".", "_tuya", "=", "tuya", "self", ".", "_tuya_platform", "=", "platform" ]
[ 281, 4 ]
[ 284, 38 ]
python
es
['es', 'mg', 'it']
False
TuyaDevice._device_can_query
(self)
Check if device can also use query method.
Check if device can also use query method.
def _device_can_query(self): """Check if device can also use query method.""" dev_type = self._tuya.device_type() return dev_type not in TUYA_TYPE_NOT_QUERY
[ "def", "_device_can_query", "(", "self", ")", ":", "dev_type", "=", "self", ".", "_tuya", ".", "device_type", "(", ")", "return", "dev_type", "not", "in", "TUYA_TYPE_NOT_QUERY" ]
[ 286, 4 ]
[ 289, 50 ]
python
en
['en', 'en', 'en']
True
TuyaDevice._inc_device_count
(self)
Increment static variable device count.
Increment static variable device count.
def _inc_device_count(self): """Increment static variable device count.""" if not self._device_can_query(): return TuyaDevice._dev_can_query_count += 1
[ "def", "_inc_device_count", "(", "self", ")", ":", "if", "not", "self", ".", "_device_can_query", "(", ")", ":", "return", "TuyaDevice", ".", "_dev_can_query_count", "+=", "1" ]
[ 291, 4 ]
[ 295, 44 ]
python
en
['fr', 'en', 'en']
True
TuyaDevice._dec_device_count
(self)
Decrement static variable device count.
Decrement static variable device count.
def _dec_device_count(self): """Decrement static variable device count.""" if not self._device_can_query(): return TuyaDevice._dev_can_query_count -= 1
[ "def", "_dec_device_count", "(", "self", ")", ":", "if", "not", "self", ".", "_device_can_query", "(", ")", ":", "return", "TuyaDevice", ".", "_dev_can_query_count", "-=", "1" ]
[ 297, 4 ]
[ 301, 44 ]
python
en
['fr', 'en', 'en']
True
TuyaDevice._get_device_config
(self)
Get updated device options.
Get updated device options.
def _get_device_config(self): """Get updated device options.""" devices_config = self.hass.data[DOMAIN].get(TUYA_DEVICES_CONF) if not devices_config: return {} dev_conf = devices_config.get(self.object_id, {}) if dev_conf: _LOGGER.debug( "C...
[ "def", "_get_device_config", "(", "self", ")", ":", "devices_config", "=", "self", ".", "hass", ".", "data", "[", "DOMAIN", "]", ".", "get", "(", "TUYA_DEVICES_CONF", ")", "if", "not", "devices_config", ":", "return", "{", "}", "dev_conf", "=", "devices_co...
[ 303, 4 ]
[ 313, 23 ]
python
en
['en', 'en', 'en']
True
TuyaDevice.async_added_to_hass
(self)
Call when entity is added to hass.
Call when entity is added to hass.
async def async_added_to_hass(self): """Call when entity is added to hass.""" self.hass.data[DOMAIN]["entities"][self.object_id] = self.entity_id self.async_on_remove( async_dispatcher_connect( self.hass, SIGNAL_DELETE_ENTITY, self._delete_callback ) ...
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "self", ".", "hass", ".", "data", "[", "DOMAIN", "]", "[", "\"entities\"", "]", "[", "self", ".", "object_id", "]", "=", "self", ".", "entity_id", "self", ".", "async_on_remove", "(", "async_d...
[ 315, 4 ]
[ 328, 32 ]
python
en
['en', 'en', 'en']
True
TuyaDevice.async_will_remove_from_hass
(self)
Call when entity is removed from hass.
Call when entity is removed from hass.
async def async_will_remove_from_hass(self): """Call when entity is removed from hass.""" self._dec_device_count()
[ "async", "def", "async_will_remove_from_hass", "(", "self", ")", ":", "self", ".", "_dec_device_count", "(", ")" ]
[ 330, 4 ]
[ 332, 32 ]
python
en
['en', 'en', 'en']
True
TuyaDevice.object_id
(self)
Return Tuya device id.
Return Tuya device id.
def object_id(self): """Return Tuya device id.""" return self._tuya.object_id()
[ "def", "object_id", "(", "self", ")", ":", "return", "self", ".", "_tuya", ".", "object_id", "(", ")" ]
[ 335, 4 ]
[ 337, 37 ]
python
en
['es', 'yo', 'en']
False
TuyaDevice.unique_id
(self)
Return a unique ID.
Return a unique ID.
def unique_id(self): """Return a unique ID.""" return f"tuya.{self._tuya.object_id()}"
[ "def", "unique_id", "(", "self", ")", ":", "return", "f\"tuya.{self._tuya.object_id()}\"" ]
[ 340, 4 ]
[ 342, 47 ]
python
ca
['fr', 'ca', 'en']
False
TuyaDevice.name
(self)
Return Tuya device name.
Return Tuya device name.
def name(self): """Return Tuya device name.""" return self._tuya.name()
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_tuya", ".", "name", "(", ")" ]
[ 345, 4 ]
[ 347, 32 ]
python
en
['es', 'ig', 'en']
False
TuyaDevice.available
(self)
Return if the device is available.
Return if the device is available.
def available(self): """Return if the device is available.""" return self._tuya.available()
[ "def", "available", "(", "self", ")", ":", "return", "self", ".", "_tuya", ".", "available", "(", ")" ]
[ 350, 4 ]
[ 352, 37 ]
python
en
['en', 'en', 'en']
True
TuyaDevice.device_info
(self)
Return a device description for device registry.
Return a device description for device registry.
def device_info(self): """Return a device description for device registry.""" _device_info = { "identifiers": {(DOMAIN, f"{self.unique_id}")}, "manufacturer": TUYA_PLATFORMS.get( self._tuya_platform, self._tuya_platform ), "name": self.name...
[ "def", "device_info", "(", "self", ")", ":", "_device_info", "=", "{", "\"identifiers\"", ":", "{", "(", "DOMAIN", ",", "f\"{self.unique_id}\"", ")", "}", ",", "\"manufacturer\"", ":", "TUYA_PLATFORMS", ".", "get", "(", "self", ".", "_tuya_platform", ",", "s...
[ 355, 4 ]
[ 365, 27 ]
python
en
['ro', 'fr', 'en']
False
TuyaDevice.update
(self)
Refresh Tuya device data.
Refresh Tuya device data.
def update(self): """Refresh Tuya device data.""" query_dev = self.hass.data[DOMAIN][TUYA_DEVICES_CONF].get(CONF_QUERY_DEVICE, "") use_discovery = ( TuyaDevice._dev_can_query_count > 1 and self.object_id != query_dev ) try: self._tuya.update(use_discovery=...
[ "def", "update", "(", "self", ")", ":", "query_dev", "=", "self", ".", "hass", ".", "data", "[", "DOMAIN", "]", "[", "TUYA_DEVICES_CONF", "]", ".", "get", "(", "CONF_QUERY_DEVICE", ",", "\"\"", ")", "use_discovery", "=", "(", "TuyaDevice", ".", "_dev_can...
[ 367, 4 ]
[ 376, 30 ]
python
en
['es', 'ha', 'en']
False
TuyaDevice._delete_callback
(self, dev_id)
Remove this entity.
Remove this entity.
async def _delete_callback(self, dev_id): """Remove this entity.""" if dev_id == self.object_id: entity_registry = ( await self.hass.helpers.entity_registry.async_get_registry() ) if entity_registry.async_is_registered(self.entity_id): ...
[ "async", "def", "_delete_callback", "(", "self", ",", "dev_id", ")", ":", "if", "dev_id", "==", "self", ".", "object_id", ":", "entity_registry", "=", "(", "await", "self", ".", "hass", ".", "helpers", ".", "entity_registry", ".", "async_get_registry", "(", ...
[ 378, 4 ]
[ 389, 41 ]
python
en
['en', 'en', 'en']
True
TuyaDevice._update_callback
(self)
Call update method.
Call update method.
def _update_callback(self): """Call update method.""" self.async_schedule_update_ha_state(True)
[ "def", "_update_callback", "(", "self", ")", ":", "self", ".", "async_schedule_update_ha_state", "(", "True", ")" ]
[ 392, 4 ]
[ 394, 49 ]
python
en
['en', 'sn', 'en']
True