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
async_api_turn_on
(hass, config, directive, context)
Process a turn on request.
Process a turn on request.
async def async_api_turn_on(hass, config, directive, context): """Process a turn on request.""" entity = directive.entity domain = entity.domain if domain == group.DOMAIN: domain = ha.DOMAIN service = SERVICE_TURN_ON if domain == cover.DOMAIN: service = cover.SERVICE_OPEN_COVER ...
[ "async", "def", "async_api_turn_on", "(", "hass", ",", "config", ",", "directive", ",", "context", ")", ":", "entity", "=", "directive", ".", "entity", "domain", "=", "entity", ".", "domain", "if", "domain", "==", "group", ".", "DOMAIN", ":", "domain", "...
[ 116, 0 ]
[ 146, 31 ]
python
en
['en', 'en', 'en']
True
async_api_turn_off
(hass, config, directive, context)
Process a turn off request.
Process a turn off request.
async def async_api_turn_off(hass, config, directive, context): """Process a turn off request.""" entity = directive.entity domain = entity.domain if entity.domain == group.DOMAIN: domain = ha.DOMAIN service = SERVICE_TURN_OFF if entity.domain == cover.DOMAIN: service = cover.SE...
[ "async", "def", "async_api_turn_off", "(", "hass", ",", "config", ",", "directive", ",", "context", ")", ":", "entity", "=", "directive", ".", "entity", "domain", "=", "entity", ".", "domain", "if", "entity", ".", "domain", "==", "group", ".", "DOMAIN", ...
[ 150, 0 ]
[ 183, 31 ]
python
en
['en', 'en', 'en']
True
async_api_set_brightness
(hass, config, directive, context)
Process a set brightness request.
Process a set brightness request.
async def async_api_set_brightness(hass, config, directive, context): """Process a set brightness request.""" entity = directive.entity brightness = int(directive.payload["brightness"]) await hass.services.async_call( entity.domain, SERVICE_TURN_ON, {ATTR_ENTITY_ID: entity.entit...
[ "async", "def", "async_api_set_brightness", "(", "hass", ",", "config", ",", "directive", ",", "context", ")", ":", "entity", "=", "directive", ".", "entity", "brightness", "=", "int", "(", "directive", ".", "payload", "[", "\"brightness\"", "]", ")", "await...
[ 187, 0 ]
[ 200, 31 ]
python
en
['en', 'lv', 'en']
True
async_api_adjust_brightness
(hass, config, directive, context)
Process an adjust brightness request.
Process an adjust brightness request.
async def async_api_adjust_brightness(hass, config, directive, context): """Process an adjust brightness request.""" entity = directive.entity brightness_delta = int(directive.payload["brightnessDelta"]) # read current state try: current = math.floor( int(entity.attributes.get(l...
[ "async", "def", "async_api_adjust_brightness", "(", "hass", ",", "config", ",", "directive", ",", "context", ")", ":", "entity", "=", "directive", ".", "entity", "brightness_delta", "=", "int", "(", "directive", ".", "payload", "[", "\"brightnessDelta\"", "]", ...
[ 204, 0 ]
[ 227, 31 ]
python
en
['en', 'mt', 'en']
True
async_api_set_color
(hass, config, directive, context)
Process a set color request.
Process a set color request.
async def async_api_set_color(hass, config, directive, context): """Process a set color request.""" entity = directive.entity rgb = color_util.color_hsb_to_RGB( float(directive.payload["color"]["hue"]), float(directive.payload["color"]["saturation"]), float(directive.payload["color"]...
[ "async", "def", "async_api_set_color", "(", "hass", ",", "config", ",", "directive", ",", "context", ")", ":", "entity", "=", "directive", ".", "entity", "rgb", "=", "color_util", ".", "color_hsb_to_RGB", "(", "float", "(", "directive", ".", "payload", "[", ...
[ 231, 0 ]
[ 248, 31 ]
python
en
['en', 'fr', 'en']
True
async_api_set_color_temperature
(hass, config, directive, context)
Process a set color temperature request.
Process a set color temperature request.
async def async_api_set_color_temperature(hass, config, directive, context): """Process a set color temperature request.""" entity = directive.entity kelvin = int(directive.payload["colorTemperatureInKelvin"]) await hass.services.async_call( entity.domain, SERVICE_TURN_ON, {ATTR...
[ "async", "def", "async_api_set_color_temperature", "(", "hass", ",", "config", ",", "directive", ",", "context", ")", ":", "entity", "=", "directive", ".", "entity", "kelvin", "=", "int", "(", "directive", ".", "payload", "[", "\"colorTemperatureInKelvin\"", "]"...
[ 252, 0 ]
[ 265, 31 ]
python
en
['en', 'ca', 'en']
True
async_api_decrease_color_temp
(hass, config, directive, context)
Process a decrease color temperature request.
Process a decrease color temperature request.
async def async_api_decrease_color_temp(hass, config, directive, context): """Process a decrease color temperature request.""" entity = directive.entity current = int(entity.attributes.get(light.ATTR_COLOR_TEMP)) max_mireds = int(entity.attributes.get(light.ATTR_MAX_MIREDS)) value = min(max_mireds,...
[ "async", "def", "async_api_decrease_color_temp", "(", "hass", ",", "config", ",", "directive", ",", "context", ")", ":", "entity", "=", "directive", ".", "entity", "current", "=", "int", "(", "entity", ".", "attributes", ".", "get", "(", "light", ".", "ATT...
[ 269, 0 ]
[ 284, 31 ]
python
en
['en', 'ca', 'en']
True
async_api_increase_color_temp
(hass, config, directive, context)
Process an increase color temperature request.
Process an increase color temperature request.
async def async_api_increase_color_temp(hass, config, directive, context): """Process an increase color temperature request.""" entity = directive.entity current = int(entity.attributes.get(light.ATTR_COLOR_TEMP)) min_mireds = int(entity.attributes.get(light.ATTR_MIN_MIREDS)) value = max(min_mireds...
[ "async", "def", "async_api_increase_color_temp", "(", "hass", ",", "config", ",", "directive", ",", "context", ")", ":", "entity", "=", "directive", ".", "entity", "current", "=", "int", "(", "entity", ".", "attributes", ".", "get", "(", "light", ".", "ATT...
[ 288, 0 ]
[ 303, 31 ]
python
en
['en', 'en', 'en']
True
async_api_activate
(hass, config, directive, context)
Process an activate request.
Process an activate request.
async def async_api_activate(hass, config, directive, context): """Process an activate request.""" entity = directive.entity domain = entity.domain await hass.services.async_call( domain, SERVICE_TURN_ON, {ATTR_ENTITY_ID: entity.entity_id}, blocking=False, contex...
[ "async", "def", "async_api_activate", "(", "hass", ",", "config", ",", "directive", ",", "context", ")", ":", "entity", "=", "directive", ".", "entity", "domain", "=", "entity", ".", "domain", "await", "hass", ".", "services", ".", "async_call", "(", "doma...
[ 307, 0 ]
[ 327, 5 ]
python
en
['en', 'en', 'en']
True
async_api_deactivate
(hass, config, directive, context)
Process a deactivate request.
Process a deactivate request.
async def async_api_deactivate(hass, config, directive, context): """Process a deactivate request.""" entity = directive.entity domain = entity.domain await hass.services.async_call( domain, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: entity.entity_id}, blocking=False, co...
[ "async", "def", "async_api_deactivate", "(", "hass", ",", "config", ",", "directive", ",", "context", ")", ":", "entity", "=", "directive", ".", "entity", "domain", "=", "entity", ".", "domain", "await", "hass", ".", "services", ".", "async_call", "(", "do...
[ 331, 0 ]
[ 351, 5 ]
python
en
['en', 'fr', 'en']
True
async_api_set_percentage
(hass, config, directive, context)
Process a set percentage request.
Process a set percentage request.
async def async_api_set_percentage(hass, config, directive, context): """Process a set percentage request.""" entity = directive.entity service = None data = {ATTR_ENTITY_ID: entity.entity_id} if entity.domain == fan.DOMAIN: service = fan.SERVICE_SET_SPEED speed = "off" per...
[ "async", "def", "async_api_set_percentage", "(", "hass", ",", "config", ",", "directive", ",", "context", ")", ":", "entity", "=", "directive", ".", "entity", "service", "=", "None", "data", "=", "{", "ATTR_ENTITY_ID", ":", "entity", ".", "entity_id", "}", ...
[ 355, 0 ]
[ 378, 31 ]
python
en
['en', 'ca', 'en']
True
async_api_adjust_percentage
(hass, config, directive, context)
Process an adjust percentage request.
Process an adjust percentage request.
async def async_api_adjust_percentage(hass, config, directive, context): """Process an adjust percentage request.""" entity = directive.entity percentage_delta = int(directive.payload["percentageDelta"]) service = None data = {ATTR_ENTITY_ID: entity.entity_id} if entity.domain == fan.DOMAIN: ...
[ "async", "def", "async_api_adjust_percentage", "(", "hass", ",", "config", ",", "directive", ",", "context", ")", ":", "entity", "=", "directive", ".", "entity", "percentage_delta", "=", "int", "(", "directive", ".", "payload", "[", "\"percentageDelta\"", "]", ...
[ 382, 0 ]
[ 411, 31 ]
python
en
['en', 'mt', 'en']
True
async_api_lock
(hass, config, directive, context)
Process a lock request.
Process a lock request.
async def async_api_lock(hass, config, directive, context): """Process a lock request.""" entity = directive.entity await hass.services.async_call( entity.domain, SERVICE_LOCK, {ATTR_ENTITY_ID: entity.entity_id}, blocking=False, context=context, ) response = ...
[ "async", "def", "async_api_lock", "(", "hass", ",", "config", ",", "directive", ",", "context", ")", ":", "entity", "=", "directive", ".", "entity", "await", "hass", ".", "services", ".", "async_call", "(", "entity", ".", "domain", ",", "SERVICE_LOCK", ","...
[ 415, 0 ]
[ 430, 19 ]
python
en
['en', 'co', 'en']
True
async_api_unlock
(hass, config, directive, context)
Process an unlock request.
Process an unlock request.
async def async_api_unlock(hass, config, directive, context): """Process an unlock request.""" if config.locale not in {"de-DE", "en-US", "ja-JP"}: msg = f"The unlock directive is not supported for the following locales: {config.locale}" raise AlexaInvalidDirectiveError(msg) entity = direct...
[ "async", "def", "async_api_unlock", "(", "hass", ",", "config", ",", "directive", ",", "context", ")", ":", "if", "config", ".", "locale", "not", "in", "{", "\"de-DE\"", ",", "\"en-US\"", ",", "\"ja-JP\"", "}", ":", "msg", "=", "f\"The unlock directive is no...
[ 434, 0 ]
[ 454, 19 ]
python
en
['en', 'lb', 'en']
True
async_api_set_volume
(hass, config, directive, context)
Process a set volume request.
Process a set volume request.
async def async_api_set_volume(hass, config, directive, context): """Process a set volume request.""" volume = round(float(directive.payload["volume"] / 100), 2) entity = directive.entity data = { ATTR_ENTITY_ID: entity.entity_id, media_player.const.ATTR_MEDIA_VOLUME_LEVEL: volume, ...
[ "async", "def", "async_api_set_volume", "(", "hass", ",", "config", ",", "directive", ",", "context", ")", ":", "volume", "=", "round", "(", "float", "(", "directive", ".", "payload", "[", "\"volume\"", "]", "/", "100", ")", ",", "2", ")", "entity", "=...
[ 458, 0 ]
[ 472, 31 ]
python
en
['en', 'fr', 'en']
True
async_api_select_input
(hass, config, directive, context)
Process a set input request.
Process a set input request.
async def async_api_select_input(hass, config, directive, context): """Process a set input request.""" media_input = directive.payload["input"] entity = directive.entity # Attempt to map the ALL UPPERCASE payload name to a source. # Strips trailing 1 to match single input devices. source_list =...
[ "async", "def", "async_api_select_input", "(", "hass", ",", "config", ",", "directive", ",", "context", ")", ":", "media_input", "=", "directive", ".", "payload", "[", "\"input\"", "]", "entity", "=", "directive", ".", "entity", "# Attempt to map the ALL UPPERCASE...
[ 476, 0 ]
[ 516, 31 ]
python
en
['en', 'lb', 'en']
True
async_api_adjust_volume
(hass, config, directive, context)
Process an adjust volume request.
Process an adjust volume request.
async def async_api_adjust_volume(hass, config, directive, context): """Process an adjust volume request.""" volume_delta = int(directive.payload["volume"]) entity = directive.entity current_level = entity.attributes.get(media_player.const.ATTR_MEDIA_VOLUME_LEVEL) # read current state try: ...
[ "async", "def", "async_api_adjust_volume", "(", "hass", ",", "config", ",", "directive", ",", "context", ")", ":", "volume_delta", "=", "int", "(", "directive", ".", "payload", "[", "\"volume\"", "]", ")", "entity", "=", "directive", ".", "entity", "current_...
[ 520, 0 ]
[ 544, 31 ]
python
en
['en', 'lb', 'en']
True
async_api_adjust_volume_step
(hass, config, directive, context)
Process an adjust volume step request.
Process an adjust volume step request.
async def async_api_adjust_volume_step(hass, config, directive, context): """Process an adjust volume step request.""" # media_player volume up/down service does not support specifying steps # each component handles it differently e.g. via config. # This workaround will simply call the volume up/Volume ...
[ "async", "def", "async_api_adjust_volume_step", "(", "hass", ",", "config", ",", "directive", ",", "context", ")", ":", "# media_player volume up/down service does not support specifying steps", "# each component handles it differently e.g. via config.", "# This workaround will simply ...
[ 548, 0 ]
[ 576, 31 ]
python
en
['en', 'lb', 'en']
True
async_api_set_mute
(hass, config, directive, context)
Process a set mute request.
Process a set mute request.
async def async_api_set_mute(hass, config, directive, context): """Process a set mute request.""" mute = bool(directive.payload["mute"]) entity = directive.entity data = { ATTR_ENTITY_ID: entity.entity_id, media_player.const.ATTR_MEDIA_VOLUME_MUTED: mute, } await hass.services.a...
[ "async", "def", "async_api_set_mute", "(", "hass", ",", "config", ",", "directive", ",", "context", ")", ":", "mute", "=", "bool", "(", "directive", ".", "payload", "[", "\"mute\"", "]", ")", "entity", "=", "directive", ".", "entity", "data", "=", "{", ...
[ 581, 0 ]
[ 594, 31 ]
python
en
['en', 'co', 'en']
True
async_api_play
(hass, config, directive, context)
Process a play request.
Process a play request.
async def async_api_play(hass, config, directive, context): """Process a play request.""" entity = directive.entity data = {ATTR_ENTITY_ID: entity.entity_id} await hass.services.async_call( entity.domain, SERVICE_MEDIA_PLAY, data, blocking=False, context=context ) return directive.resp...
[ "async", "def", "async_api_play", "(", "hass", ",", "config", ",", "directive", ",", "context", ")", ":", "entity", "=", "directive", ".", "entity", "data", "=", "{", "ATTR_ENTITY_ID", ":", "entity", ".", "entity_id", "}", "await", "hass", ".", "services",...
[ 598, 0 ]
[ 607, 31 ]
python
en
['en', 'en', 'en']
True
async_api_pause
(hass, config, directive, context)
Process a pause request.
Process a pause request.
async def async_api_pause(hass, config, directive, context): """Process a pause request.""" entity = directive.entity data = {ATTR_ENTITY_ID: entity.entity_id} await hass.services.async_call( entity.domain, SERVICE_MEDIA_PAUSE, data, blocking=False, context=context ) return directive.r...
[ "async", "def", "async_api_pause", "(", "hass", ",", "config", ",", "directive", ",", "context", ")", ":", "entity", "=", "directive", ".", "entity", "data", "=", "{", "ATTR_ENTITY_ID", ":", "entity", ".", "entity_id", "}", "await", "hass", ".", "services"...
[ 611, 0 ]
[ 620, 31 ]
python
en
['en', 'en', 'en']
True
async_api_stop
(hass, config, directive, context)
Process a stop request.
Process a stop request.
async def async_api_stop(hass, config, directive, context): """Process a stop request.""" entity = directive.entity data = {ATTR_ENTITY_ID: entity.entity_id} await hass.services.async_call( entity.domain, SERVICE_MEDIA_STOP, data, blocking=False, context=context ) return directive.resp...
[ "async", "def", "async_api_stop", "(", "hass", ",", "config", ",", "directive", ",", "context", ")", ":", "entity", "=", "directive", ".", "entity", "data", "=", "{", "ATTR_ENTITY_ID", ":", "entity", ".", "entity_id", "}", "await", "hass", ".", "services",...
[ 624, 0 ]
[ 633, 31 ]
python
en
['en', 'en', 'en']
True
async_api_next
(hass, config, directive, context)
Process a next request.
Process a next request.
async def async_api_next(hass, config, directive, context): """Process a next request.""" entity = directive.entity data = {ATTR_ENTITY_ID: entity.entity_id} await hass.services.async_call( entity.domain, SERVICE_MEDIA_NEXT_TRACK, data, blocking=False, context=context ) return directiv...
[ "async", "def", "async_api_next", "(", "hass", ",", "config", ",", "directive", ",", "context", ")", ":", "entity", "=", "directive", ".", "entity", "data", "=", "{", "ATTR_ENTITY_ID", ":", "entity", ".", "entity_id", "}", "await", "hass", ".", "services",...
[ 637, 0 ]
[ 646, 31 ]
python
en
['en', 'fr', 'en']
True
async_api_previous
(hass, config, directive, context)
Process a previous request.
Process a previous request.
async def async_api_previous(hass, config, directive, context): """Process a previous request.""" entity = directive.entity data = {ATTR_ENTITY_ID: entity.entity_id} await hass.services.async_call( entity.domain, SERVICE_MEDIA_PREVIOUS_TRACK, data, blocking=False, ...
[ "async", "def", "async_api_previous", "(", "hass", ",", "config", ",", "directive", ",", "context", ")", ":", "entity", "=", "directive", ".", "entity", "data", "=", "{", "ATTR_ENTITY_ID", ":", "entity", ".", "entity_id", "}", "await", "hass", ".", "servic...
[ 650, 0 ]
[ 663, 31 ]
python
en
['en', 'fr', 'en']
True
temperature_from_object
(hass, temp_obj, interval=False)
Get temperature from Temperature object in requested unit.
Get temperature from Temperature object in requested unit.
def temperature_from_object(hass, temp_obj, interval=False): """Get temperature from Temperature object in requested unit.""" to_unit = hass.config.units.temperature_unit from_unit = TEMP_CELSIUS temp = float(temp_obj["value"]) if temp_obj["scale"] == "FAHRENHEIT": from_unit = TEMP_FAHRENHE...
[ "def", "temperature_from_object", "(", "hass", ",", "temp_obj", ",", "interval", "=", "False", ")", ":", "to_unit", "=", "hass", ".", "config", ".", "units", ".", "temperature_unit", "from_unit", "=", "TEMP_CELSIUS", "temp", "=", "float", "(", "temp_obj", "[...
[ 666, 0 ]
[ 679, 66 ]
python
en
['en', 'en', 'en']
True
async_api_set_target_temp
(hass, config, directive, context)
Process a set target temperature request.
Process a set target temperature request.
async def async_api_set_target_temp(hass, config, directive, context): """Process a set target temperature request.""" entity = directive.entity min_temp = entity.attributes.get(climate.ATTR_MIN_TEMP) max_temp = entity.attributes.get(climate.ATTR_MAX_TEMP) unit = hass.config.units.temperature_unit ...
[ "async", "def", "async_api_set_target_temp", "(", "hass", ",", "config", ",", "directive", ",", "context", ")", ":", "entity", "=", "directive", ".", "entity", "min_temp", "=", "entity", ".", "attributes", ".", "get", "(", "climate", ".", "ATTR_MIN_TEMP", ")...
[ 683, 0 ]
[ 739, 19 ]
python
en
['en', 'ca', 'en']
True
async_api_adjust_target_temp
(hass, config, directive, context)
Process an adjust target temperature request.
Process an adjust target temperature request.
async def async_api_adjust_target_temp(hass, config, directive, context): """Process an adjust target temperature request.""" entity = directive.entity min_temp = entity.attributes.get(climate.ATTR_MIN_TEMP) max_temp = entity.attributes.get(climate.ATTR_MAX_TEMP) unit = hass.config.units.temperature...
[ "async", "def", "async_api_adjust_target_temp", "(", "hass", ",", "config", ",", "directive", ",", "context", ")", ":", "entity", "=", "directive", ".", "entity", "min_temp", "=", "entity", ".", "attributes", ".", "get", "(", "climate", ".", "ATTR_MIN_TEMP", ...
[ 743, 0 ]
[ 776, 19 ]
python
en
['en', 'en', 'en']
True
async_api_set_thermostat_mode
(hass, config, directive, context)
Process a set thermostat mode request.
Process a set thermostat mode request.
async def async_api_set_thermostat_mode(hass, config, directive, context): """Process a set thermostat mode request.""" entity = directive.entity mode = directive.payload["thermostatMode"] mode = mode if isinstance(mode, str) else mode["value"] data = {ATTR_ENTITY_ID: entity.entity_id} ha_pres...
[ "async", "def", "async_api_set_thermostat_mode", "(", "hass", ",", "config", ",", "directive", ",", "context", ")", ":", "entity", "=", "directive", ".", "entity", "mode", "=", "directive", ".", "payload", "[", "\"thermostatMode\"", "]", "mode", "=", "mode", ...
[ 780, 0 ]
[ 839, 19 ]
python
en
['en', 'en', 'en']
True
async_api_reportstate
(hass, config, directive, context)
Process a ReportState request.
Process a ReportState request.
async def async_api_reportstate(hass, config, directive, context): """Process a ReportState request.""" return directive.response(name="StateReport")
[ "async", "def", "async_api_reportstate", "(", "hass", ",", "config", ",", "directive", ",", "context", ")", ":", "return", "directive", ".", "response", "(", "name", "=", "\"StateReport\"", ")" ]
[ 843, 0 ]
[ 845, 49 ]
python
en
['en', 'co', 'en']
True
async_api_set_power_level
(hass, config, directive, context)
Process a SetPowerLevel request.
Process a SetPowerLevel request.
async def async_api_set_power_level(hass, config, directive, context): """Process a SetPowerLevel request.""" entity = directive.entity service = None data = {ATTR_ENTITY_ID: entity.entity_id} if entity.domain == fan.DOMAIN: service = fan.SERVICE_SET_SPEED speed = "off" per...
[ "async", "def", "async_api_set_power_level", "(", "hass", ",", "config", ",", "directive", ",", "context", ")", ":", "entity", "=", "directive", ".", "entity", "service", "=", "None", "data", "=", "{", "ATTR_ENTITY_ID", ":", "entity", ".", "entity_id", "}", ...
[ 849, 0 ]
[ 873, 31 ]
python
en
['en', 'lb', 'en']
True
async_api_adjust_power_level
(hass, config, directive, context)
Process an AdjustPowerLevel request.
Process an AdjustPowerLevel request.
async def async_api_adjust_power_level(hass, config, directive, context): """Process an AdjustPowerLevel request.""" entity = directive.entity percentage_delta = int(directive.payload["powerLevelDelta"]) service = None data = {ATTR_ENTITY_ID: entity.entity_id} if entity.domain == fan.DOMAIN: ...
[ "async", "def", "async_api_adjust_power_level", "(", "hass", ",", "config", ",", "directive", ",", "context", ")", ":", "entity", "=", "directive", ".", "entity", "percentage_delta", "=", "int", "(", "directive", ".", "payload", "[", "\"powerLevelDelta\"", "]", ...
[ 877, 0 ]
[ 906, 31 ]
python
en
['en', 'lb', 'en']
True
async_api_arm
(hass, config, directive, context)
Process a Security Panel Arm request.
Process a Security Panel Arm request.
async def async_api_arm(hass, config, directive, context): """Process a Security Panel Arm request.""" entity = directive.entity service = None arm_state = directive.payload["armState"] data = {ATTR_ENTITY_ID: entity.entity_id} if entity.state != STATE_ALARM_DISARMED: msg = "You must di...
[ "async", "def", "async_api_arm", "(", "hass", ",", "config", ",", "directive", ",", "context", ")", ":", "entity", "=", "directive", ".", "entity", "service", "=", "None", "arm_state", "=", "directive", ".", "payload", "[", "\"armState\"", "]", "data", "="...
[ 910, 0 ]
[ 947, 19 ]
python
en
['en', 'en', 'en']
True
async_api_disarm
(hass, config, directive, context)
Process a Security Panel Disarm request.
Process a Security Panel Disarm request.
async def async_api_disarm(hass, config, directive, context): """Process a Security Panel Disarm request.""" entity = directive.entity data = {ATTR_ENTITY_ID: entity.entity_id} response = directive.response() # Per Alexa Documentation: If you receive a Disarm directive, and the system is already di...
[ "async", "def", "async_api_disarm", "(", "hass", ",", "config", ",", "directive", ",", "context", ")", ":", "entity", "=", "directive", ".", "entity", "data", "=", "{", "ATTR_ENTITY_ID", ":", "entity", ".", "entity_id", "}", "response", "=", "directive", "...
[ 951, 0 ]
[ 982, 19 ]
python
en
['en', 'en', 'en']
True
async_api_set_mode
(hass, config, directive, context)
Process a SetMode directive.
Process a SetMode directive.
async def async_api_set_mode(hass, config, directive, context): """Process a SetMode directive.""" entity = directive.entity instance = directive.instance domain = entity.domain service = None data = {ATTR_ENTITY_ID: entity.entity_id} mode = directive.payload["mode"] # Fan Direction ...
[ "async", "def", "async_api_set_mode", "(", "hass", ",", "config", ",", "directive", ",", "context", ")", ":", "entity", "=", "directive", ".", "entity", "instance", "=", "directive", ".", "instance", "domain", "=", "entity", ".", "domain", "service", "=", ...
[ 986, 0 ]
[ 1031, 19 ]
python
en
['en', 'su', 'en']
True
async_api_adjust_mode
(hass, config, directive, context)
Process a AdjustMode request. Requires capabilityResources supportedModes to be ordered. Only supportedModes with ordered=True support the adjustMode directive.
Process a AdjustMode request.
async def async_api_adjust_mode(hass, config, directive, context): """Process a AdjustMode request. Requires capabilityResources supportedModes to be ordered. Only supportedModes with ordered=True support the adjustMode directive. """ # Currently no supportedModes are configured with ordered=True ...
[ "async", "def", "async_api_adjust_mode", "(", "hass", ",", "config", ",", "directive", ",", "context", ")", ":", "# Currently no supportedModes are configured with ordered=True to support this request.", "msg", "=", "\"Entity does not support directive\"", "raise", "AlexaInvalidD...
[ 1035, 0 ]
[ 1044, 41 ]
python
en
['en', 'en', 'en']
True
async_api_toggle_on
(hass, config, directive, context)
Process a toggle on request.
Process a toggle on request.
async def async_api_toggle_on(hass, config, directive, context): """Process a toggle on request.""" entity = directive.entity instance = directive.instance domain = entity.domain service = None data = {ATTR_ENTITY_ID: entity.entity_id} # Fan Oscillating if instance == f"{fan.DOMAIN}.{fa...
[ "async", "def", "async_api_toggle_on", "(", "hass", ",", "config", ",", "directive", ",", "context", ")", ":", "entity", "=", "directive", ".", "entity", "instance", "=", "directive", ".", "instance", "domain", "=", "entity", ".", "domain", "service", "=", ...
[ 1048, 0 ]
[ 1078, 19 ]
python
en
['en', 'en', 'en']
True
async_api_toggle_off
(hass, config, directive, context)
Process a toggle off request.
Process a toggle off request.
async def async_api_toggle_off(hass, config, directive, context): """Process a toggle off request.""" entity = directive.entity instance = directive.instance domain = entity.domain service = None data = {ATTR_ENTITY_ID: entity.entity_id} # Fan Oscillating if instance == f"{fan.DOMAIN}.{...
[ "async", "def", "async_api_toggle_off", "(", "hass", ",", "config", ",", "directive", ",", "context", ")", ":", "entity", "=", "directive", ".", "entity", "instance", "=", "directive", ".", "instance", "domain", "=", "entity", ".", "domain", "service", "=", ...
[ 1082, 0 ]
[ 1112, 19 ]
python
en
['en', 'en', 'en']
True
async_api_set_range
(hass, config, directive, context)
Process a next request.
Process a next request.
async def async_api_set_range(hass, config, directive, context): """Process a next request.""" entity = directive.entity instance = directive.instance domain = entity.domain service = None data = {ATTR_ENTITY_ID: entity.entity_id} range_value = directive.payload["rangeValue"] # Fan Spee...
[ "async", "def", "async_api_set_range", "(", "hass", ",", "config", ",", "directive", ",", "context", ")", ":", "entity", "=", "directive", ".", "entity", "instance", "=", "directive", ".", "instance", "domain", "=", "entity", ".", "domain", "service", "=", ...
[ 1116, 0 ]
[ 1203, 19 ]
python
en
['en', 'fr', 'en']
True
async_api_adjust_range
(hass, config, directive, context)
Process a next request.
Process a next request.
async def async_api_adjust_range(hass, config, directive, context): """Process a next request.""" entity = directive.entity instance = directive.instance domain = entity.domain service = None data = {ATTR_ENTITY_ID: entity.entity_id} range_delta = directive.payload["rangeValueDelta"] ran...
[ "async", "def", "async_api_adjust_range", "(", "hass", ",", "config", ",", "directive", ",", "context", ")", ":", "entity", "=", "directive", ".", "entity", "instance", "=", "directive", ".", "instance", "domain", "=", "entity", ".", "domain", "service", "="...
[ 1207, 0 ]
[ 1318, 19 ]
python
en
['en', 'fr', 'en']
True
async_api_changechannel
(hass, config, directive, context)
Process a change channel request.
Process a change channel request.
async def async_api_changechannel(hass, config, directive, context): """Process a change channel request.""" channel = "0" entity = directive.entity channel_payload = directive.payload["channel"] metadata_payload = directive.payload["channelMetadata"] payload_name = "number" if "number" in ...
[ "async", "def", "async_api_changechannel", "(", "hass", ",", "config", ",", "directive", ",", "context", ")", ":", "channel", "=", "\"0\"", "entity", "=", "directive", ".", "entity", "channel_payload", "=", "directive", ".", "payload", "[", "\"channel\"", "]",...
[ 1322, 0 ]
[ 1370, 19 ]
python
en
['en', 'en', 'en']
True
async_api_skipchannel
(hass, config, directive, context)
Process a skipchannel request.
Process a skipchannel request.
async def async_api_skipchannel(hass, config, directive, context): """Process a skipchannel request.""" channel = int(directive.payload["channelCount"]) entity = directive.entity data = {ATTR_ENTITY_ID: entity.entity_id} if channel < 0: service_media = SERVICE_MEDIA_PREVIOUS_TRACK else...
[ "async", "def", "async_api_skipchannel", "(", "hass", ",", "config", ",", "directive", ",", "context", ")", ":", "channel", "=", "int", "(", "directive", ".", "payload", "[", "\"channelCount\"", "]", ")", "entity", "=", "directive", ".", "entity", "data", ...
[ 1374, 0 ]
[ 1401, 19 ]
python
en
['en', 'en', 'en']
True
async_api_seek
(hass, config, directive, context)
Process a seek request.
Process a seek request.
async def async_api_seek(hass, config, directive, context): """Process a seek request.""" entity = directive.entity position_delta = int(directive.payload["deltaPositionMilliseconds"]) current_position = entity.attributes.get(media_player.ATTR_MEDIA_POSITION) if not current_position: msg = ...
[ "async", "def", "async_api_seek", "(", "hass", ",", "config", ",", "directive", ",", "context", ")", ":", "entity", "=", "directive", ".", "entity", "position_delta", "=", "int", "(", "directive", ".", "payload", "[", "\"deltaPositionMilliseconds\"", "]", ")",...
[ 1405, 0 ]
[ 1443, 5 ]
python
en
['en', 'co', 'en']
True
async_api_set_eq_mode
(hass, config, directive, context)
Process a SetMode request for EqualizerController.
Process a SetMode request for EqualizerController.
async def async_api_set_eq_mode(hass, config, directive, context): """Process a SetMode request for EqualizerController.""" mode = directive.payload["mode"] entity = directive.entity data = {ATTR_ENTITY_ID: entity.entity_id} sound_mode_list = entity.attributes.get(media_player.const.ATTR_SOUND_MODE...
[ "async", "def", "async_api_set_eq_mode", "(", "hass", ",", "config", ",", "directive", ",", "context", ")", ":", "mode", "=", "directive", ".", "payload", "[", "\"mode\"", "]", "entity", "=", "directive", ".", "entity", "data", "=", "{", "ATTR_ENTITY_ID", ...
[ 1447, 0 ]
[ 1468, 31 ]
python
en
['en', 'en', 'en']
True
async_api_bands_directive
(hass, config, directive, context)
Handle an AdjustBands, ResetBands, SetBands request. Only mode directives are currently supported for the EqualizerController.
Handle an AdjustBands, ResetBands, SetBands request.
async def async_api_bands_directive(hass, config, directive, context): """Handle an AdjustBands, ResetBands, SetBands request. Only mode directives are currently supported for the EqualizerController. """ # Currently bands directives are not supported. msg = "Entity does not support directive" ...
[ "async", "def", "async_api_bands_directive", "(", "hass", ",", "config", ",", "directive", ",", "context", ")", ":", "# Currently bands directives are not supported.", "msg", "=", "\"Entity does not support directive\"", "raise", "AlexaInvalidDirectiveError", "(", "msg", ")...
[ 1474, 0 ]
[ 1481, 41 ]
python
en
['en', 'lb', 'en']
True
async_api_hold
(hass, config, directive, context)
Process a TimeHoldController Hold request.
Process a TimeHoldController Hold request.
async def async_api_hold(hass, config, directive, context): """Process a TimeHoldController Hold request.""" entity = directive.entity data = {ATTR_ENTITY_ID: entity.entity_id} if entity.domain == timer.DOMAIN: service = timer.SERVICE_PAUSE elif entity.domain == vacuum.DOMAIN: serv...
[ "async", "def", "async_api_hold", "(", "hass", ",", "config", ",", "directive", ",", "context", ")", ":", "entity", "=", "directive", ".", "entity", "data", "=", "{", "ATTR_ENTITY_ID", ":", "entity", ".", "entity_id", "}", "if", "entity", ".", "domain", ...
[ 1485, 0 ]
[ 1504, 31 ]
python
en
['en', 'en', 'en']
True
async_api_resume
(hass, config, directive, context)
Process a TimeHoldController Resume request.
Process a TimeHoldController Resume request.
async def async_api_resume(hass, config, directive, context): """Process a TimeHoldController Resume request.""" entity = directive.entity data = {ATTR_ENTITY_ID: entity.entity_id} if entity.domain == timer.DOMAIN: service = timer.SERVICE_START elif entity.domain == vacuum.DOMAIN: ...
[ "async", "def", "async_api_resume", "(", "hass", ",", "config", ",", "directive", ",", "context", ")", ":", "entity", "=", "directive", ".", "entity", "data", "=", "{", "ATTR_ENTITY_ID", ":", "entity", ".", "entity_id", "}", "if", "entity", ".", "domain", ...
[ 1508, 0 ]
[ 1527, 31 ]
python
en
['en', 'en', 'en']
True
async_api_initialize_camera_stream
(hass, config, directive, context)
Process a InitializeCameraStreams request.
Process a InitializeCameraStreams request.
async def async_api_initialize_camera_stream(hass, config, directive, context): """Process a InitializeCameraStreams request.""" entity = directive.entity stream_source = await camera.async_request_stream(hass, entity.entity_id, fmt="hls") camera_image = hass.states.get(entity.entity_id).attributes[ATTR...
[ "async", "def", "async_api_initialize_camera_stream", "(", "hass", ",", "config", ",", "directive", ",", "context", ")", ":", "entity", "=", "directive", ".", "entity", "stream_source", "=", "await", "camera", ".", "async_request_stream", "(", "hass", ",", "enti...
[ 1531, 0 ]
[ 1565, 5 ]
python
en
['en', 'en', 'en']
True
test_reproducing_states
(hass, caplog)
Test reproducing Switch states.
Test reproducing Switch states.
async def test_reproducing_states(hass, caplog): """Test reproducing Switch states.""" hass.states.async_set("switch.entity_off", "off", {}) hass.states.async_set("switch.entity_on", "on", {}) turn_on_calls = async_mock_service(hass, "switch", "turn_on") turn_off_calls = async_mock_service(hass, "s...
[ "async", "def", "test_reproducing_states", "(", "hass", ",", "caplog", ")", ":", "hass", ".", "states", ".", "async_set", "(", "\"switch.entity_off\"", ",", "\"off\"", ",", "{", "}", ")", "hass", ".", "states", ".", "async_set", "(", "\"switch.entity_on\"", ...
[ 6, 0 ]
[ 47, 70 ]
python
en
['en', 'en', 'en']
True
get_pairs
(word)
Return set of symbol pairs in a word. Word is represented as tuple of symbols (symbols being variable-length strings).
Return set of symbol pairs in a word.
def get_pairs(word): """ Return set of symbol pairs in a word. Word is represented as tuple of symbols (symbols being variable-length strings). """ pairs = set() prev_char = word[0] for char in word[1:]: pairs.add((prev_char, char)) prev_char = char pairs = set(pairs) ...
[ "def", "get_pairs", "(", "word", ")", ":", "pairs", "=", "set", "(", ")", "prev_char", "=", "word", "[", "0", "]", "for", "char", "in", "word", "[", "1", ":", "]", ":", "pairs", ".", "add", "(", "(", "prev_char", ",", "char", ")", ")", "prev_ch...
[ 102, 0 ]
[ 115, 16 ]
python
en
['en', 'error', 'th']
False
CTRLTokenizer._tokenize
(self, text)
Tokenize a string.
Tokenize a string.
def _tokenize(self, text): """Tokenize a string.""" split_tokens = [] words = re.findall(r"\S+\n?", text) for token in words: split_tokens.extend([t for t in self.bpe(token).split(" ")]) return split_tokens
[ "def", "_tokenize", "(", "self", ",", "text", ")", ":", "split_tokens", "=", "[", "]", "words", "=", "re", ".", "findall", "(", "r\"\\S+\\n?\"", ",", "text", ")", "for", "token", "in", "words", ":", "split_tokens", ".", "extend", "(", "[", "t", "for"...
[ 203, 4 ]
[ 211, 27 ]
python
en
['en', 'gl', 'en']
True
CTRLTokenizer._convert_token_to_id
(self, token)
Converts a token (str) in an id using the vocab.
Converts a token (str) in an id using the vocab.
def _convert_token_to_id(self, token): """ Converts a token (str) in an id using the vocab. """ return self.encoder.get(token, self.encoder.get(self.unk_token))
[ "def", "_convert_token_to_id", "(", "self", ",", "token", ")", ":", "return", "self", ".", "encoder", ".", "get", "(", "token", ",", "self", ".", "encoder", ".", "get", "(", "self", ".", "unk_token", ")", ")" ]
[ 213, 4 ]
[ 215, 72 ]
python
en
['en', 'en', 'en']
True
CTRLTokenizer._convert_id_to_token
(self, index)
Converts an index (integer) in a token (str) using the vocab.
Converts an index (integer) in a token (str) using the vocab.
def _convert_id_to_token(self, index): """Converts an index (integer) in a token (str) using the vocab.""" return self.decoder.get(index, self.unk_token)
[ "def", "_convert_id_to_token", "(", "self", ",", "index", ")", ":", "return", "self", ".", "decoder", ".", "get", "(", "index", ",", "self", ".", "unk_token", ")" ]
[ 217, 4 ]
[ 219, 54 ]
python
en
['en', 'en', 'en']
True
CTRLTokenizer.convert_tokens_to_string
(self, tokens)
Converts a sequence of tokens (string) in a single string.
Converts a sequence of tokens (string) in a single string.
def convert_tokens_to_string(self, tokens): """ Converts a sequence of tokens (string) in a single string. """ out_string = " ".join(tokens).replace("@@ ", "").strip() return out_string
[ "def", "convert_tokens_to_string", "(", "self", ",", "tokens", ")", ":", "out_string", "=", "\" \"", ".", "join", "(", "tokens", ")", ".", "replace", "(", "\"@@ \"", ",", "\"\"", ")", ".", "strip", "(", ")", "return", "out_string" ]
[ 221, 4 ]
[ 224, 25 ]
python
en
['en', 'en', 'en']
True
get_mean_and_std
(dataset)
Compute the mean and std value of dataset.
Compute the mean and std value of dataset.
def get_mean_and_std(dataset): '''Compute the mean and std value of dataset.''' dataloader = torch.utils.data.DataLoader(dataset, batch_size=1, shuffle=True, num_workers=2) mean = torch.zeros(3) std = torch.zeros(3) print('==> Computing mean and std..') for inputs, targets in dataloader: ...
[ "def", "get_mean_and_std", "(", "dataset", ")", ":", "dataloader", "=", "torch", ".", "utils", ".", "data", ".", "DataLoader", "(", "dataset", ",", "batch_size", "=", "1", ",", "shuffle", "=", "True", ",", "num_workers", "=", "2", ")", "mean", "=", "to...
[ 14, 0 ]
[ 26, 20 ]
python
en
['en', 'en', 'en']
True
init_params
(net)
Init layer parameters.
Init layer parameters.
def init_params(net): '''Init layer parameters.''' for m in net.modules(): if isinstance(m, nn.Conv2d): init.kaiming_normal(m.weight, mode='fan_out') if m.bias: init.constant(m.bias, 0) elif isinstance(m, nn.BatchNorm2d): init.constant(m.weight...
[ "def", "init_params", "(", "net", ")", ":", "for", "m", "in", "net", ".", "modules", "(", ")", ":", "if", "isinstance", "(", "m", ",", "nn", ".", "Conv2d", ")", ":", "init", ".", "kaiming_normal", "(", "m", ".", "weight", ",", "mode", "=", "'fan_...
[ 28, 0 ]
[ 41, 40 ]
python
en
['en', 'id', 'en']
True
setType
(key, valueType)
check key type
check key type
def setType(key, valueType): '''check key type''' return And(valueType, error=SCHEMA_TYPE_ERROR % (key, valueType.__name__))
[ "def", "setType", "(", "key", ",", "valueType", ")", ":", "return", "And", "(", "valueType", ",", "error", "=", "SCHEMA_TYPE_ERROR", "%", "(", "key", ",", "valueType", ".", "__name__", ")", ")" ]
[ 19, 0 ]
[ 21, 78 ]
python
en
['en', 'ht', 'en']
True
setChoice
(key, *args)
check choice
check choice
def setChoice(key, *args): '''check choice''' return And(lambda n: n in args, error=SCHEMA_RANGE_ERROR % (key, str(args)))
[ "def", "setChoice", "(", "key", ",", "*", "args", ")", ":", "return", "And", "(", "lambda", "n", ":", "n", "in", "args", ",", "error", "=", "SCHEMA_RANGE_ERROR", "%", "(", "key", ",", "str", "(", "args", ")", ")", ")" ]
[ 24, 0 ]
[ 26, 80 ]
python
en
['en', 'fil', 'en']
False
setNumberRange
(key, keyType, start, end)
check number range
check number range
def setNumberRange(key, keyType, start, end): '''check number range''' return And( And(keyType, error=SCHEMA_TYPE_ERROR % (key, keyType.__name__)), And(lambda n: start <= n <= end, error=SCHEMA_RANGE_ERROR % (key, '(%s,%s)' % (start, end))), )
[ "def", "setNumberRange", "(", "key", ",", "keyType", ",", "start", ",", "end", ")", ":", "return", "And", "(", "And", "(", "keyType", ",", "error", "=", "SCHEMA_TYPE_ERROR", "%", "(", "key", ",", "keyType", ".", "__name__", ")", ")", ",", "And", "(",...
[ 29, 0 ]
[ 34, 5 ]
python
en
['en', 'da', 'en']
True
setPathCheck
(key)
check if path exist
check if path exist
def setPathCheck(key): '''check if path exist''' return And(os.path.exists, error=SCHEMA_PATH_ERROR % key)
[ "def", "setPathCheck", "(", "key", ")", ":", "return", "And", "(", "os", ".", "path", ".", "exists", ",", "error", "=", "SCHEMA_PATH_ERROR", "%", "key", ")" ]
[ 37, 0 ]
[ 39, 61 ]
python
en
['en', 'en', 'en']
True
AlgoSchema.__init__
(self, algo_type)
Parameters: ----------- algo_type: str One of ['tuner', 'assessor', 'advisor']. 'tuner': This AlgoSchema class create the schema of tuner section. 'assessor': This AlgoSchema class create the schema of assessor section. 'advisor': This AlgoSchema ...
Parameters: ----------- algo_type: str One of ['tuner', 'assessor', 'advisor']. 'tuner': This AlgoSchema class create the schema of tuner section. 'assessor': This AlgoSchema class create the schema of assessor section. 'advisor': This AlgoSchema ...
def __init__(self, algo_type): """ Parameters: ----------- algo_type: str One of ['tuner', 'assessor', 'advisor']. 'tuner': This AlgoSchema class create the schema of tuner section. 'assessor': This AlgoSchema class create the schema of assessor sectio...
[ "def", "__init__", "(", "self", ",", "algo_type", ")", ":", "assert", "algo_type", "in", "[", "'tuner'", ",", "'assessor'", ",", "'advisor'", "]", "self", ".", "algo_type", "=", "algo_type", "self", ".", "algo_schema", "=", "{", "Optional", "(", "'codeDir'...
[ 49, 4 ]
[ 78, 77 ]
python
en
['en', 'error', 'th']
False
NNIConfigSchema.validate_search_space_content
(self, experiment_config)
Validate searchspace content, if the searchspace file is not json format or its values does not contain _type and _value which must be specified, it will not be a valid searchspace file
Validate searchspace content, if the searchspace file is not json format or its values does not contain _type and _value which must be specified, it will not be a valid searchspace file
def validate_search_space_content(self, experiment_config): '''Validate searchspace content, if the searchspace file is not json format or its values does not contain _type and _value which must be specified, it will not be a valid searchspace file''' try: search_space_conten...
[ "def", "validate_search_space_content", "(", "self", ",", "experiment_config", ")", ":", "try", ":", "search_space_content", "=", "json", ".", "load", "(", "open", "(", "experiment_config", ".", "get", "(", "'searchSpacePath'", ")", ",", "'r'", ")", ")", "for"...
[ 509, 4 ]
[ 519, 87 ]
python
en
['de', 'en', 'en']
True
NNIConfigSchema.validate_kubeflow_operators
(self, experiment_config)
Validate whether the kubeflow operators are valid
Validate whether the kubeflow operators are valid
def validate_kubeflow_operators(self, experiment_config): '''Validate whether the kubeflow operators are valid''' if experiment_config.get('kubeflowConfig'): if experiment_config.get('kubeflowConfig').get('operator') == 'tf-operator': if experiment_config.get('trial').get('ma...
[ "def", "validate_kubeflow_operators", "(", "self", ",", "experiment_config", ")", ":", "if", "experiment_config", ".", "get", "(", "'kubeflowConfig'", ")", ":", "if", "experiment_config", ".", "get", "(", "'kubeflowConfig'", ")", ".", "get", "(", "'operator'", "...
[ 521, 4 ]
[ 543, 65 ]
python
en
['en', 'en', 'en']
True
NNIConfigSchema.validate_annotation_content
(self, experiment_config, spec_key, builtin_name)
Valid whether useAnnotation and searchSpacePath is coexist spec_key: 'advisor' or 'tuner' builtin_name: 'builtinAdvisorName' or 'builtinTunerName'
Valid whether useAnnotation and searchSpacePath is coexist spec_key: 'advisor' or 'tuner' builtin_name: 'builtinAdvisorName' or 'builtinTunerName'
def validate_annotation_content(self, experiment_config, spec_key, builtin_name): ''' Valid whether useAnnotation and searchSpacePath is coexist spec_key: 'advisor' or 'tuner' builtin_name: 'builtinAdvisorName' or 'builtinTunerName' ''' if experiment_config.get('useAnnota...
[ "def", "validate_annotation_content", "(", "self", ",", "experiment_config", ",", "spec_key", ",", "builtin_name", ")", ":", "if", "experiment_config", ".", "get", "(", "'useAnnotation'", ")", ":", "if", "experiment_config", ".", "get", "(", "'searchSpacePath'", "...
[ 545, 4 ]
[ 561, 69 ]
python
en
['en', 'error', 'th']
False
NNIConfigSchema.validate_pai_config_path
(self, experiment_config)
validate paiConfigPath field
validate paiConfigPath field
def validate_pai_config_path(self, experiment_config): '''validate paiConfigPath field''' if experiment_config.get('trainingServicePlatform') == 'pai': if experiment_config.get('trial', {}).get('paiConfigPath'): # validate commands pai_config = get_yml_content...
[ "def", "validate_pai_config_path", "(", "self", ",", "experiment_config", ")", ":", "if", "experiment_config", ".", "get", "(", "'trainingServicePlatform'", ")", "==", "'pai'", ":", "if", "experiment_config", ".", "get", "(", "'trial'", ",", "{", "}", ")", "."...
[ 563, 4 ]
[ 583, 124 ]
python
en
['en', 'ky', 'ur']
False
NNIConfigSchema.validate_pai_trial_conifg
(self, experiment_config)
validate the trial config in pai platform
validate the trial config in pai platform
def validate_pai_trial_conifg(self, experiment_config): '''validate the trial config in pai platform''' if experiment_config.get('trainingServicePlatform') in ['pai']: if experiment_config.get('trial').get('shmMB') and \ experiment_config['trial']['shmMB'] > experiment_co...
[ "def", "validate_pai_trial_conifg", "(", "self", ",", "experiment_config", ")", ":", "if", "experiment_config", ".", "get", "(", "'trainingServicePlatform'", ")", "in", "[", "'pai'", "]", ":", "if", "experiment_config", ".", "get", "(", "'trial'", ")", ".", "g...
[ 585, 4 ]
[ 599, 60 ]
python
en
['en', 'en', 'en']
True
NNIConfigSchema.validate_eth0_device
(self, experiment_config)
validate whether the machine has eth0 device
validate whether the machine has eth0 device
def validate_eth0_device(self, experiment_config): '''validate whether the machine has eth0 device''' if experiment_config.get('trainingServicePlatform') not in ['local'] \ and not experiment_config.get('nniManagerIp') \ and 'eth0' not in netifaces.interfaces(): ...
[ "def", "validate_eth0_device", "(", "self", ",", "experiment_config", ")", ":", "if", "experiment_config", ".", "get", "(", "'trainingServicePlatform'", ")", "not", "in", "[", "'local'", "]", "and", "not", "experiment_config", ".", "get", "(", "'nniManagerIp'", ...
[ 601, 4 ]
[ 606, 123 ]
python
en
['en', 'en', 'en']
True
main_loop
(args)
main loop logic for trial keeper
main loop logic for trial keeper
def main_loop(args): '''main loop logic for trial keeper''' global _trial_process if not os.path.exists(LOG_DIR): os.makedirs(LOG_DIR) trial_keeper_syslogger = RemoteLogger(args.nnimanager_ip, args.nnimanager_port, 'trial_keeper', StdOutputType.Stdout,...
[ "def", "main_loop", "(", "args", ")", ":", "global", "_trial_process", "if", "not", "os", ".", "path", ".", "exists", "(", "LOG_DIR", ")", ":", "os", ".", "makedirs", "(", "LOG_DIR", ")", "trial_keeper_syslogger", "=", "RemoteLogger", "(", "args", ".", "...
[ 63, 0 ]
[ 128, 21 ]
python
en
['en', 'af', 'en']
True
download_parameter
(meta_list, args)
Download parameter file to local working directory. meta_list format is defined in paiJobRestServer.ts example meta_list: [ {"experimentId":"yWFJarYa","trialId":"UpPkl","filePath":"/chec/nni/experiments/yWFJarYa/trials/UpPkl/parameter_1.cfg"}, {"experimentId":"yWFJarYa","trialId":"aIUMA...
Download parameter file to local working directory. meta_list format is defined in paiJobRestServer.ts example meta_list: [ {"experimentId":"yWFJarYa","trialId":"UpPkl","filePath":"/chec/nni/experiments/yWFJarYa/trials/UpPkl/parameter_1.cfg"}, {"experimentId":"yWFJarYa","trialId":"aIUMA...
def download_parameter(meta_list, args): """ Download parameter file to local working directory. meta_list format is defined in paiJobRestServer.ts example meta_list: [ {"experimentId":"yWFJarYa","trialId":"UpPkl","filePath":"/chec/nni/experiments/yWFJarYa/trials/UpPkl/parameter_1.cfg"}, ...
[ "def", "download_parameter", "(", "meta_list", ",", "args", ")", ":", "nni_log", "(", "LogType", ".", "Debug", ",", "str", "(", "meta_list", ")", ")", "nni_log", "(", "LogType", ".", "Debug", ",", "'NNI_SYS_DIR: {}, trial Id: {}, experiment ID: {}'", ".", "forma...
[ 173, 0 ]
[ 192, 92 ]
python
en
['en', 'error', 'th']
False
test_validating_mfa
(hass)
Test validating mfa code.
Test validating mfa code.
async def test_validating_mfa(hass): """Test validating mfa code.""" notify_auth_module = await auth_mfa_module_from_config(hass, {"type": "notify"}) await notify_auth_module.async_setup_user("test-user", {"notify_service": "dummy"}) with patch("pyotp.HOTP.verify", return_value=True): assert aw...
[ "async", "def", "test_validating_mfa", "(", "hass", ")", ":", "notify_auth_module", "=", "await", "auth_mfa_module_from_config", "(", "hass", ",", "{", "\"type\"", ":", "\"notify\"", "}", ")", "await", "notify_auth_module", ".", "async_setup_user", "(", "\"test-user...
[ 15, 0 ]
[ 21, 88 ]
python
en
['en', 'sn', 'en']
True
test_validating_mfa_invalid_code
(hass)
Test validating an invalid mfa code.
Test validating an invalid mfa code.
async def test_validating_mfa_invalid_code(hass): """Test validating an invalid mfa code.""" notify_auth_module = await auth_mfa_module_from_config(hass, {"type": "notify"}) await notify_auth_module.async_setup_user("test-user", {"notify_service": "dummy"}) with patch("pyotp.HOTP.verify", return_value=...
[ "async", "def", "test_validating_mfa_invalid_code", "(", "hass", ")", ":", "notify_auth_module", "=", "await", "auth_mfa_module_from_config", "(", "hass", ",", "{", "\"type\"", ":", "\"notify\"", "}", ")", "await", "notify_auth_module", ".", "async_setup_user", "(", ...
[ 24, 0 ]
[ 33, 9 ]
python
en
['en', 'en', 'nl']
True
test_validating_mfa_invalid_user
(hass)
Test validating an mfa code with invalid user.
Test validating an mfa code with invalid user.
async def test_validating_mfa_invalid_user(hass): """Test validating an mfa code with invalid user.""" notify_auth_module = await auth_mfa_module_from_config(hass, {"type": "notify"}) await notify_auth_module.async_setup_user("test-user", {"notify_service": "dummy"}) assert ( await notify_auth_...
[ "async", "def", "test_validating_mfa_invalid_user", "(", "hass", ")", ":", "notify_auth_module", "=", "await", "auth_mfa_module_from_config", "(", "hass", ",", "{", "\"type\"", ":", "\"notify\"", "}", ")", "await", "notify_auth_module", ".", "async_setup_user", "(", ...
[ 36, 0 ]
[ 44, 5 ]
python
en
['en', 'en', 'en']
True
test_validating_mfa_counter
(hass)
Test counter will move only after generate code.
Test counter will move only after generate code.
async def test_validating_mfa_counter(hass): """Test counter will move only after generate code.""" notify_auth_module = await auth_mfa_module_from_config(hass, {"type": "notify"}) await notify_auth_module.async_setup_user( "test-user", {"counter": 0, "notify_service": "dummy"} ) async_mock_...
[ "async", "def", "test_validating_mfa_counter", "(", "hass", ")", ":", "notify_auth_module", "=", "await", "auth_mfa_module_from_config", "(", "hass", ",", "{", "\"type\"", ":", "\"notify\"", "}", ")", "await", "notify_auth_module", ".", "async_setup_user", "(", "\"t...
[ 47, 0 ]
[ 80, 57 ]
python
en
['en', 'en', 'en']
True
test_setup_depose_user
(hass)
Test set up and despose user.
Test set up and despose user.
async def test_setup_depose_user(hass): """Test set up and despose user.""" notify_auth_module = await auth_mfa_module_from_config(hass, {"type": "notify"}) await notify_auth_module.async_setup_user("test-user", {}) assert len(notify_auth_module._user_settings) == 1 await notify_auth_module.async_se...
[ "async", "def", "test_setup_depose_user", "(", "hass", ")", ":", "notify_auth_module", "=", "await", "auth_mfa_module_from_config", "(", "hass", ",", "{", "\"type\"", ":", "\"notify\"", "}", ")", "await", "notify_auth_module", ".", "async_setup_user", "(", "\"test-u...
[ 83, 0 ]
[ 95, 54 ]
python
en
['en', 'en', 'en']
True
test_login_flow_validates_mfa
(hass)
Test login flow with mfa enabled.
Test login flow with mfa enabled.
async def test_login_flow_validates_mfa(hass): """Test login flow with mfa enabled.""" hass.auth = await auth_manager_from_config( hass, [ { "type": "insecure_example", "users": [{"username": "test-user", "password": "test-pass"}], } ...
[ "async", "def", "test_login_flow_validates_mfa", "(", "hass", ")", ":", "hass", ".", "auth", "=", "await", "auth_manager_from_config", "(", "hass", ",", "[", "{", "\"type\"", ":", "\"insecure_example\"", ",", "\"users\"", ":", "[", "{", "\"username\"", ":", "\...
[ 98, 0 ]
[ 231, 47 ]
python
en
['en', 'en', 'en']
True
test_setup_user_notify_service
(hass)
Test allow select notify service during mfa setup.
Test allow select notify service during mfa setup.
async def test_setup_user_notify_service(hass): """Test allow select notify service during mfa setup.""" notify_calls = async_mock_service(hass, "notify", "test1", NOTIFY_SERVICE_SCHEMA) async_mock_service(hass, "notify", "test2", NOTIFY_SERVICE_SCHEMA) notify_auth_module = await auth_mfa_module_from_co...
[ "async", "def", "test_setup_user_notify_service", "(", "hass", ")", ":", "notify_calls", "=", "async_mock_service", "(", "hass", ",", "\"notify\"", ",", "\"test1\"", ",", "NOTIFY_SERVICE_SCHEMA", ")", "async_mock_service", "(", "hass", ",", "\"notify\"", ",", "\"tes...
[ 234, 0 ]
[ 285, 71 ]
python
en
['en', 'en', 'en']
True
test_include_exclude_config
(hass)
Test allow include exclude config.
Test allow include exclude config.
async def test_include_exclude_config(hass): """Test allow include exclude config.""" async_mock_service(hass, "notify", "include1", NOTIFY_SERVICE_SCHEMA) async_mock_service(hass, "notify", "include2", NOTIFY_SERVICE_SCHEMA) async_mock_service(hass, "notify", "exclude1", NOTIFY_SERVICE_SCHEMA) asyn...
[ "async", "def", "test_include_exclude_config", "(", "hass", ")", ":", "async_mock_service", "(", "hass", ",", "\"notify\"", ",", "\"include1\"", ",", "NOTIFY_SERVICE_SCHEMA", ")", "async_mock_service", "(", "hass", ",", "\"notify\"", ",", "\"include2\"", ",", "NOTIF...
[ 288, 0 ]
[ 319, 35 ]
python
en
['en', 'en', 'en']
True
test_setup_user_no_notify_service
(hass)
Test setup flow abort if there is no available notify service.
Test setup flow abort if there is no available notify service.
async def test_setup_user_no_notify_service(hass): """Test setup flow abort if there is no available notify service.""" async_mock_service(hass, "notify", "test1", NOTIFY_SERVICE_SCHEMA) notify_auth_module = await auth_mfa_module_from_config( hass, {"type": "notify", "exclude": "test1"} ) s...
[ "async", "def", "test_setup_user_no_notify_service", "(", "hass", ")", ":", "async_mock_service", "(", "hass", ",", "\"notify\"", ",", "\"test1\"", ",", "NOTIFY_SERVICE_SCHEMA", ")", "notify_auth_module", "=", "await", "auth_mfa_module_from_config", "(", "hass", ",", ...
[ 322, 0 ]
[ 335, 51 ]
python
en
['en', 'en', 'en']
True
test_not_raise_exception_when_service_not_exist
(hass)
Test login flow will not raise exception when notify service error.
Test login flow will not raise exception when notify service error.
async def test_not_raise_exception_when_service_not_exist(hass): """Test login flow will not raise exception when notify service error.""" hass.auth = await auth_manager_from_config( hass, [ { "type": "insecure_example", "users": [{"username": "test-us...
[ "async", "def", "test_not_raise_exception_when_service_not_exist", "(", "hass", ")", ":", "hass", ".", "auth", "=", "await", "auth_manager_from_config", "(", "hass", ",", "[", "{", "\"type\"", ":", "\"insecure_example\"", ",", "\"users\"", ":", "[", "{", "\"userna...
[ 338, 0 ]
[ 381, 38 ]
python
en
['en', 'de', 'en']
True
test_race_condition_in_data_loading
(hass)
Test race condition in the data loading.
Test race condition in the data loading.
async def test_race_condition_in_data_loading(hass): """Test race condition in the data loading.""" counter = 0 async def mock_load(_): """Mock homeassistant.helpers.storage.Store.async_load.""" nonlocal counter counter += 1 await asyncio.sleep(0) notify_auth_module = a...
[ "async", "def", "test_race_condition_in_data_loading", "(", "hass", ")", ":", "counter", "=", "0", "async", "def", "mock_load", "(", "_", ")", ":", "\"\"\"Mock homeassistant.helpers.storage.Store.async_load.\"\"\"", "nonlocal", "counter", "counter", "+=", "1", "await", ...
[ 384, 0 ]
[ 401, 34 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_devices, discovery_info=None)
Set up the Environment Canada camera.
Set up the Environment Canada camera.
def setup_platform(hass, config, add_devices, discovery_info=None): """Set up the Environment Canada camera.""" if config.get(CONF_STATION): radar_object = ECRadar( station_id=config[CONF_STATION], precip_type=config.get(CONF_PRECIP_TYPE) ) else: lat = config.get(CONF_LA...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_devices", ",", "discovery_info", "=", "None", ")", ":", "if", "config", ".", "get", "(", "CONF_STATION", ")", ":", "radar_object", "=", "ECRadar", "(", "station_id", "=", "config", "[", "CONF_S...
[ 37, 0 ]
[ 53, 5 ]
python
en
['en', 'fil', 'en']
True
ECCamera.__init__
(self, radar_object, camera_name, is_loop)
Initialize the camera.
Initialize the camera.
def __init__(self, radar_object, camera_name, is_loop): """Initialize the camera.""" super().__init__() self.radar_object = radar_object self.camera_name = camera_name self.is_loop = is_loop self.content_type = "image/gif" self.image = None self.timestamp...
[ "def", "__init__", "(", "self", ",", "radar_object", ",", "camera_name", ",", "is_loop", ")", ":", "super", "(", ")", ".", "__init__", "(", ")", "self", ".", "radar_object", "=", "radar_object", "self", ".", "camera_name", "=", "camera_name", "self", ".", ...
[ 59, 4 ]
[ 68, 29 ]
python
en
['en', 'en', 'en']
True
ECCamera.camera_image
(self)
Return bytes of camera image.
Return bytes of camera image.
def camera_image(self): """Return bytes of camera image.""" self.update() return self.image
[ "def", "camera_image", "(", "self", ")", ":", "self", ".", "update", "(", ")", "return", "self", ".", "image" ]
[ 70, 4 ]
[ 73, 25 ]
python
en
['en', 'zu', 'en']
True
ECCamera.name
(self)
Return the name of the camera.
Return the name of the camera.
def name(self): """Return the name of the camera.""" if self.camera_name is not None: return self.camera_name return "Environment Canada Radar"
[ "def", "name", "(", "self", ")", ":", "if", "self", ".", "camera_name", "is", "not", "None", ":", "return", "self", ".", "camera_name", "return", "\"Environment Canada Radar\"" ]
[ 76, 4 ]
[ 80, 41 ]
python
en
['en', 'en', 'en']
True
ECCamera.device_state_attributes
(self)
Return the state attributes of the device.
Return the state attributes of the device.
def device_state_attributes(self): """Return the state attributes of the device.""" return {ATTR_ATTRIBUTION: CONF_ATTRIBUTION, ATTR_UPDATED: self.timestamp}
[ "def", "device_state_attributes", "(", "self", ")", ":", "return", "{", "ATTR_ATTRIBUTION", ":", "CONF_ATTRIBUTION", ",", "ATTR_UPDATED", ":", "self", ".", "timestamp", "}" ]
[ 83, 4 ]
[ 85, 81 ]
python
en
['en', 'en', 'en']
True
ECCamera.update
(self)
Update radar image.
Update radar image.
def update(self): """Update radar image.""" if self.is_loop: self.image = self.radar_object.get_loop() else: self.image = self.radar_object.get_latest_frame() self.timestamp = self.radar_object.timestamp
[ "def", "update", "(", "self", ")", ":", "if", "self", ".", "is_loop", ":", "self", ".", "image", "=", "self", ".", "radar_object", ".", "get_loop", "(", ")", "else", ":", "self", ".", "image", "=", "self", ".", "radar_object", ".", "get_latest_frame", ...
[ 88, 4 ]
[ 94, 52 ]
python
en
['es', 'id', 'en']
False
threaded_listener_factory
(async_factory: Callable[..., Any])
Convert an async event helper to a threaded one.
Convert an async event helper to a threaded one.
def threaded_listener_factory(async_factory: Callable[..., Any]) -> CALLBACK_TYPE: """Convert an async event helper to a threaded one.""" @ft.wraps(async_factory) def factory(*args: Any, **kwargs: Any) -> CALLBACK_TYPE: """Call async event helper safely.""" hass = args[0] if not is...
[ "def", "threaded_listener_factory", "(", "async_factory", ":", "Callable", "[", "...", ",", "Any", "]", ")", "->", "CALLBACK_TYPE", ":", "@", "ft", ".", "wraps", "(", "async_factory", ")", "def", "factory", "(", "*", "args", ":", "Any", ",", "*", "*", ...
[ 118, 0 ]
[ 139, 18 ]
python
en
['en', 'lb', 'en']
True
async_track_state_change
( hass: HomeAssistant, entity_ids: Union[str, Iterable[str]], action: Callable[[str, State, State], None], from_state: Union[None, str, Iterable[str]] = None, to_state: Union[None, str, Iterable[str]] = None, )
Track specific state changes. entity_ids, from_state and to_state can be string or list. Use list to match multiple. Returns a function that can be called to remove the listener. If entity_ids are not MATCH_ALL along with from_state and to_state being None, async_track_state_change_event should b...
Track specific state changes.
def async_track_state_change( hass: HomeAssistant, entity_ids: Union[str, Iterable[str]], action: Callable[[str, State, State], None], from_state: Union[None, str, Iterable[str]] = None, to_state: Union[None, str, Iterable[str]] = None, ) -> CALLBACK_TYPE: """Track specific state changes. e...
[ "def", "async_track_state_change", "(", "hass", ":", "HomeAssistant", ",", "entity_ids", ":", "Union", "[", "str", ",", "Iterable", "[", "str", "]", "]", ",", "action", ":", "Callable", "[", "[", "str", ",", "State", ",", "State", "]", ",", "None", "]"...
[ 144, 0 ]
[ 215, 76 ]
python
en
['en', 'en', 'en']
True
async_track_state_change_event
( hass: HomeAssistant, entity_ids: Union[str, Iterable[str]], action: Callable[[Event], Any], )
Track specific state change events indexed by entity_id. Unlike async_track_state_change, async_track_state_change_event passes the full event to the callback. In order to avoid having to iterate a long list of EVENT_STATE_CHANGED and fire and create a job for each one, we keep a dict of entity id...
Track specific state change events indexed by entity_id.
def async_track_state_change_event( hass: HomeAssistant, entity_ids: Union[str, Iterable[str]], action: Callable[[Event], Any], ) -> Callable[[], None]: """Track specific state change events indexed by entity_id. Unlike async_track_state_change, async_track_state_change_event passes the full ev...
[ "def", "async_track_state_change_event", "(", "hass", ":", "HomeAssistant", ",", "entity_ids", ":", "Union", "[", "str", ",", "Iterable", "[", "str", "]", "]", ",", "action", ":", "Callable", "[", "[", "Event", "]", ",", "Any", "]", ",", ")", "->", "Ca...
[ 222, 0 ]
[ 282, 26 ]
python
en
['en', 'en', 'en']
True
_remove_empty_listener
()
Remove a listener that does nothing.
Remove a listener that does nothing.
def _remove_empty_listener() -> None: """Remove a listener that does nothing."""
[ "def", "_remove_empty_listener", "(", ")", "->", "None", ":" ]
[ 286, 0 ]
[ 287, 46 ]
python
en
['en', 'en', 'en']
True
_async_remove_indexed_listeners
( hass: HomeAssistant, data_key: str, listener_key: str, storage_keys: Iterable[str], job: HassJob, )
Remove a listener.
Remove a listener.
def _async_remove_indexed_listeners( hass: HomeAssistant, data_key: str, listener_key: str, storage_keys: Iterable[str], job: HassJob, ) -> None: """Remove a listener.""" callbacks = hass.data[data_key] for storage_key in storage_keys: callbacks[storage_key].remove(job) ...
[ "def", "_async_remove_indexed_listeners", "(", "hass", ":", "HomeAssistant", ",", "data_key", ":", "str", ",", "listener_key", ":", "str", ",", "storage_keys", ":", "Iterable", "[", "str", "]", ",", "job", ":", "HassJob", ",", ")", "->", "None", ":", "call...
[ 291, 0 ]
[ 309, 35 ]
python
en
['es', 'it', 'en']
False
async_track_entity_registry_updated_event
( hass: HomeAssistant, entity_ids: Union[str, Iterable[str]], action: Callable[[Event], Any], )
Track specific entity registry updated events indexed by entity_id. Similar to async_track_state_change_event.
Track specific entity registry updated events indexed by entity_id.
def async_track_entity_registry_updated_event( hass: HomeAssistant, entity_ids: Union[str, Iterable[str]], action: Callable[[Event], Any], ) -> Callable[[], None]: """Track specific entity registry updated events indexed by entity_id. Similar to async_track_state_change_event. """ entity_id...
[ "def", "async_track_entity_registry_updated_event", "(", "hass", ":", "HomeAssistant", ",", "entity_ids", ":", "Union", "[", "str", ",", "Iterable", "[", "str", "]", "]", ",", "action", ":", "Callable", "[", "[", "Event", "]", ",", "Any", "]", ",", ")", ...
[ 313, 0 ]
[ 367, 26 ]
python
en
['en', 'en', 'en']
True
async_track_state_added_domain
( hass: HomeAssistant, domains: Union[str, Iterable[str]], action: Callable[[Event], Any], )
Track state change events when an entity is added to domains.
Track state change events when an entity is added to domains.
def async_track_state_added_domain( hass: HomeAssistant, domains: Union[str, Iterable[str]], action: Callable[[Event], Any], ) -> Callable[[], None]: """Track state change events when an entity is added to domains.""" domains = _async_string_to_lower_list(domains) if not domains: return ...
[ "def", "async_track_state_added_domain", "(", "hass", ":", "HomeAssistant", ",", "domains", ":", "Union", "[", "str", ",", "Iterable", "[", "str", "]", "]", ",", "action", ":", "Callable", "[", "[", "Event", "]", ",", "Any", "]", ",", ")", "->", "Calla...
[ 391, 0 ]
[ 433, 26 ]
python
en
['en', 'en', 'en']
True
async_track_state_removed_domain
( hass: HomeAssistant, domains: Union[str, Iterable[str]], action: Callable[[Event], Any], )
Track state change events when an entity is removed from domains.
Track state change events when an entity is removed from domains.
def async_track_state_removed_domain( hass: HomeAssistant, domains: Union[str, Iterable[str]], action: Callable[[Event], Any], ) -> Callable[[], None]: """Track state change events when an entity is removed from domains.""" domains = _async_string_to_lower_list(domains) if not domains: r...
[ "def", "async_track_state_removed_domain", "(", "hass", ":", "HomeAssistant", ",", "domains", ":", "Union", "[", "str", ",", "Iterable", "[", "str", "]", "]", ",", "action", ":", "Callable", "[", "[", "Event", "]", ",", "Any", "]", ",", ")", "->", "Cal...
[ 437, 0 ]
[ 479, 26 ]
python
en
['en', 'en', 'en']
True
async_track_state_change_filtered
( hass: HomeAssistant, track_states: TrackStates, action: Callable[[Event], Any], )
Track state changes with a TrackStates filter that can be updated. Parameters ---------- hass Home assistant object. track_states A TrackStates data class. action Callable to call with results. Returns ------- Object used to update the listeners (async_update_li...
Track state changes with a TrackStates filter that can be updated.
def async_track_state_change_filtered( hass: HomeAssistant, track_states: TrackStates, action: Callable[[Event], Any], ) -> _TrackStateChangeFiltered: """Track state changes with a TrackStates filter that can be updated. Parameters ---------- hass Home assistant object. track_st...
[ "def", "async_track_state_change_filtered", "(", "hass", ":", "HomeAssistant", ",", "track_states", ":", "TrackStates", ",", "action", ":", "Callable", "[", "[", "Event", "]", ",", "Any", "]", ",", ")", "->", "_TrackStateChangeFiltered", ":", "tracker", "=", "...
[ 615, 0 ]
[ 639, 18 ]
python
en
['en', 'en', 'en']
True
async_track_template
( hass: HomeAssistant, template: Template, action: Callable[[str, Optional[State], Optional[State]], None], variables: Optional[TemplateVarsType] = None, )
Add a listener that fires when a a template evaluates to 'true'. Listen for the result of the template becoming true, or a true-like string result, such as 'On', 'Open', or 'Yes'. If the template results in an error state when the value changes, this will be logged and not passed through. If the i...
Add a listener that fires when a a template evaluates to 'true'.
def async_track_template( hass: HomeAssistant, template: Template, action: Callable[[str, Optional[State], Optional[State]], None], variables: Optional[TemplateVarsType] = None, ) -> Callable[[], None]: """Add a listener that fires when a a template evaluates to 'true'. Listen for the result of...
[ "def", "async_track_template", "(", "hass", ":", "HomeAssistant", ",", "template", ":", "Template", ",", "action", ":", "Callable", "[", "[", "str", ",", "Optional", "[", "State", "]", ",", "Optional", "[", "State", "]", "]", ",", "None", "]", ",", "va...
[ 644, 0 ]
[ 726, 28 ]
python
en
['en', 'en', 'en']
True
async_track_template_result
( hass: HomeAssistant, track_templates: Iterable[TrackTemplate], action: TrackTemplateResultListener, raise_on_template_error: bool = False, )
Add a listener that fires when the result of a template changes. The action will fire with the initial result from the template, and then whenever the output from the template changes. The template will be reevaluated if any states referenced in the last run of the template change, or if manually trigg...
Add a listener that fires when the result of a template changes.
def async_track_template_result( hass: HomeAssistant, track_templates: Iterable[TrackTemplate], action: TrackTemplateResultListener, raise_on_template_error: bool = False, ) -> _TrackTemplateResultInfo: """Add a listener that fires when the result of a template changes. The action will fire wit...
[ "def", "async_track_template_result", "(", "hass", ":", "HomeAssistant", ",", "track_templates", ":", "Iterable", "[", "TrackTemplate", "]", ",", "action", ":", "TrackTemplateResultListener", ",", "raise_on_template_error", ":", "bool", "=", "False", ",", ")", "->",...
[ 983, 0 ]
[ 1024, 18 ]
python
en
['en', 'en', 'en']
True
async_track_same_state
( hass: HomeAssistant, period: timedelta, action: Callable[..., None], async_check_same_func: Callable[[str, Optional[State], Optional[State]], bool], entity_ids: Union[str, Iterable[str]] = MATCH_ALL, )
Track the state of entities for a period and run an action. If async_check_func is None it use the state of orig_value. Without entity_ids we track all state changes.
Track the state of entities for a period and run an action.
def async_track_same_state( hass: HomeAssistant, period: timedelta, action: Callable[..., None], async_check_same_func: Callable[[str, Optional[State], Optional[State]], bool], entity_ids: Union[str, Iterable[str]] = MATCH_ALL, ) -> CALLBACK_TYPE: """Track the state of entities for a period and ...
[ "def", "async_track_same_state", "(", "hass", ":", "HomeAssistant", ",", "period", ":", "timedelta", ",", "action", ":", "Callable", "[", "...", ",", "None", "]", ",", "async_check_same_func", ":", "Callable", "[", "[", "str", ",", "Optional", "[", "State", ...
[ 1029, 0 ]
[ 1091, 25 ]
python
en
['en', 'en', 'en']
True
async_track_point_in_time
( hass: HomeAssistant, action: Union[HassJob, Callable[..., None]], point_in_time: datetime, )
Add a listener that fires once after a specific point in time.
Add a listener that fires once after a specific point in time.
def async_track_point_in_time( hass: HomeAssistant, action: Union[HassJob, Callable[..., None]], point_in_time: datetime, ) -> CALLBACK_TYPE: """Add a listener that fires once after a specific point in time.""" job = action if isinstance(action, HassJob) else HassJob(action) @callback def ...
[ "def", "async_track_point_in_time", "(", "hass", ":", "HomeAssistant", ",", "action", ":", "Union", "[", "HassJob", ",", "Callable", "[", "...", ",", "None", "]", "]", ",", "point_in_time", ":", "datetime", ",", ")", "->", "CALLBACK_TYPE", ":", "job", "=",...
[ 1099, 0 ]
[ 1113, 76 ]
python
en
['en', 'en', 'en']
True
async_track_point_in_utc_time
( hass: HomeAssistant, action: Union[HassJob, Callable[..., None]], point_in_time: datetime, )
Add a listener that fires once after a specific point in UTC time.
Add a listener that fires once after a specific point in UTC time.
def async_track_point_in_utc_time( hass: HomeAssistant, action: Union[HassJob, Callable[..., None]], point_in_time: datetime, ) -> CALLBACK_TYPE: """Add a listener that fires once after a specific point in UTC time.""" # Ensure point_in_time is UTC utc_point_in_time = dt_util.as_utc(point_in_tim...
[ "def", "async_track_point_in_utc_time", "(", "hass", ":", "HomeAssistant", ",", "action", ":", "Union", "[", "HassJob", ",", "Callable", "[", "...", ",", "None", "]", "]", ",", "point_in_time", ":", "datetime", ",", ")", "->", "CALLBACK_TYPE", ":", "# Ensure...
[ 1121, 0 ]
[ 1166, 39 ]
python
en
['en', 'en', 'en']
True
async_call_later
( hass: HomeAssistant, delay: float, action: Union[HassJob, Callable[..., None]] )
Add a listener that is called in <delay>.
Add a listener that is called in <delay>.
def async_call_later( hass: HomeAssistant, delay: float, action: Union[HassJob, Callable[..., None]] ) -> CALLBACK_TYPE: """Add a listener that is called in <delay>.""" return async_track_point_in_utc_time( hass, action, dt_util.utcnow() + timedelta(seconds=delay) )
[ "def", "async_call_later", "(", "hass", ":", "HomeAssistant", ",", "delay", ":", "float", ",", "action", ":", "Union", "[", "HassJob", ",", "Callable", "[", "...", ",", "None", "]", "]", ")", "->", "CALLBACK_TYPE", ":", "return", "async_track_point_in_utc_ti...
[ 1174, 0 ]
[ 1180, 5 ]
python
en
['en', 'en', 'en']
True