Search is not available for this dataset
identifier
stringlengths 1
155
| parameters
stringlengths 2
6.09k
| docstring
stringlengths 11
63.4k
| docstring_summary
stringlengths 0
63.4k
| function
stringlengths 29
99.8k
| function_tokens
sequence | start_point
sequence | end_point
sequence | language
stringclasses 1
value | docstring_language
stringlengths 2
7
| docstring_language_predictions
stringlengths 18
23
| is_langid_reliable
stringclasses 2
values |
---|---|---|---|---|---|---|---|---|---|---|---|
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Dyson fan components. | Set up the Dyson fan components. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Dyson fan components."""
if discovery_info is None:
return
_LOGGER.debug("Creating new Dyson fans")
if DYSON_FAN_DEVICES not in hass.data:
hass.data[DYSON_FAN_DEVICES] = []
# Get Dyson Devices from parent component
has_purecool_devices = False
device_serials = [device.serial for device in hass.data[DYSON_FAN_DEVICES]]
for device in hass.data[DYSON_DEVICES]:
if device.serial not in device_serials:
if isinstance(device, DysonPureCool):
has_purecool_devices = True
dyson_entity = DysonPureCoolDevice(device)
hass.data[DYSON_FAN_DEVICES].append(dyson_entity)
elif isinstance(device, DysonPureCoolLink):
dyson_entity = DysonPureCoolLinkDevice(hass, device)
hass.data[DYSON_FAN_DEVICES].append(dyson_entity)
add_entities(hass.data[DYSON_FAN_DEVICES])
def service_handle(service):
"""Handle the Dyson services."""
entity_id = service.data[ATTR_ENTITY_ID]
fan_device = next(
(fan for fan in hass.data[DYSON_FAN_DEVICES] if fan.entity_id == entity_id),
None,
)
if fan_device is None:
_LOGGER.warning("Unable to find Dyson fan device %s", str(entity_id))
return
if service.service == SERVICE_SET_NIGHT_MODE:
fan_device.set_night_mode(service.data[ATTR_NIGHT_MODE])
if service.service == SERVICE_SET_AUTO_MODE:
fan_device.set_auto_mode(service.data[ATTR_AUTO_MODE])
if service.service == SERVICE_SET_ANGLE:
fan_device.set_angle(
service.data[ATTR_ANGLE_LOW], service.data[ATTR_ANGLE_HIGH]
)
if service.service == SERVICE_SET_FLOW_DIRECTION_FRONT:
fan_device.set_flow_direction_front(service.data[ATTR_FLOW_DIRECTION_FRONT])
if service.service == SERVICE_SET_TIMER:
fan_device.set_timer(service.data[ATTR_TIMER])
if service.service == SERVICE_SET_DYSON_SPEED:
fan_device.set_dyson_speed(service.data[ATTR_DYSON_SPEED])
# Register dyson service(s)
hass.services.register(
DYSON_DOMAIN,
SERVICE_SET_NIGHT_MODE,
service_handle,
schema=DYSON_SET_NIGHT_MODE_SCHEMA,
)
hass.services.register(
DYSON_DOMAIN, SERVICE_SET_AUTO_MODE, service_handle, schema=SET_AUTO_MODE_SCHEMA
)
if has_purecool_devices:
hass.services.register(
DYSON_DOMAIN, SERVICE_SET_ANGLE, service_handle, schema=SET_ANGLE_SCHEMA
)
hass.services.register(
DYSON_DOMAIN,
SERVICE_SET_FLOW_DIRECTION_FRONT,
service_handle,
schema=SET_FLOW_DIRECTION_FRONT_SCHEMA,
)
hass.services.register(
DYSON_DOMAIN, SERVICE_SET_TIMER, service_handle, schema=SET_TIMER_SCHEMA
)
hass.services.register(
DYSON_DOMAIN,
SERVICE_SET_DYSON_SPEED,
service_handle,
schema=SET_DYSON_SPEED_SCHEMA,
) | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"if",
"discovery_info",
"is",
"None",
":",
"return",
"_LOGGER",
".",
"debug",
"(",
"\"Creating new Dyson fans\"",
")",
"if",
"DYSON_FAN_DEVICES",
"not",
"in",
"hass",
".",
"data",
":",
"hass",
".",
"data",
"[",
"DYSON_FAN_DEVICES",
"]",
"=",
"[",
"]",
"# Get Dyson Devices from parent component",
"has_purecool_devices",
"=",
"False",
"device_serials",
"=",
"[",
"device",
".",
"serial",
"for",
"device",
"in",
"hass",
".",
"data",
"[",
"DYSON_FAN_DEVICES",
"]",
"]",
"for",
"device",
"in",
"hass",
".",
"data",
"[",
"DYSON_DEVICES",
"]",
":",
"if",
"device",
".",
"serial",
"not",
"in",
"device_serials",
":",
"if",
"isinstance",
"(",
"device",
",",
"DysonPureCool",
")",
":",
"has_purecool_devices",
"=",
"True",
"dyson_entity",
"=",
"DysonPureCoolDevice",
"(",
"device",
")",
"hass",
".",
"data",
"[",
"DYSON_FAN_DEVICES",
"]",
".",
"append",
"(",
"dyson_entity",
")",
"elif",
"isinstance",
"(",
"device",
",",
"DysonPureCoolLink",
")",
":",
"dyson_entity",
"=",
"DysonPureCoolLinkDevice",
"(",
"hass",
",",
"device",
")",
"hass",
".",
"data",
"[",
"DYSON_FAN_DEVICES",
"]",
".",
"append",
"(",
"dyson_entity",
")",
"add_entities",
"(",
"hass",
".",
"data",
"[",
"DYSON_FAN_DEVICES",
"]",
")",
"def",
"service_handle",
"(",
"service",
")",
":",
"\"\"\"Handle the Dyson services.\"\"\"",
"entity_id",
"=",
"service",
".",
"data",
"[",
"ATTR_ENTITY_ID",
"]",
"fan_device",
"=",
"next",
"(",
"(",
"fan",
"for",
"fan",
"in",
"hass",
".",
"data",
"[",
"DYSON_FAN_DEVICES",
"]",
"if",
"fan",
".",
"entity_id",
"==",
"entity_id",
")",
",",
"None",
",",
")",
"if",
"fan_device",
"is",
"None",
":",
"_LOGGER",
".",
"warning",
"(",
"\"Unable to find Dyson fan device %s\"",
",",
"str",
"(",
"entity_id",
")",
")",
"return",
"if",
"service",
".",
"service",
"==",
"SERVICE_SET_NIGHT_MODE",
":",
"fan_device",
".",
"set_night_mode",
"(",
"service",
".",
"data",
"[",
"ATTR_NIGHT_MODE",
"]",
")",
"if",
"service",
".",
"service",
"==",
"SERVICE_SET_AUTO_MODE",
":",
"fan_device",
".",
"set_auto_mode",
"(",
"service",
".",
"data",
"[",
"ATTR_AUTO_MODE",
"]",
")",
"if",
"service",
".",
"service",
"==",
"SERVICE_SET_ANGLE",
":",
"fan_device",
".",
"set_angle",
"(",
"service",
".",
"data",
"[",
"ATTR_ANGLE_LOW",
"]",
",",
"service",
".",
"data",
"[",
"ATTR_ANGLE_HIGH",
"]",
")",
"if",
"service",
".",
"service",
"==",
"SERVICE_SET_FLOW_DIRECTION_FRONT",
":",
"fan_device",
".",
"set_flow_direction_front",
"(",
"service",
".",
"data",
"[",
"ATTR_FLOW_DIRECTION_FRONT",
"]",
")",
"if",
"service",
".",
"service",
"==",
"SERVICE_SET_TIMER",
":",
"fan_device",
".",
"set_timer",
"(",
"service",
".",
"data",
"[",
"ATTR_TIMER",
"]",
")",
"if",
"service",
".",
"service",
"==",
"SERVICE_SET_DYSON_SPEED",
":",
"fan_device",
".",
"set_dyson_speed",
"(",
"service",
".",
"data",
"[",
"ATTR_DYSON_SPEED",
"]",
")",
"# Register dyson service(s)",
"hass",
".",
"services",
".",
"register",
"(",
"DYSON_DOMAIN",
",",
"SERVICE_SET_NIGHT_MODE",
",",
"service_handle",
",",
"schema",
"=",
"DYSON_SET_NIGHT_MODE_SCHEMA",
",",
")",
"hass",
".",
"services",
".",
"register",
"(",
"DYSON_DOMAIN",
",",
"SERVICE_SET_AUTO_MODE",
",",
"service_handle",
",",
"schema",
"=",
"SET_AUTO_MODE_SCHEMA",
")",
"if",
"has_purecool_devices",
":",
"hass",
".",
"services",
".",
"register",
"(",
"DYSON_DOMAIN",
",",
"SERVICE_SET_ANGLE",
",",
"service_handle",
",",
"schema",
"=",
"SET_ANGLE_SCHEMA",
")",
"hass",
".",
"services",
".",
"register",
"(",
"DYSON_DOMAIN",
",",
"SERVICE_SET_FLOW_DIRECTION_FRONT",
",",
"service_handle",
",",
"schema",
"=",
"SET_FLOW_DIRECTION_FRONT_SCHEMA",
",",
")",
"hass",
".",
"services",
".",
"register",
"(",
"DYSON_DOMAIN",
",",
"SERVICE_SET_TIMER",
",",
"service_handle",
",",
"schema",
"=",
"SET_TIMER_SCHEMA",
")",
"hass",
".",
"services",
".",
"register",
"(",
"DYSON_DOMAIN",
",",
"SERVICE_SET_DYSON_SPEED",
",",
"service_handle",
",",
"schema",
"=",
"SET_DYSON_SPEED_SCHEMA",
",",
")"
] | [
90,
0
] | [
178,
9
] | python | en | ['en', 'fr', 'en'] | True |
DysonPureCoolLinkDevice.__init__ | (self, hass, device) | Initialize the fan. | Initialize the fan. | def __init__(self, hass, device):
"""Initialize the fan."""
_LOGGER.debug("Creating device %s", device.name)
self.hass = hass
self._device = device | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"device",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Creating device %s\"",
",",
"device",
".",
"name",
")",
"self",
".",
"hass",
"=",
"hass",
"self",
".",
"_device",
"=",
"device"
] | [
184,
4
] | [
188,
29
] | python | en | ['en', 'fy', 'en'] | True |
DysonPureCoolLinkDevice.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._device.add_message_listener(self.on_message) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"_device",
".",
"add_message_listener",
"(",
"self",
".",
"on_message",
")"
] | [
190,
4
] | [
192,
58
] | python | en | ['en', 'en', 'en'] | True |
DysonPureCoolLinkDevice.on_message | (self, message) | Call when new messages received from the fan. | Call when new messages received from the fan. | def on_message(self, message):
"""Call when new messages received from the fan."""
if isinstance(message, DysonPureCoolState):
_LOGGER.debug("Message received for fan device %s: %s", self.name, message)
self.schedule_update_ha_state() | [
"def",
"on_message",
"(",
"self",
",",
"message",
")",
":",
"if",
"isinstance",
"(",
"message",
",",
"DysonPureCoolState",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Message received for fan device %s: %s\"",
",",
"self",
".",
"name",
",",
"message",
")",
"self",
".",
"schedule_update_ha_state",
"(",
")"
] | [
194,
4
] | [
199,
43
] | python | en | ['en', 'en', 'en'] | True |
DysonPureCoolLinkDevice.should_poll | (self) | No polling needed. | No polling needed. | def should_poll(self):
"""No polling needed."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
202,
4
] | [
204,
20
] | python | en | ['en', 'en', 'en'] | True |
DysonPureCoolLinkDevice.name | (self) | Return the display name of this fan. | Return the display name of this fan. | def name(self):
"""Return the display name of this fan."""
return self._device.name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device",
".",
"name"
] | [
207,
4
] | [
209,
32
] | python | en | ['en', 'en', 'en'] | True |
DysonPureCoolLinkDevice.set_speed | (self, speed: str) | Set the speed of the fan. Never called ??. | Set the speed of the fan. Never called ??. | def set_speed(self, speed: str) -> None:
"""Set the speed of the fan. Never called ??."""
_LOGGER.debug("Set fan speed to: %s", speed)
if speed == FanSpeed.FAN_SPEED_AUTO.value:
self._device.set_configuration(fan_mode=FanMode.AUTO)
else:
fan_speed = FanSpeed(f"{int(speed):04d}")
self._device.set_configuration(fan_mode=FanMode.FAN, fan_speed=fan_speed) | [
"def",
"set_speed",
"(",
"self",
",",
"speed",
":",
"str",
")",
"->",
"None",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Set fan speed to: %s\"",
",",
"speed",
")",
"if",
"speed",
"==",
"FanSpeed",
".",
"FAN_SPEED_AUTO",
".",
"value",
":",
"self",
".",
"_device",
".",
"set_configuration",
"(",
"fan_mode",
"=",
"FanMode",
".",
"AUTO",
")",
"else",
":",
"fan_speed",
"=",
"FanSpeed",
"(",
"f\"{int(speed):04d}\"",
")",
"self",
".",
"_device",
".",
"set_configuration",
"(",
"fan_mode",
"=",
"FanMode",
".",
"FAN",
",",
"fan_speed",
"=",
"fan_speed",
")"
] | [
211,
4
] | [
219,
85
] | python | en | ['en', 'en', 'en'] | True |
DysonPureCoolLinkDevice.turn_on | (self, speed: str = None, **kwargs) | Turn on the fan. | Turn on the fan. | def turn_on(self, speed: str = None, **kwargs) -> None:
"""Turn on the fan."""
_LOGGER.debug("Turn on fan %s with speed %s", self.name, speed)
if speed:
if speed == FanSpeed.FAN_SPEED_AUTO.value:
self._device.set_configuration(fan_mode=FanMode.AUTO)
else:
fan_speed = FanSpeed(f"{int(speed):04d}")
self._device.set_configuration(
fan_mode=FanMode.FAN, fan_speed=fan_speed
)
else:
# Speed not set, just turn on
self._device.set_configuration(fan_mode=FanMode.FAN) | [
"def",
"turn_on",
"(",
"self",
",",
"speed",
":",
"str",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
"->",
"None",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Turn on fan %s with speed %s\"",
",",
"self",
".",
"name",
",",
"speed",
")",
"if",
"speed",
":",
"if",
"speed",
"==",
"FanSpeed",
".",
"FAN_SPEED_AUTO",
".",
"value",
":",
"self",
".",
"_device",
".",
"set_configuration",
"(",
"fan_mode",
"=",
"FanMode",
".",
"AUTO",
")",
"else",
":",
"fan_speed",
"=",
"FanSpeed",
"(",
"f\"{int(speed):04d}\"",
")",
"self",
".",
"_device",
".",
"set_configuration",
"(",
"fan_mode",
"=",
"FanMode",
".",
"FAN",
",",
"fan_speed",
"=",
"fan_speed",
")",
"else",
":",
"# Speed not set, just turn on",
"self",
".",
"_device",
".",
"set_configuration",
"(",
"fan_mode",
"=",
"FanMode",
".",
"FAN",
")"
] | [
221,
4
] | [
234,
64
] | python | en | ['en', 'fy', 'en'] | True |
DysonPureCoolLinkDevice.turn_off | (self, **kwargs) | Turn off the fan. | Turn off the fan. | def turn_off(self, **kwargs) -> None:
"""Turn off the fan."""
_LOGGER.debug("Turn off fan %s", self.name)
self._device.set_configuration(fan_mode=FanMode.OFF) | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
"->",
"None",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Turn off fan %s\"",
",",
"self",
".",
"name",
")",
"self",
".",
"_device",
".",
"set_configuration",
"(",
"fan_mode",
"=",
"FanMode",
".",
"OFF",
")"
] | [
236,
4
] | [
239,
60
] | python | en | ['en', 'fy', 'en'] | True |
DysonPureCoolLinkDevice.oscillate | (self, oscillating: bool) | Turn on/off oscillating. | Turn on/off oscillating. | def oscillate(self, oscillating: bool) -> None:
"""Turn on/off oscillating."""
_LOGGER.debug("Turn oscillation %s for device %s", oscillating, self.name)
if oscillating:
self._device.set_configuration(oscillation=Oscillation.OSCILLATION_ON)
else:
self._device.set_configuration(oscillation=Oscillation.OSCILLATION_OFF) | [
"def",
"oscillate",
"(",
"self",
",",
"oscillating",
":",
"bool",
")",
"->",
"None",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Turn oscillation %s for device %s\"",
",",
"oscillating",
",",
"self",
".",
"name",
")",
"if",
"oscillating",
":",
"self",
".",
"_device",
".",
"set_configuration",
"(",
"oscillation",
"=",
"Oscillation",
".",
"OSCILLATION_ON",
")",
"else",
":",
"self",
".",
"_device",
".",
"set_configuration",
"(",
"oscillation",
"=",
"Oscillation",
".",
"OSCILLATION_OFF",
")"
] | [
241,
4
] | [
248,
83
] | python | en | ['it', 'ja', 'en'] | False |
DysonPureCoolLinkDevice.oscillating | (self) | Return the oscillation state. | Return the oscillation state. | def oscillating(self):
"""Return the oscillation state."""
return self._device.state and self._device.state.oscillation == "ON" | [
"def",
"oscillating",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device",
".",
"state",
"and",
"self",
".",
"_device",
".",
"state",
".",
"oscillation",
"==",
"\"ON\""
] | [
251,
4
] | [
253,
76
] | python | en | ['en', 'en', 'en'] | True |
DysonPureCoolLinkDevice.is_on | (self) | Return true if the entity is on. | Return true if the entity is on. | def is_on(self):
"""Return true if the entity is on."""
if self._device.state:
return self._device.state.fan_mode == "FAN"
return False | [
"def",
"is_on",
"(",
"self",
")",
":",
"if",
"self",
".",
"_device",
".",
"state",
":",
"return",
"self",
".",
"_device",
".",
"state",
".",
"fan_mode",
"==",
"\"FAN\"",
"return",
"False"
] | [
256,
4
] | [
260,
20
] | python | en | ['en', 'en', 'en'] | True |
DysonPureCoolLinkDevice.speed | (self) | Return the current speed. | Return the current speed. | def speed(self) -> str:
"""Return the current speed."""
if self._device.state:
if self._device.state.speed == FanSpeed.FAN_SPEED_AUTO.value:
return self._device.state.speed
return int(self._device.state.speed)
return None | [
"def",
"speed",
"(",
"self",
")",
"->",
"str",
":",
"if",
"self",
".",
"_device",
".",
"state",
":",
"if",
"self",
".",
"_device",
".",
"state",
".",
"speed",
"==",
"FanSpeed",
".",
"FAN_SPEED_AUTO",
".",
"value",
":",
"return",
"self",
".",
"_device",
".",
"state",
".",
"speed",
"return",
"int",
"(",
"self",
".",
"_device",
".",
"state",
".",
"speed",
")",
"return",
"None"
] | [
263,
4
] | [
269,
19
] | python | en | ['en', 'en', 'en'] | True |
DysonPureCoolLinkDevice.current_direction | (self) | Return direction of the fan [forward, reverse]. | Return direction of the fan [forward, reverse]. | def current_direction(self):
"""Return direction of the fan [forward, reverse]."""
return None | [
"def",
"current_direction",
"(",
"self",
")",
":",
"return",
"None"
] | [
272,
4
] | [
274,
19
] | python | en | ['en', 'fy', 'en'] | True |
DysonPureCoolLinkDevice.night_mode | (self) | Return Night mode. | Return Night mode. | def night_mode(self):
"""Return Night mode."""
return self._device.state.night_mode == "ON" | [
"def",
"night_mode",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device",
".",
"state",
".",
"night_mode",
"==",
"\"ON\""
] | [
277,
4
] | [
279,
52
] | python | en | ['en', 'sn', 'en'] | True |
DysonPureCoolLinkDevice.set_night_mode | (self, night_mode: bool) | Turn fan in night mode. | Turn fan in night mode. | def set_night_mode(self, night_mode: bool) -> None:
"""Turn fan in night mode."""
_LOGGER.debug("Set %s night mode %s", self.name, night_mode)
if night_mode:
self._device.set_configuration(night_mode=NightMode.NIGHT_MODE_ON)
else:
self._device.set_configuration(night_mode=NightMode.NIGHT_MODE_OFF) | [
"def",
"set_night_mode",
"(",
"self",
",",
"night_mode",
":",
"bool",
")",
"->",
"None",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Set %s night mode %s\"",
",",
"self",
".",
"name",
",",
"night_mode",
")",
"if",
"night_mode",
":",
"self",
".",
"_device",
".",
"set_configuration",
"(",
"night_mode",
"=",
"NightMode",
".",
"NIGHT_MODE_ON",
")",
"else",
":",
"self",
".",
"_device",
".",
"set_configuration",
"(",
"night_mode",
"=",
"NightMode",
".",
"NIGHT_MODE_OFF",
")"
] | [
281,
4
] | [
287,
79
] | python | en | ['en', 'fy', 'en'] | True |
DysonPureCoolLinkDevice.auto_mode | (self) | Return auto mode. | Return auto mode. | def auto_mode(self):
"""Return auto mode."""
return self._device.state.fan_mode == "AUTO" | [
"def",
"auto_mode",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device",
".",
"state",
".",
"fan_mode",
"==",
"\"AUTO\""
] | [
290,
4
] | [
292,
52
] | python | bs | ['de', 'bs', 'en'] | False |
DysonPureCoolLinkDevice.set_auto_mode | (self, auto_mode: bool) | Turn fan in auto mode. | Turn fan in auto mode. | def set_auto_mode(self, auto_mode: bool) -> None:
"""Turn fan in auto mode."""
_LOGGER.debug("Set %s auto mode %s", self.name, auto_mode)
if auto_mode:
self._device.set_configuration(fan_mode=FanMode.AUTO)
else:
self._device.set_configuration(fan_mode=FanMode.FAN) | [
"def",
"set_auto_mode",
"(",
"self",
",",
"auto_mode",
":",
"bool",
")",
"->",
"None",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Set %s auto mode %s\"",
",",
"self",
".",
"name",
",",
"auto_mode",
")",
"if",
"auto_mode",
":",
"self",
".",
"_device",
".",
"set_configuration",
"(",
"fan_mode",
"=",
"FanMode",
".",
"AUTO",
")",
"else",
":",
"self",
".",
"_device",
".",
"set_configuration",
"(",
"fan_mode",
"=",
"FanMode",
".",
"FAN",
")"
] | [
294,
4
] | [
300,
64
] | python | en | ['en', 'fy', 'nl'] | False |
DysonPureCoolLinkDevice.speed_list | (self) | Get the list of available speeds. | Get the list of available speeds. | def speed_list(self) -> list:
"""Get the list of available speeds."""
supported_speeds = [
FanSpeed.FAN_SPEED_AUTO.value,
int(FanSpeed.FAN_SPEED_1.value),
int(FanSpeed.FAN_SPEED_2.value),
int(FanSpeed.FAN_SPEED_3.value),
int(FanSpeed.FAN_SPEED_4.value),
int(FanSpeed.FAN_SPEED_5.value),
int(FanSpeed.FAN_SPEED_6.value),
int(FanSpeed.FAN_SPEED_7.value),
int(FanSpeed.FAN_SPEED_8.value),
int(FanSpeed.FAN_SPEED_9.value),
int(FanSpeed.FAN_SPEED_10.value),
]
return supported_speeds | [
"def",
"speed_list",
"(",
"self",
")",
"->",
"list",
":",
"supported_speeds",
"=",
"[",
"FanSpeed",
".",
"FAN_SPEED_AUTO",
".",
"value",
",",
"int",
"(",
"FanSpeed",
".",
"FAN_SPEED_1",
".",
"value",
")",
",",
"int",
"(",
"FanSpeed",
".",
"FAN_SPEED_2",
".",
"value",
")",
",",
"int",
"(",
"FanSpeed",
".",
"FAN_SPEED_3",
".",
"value",
")",
",",
"int",
"(",
"FanSpeed",
".",
"FAN_SPEED_4",
".",
"value",
")",
",",
"int",
"(",
"FanSpeed",
".",
"FAN_SPEED_5",
".",
"value",
")",
",",
"int",
"(",
"FanSpeed",
".",
"FAN_SPEED_6",
".",
"value",
")",
",",
"int",
"(",
"FanSpeed",
".",
"FAN_SPEED_7",
".",
"value",
")",
",",
"int",
"(",
"FanSpeed",
".",
"FAN_SPEED_8",
".",
"value",
")",
",",
"int",
"(",
"FanSpeed",
".",
"FAN_SPEED_9",
".",
"value",
")",
",",
"int",
"(",
"FanSpeed",
".",
"FAN_SPEED_10",
".",
"value",
")",
",",
"]",
"return",
"supported_speeds"
] | [
303,
4
] | [
319,
31
] | python | en | ['en', 'en', 'en'] | True |
DysonPureCoolLinkDevice.supported_features | (self) | Flag supported features. | Flag supported features. | def supported_features(self) -> int:
"""Flag supported features."""
return SUPPORT_OSCILLATE | SUPPORT_SET_SPEED | [
"def",
"supported_features",
"(",
"self",
")",
"->",
"int",
":",
"return",
"SUPPORT_OSCILLATE",
"|",
"SUPPORT_SET_SPEED"
] | [
322,
4
] | [
324,
52
] | python | en | ['da', 'en', 'en'] | True |
DysonPureCoolLinkDevice.device_state_attributes | (self) | Return optional state attributes. | Return optional state attributes. | def device_state_attributes(self) -> dict:
"""Return optional state attributes."""
return {ATTR_NIGHT_MODE: self.night_mode, ATTR_AUTO_MODE: self.auto_mode} | [
"def",
"device_state_attributes",
"(",
"self",
")",
"->",
"dict",
":",
"return",
"{",
"ATTR_NIGHT_MODE",
":",
"self",
".",
"night_mode",
",",
"ATTR_AUTO_MODE",
":",
"self",
".",
"auto_mode",
"}"
] | [
327,
4
] | [
329,
81
] | python | en | ['en', 'en', 'en'] | True |
DysonPureCoolDevice.__init__ | (self, device) | Initialize the fan. | Initialize the fan. | def __init__(self, device):
"""Initialize the fan."""
self._device = device | [
"def",
"__init__",
"(",
"self",
",",
"device",
")",
":",
"self",
".",
"_device",
"=",
"device"
] | [
335,
4
] | [
337,
29
] | python | en | ['en', 'fy', 'en'] | True |
DysonPureCoolDevice.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._device.add_message_listener(self.on_message) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"_device",
".",
"add_message_listener",
"(",
"self",
".",
"on_message",
")"
] | [
339,
4
] | [
341,
58
] | python | en | ['en', 'en', 'en'] | True |
DysonPureCoolDevice.on_message | (self, message) | Call when new messages received from the fan. | Call when new messages received from the fan. | def on_message(self, message):
"""Call when new messages received from the fan."""
if isinstance(message, DysonPureCoolV2State):
_LOGGER.debug("Message received for fan device %s: %s", self.name, message)
self.schedule_update_ha_state() | [
"def",
"on_message",
"(",
"self",
",",
"message",
")",
":",
"if",
"isinstance",
"(",
"message",
",",
"DysonPureCoolV2State",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Message received for fan device %s: %s\"",
",",
"self",
".",
"name",
",",
"message",
")",
"self",
".",
"schedule_update_ha_state",
"(",
")"
] | [
343,
4
] | [
347,
43
] | python | en | ['en', 'en', 'en'] | True |
DysonPureCoolDevice.should_poll | (self) | No polling needed. | No polling needed. | def should_poll(self):
"""No polling needed."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
350,
4
] | [
352,
20
] | python | en | ['en', 'en', 'en'] | True |
DysonPureCoolDevice.name | (self) | Return the display name of this fan. | Return the display name of this fan. | def name(self):
"""Return the display name of this fan."""
return self._device.name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device",
".",
"name"
] | [
355,
4
] | [
357,
32
] | python | en | ['en', 'en', 'en'] | True |
DysonPureCoolDevice.turn_on | (self, speed: str = None, **kwargs) | Turn on the fan. | Turn on the fan. | def turn_on(self, speed: str = None, **kwargs) -> None:
"""Turn on the fan."""
_LOGGER.debug("Turn on fan %s", self.name)
if speed is not None:
self.set_speed(speed)
else:
self._device.turn_on() | [
"def",
"turn_on",
"(",
"self",
",",
"speed",
":",
"str",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
"->",
"None",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Turn on fan %s\"",
",",
"self",
".",
"name",
")",
"if",
"speed",
"is",
"not",
"None",
":",
"self",
".",
"set_speed",
"(",
"speed",
")",
"else",
":",
"self",
".",
"_device",
".",
"turn_on",
"(",
")"
] | [
359,
4
] | [
366,
34
] | python | en | ['en', 'fy', 'en'] | True |
DysonPureCoolDevice.set_speed | (self, speed: str) | Set the speed of the fan. | Set the speed of the fan. | def set_speed(self, speed: str) -> None:
"""Set the speed of the fan."""
if speed == SPEED_LOW:
self._device.set_fan_speed(FanSpeed.FAN_SPEED_4)
elif speed == SPEED_MEDIUM:
self._device.set_fan_speed(FanSpeed.FAN_SPEED_7)
elif speed == SPEED_HIGH:
self._device.set_fan_speed(FanSpeed.FAN_SPEED_10) | [
"def",
"set_speed",
"(",
"self",
",",
"speed",
":",
"str",
")",
"->",
"None",
":",
"if",
"speed",
"==",
"SPEED_LOW",
":",
"self",
".",
"_device",
".",
"set_fan_speed",
"(",
"FanSpeed",
".",
"FAN_SPEED_4",
")",
"elif",
"speed",
"==",
"SPEED_MEDIUM",
":",
"self",
".",
"_device",
".",
"set_fan_speed",
"(",
"FanSpeed",
".",
"FAN_SPEED_7",
")",
"elif",
"speed",
"==",
"SPEED_HIGH",
":",
"self",
".",
"_device",
".",
"set_fan_speed",
"(",
"FanSpeed",
".",
"FAN_SPEED_10",
")"
] | [
368,
4
] | [
375,
61
] | python | en | ['en', 'en', 'en'] | True |
DysonPureCoolDevice.turn_off | (self, **kwargs) | Turn off the fan. | Turn off the fan. | def turn_off(self, **kwargs):
"""Turn off the fan."""
_LOGGER.debug("Turn off fan %s", self.name)
self._device.turn_off() | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Turn off fan %s\"",
",",
"self",
".",
"name",
")",
"self",
".",
"_device",
".",
"turn_off",
"(",
")"
] | [
377,
4
] | [
380,
31
] | python | en | ['en', 'fy', 'en'] | True |
DysonPureCoolDevice.set_dyson_speed | (self, speed: str = None) | Set the exact speed of the purecool fan. | Set the exact speed of the purecool fan. | def set_dyson_speed(self, speed: str = None) -> None:
"""Set the exact speed of the purecool fan."""
_LOGGER.debug("Set exact speed for fan %s", self.name)
fan_speed = FanSpeed(f"{int(speed):04d}")
self._device.set_fan_speed(fan_speed) | [
"def",
"set_dyson_speed",
"(",
"self",
",",
"speed",
":",
"str",
"=",
"None",
")",
"->",
"None",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Set exact speed for fan %s\"",
",",
"self",
".",
"name",
")",
"fan_speed",
"=",
"FanSpeed",
"(",
"f\"{int(speed):04d}\"",
")",
"self",
".",
"_device",
".",
"set_fan_speed",
"(",
"fan_speed",
")"
] | [
382,
4
] | [
387,
45
] | python | en | ['en', 'en', 'en'] | True |
DysonPureCoolDevice.oscillate | (self, oscillating: bool) | Turn on/off oscillating. | Turn on/off oscillating. | def oscillate(self, oscillating: bool) -> None:
"""Turn on/off oscillating."""
_LOGGER.debug("Turn oscillation %s for device %s", oscillating, self.name)
if oscillating:
self._device.enable_oscillation()
else:
self._device.disable_oscillation() | [
"def",
"oscillate",
"(",
"self",
",",
"oscillating",
":",
"bool",
")",
"->",
"None",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Turn oscillation %s for device %s\"",
",",
"oscillating",
",",
"self",
".",
"name",
")",
"if",
"oscillating",
":",
"self",
".",
"_device",
".",
"enable_oscillation",
"(",
")",
"else",
":",
"self",
".",
"_device",
".",
"disable_oscillation",
"(",
")"
] | [
389,
4
] | [
396,
46
] | python | en | ['it', 'ja', 'en'] | False |
DysonPureCoolDevice.set_night_mode | (self, night_mode: bool) | Turn on/off night mode. | Turn on/off night mode. | def set_night_mode(self, night_mode: bool) -> None:
"""Turn on/off night mode."""
_LOGGER.debug("Turn night mode %s for device %s", night_mode, self.name)
if night_mode:
self._device.enable_night_mode()
else:
self._device.disable_night_mode() | [
"def",
"set_night_mode",
"(",
"self",
",",
"night_mode",
":",
"bool",
")",
"->",
"None",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Turn night mode %s for device %s\"",
",",
"night_mode",
",",
"self",
".",
"name",
")",
"if",
"night_mode",
":",
"self",
".",
"_device",
".",
"enable_night_mode",
"(",
")",
"else",
":",
"self",
".",
"_device",
".",
"disable_night_mode",
"(",
")"
] | [
398,
4
] | [
405,
45
] | python | en | ['en', 'yo', 'en'] | True |
DysonPureCoolDevice.set_auto_mode | (self, auto_mode: bool) | Turn auto mode on/off. | Turn auto mode on/off. | def set_auto_mode(self, auto_mode: bool) -> None:
"""Turn auto mode on/off."""
_LOGGER.debug("Turn auto mode %s for device %s", auto_mode, self.name)
if auto_mode:
self._device.enable_auto_mode()
else:
self._device.disable_auto_mode() | [
"def",
"set_auto_mode",
"(",
"self",
",",
"auto_mode",
":",
"bool",
")",
"->",
"None",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Turn auto mode %s for device %s\"",
",",
"auto_mode",
",",
"self",
".",
"name",
")",
"if",
"auto_mode",
":",
"self",
".",
"_device",
".",
"enable_auto_mode",
"(",
")",
"else",
":",
"self",
".",
"_device",
".",
"disable_auto_mode",
"(",
")"
] | [
407,
4
] | [
413,
44
] | python | de | ['de', 'fi', 'en'] | False |
DysonPureCoolDevice.set_angle | (self, angle_low: int, angle_high: int) | Set device angle. | Set device angle. | def set_angle(self, angle_low: int, angle_high: int) -> None:
"""Set device angle."""
_LOGGER.debug(
"set low %s and high angle %s for device %s",
angle_low,
angle_high,
self.name,
)
self._device.enable_oscillation(angle_low, angle_high) | [
"def",
"set_angle",
"(",
"self",
",",
"angle_low",
":",
"int",
",",
"angle_high",
":",
"int",
")",
"->",
"None",
":",
"_LOGGER",
".",
"debug",
"(",
"\"set low %s and high angle %s for device %s\"",
",",
"angle_low",
",",
"angle_high",
",",
"self",
".",
"name",
",",
")",
"self",
".",
"_device",
".",
"enable_oscillation",
"(",
"angle_low",
",",
"angle_high",
")"
] | [
415,
4
] | [
423,
62
] | python | en | ['fr', 'haw', 'en'] | False |
DysonPureCoolDevice.set_flow_direction_front | (self, flow_direction_front: bool) | Set frontal airflow direction. | Set frontal airflow direction. | def set_flow_direction_front(self, flow_direction_front: bool) -> None:
"""Set frontal airflow direction."""
_LOGGER.debug(
"Set frontal flow direction to %s for device %s",
flow_direction_front,
self.name,
)
if flow_direction_front:
self._device.enable_frontal_direction()
else:
self._device.disable_frontal_direction() | [
"def",
"set_flow_direction_front",
"(",
"self",
",",
"flow_direction_front",
":",
"bool",
")",
"->",
"None",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Set frontal flow direction to %s for device %s\"",
",",
"flow_direction_front",
",",
"self",
".",
"name",
",",
")",
"if",
"flow_direction_front",
":",
"self",
".",
"_device",
".",
"enable_frontal_direction",
"(",
")",
"else",
":",
"self",
".",
"_device",
".",
"disable_frontal_direction",
"(",
")"
] | [
425,
4
] | [
436,
52
] | python | en | ['en', 'en', 'en'] | True |
DysonPureCoolDevice.oscillating | (self) | Return the oscillation state. | Return the oscillation state. | def oscillating(self):
"""Return the oscillation state."""
return self._device.state and self._device.state.oscillation == "OION" | [
"def",
"oscillating",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device",
".",
"state",
"and",
"self",
".",
"_device",
".",
"state",
".",
"oscillation",
"==",
"\"OION\""
] | [
448,
4
] | [
450,
78
] | python | en | ['en', 'en', 'en'] | True |
DysonPureCoolDevice.is_on | (self) | Return true if the entity is on. | Return true if the entity is on. | def is_on(self):
"""Return true if the entity is on."""
if self._device.state:
return self._device.state.fan_power == "ON" | [
"def",
"is_on",
"(",
"self",
")",
":",
"if",
"self",
".",
"_device",
".",
"state",
":",
"return",
"self",
".",
"_device",
".",
"state",
".",
"fan_power",
"==",
"\"ON\""
] | [
453,
4
] | [
456,
55
] | python | en | ['en', 'en', 'en'] | True |
DysonPureCoolDevice.speed | (self) | Return the current speed. | Return the current speed. | def speed(self):
"""Return the current speed."""
speed_map = {
FanSpeed.FAN_SPEED_1.value: SPEED_LOW,
FanSpeed.FAN_SPEED_2.value: SPEED_LOW,
FanSpeed.FAN_SPEED_3.value: SPEED_LOW,
FanSpeed.FAN_SPEED_4.value: SPEED_LOW,
FanSpeed.FAN_SPEED_AUTO.value: SPEED_MEDIUM,
FanSpeed.FAN_SPEED_5.value: SPEED_MEDIUM,
FanSpeed.FAN_SPEED_6.value: SPEED_MEDIUM,
FanSpeed.FAN_SPEED_7.value: SPEED_MEDIUM,
FanSpeed.FAN_SPEED_8.value: SPEED_HIGH,
FanSpeed.FAN_SPEED_9.value: SPEED_HIGH,
FanSpeed.FAN_SPEED_10.value: SPEED_HIGH,
}
return speed_map[self._device.state.speed] | [
"def",
"speed",
"(",
"self",
")",
":",
"speed_map",
"=",
"{",
"FanSpeed",
".",
"FAN_SPEED_1",
".",
"value",
":",
"SPEED_LOW",
",",
"FanSpeed",
".",
"FAN_SPEED_2",
".",
"value",
":",
"SPEED_LOW",
",",
"FanSpeed",
".",
"FAN_SPEED_3",
".",
"value",
":",
"SPEED_LOW",
",",
"FanSpeed",
".",
"FAN_SPEED_4",
".",
"value",
":",
"SPEED_LOW",
",",
"FanSpeed",
".",
"FAN_SPEED_AUTO",
".",
"value",
":",
"SPEED_MEDIUM",
",",
"FanSpeed",
".",
"FAN_SPEED_5",
".",
"value",
":",
"SPEED_MEDIUM",
",",
"FanSpeed",
".",
"FAN_SPEED_6",
".",
"value",
":",
"SPEED_MEDIUM",
",",
"FanSpeed",
".",
"FAN_SPEED_7",
".",
"value",
":",
"SPEED_MEDIUM",
",",
"FanSpeed",
".",
"FAN_SPEED_8",
".",
"value",
":",
"SPEED_HIGH",
",",
"FanSpeed",
".",
"FAN_SPEED_9",
".",
"value",
":",
"SPEED_HIGH",
",",
"FanSpeed",
".",
"FAN_SPEED_10",
".",
"value",
":",
"SPEED_HIGH",
",",
"}",
"return",
"speed_map",
"[",
"self",
".",
"_device",
".",
"state",
".",
"speed",
"]"
] | [
459,
4
] | [
475,
50
] | python | en | ['en', 'en', 'en'] | True |
DysonPureCoolDevice.dyson_speed | (self) | Return the current speed. | Return the current speed. | def dyson_speed(self):
"""Return the current speed."""
if self._device.state:
if self._device.state.speed == FanSpeed.FAN_SPEED_AUTO.value:
return self._device.state.speed
return int(self._device.state.speed) | [
"def",
"dyson_speed",
"(",
"self",
")",
":",
"if",
"self",
".",
"_device",
".",
"state",
":",
"if",
"self",
".",
"_device",
".",
"state",
".",
"speed",
"==",
"FanSpeed",
".",
"FAN_SPEED_AUTO",
".",
"value",
":",
"return",
"self",
".",
"_device",
".",
"state",
".",
"speed",
"return",
"int",
"(",
"self",
".",
"_device",
".",
"state",
".",
"speed",
")"
] | [
478,
4
] | [
483,
48
] | python | en | ['en', 'en', 'en'] | True |
DysonPureCoolDevice.night_mode | (self) | Return Night mode. | Return Night mode. | def night_mode(self):
"""Return Night mode."""
return self._device.state.night_mode == "ON" | [
"def",
"night_mode",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device",
".",
"state",
".",
"night_mode",
"==",
"\"ON\""
] | [
486,
4
] | [
488,
52
] | python | en | ['en', 'sn', 'en'] | True |
DysonPureCoolDevice.auto_mode | (self) | Return Auto mode. | Return Auto mode. | def auto_mode(self):
"""Return Auto mode."""
return self._device.state.auto_mode == "ON" | [
"def",
"auto_mode",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device",
".",
"state",
".",
"auto_mode",
"==",
"\"ON\""
] | [
491,
4
] | [
493,
51
] | python | en | ['en', 'bs', 'en'] | True |
DysonPureCoolDevice.angle_low | (self) | Return angle high. | Return angle high. | def angle_low(self):
"""Return angle high."""
return int(self._device.state.oscillation_angle_low) | [
"def",
"angle_low",
"(",
"self",
")",
":",
"return",
"int",
"(",
"self",
".",
"_device",
".",
"state",
".",
"oscillation_angle_low",
")"
] | [
496,
4
] | [
498,
60
] | python | ceb | ['tl', 'ceb', 'en'] | False |
DysonPureCoolDevice.angle_high | (self) | Return angle low. | Return angle low. | def angle_high(self):
"""Return angle low."""
return int(self._device.state.oscillation_angle_high) | [
"def",
"angle_high",
"(",
"self",
")",
":",
"return",
"int",
"(",
"self",
".",
"_device",
".",
"state",
".",
"oscillation_angle_high",
")"
] | [
501,
4
] | [
503,
61
] | python | en | ['en', 'tg', 'en'] | True |
DysonPureCoolDevice.flow_direction_front | (self) | Return frontal flow direction. | Return frontal flow direction. | def flow_direction_front(self):
"""Return frontal flow direction."""
return self._device.state.front_direction == "ON" | [
"def",
"flow_direction_front",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device",
".",
"state",
".",
"front_direction",
"==",
"\"ON\""
] | [
506,
4
] | [
508,
57
] | python | en | ['en', 'da', 'en'] | True |
DysonPureCoolDevice.timer | (self) | Return timer. | Return timer. | def timer(self):
"""Return timer."""
return self._device.state.sleep_timer | [
"def",
"timer",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device",
".",
"state",
".",
"sleep_timer"
] | [
511,
4
] | [
513,
45
] | python | en | ['en', 'no', 'en'] | False |
DysonPureCoolDevice.hepa_filter | (self) | Return the HEPA filter state. | Return the HEPA filter state. | def hepa_filter(self):
"""Return the HEPA filter state."""
return int(self._device.state.hepa_filter_state) | [
"def",
"hepa_filter",
"(",
"self",
")",
":",
"return",
"int",
"(",
"self",
".",
"_device",
".",
"state",
".",
"hepa_filter_state",
")"
] | [
516,
4
] | [
518,
56
] | python | en | ['en', 'en', 'en'] | True |
DysonPureCoolDevice.carbon_filter | (self) | Return the carbon filter state. | Return the carbon filter state. | def carbon_filter(self):
"""Return the carbon filter state."""
if self._device.state.carbon_filter_state == "INV":
return self._device.state.carbon_filter_state
return int(self._device.state.carbon_filter_state) | [
"def",
"carbon_filter",
"(",
"self",
")",
":",
"if",
"self",
".",
"_device",
".",
"state",
".",
"carbon_filter_state",
"==",
"\"INV\"",
":",
"return",
"self",
".",
"_device",
".",
"state",
".",
"carbon_filter_state",
"return",
"int",
"(",
"self",
".",
"_device",
".",
"state",
".",
"carbon_filter_state",
")"
] | [
521,
4
] | [
525,
58
] | python | en | ['en', 'en', 'en'] | True |
DysonPureCoolDevice.speed_list | (self) | Get the list of available speeds. | Get the list of available speeds. | def speed_list(self) -> list:
"""Get the list of available speeds."""
return [SPEED_LOW, SPEED_MEDIUM, SPEED_HIGH] | [
"def",
"speed_list",
"(",
"self",
")",
"->",
"list",
":",
"return",
"[",
"SPEED_LOW",
",",
"SPEED_MEDIUM",
",",
"SPEED_HIGH",
"]"
] | [
528,
4
] | [
530,
52
] | python | en | ['en', 'en', 'en'] | True |
DysonPureCoolDevice.dyson_speed_list | (self) | Get the list of available dyson speeds. | Get the list of available dyson speeds. | def dyson_speed_list(self) -> list:
"""Get the list of available dyson speeds."""
return [
int(FanSpeed.FAN_SPEED_1.value),
int(FanSpeed.FAN_SPEED_2.value),
int(FanSpeed.FAN_SPEED_3.value),
int(FanSpeed.FAN_SPEED_4.value),
int(FanSpeed.FAN_SPEED_5.value),
int(FanSpeed.FAN_SPEED_6.value),
int(FanSpeed.FAN_SPEED_7.value),
int(FanSpeed.FAN_SPEED_8.value),
int(FanSpeed.FAN_SPEED_9.value),
int(FanSpeed.FAN_SPEED_10.value),
] | [
"def",
"dyson_speed_list",
"(",
"self",
")",
"->",
"list",
":",
"return",
"[",
"int",
"(",
"FanSpeed",
".",
"FAN_SPEED_1",
".",
"value",
")",
",",
"int",
"(",
"FanSpeed",
".",
"FAN_SPEED_2",
".",
"value",
")",
",",
"int",
"(",
"FanSpeed",
".",
"FAN_SPEED_3",
".",
"value",
")",
",",
"int",
"(",
"FanSpeed",
".",
"FAN_SPEED_4",
".",
"value",
")",
",",
"int",
"(",
"FanSpeed",
".",
"FAN_SPEED_5",
".",
"value",
")",
",",
"int",
"(",
"FanSpeed",
".",
"FAN_SPEED_6",
".",
"value",
")",
",",
"int",
"(",
"FanSpeed",
".",
"FAN_SPEED_7",
".",
"value",
")",
",",
"int",
"(",
"FanSpeed",
".",
"FAN_SPEED_8",
".",
"value",
")",
",",
"int",
"(",
"FanSpeed",
".",
"FAN_SPEED_9",
".",
"value",
")",
",",
"int",
"(",
"FanSpeed",
".",
"FAN_SPEED_10",
".",
"value",
")",
",",
"]"
] | [
533,
4
] | [
546,
9
] | python | en | ['en', 'en', 'en'] | True |
DysonPureCoolDevice.device_serial | (self) | Return fan's serial number. | Return fan's serial number. | def device_serial(self):
"""Return fan's serial number."""
return self._device.serial | [
"def",
"device_serial",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device",
".",
"serial"
] | [
549,
4
] | [
551,
34
] | python | en | ['en', 'af', 'en'] | True |
DysonPureCoolDevice.supported_features | (self) | Flag supported features. | Flag supported features. | def supported_features(self) -> int:
"""Flag supported features."""
return SUPPORT_OSCILLATE | SUPPORT_SET_SPEED | [
"def",
"supported_features",
"(",
"self",
")",
"->",
"int",
":",
"return",
"SUPPORT_OSCILLATE",
"|",
"SUPPORT_SET_SPEED"
] | [
554,
4
] | [
556,
52
] | python | en | ['da', 'en', 'en'] | True |
DysonPureCoolDevice.device_state_attributes | (self) | Return optional state attributes. | Return optional state attributes. | def device_state_attributes(self) -> dict:
"""Return optional state attributes."""
return {
ATTR_NIGHT_MODE: self.night_mode,
ATTR_AUTO_MODE: self.auto_mode,
ATTR_ANGLE_LOW: self.angle_low,
ATTR_ANGLE_HIGH: self.angle_high,
ATTR_FLOW_DIRECTION_FRONT: self.flow_direction_front,
ATTR_TIMER: self.timer,
ATTR_HEPA_FILTER: self.hepa_filter,
ATTR_CARBON_FILTER: self.carbon_filter,
ATTR_DYSON_SPEED: self.dyson_speed,
ATTR_DYSON_SPEED_LIST: self.dyson_speed_list,
} | [
"def",
"device_state_attributes",
"(",
"self",
")",
"->",
"dict",
":",
"return",
"{",
"ATTR_NIGHT_MODE",
":",
"self",
".",
"night_mode",
",",
"ATTR_AUTO_MODE",
":",
"self",
".",
"auto_mode",
",",
"ATTR_ANGLE_LOW",
":",
"self",
".",
"angle_low",
",",
"ATTR_ANGLE_HIGH",
":",
"self",
".",
"angle_high",
",",
"ATTR_FLOW_DIRECTION_FRONT",
":",
"self",
".",
"flow_direction_front",
",",
"ATTR_TIMER",
":",
"self",
".",
"timer",
",",
"ATTR_HEPA_FILTER",
":",
"self",
".",
"hepa_filter",
",",
"ATTR_CARBON_FILTER",
":",
"self",
".",
"carbon_filter",
",",
"ATTR_DYSON_SPEED",
":",
"self",
".",
"dyson_speed",
",",
"ATTR_DYSON_SPEED_LIST",
":",
"self",
".",
"dyson_speed_list",
",",
"}"
] | [
559,
4
] | [
572,
9
] | python | en | ['en', 'en', 'en'] | True |
get_scanner | (hass, config) | Validate the configuration and return FritzBoxScanner. | Validate the configuration and return FritzBoxScanner. | def get_scanner(hass, config):
"""Validate the configuration and return FritzBoxScanner."""
scanner = FritzBoxScanner(config[DOMAIN])
return scanner if scanner.success_init else None | [
"def",
"get_scanner",
"(",
"hass",
",",
"config",
")",
":",
"scanner",
"=",
"FritzBoxScanner",
"(",
"config",
"[",
"DOMAIN",
"]",
")",
"return",
"scanner",
"if",
"scanner",
".",
"success_init",
"else",
"None"
] | [
29,
0
] | [
32,
52
] | python | en | ['en', 'en', 'en'] | True |
FritzBoxScanner.__init__ | (self, config) | Initialize the scanner. | Initialize the scanner. | def __init__(self, config):
"""Initialize the scanner."""
self.last_results = []
self.host = config[CONF_HOST]
self.username = config[CONF_USERNAME]
self.password = config.get(CONF_PASSWORD)
self.success_init = True
# Establish a connection to the FRITZ!Box.
try:
self.fritz_box = FritzHosts(
address=self.host, user=self.username, password=self.password
)
except (ValueError, TypeError):
self.fritz_box = None
# At this point it is difficult to tell if a connection is established.
# So just check for null objects.
if self.fritz_box is None or not self.fritz_box.modelname:
self.success_init = False
if self.success_init:
_LOGGER.info("Successfully connected to %s", self.fritz_box.modelname)
self._update_info()
else:
_LOGGER.error(
"Failed to establish connection to FRITZ!Box with IP: %s", self.host
) | [
"def",
"__init__",
"(",
"self",
",",
"config",
")",
":",
"self",
".",
"last_results",
"=",
"[",
"]",
"self",
".",
"host",
"=",
"config",
"[",
"CONF_HOST",
"]",
"self",
".",
"username",
"=",
"config",
"[",
"CONF_USERNAME",
"]",
"self",
".",
"password",
"=",
"config",
".",
"get",
"(",
"CONF_PASSWORD",
")",
"self",
".",
"success_init",
"=",
"True",
"# Establish a connection to the FRITZ!Box.",
"try",
":",
"self",
".",
"fritz_box",
"=",
"FritzHosts",
"(",
"address",
"=",
"self",
".",
"host",
",",
"user",
"=",
"self",
".",
"username",
",",
"password",
"=",
"self",
".",
"password",
")",
"except",
"(",
"ValueError",
",",
"TypeError",
")",
":",
"self",
".",
"fritz_box",
"=",
"None",
"# At this point it is difficult to tell if a connection is established.",
"# So just check for null objects.",
"if",
"self",
".",
"fritz_box",
"is",
"None",
"or",
"not",
"self",
".",
"fritz_box",
".",
"modelname",
":",
"self",
".",
"success_init",
"=",
"False",
"if",
"self",
".",
"success_init",
":",
"_LOGGER",
".",
"info",
"(",
"\"Successfully connected to %s\"",
",",
"self",
".",
"fritz_box",
".",
"modelname",
")",
"self",
".",
"_update_info",
"(",
")",
"else",
":",
"_LOGGER",
".",
"error",
"(",
"\"Failed to establish connection to FRITZ!Box with IP: %s\"",
",",
"self",
".",
"host",
")"
] | [
38,
4
] | [
65,
13
] | python | en | ['en', 'en', 'en'] | True |
FritzBoxScanner.scan_devices | (self) | Scan for new devices and return a list of found device ids. | Scan for new devices and return a list of found device ids. | def scan_devices(self):
"""Scan for new devices and return a list of found device ids."""
self._update_info()
active_hosts = []
for known_host in self.last_results:
if known_host["status"] and known_host.get("mac"):
active_hosts.append(known_host["mac"])
return active_hosts | [
"def",
"scan_devices",
"(",
"self",
")",
":",
"self",
".",
"_update_info",
"(",
")",
"active_hosts",
"=",
"[",
"]",
"for",
"known_host",
"in",
"self",
".",
"last_results",
":",
"if",
"known_host",
"[",
"\"status\"",
"]",
"and",
"known_host",
".",
"get",
"(",
"\"mac\"",
")",
":",
"active_hosts",
".",
"append",
"(",
"known_host",
"[",
"\"mac\"",
"]",
")",
"return",
"active_hosts"
] | [
67,
4
] | [
74,
27
] | python | en | ['en', 'en', 'en'] | True |
FritzBoxScanner.get_device_name | (self, device) | Return the name of the given device or None if is not known. | Return the name of the given device or None if is not known. | def get_device_name(self, device):
"""Return the name of the given device or None if is not known."""
ret = self.fritz_box.get_specific_host_entry(device).get("NewHostName")
if ret == {}:
return None
return ret | [
"def",
"get_device_name",
"(",
"self",
",",
"device",
")",
":",
"ret",
"=",
"self",
".",
"fritz_box",
".",
"get_specific_host_entry",
"(",
"device",
")",
".",
"get",
"(",
"\"NewHostName\"",
")",
"if",
"ret",
"==",
"{",
"}",
":",
"return",
"None",
"return",
"ret"
] | [
76,
4
] | [
81,
18
] | python | en | ['en', 'en', 'en'] | True |
FritzBoxScanner.get_extra_attributes | (self, device) | Return the attributes (ip, mac) of the given device or None if is not known. | Return the attributes (ip, mac) of the given device or None if is not known. | def get_extra_attributes(self, device):
"""Return the attributes (ip, mac) of the given device or None if is not known."""
ip_device = None
try:
ip_device = self.fritz_box.get_specific_host_entry(device).get(
"NewIPAddress"
)
except fritzexceptions.FritzLookUpError as fritz_lookup_error:
_LOGGER.warning(
"Host entry for %s not found: %s", device, fritz_lookup_error
)
if not ip_device:
return {}
return {"ip": ip_device, "mac": device} | [
"def",
"get_extra_attributes",
"(",
"self",
",",
"device",
")",
":",
"ip_device",
"=",
"None",
"try",
":",
"ip_device",
"=",
"self",
".",
"fritz_box",
".",
"get_specific_host_entry",
"(",
"device",
")",
".",
"get",
"(",
"\"NewIPAddress\"",
")",
"except",
"fritzexceptions",
".",
"FritzLookUpError",
"as",
"fritz_lookup_error",
":",
"_LOGGER",
".",
"warning",
"(",
"\"Host entry for %s not found: %s\"",
",",
"device",
",",
"fritz_lookup_error",
")",
"if",
"not",
"ip_device",
":",
"return",
"{",
"}",
"return",
"{",
"\"ip\"",
":",
"ip_device",
",",
"\"mac\"",
":",
"device",
"}"
] | [
83,
4
] | [
97,
47
] | python | en | ['en', 'en', 'en'] | True |
FritzBoxScanner._update_info | (self) | Retrieve latest information from the FRITZ!Box. | Retrieve latest information from the FRITZ!Box. | def _update_info(self):
"""Retrieve latest information from the FRITZ!Box."""
if not self.success_init:
return False
_LOGGER.debug("Scanning")
self.last_results = self.fritz_box.get_hosts_info()
return True | [
"def",
"_update_info",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"success_init",
":",
"return",
"False",
"_LOGGER",
".",
"debug",
"(",
"\"Scanning\"",
")",
"self",
".",
"last_results",
"=",
"self",
".",
"fritz_box",
".",
"get_hosts_info",
"(",
")",
"return",
"True"
] | [
99,
4
] | [
106,
19
] | python | en | ['en', 'en', 'en'] | True |
test_delete_script | (hass, hass_client) | Test deleting a script. | Test deleting a script. | async def test_delete_script(hass, hass_client):
"""Test deleting a script."""
with patch.object(config, "SECTIONS", ["script"]):
await async_setup_component(hass, "config", {})
client = await hass_client()
orig_data = {"one": {}, "two": {}}
def mock_read(path):
"""Mock reading data."""
return orig_data
written = []
def mock_write(path, data):
"""Mock writing data."""
written.append(data)
with patch("homeassistant.components.config._read", mock_read), patch(
"homeassistant.components.config._write", mock_write
):
resp = await client.delete("/api/config/script/config/two")
assert resp.status == 200
result = await resp.json()
assert result == {"result": "ok"}
assert len(written) == 1
assert written[0] == {"one": {}} | [
"async",
"def",
"test_delete_script",
"(",
"hass",
",",
"hass_client",
")",
":",
"with",
"patch",
".",
"object",
"(",
"config",
",",
"\"SECTIONS\"",
",",
"[",
"\"script\"",
"]",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"config\"",
",",
"{",
"}",
")",
"client",
"=",
"await",
"hass_client",
"(",
")",
"orig_data",
"=",
"{",
"\"one\"",
":",
"{",
"}",
",",
"\"two\"",
":",
"{",
"}",
"}",
"def",
"mock_read",
"(",
"path",
")",
":",
"\"\"\"Mock reading data.\"\"\"",
"return",
"orig_data",
"written",
"=",
"[",
"]",
"def",
"mock_write",
"(",
"path",
",",
"data",
")",
":",
"\"\"\"Mock writing data.\"\"\"",
"written",
".",
"append",
"(",
"data",
")",
"with",
"patch",
"(",
"\"homeassistant.components.config._read\"",
",",
"mock_read",
")",
",",
"patch",
"(",
"\"homeassistant.components.config._write\"",
",",
"mock_write",
")",
":",
"resp",
"=",
"await",
"client",
".",
"delete",
"(",
"\"/api/config/script/config/two\"",
")",
"assert",
"resp",
".",
"status",
"==",
"200",
"result",
"=",
"await",
"resp",
".",
"json",
"(",
")",
"assert",
"result",
"==",
"{",
"\"result\"",
":",
"\"ok\"",
"}",
"assert",
"len",
"(",
"written",
")",
"==",
"1",
"assert",
"written",
"[",
"0",
"]",
"==",
"{",
"\"one\"",
":",
"{",
"}",
"}"
] | [
7,
0
] | [
36,
36
] | python | ca | ['ca', 'en', 'pt'] | False |
async_setup | (hass, config) | Set up the Kodi integration. | Set up the Kodi integration. | async def async_setup(hass, config):
"""Set up the Kodi integration."""
hass.data.setdefault(DOMAIN, {})
return True | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"hass",
".",
"data",
".",
"setdefault",
"(",
"DOMAIN",
",",
"{",
"}",
")",
"return",
"True"
] | [
31,
0
] | [
34,
15
] | python | en | ['en', 'cs', 'en'] | True |
async_setup_entry | (hass: HomeAssistant, entry: ConfigEntry) | Set up Kodi from a config entry. | Set up Kodi from a config entry. | async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Set up Kodi from a config entry."""
conn = get_kodi_connection(
entry.data[CONF_HOST],
entry.data[CONF_PORT],
entry.data[CONF_WS_PORT],
entry.data[CONF_USERNAME],
entry.data[CONF_PASSWORD],
entry.data[CONF_SSL],
session=async_get_clientsession(hass),
)
kodi = Kodi(conn)
try:
await conn.connect()
except CannotConnectError:
pass
except InvalidAuthError as error:
_LOGGER.error(
"Login to %s failed: [%s]",
entry.data[CONF_HOST],
error,
)
return False
async def _close(event):
await conn.close()
remove_stop_listener = hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, _close)
hass.data[DOMAIN][entry.entry_id] = {
DATA_CONNECTION: conn,
DATA_KODI: kodi,
DATA_REMOVE_LISTENER: remove_stop_listener,
}
for component in PLATFORMS:
hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, component)
)
return True | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
":",
"conn",
"=",
"get_kodi_connection",
"(",
"entry",
".",
"data",
"[",
"CONF_HOST",
"]",
",",
"entry",
".",
"data",
"[",
"CONF_PORT",
"]",
",",
"entry",
".",
"data",
"[",
"CONF_WS_PORT",
"]",
",",
"entry",
".",
"data",
"[",
"CONF_USERNAME",
"]",
",",
"entry",
".",
"data",
"[",
"CONF_PASSWORD",
"]",
",",
"entry",
".",
"data",
"[",
"CONF_SSL",
"]",
",",
"session",
"=",
"async_get_clientsession",
"(",
"hass",
")",
",",
")",
"kodi",
"=",
"Kodi",
"(",
"conn",
")",
"try",
":",
"await",
"conn",
".",
"connect",
"(",
")",
"except",
"CannotConnectError",
":",
"pass",
"except",
"InvalidAuthError",
"as",
"error",
":",
"_LOGGER",
".",
"error",
"(",
"\"Login to %s failed: [%s]\"",
",",
"entry",
".",
"data",
"[",
"CONF_HOST",
"]",
",",
"error",
",",
")",
"return",
"False",
"async",
"def",
"_close",
"(",
"event",
")",
":",
"await",
"conn",
".",
"close",
"(",
")",
"remove_stop_listener",
"=",
"hass",
".",
"bus",
".",
"async_listen_once",
"(",
"EVENT_HOMEASSISTANT_STOP",
",",
"_close",
")",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"entry",
".",
"entry_id",
"]",
"=",
"{",
"DATA_CONNECTION",
":",
"conn",
",",
"DATA_KODI",
":",
"kodi",
",",
"DATA_REMOVE_LISTENER",
":",
"remove_stop_listener",
",",
"}",
"for",
"component",
"in",
"PLATFORMS",
":",
"hass",
".",
"async_create_task",
"(",
"hass",
".",
"config_entries",
".",
"async_forward_entry_setup",
"(",
"entry",
",",
"component",
")",
")",
"return",
"True"
] | [
37,
0
] | [
79,
15
] | python | en | ['en', 'en', 'en'] | True |
async_unload_entry | (hass: HomeAssistant, entry: ConfigEntry) | Unload a config entry. | Unload a config entry. | async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Unload a config entry."""
unload_ok = all(
await asyncio.gather(
*[
hass.config_entries.async_forward_entry_unload(entry, component)
for component in PLATFORMS
]
)
)
if unload_ok:
data = hass.data[DOMAIN].pop(entry.entry_id)
await data[DATA_CONNECTION].close()
data[DATA_REMOVE_LISTENER]()
return unload_ok | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
":",
"unload_ok",
"=",
"all",
"(",
"await",
"asyncio",
".",
"gather",
"(",
"*",
"[",
"hass",
".",
"config_entries",
".",
"async_forward_entry_unload",
"(",
"entry",
",",
"component",
")",
"for",
"component",
"in",
"PLATFORMS",
"]",
")",
")",
"if",
"unload_ok",
":",
"data",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
".",
"pop",
"(",
"entry",
".",
"entry_id",
")",
"await",
"data",
"[",
"DATA_CONNECTION",
"]",
".",
"close",
"(",
")",
"data",
"[",
"DATA_REMOVE_LISTENER",
"]",
"(",
")",
"return",
"unload_ok"
] | [
82,
0
] | [
97,
20
] | python | en | ['en', 'es', 'en'] | True |
AlexaDirective.__init__ | (self, request) | Initialize a directive. | Initialize a directive. | def __init__(self, request):
"""Initialize a directive."""
self._directive = request[API_DIRECTIVE]
self.namespace = self._directive[API_HEADER]["namespace"]
self.name = self._directive[API_HEADER]["name"]
self.payload = self._directive[API_PAYLOAD]
self.has_endpoint = API_ENDPOINT in self._directive
self.entity = self.entity_id = self.endpoint = self.instance = None | [
"def",
"__init__",
"(",
"self",
",",
"request",
")",
":",
"self",
".",
"_directive",
"=",
"request",
"[",
"API_DIRECTIVE",
"]",
"self",
".",
"namespace",
"=",
"self",
".",
"_directive",
"[",
"API_HEADER",
"]",
"[",
"\"namespace\"",
"]",
"self",
".",
"name",
"=",
"self",
".",
"_directive",
"[",
"API_HEADER",
"]",
"[",
"\"name\"",
"]",
"self",
".",
"payload",
"=",
"self",
".",
"_directive",
"[",
"API_PAYLOAD",
"]",
"self",
".",
"has_endpoint",
"=",
"API_ENDPOINT",
"in",
"self",
".",
"_directive",
"self",
".",
"entity",
"=",
"self",
".",
"entity_id",
"=",
"self",
".",
"endpoint",
"=",
"self",
".",
"instance",
"=",
"None"
] | [
22,
4
] | [
30,
75
] | python | it | ['it', 'en', 'it'] | True |
AlexaDirective.load_entity | (self, hass, config) | Set attributes related to the entity for this request.
Sets these attributes when self.has_endpoint is True:
- entity
- entity_id
- endpoint
- instance (when header includes instance property)
Behavior when self.has_endpoint is False is undefined.
Will raise AlexaInvalidEndpointError if the endpoint in the request is
malformed or nonexistent.
| Set attributes related to the entity for this request. | def load_entity(self, hass, config):
"""Set attributes related to the entity for this request.
Sets these attributes when self.has_endpoint is True:
- entity
- entity_id
- endpoint
- instance (when header includes instance property)
Behavior when self.has_endpoint is False is undefined.
Will raise AlexaInvalidEndpointError if the endpoint in the request is
malformed or nonexistent.
"""
_endpoint_id = self._directive[API_ENDPOINT]["endpointId"]
self.entity_id = _endpoint_id.replace("#", ".")
self.entity = hass.states.get(self.entity_id)
if not self.entity or not config.should_expose(self.entity_id):
raise AlexaInvalidEndpointError(_endpoint_id)
self.endpoint = ENTITY_ADAPTERS[self.entity.domain](hass, config, self.entity)
if "instance" in self._directive[API_HEADER]:
self.instance = self._directive[API_HEADER]["instance"] | [
"def",
"load_entity",
"(",
"self",
",",
"hass",
",",
"config",
")",
":",
"_endpoint_id",
"=",
"self",
".",
"_directive",
"[",
"API_ENDPOINT",
"]",
"[",
"\"endpointId\"",
"]",
"self",
".",
"entity_id",
"=",
"_endpoint_id",
".",
"replace",
"(",
"\"#\"",
",",
"\".\"",
")",
"self",
".",
"entity",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"self",
".",
"entity_id",
")",
"if",
"not",
"self",
".",
"entity",
"or",
"not",
"config",
".",
"should_expose",
"(",
"self",
".",
"entity_id",
")",
":",
"raise",
"AlexaInvalidEndpointError",
"(",
"_endpoint_id",
")",
"self",
".",
"endpoint",
"=",
"ENTITY_ADAPTERS",
"[",
"self",
".",
"entity",
".",
"domain",
"]",
"(",
"hass",
",",
"config",
",",
"self",
".",
"entity",
")",
"if",
"\"instance\"",
"in",
"self",
".",
"_directive",
"[",
"API_HEADER",
"]",
":",
"self",
".",
"instance",
"=",
"self",
".",
"_directive",
"[",
"API_HEADER",
"]",
"[",
"\"instance\"",
"]"
] | [
32,
4
] | [
56,
67
] | python | en | ['en', 'en', 'en'] | True |
AlexaDirective.response | (self, name="Response", namespace="Alexa", payload=None) | Create an API formatted response.
Async friendly.
| Create an API formatted response. | def response(self, name="Response", namespace="Alexa", payload=None):
"""Create an API formatted response.
Async friendly.
"""
response = AlexaResponse(name, namespace, payload)
token = self._directive[API_HEADER].get("correlationToken")
if token:
response.set_correlation_token(token)
if self.has_endpoint:
response.set_endpoint(self._directive[API_ENDPOINT].copy())
return response | [
"def",
"response",
"(",
"self",
",",
"name",
"=",
"\"Response\"",
",",
"namespace",
"=",
"\"Alexa\"",
",",
"payload",
"=",
"None",
")",
":",
"response",
"=",
"AlexaResponse",
"(",
"name",
",",
"namespace",
",",
"payload",
")",
"token",
"=",
"self",
".",
"_directive",
"[",
"API_HEADER",
"]",
".",
"get",
"(",
"\"correlationToken\"",
")",
"if",
"token",
":",
"response",
".",
"set_correlation_token",
"(",
"token",
")",
"if",
"self",
".",
"has_endpoint",
":",
"response",
".",
"set_endpoint",
"(",
"self",
".",
"_directive",
"[",
"API_ENDPOINT",
"]",
".",
"copy",
"(",
")",
")",
"return",
"response"
] | [
58,
4
] | [
72,
23
] | python | en | ['en', 'en', 'en'] | True |
AlexaDirective.error | (
self,
namespace="Alexa",
error_type="INTERNAL_ERROR",
error_message="",
payload=None,
) | Create a API formatted error response.
Async friendly.
| Create a API formatted error response. | def error(
self,
namespace="Alexa",
error_type="INTERNAL_ERROR",
error_message="",
payload=None,
):
"""Create a API formatted error response.
Async friendly.
"""
payload = payload or {}
payload["type"] = error_type
payload["message"] = error_message
_LOGGER.info(
"Request %s/%s error %s: %s",
self._directive[API_HEADER]["namespace"],
self._directive[API_HEADER]["name"],
error_type,
error_message,
)
return self.response(name="ErrorResponse", namespace=namespace, payload=payload) | [
"def",
"error",
"(",
"self",
",",
"namespace",
"=",
"\"Alexa\"",
",",
"error_type",
"=",
"\"INTERNAL_ERROR\"",
",",
"error_message",
"=",
"\"\"",
",",
"payload",
"=",
"None",
",",
")",
":",
"payload",
"=",
"payload",
"or",
"{",
"}",
"payload",
"[",
"\"type\"",
"]",
"=",
"error_type",
"payload",
"[",
"\"message\"",
"]",
"=",
"error_message",
"_LOGGER",
".",
"info",
"(",
"\"Request %s/%s error %s: %s\"",
",",
"self",
".",
"_directive",
"[",
"API_HEADER",
"]",
"[",
"\"namespace\"",
"]",
",",
"self",
".",
"_directive",
"[",
"API_HEADER",
"]",
"[",
"\"name\"",
"]",
",",
"error_type",
",",
"error_message",
",",
")",
"return",
"self",
".",
"response",
"(",
"name",
"=",
"\"ErrorResponse\"",
",",
"namespace",
"=",
"namespace",
",",
"payload",
"=",
"payload",
")"
] | [
74,
4
] | [
97,
88
] | python | en | ['en', 'en', 'en'] | True |
AlexaResponse.__init__ | (self, name, namespace, payload=None) | Initialize the response. | Initialize the response. | def __init__(self, name, namespace, payload=None):
"""Initialize the response."""
payload = payload or {}
self._response = {
API_EVENT: {
API_HEADER: {
"namespace": namespace,
"name": name,
"messageId": str(uuid4()),
"payloadVersion": "3",
},
API_PAYLOAD: payload,
}
} | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"namespace",
",",
"payload",
"=",
"None",
")",
":",
"payload",
"=",
"payload",
"or",
"{",
"}",
"self",
".",
"_response",
"=",
"{",
"API_EVENT",
":",
"{",
"API_HEADER",
":",
"{",
"\"namespace\"",
":",
"namespace",
",",
"\"name\"",
":",
"name",
",",
"\"messageId\"",
":",
"str",
"(",
"uuid4",
"(",
")",
")",
",",
"\"payloadVersion\"",
":",
"\"3\"",
",",
"}",
",",
"API_PAYLOAD",
":",
"payload",
",",
"}",
"}"
] | [
103,
4
] | [
116,
9
] | python | en | ['en', 'en', 'en'] | True |
AlexaResponse.name | (self) | Return the name of this response. | Return the name of this response. | def name(self):
"""Return the name of this response."""
return self._response[API_EVENT][API_HEADER]["name"] | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_response",
"[",
"API_EVENT",
"]",
"[",
"API_HEADER",
"]",
"[",
"\"name\"",
"]"
] | [
119,
4
] | [
121,
60
] | python | en | ['en', 'en', 'en'] | True |
AlexaResponse.namespace | (self) | Return the namespace of this response. | Return the namespace of this response. | def namespace(self):
"""Return the namespace of this response."""
return self._response[API_EVENT][API_HEADER]["namespace"] | [
"def",
"namespace",
"(",
"self",
")",
":",
"return",
"self",
".",
"_response",
"[",
"API_EVENT",
"]",
"[",
"API_HEADER",
"]",
"[",
"\"namespace\"",
"]"
] | [
124,
4
] | [
126,
65
] | python | en | ['en', 'en', 'en'] | True |
AlexaResponse.set_correlation_token | (self, token) | Set the correlationToken.
This should normally mirror the value from a request, and is set by
AlexaDirective.response() usually.
| Set the correlationToken. | def set_correlation_token(self, token):
"""Set the correlationToken.
This should normally mirror the value from a request, and is set by
AlexaDirective.response() usually.
"""
self._response[API_EVENT][API_HEADER]["correlationToken"] = token | [
"def",
"set_correlation_token",
"(",
"self",
",",
"token",
")",
":",
"self",
".",
"_response",
"[",
"API_EVENT",
"]",
"[",
"API_HEADER",
"]",
"[",
"\"correlationToken\"",
"]",
"=",
"token"
] | [
128,
4
] | [
134,
73
] | python | en | ['en', 'sr', 'en'] | True |
AlexaResponse.set_endpoint_full | (self, bearer_token, endpoint_id, cookie=None) | Set the endpoint dictionary.
This is used to send proactive messages to Alexa.
| Set the endpoint dictionary. | def set_endpoint_full(self, bearer_token, endpoint_id, cookie=None):
"""Set the endpoint dictionary.
This is used to send proactive messages to Alexa.
"""
self._response[API_EVENT][API_ENDPOINT] = {
API_SCOPE: {"type": "BearerToken", "token": bearer_token}
}
if endpoint_id is not None:
self._response[API_EVENT][API_ENDPOINT]["endpointId"] = endpoint_id
if cookie is not None:
self._response[API_EVENT][API_ENDPOINT]["cookie"] = cookie | [
"def",
"set_endpoint_full",
"(",
"self",
",",
"bearer_token",
",",
"endpoint_id",
",",
"cookie",
"=",
"None",
")",
":",
"self",
".",
"_response",
"[",
"API_EVENT",
"]",
"[",
"API_ENDPOINT",
"]",
"=",
"{",
"API_SCOPE",
":",
"{",
"\"type\"",
":",
"\"BearerToken\"",
",",
"\"token\"",
":",
"bearer_token",
"}",
"}",
"if",
"endpoint_id",
"is",
"not",
"None",
":",
"self",
".",
"_response",
"[",
"API_EVENT",
"]",
"[",
"API_ENDPOINT",
"]",
"[",
"\"endpointId\"",
"]",
"=",
"endpoint_id",
"if",
"cookie",
"is",
"not",
"None",
":",
"self",
".",
"_response",
"[",
"API_EVENT",
"]",
"[",
"API_ENDPOINT",
"]",
"[",
"\"cookie\"",
"]",
"=",
"cookie"
] | [
136,
4
] | [
149,
70
] | python | en | ['en', 'en', 'en'] | True |
AlexaResponse.set_endpoint | (self, endpoint) | Set the endpoint.
This should normally mirror the value from a request, and is set by
AlexaDirective.response() usually.
| Set the endpoint. | def set_endpoint(self, endpoint):
"""Set the endpoint.
This should normally mirror the value from a request, and is set by
AlexaDirective.response() usually.
"""
self._response[API_EVENT][API_ENDPOINT] = endpoint | [
"def",
"set_endpoint",
"(",
"self",
",",
"endpoint",
")",
":",
"self",
".",
"_response",
"[",
"API_EVENT",
"]",
"[",
"API_ENDPOINT",
"]",
"=",
"endpoint"
] | [
151,
4
] | [
157,
58
] | python | en | ['en', 'en', 'en'] | True |
AlexaResponse.add_context_property | (self, prop) | Add a property to the response context.
The Alexa response includes a list of properties which provides
feedback on how states have changed. For example if a user asks,
"Alexa, set thermostat to 20 degrees", the API expects a response with
the new value of the property, and Alexa will respond to the user
"Thermostat set to 20 degrees".
async_handle_message() will call .merge_context_properties() for every
request automatically, however often handlers will call services to
change state but the effects of those changes are applied
asynchronously. Thus, handlers should call this method to confirm
changes before returning.
| Add a property to the response context. | def add_context_property(self, prop):
"""Add a property to the response context.
The Alexa response includes a list of properties which provides
feedback on how states have changed. For example if a user asks,
"Alexa, set thermostat to 20 degrees", the API expects a response with
the new value of the property, and Alexa will respond to the user
"Thermostat set to 20 degrees".
async_handle_message() will call .merge_context_properties() for every
request automatically, however often handlers will call services to
change state but the effects of those changes are applied
asynchronously. Thus, handlers should call this method to confirm
changes before returning.
"""
self._properties().append(prop) | [
"def",
"add_context_property",
"(",
"self",
",",
"prop",
")",
":",
"self",
".",
"_properties",
"(",
")",
".",
"append",
"(",
"prop",
")"
] | [
163,
4
] | [
178,
39
] | python | en | ['en', 'en', 'en'] | True |
AlexaResponse.merge_context_properties | (self, endpoint) | Add all properties from given endpoint if not already set.
Handlers should be using .add_context_property().
| Add all properties from given endpoint if not already set. | def merge_context_properties(self, endpoint):
"""Add all properties from given endpoint if not already set.
Handlers should be using .add_context_property().
"""
properties = self._properties()
already_set = {(p["namespace"], p["name"]) for p in properties}
for prop in endpoint.serialize_properties():
if (prop["namespace"], prop["name"]) not in already_set:
self.add_context_property(prop) | [
"def",
"merge_context_properties",
"(",
"self",
",",
"endpoint",
")",
":",
"properties",
"=",
"self",
".",
"_properties",
"(",
")",
"already_set",
"=",
"{",
"(",
"p",
"[",
"\"namespace\"",
"]",
",",
"p",
"[",
"\"name\"",
"]",
")",
"for",
"p",
"in",
"properties",
"}",
"for",
"prop",
"in",
"endpoint",
".",
"serialize_properties",
"(",
")",
":",
"if",
"(",
"prop",
"[",
"\"namespace\"",
"]",
",",
"prop",
"[",
"\"name\"",
"]",
")",
"not",
"in",
"already_set",
":",
"self",
".",
"add_context_property",
"(",
"prop",
")"
] | [
180,
4
] | [
190,
47
] | python | en | ['en', 'en', 'en'] | True |
AlexaResponse.serialize | (self) | Return response as a JSON-able data structure. | Return response as a JSON-able data structure. | def serialize(self):
"""Return response as a JSON-able data structure."""
return self._response | [
"def",
"serialize",
"(",
"self",
")",
":",
"return",
"self",
".",
"_response"
] | [
192,
4
] | [
194,
29
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (
hass: HomeAssistantType,
config_entry: ConfigEntry,
async_add_entities: Callable[[List[Entity], bool], None],
) | Set up from config entry. | Set up from config entry. | async def async_setup_entry(
hass: HomeAssistantType,
config_entry: ConfigEntry,
async_add_entities: Callable[[List[Entity], bool], None],
) -> None:
"""Set up from config entry."""
router = hass.data[DOMAIN].routers[config_entry.data[CONF_URL]]
switches: List[Entity] = []
if router.data.get(KEY_DIALUP_MOBILE_DATASWITCH):
switches.append(HuaweiLteMobileDataSwitch(router))
async_add_entities(switches, True) | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistantType",
",",
"config_entry",
":",
"ConfigEntry",
",",
"async_add_entities",
":",
"Callable",
"[",
"[",
"List",
"[",
"Entity",
"]",
",",
"bool",
"]",
",",
"None",
"]",
",",
")",
"->",
"None",
":",
"router",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
".",
"routers",
"[",
"config_entry",
".",
"data",
"[",
"CONF_URL",
"]",
"]",
"switches",
":",
"List",
"[",
"Entity",
"]",
"=",
"[",
"]",
"if",
"router",
".",
"data",
".",
"get",
"(",
"KEY_DIALUP_MOBILE_DATASWITCH",
")",
":",
"switches",
".",
"append",
"(",
"HuaweiLteMobileDataSwitch",
"(",
"router",
")",
")",
"async_add_entities",
"(",
"switches",
",",
"True",
")"
] | [
23,
0
] | [
35,
38
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass, config) | Set up the Cast component. | Set up the Cast component. | async def async_setup(hass, config):
"""Set up the Cast component."""
conf = config.get(DOMAIN)
hass.data[DOMAIN] = conf or {}
if conf is not None:
hass.async_create_task(
hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_IMPORT}
)
)
return True | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"conf",
"=",
"config",
".",
"get",
"(",
"DOMAIN",
")",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"=",
"conf",
"or",
"{",
"}",
"if",
"conf",
"is",
"not",
"None",
":",
"hass",
".",
"async_create_task",
"(",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"config_entries",
".",
"SOURCE_IMPORT",
"}",
")",
")",
"return",
"True"
] | [
7,
0
] | [
20,
15
] | python | en | ['en', 'fr', 'en'] | True |
async_setup_entry | (hass, entry: config_entries.ConfigEntry) | Set up Cast from a config entry. | Set up Cast from a config entry. | async def async_setup_entry(hass, entry: config_entries.ConfigEntry):
"""Set up Cast from a config entry."""
await home_assistant_cast.async_setup_ha_cast(hass, entry)
hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, "media_player")
)
return True | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"entry",
":",
"config_entries",
".",
"ConfigEntry",
")",
":",
"await",
"home_assistant_cast",
".",
"async_setup_ha_cast",
"(",
"hass",
",",
"entry",
")",
"hass",
".",
"async_create_task",
"(",
"hass",
".",
"config_entries",
".",
"async_forward_entry_setup",
"(",
"entry",
",",
"\"media_player\"",
")",
")",
"return",
"True"
] | [
23,
0
] | [
30,
15
] | python | en | ['en', 'en', 'en'] | True |
async_add_entities | (
_async_add_entities: Callable,
entities: List[
Tuple[
zha_typing.ZhaEntityType,
Tuple[str, zha_typing.ZhaDeviceType, List[zha_typing.ChannelType]],
]
],
update_before_add: bool = True,
) | Add entities helper. | Add entities helper. | async def async_add_entities(
_async_add_entities: Callable,
entities: List[
Tuple[
zha_typing.ZhaEntityType,
Tuple[str, zha_typing.ZhaDeviceType, List[zha_typing.ChannelType]],
]
],
update_before_add: bool = True,
) -> None:
"""Add entities helper."""
if not entities:
return
to_add = [ent_cls(*args) for ent_cls, args in entities]
_async_add_entities(to_add, update_before_add=update_before_add)
entities.clear() | [
"async",
"def",
"async_add_entities",
"(",
"_async_add_entities",
":",
"Callable",
",",
"entities",
":",
"List",
"[",
"Tuple",
"[",
"zha_typing",
".",
"ZhaEntityType",
",",
"Tuple",
"[",
"str",
",",
"zha_typing",
".",
"ZhaDeviceType",
",",
"List",
"[",
"zha_typing",
".",
"ChannelType",
"]",
"]",
",",
"]",
"]",
",",
"update_before_add",
":",
"bool",
"=",
"True",
",",
")",
"->",
"None",
":",
"if",
"not",
"entities",
":",
"return",
"to_add",
"=",
"[",
"ent_cls",
"(",
"*",
"args",
")",
"for",
"ent_cls",
",",
"args",
"in",
"entities",
"]",
"_async_add_entities",
"(",
"to_add",
",",
"update_before_add",
"=",
"update_before_add",
")",
"entities",
".",
"clear",
"(",
")"
] | [
33,
0
] | [
48,
20
] | python | en | ['en', 'fy', 'en'] | True |
ProbeEndpoint.__init__ | (self) | Initialize instance. | Initialize instance. | def __init__(self):
"""Initialize instance."""
self._device_configs = {} | [
"def",
"__init__",
"(",
"self",
")",
":",
"self",
".",
"_device_configs",
"=",
"{",
"}"
] | [
54,
4
] | [
56,
33
] | python | en | ['en', 'en', 'it'] | False |
ProbeEndpoint.discover_entities | (self, channel_pool: zha_typing.ChannelPoolType) | Process an endpoint on a zigpy device. | Process an endpoint on a zigpy device. | def discover_entities(self, channel_pool: zha_typing.ChannelPoolType) -> None:
"""Process an endpoint on a zigpy device."""
self.discover_by_device_type(channel_pool)
self.discover_by_cluster_id(channel_pool) | [
"def",
"discover_entities",
"(",
"self",
",",
"channel_pool",
":",
"zha_typing",
".",
"ChannelPoolType",
")",
"->",
"None",
":",
"self",
".",
"discover_by_device_type",
"(",
"channel_pool",
")",
"self",
".",
"discover_by_cluster_id",
"(",
"channel_pool",
")"
] | [
59,
4
] | [
62,
49
] | python | en | ['en', 'en', 'en'] | True |
ProbeEndpoint.discover_by_device_type | (self, channel_pool: zha_typing.ChannelPoolType) | Process an endpoint on a zigpy device. | Process an endpoint on a zigpy device. | def discover_by_device_type(self, channel_pool: zha_typing.ChannelPoolType) -> None:
"""Process an endpoint on a zigpy device."""
unique_id = channel_pool.unique_id
component = self._device_configs.get(unique_id, {}).get(ha_const.CONF_TYPE)
if component is None:
ep_profile_id = channel_pool.endpoint.profile_id
ep_device_type = channel_pool.endpoint.device_type
component = zha_regs.DEVICE_CLASS[ep_profile_id].get(ep_device_type)
if component and component in zha_const.COMPONENTS:
channels = channel_pool.unclaimed_channels()
entity_class, claimed = zha_regs.ZHA_ENTITIES.get_entity(
component, channel_pool.manufacturer, channel_pool.model, channels
)
if entity_class is None:
return
channel_pool.claim_channels(claimed)
channel_pool.async_new_entity(component, entity_class, unique_id, claimed) | [
"def",
"discover_by_device_type",
"(",
"self",
",",
"channel_pool",
":",
"zha_typing",
".",
"ChannelPoolType",
")",
"->",
"None",
":",
"unique_id",
"=",
"channel_pool",
".",
"unique_id",
"component",
"=",
"self",
".",
"_device_configs",
".",
"get",
"(",
"unique_id",
",",
"{",
"}",
")",
".",
"get",
"(",
"ha_const",
".",
"CONF_TYPE",
")",
"if",
"component",
"is",
"None",
":",
"ep_profile_id",
"=",
"channel_pool",
".",
"endpoint",
".",
"profile_id",
"ep_device_type",
"=",
"channel_pool",
".",
"endpoint",
".",
"device_type",
"component",
"=",
"zha_regs",
".",
"DEVICE_CLASS",
"[",
"ep_profile_id",
"]",
".",
"get",
"(",
"ep_device_type",
")",
"if",
"component",
"and",
"component",
"in",
"zha_const",
".",
"COMPONENTS",
":",
"channels",
"=",
"channel_pool",
".",
"unclaimed_channels",
"(",
")",
"entity_class",
",",
"claimed",
"=",
"zha_regs",
".",
"ZHA_ENTITIES",
".",
"get_entity",
"(",
"component",
",",
"channel_pool",
".",
"manufacturer",
",",
"channel_pool",
".",
"model",
",",
"channels",
")",
"if",
"entity_class",
"is",
"None",
":",
"return",
"channel_pool",
".",
"claim_channels",
"(",
"claimed",
")",
"channel_pool",
".",
"async_new_entity",
"(",
"component",
",",
"entity_class",
",",
"unique_id",
",",
"claimed",
")"
] | [
65,
4
] | [
84,
86
] | python | en | ['en', 'en', 'en'] | True |
ProbeEndpoint.discover_by_cluster_id | (self, channel_pool: zha_typing.ChannelPoolType) | Process an endpoint on a zigpy device. | Process an endpoint on a zigpy device. | def discover_by_cluster_id(self, channel_pool: zha_typing.ChannelPoolType) -> None:
"""Process an endpoint on a zigpy device."""
items = zha_regs.SINGLE_INPUT_CLUSTER_DEVICE_CLASS.items()
single_input_clusters = {
cluster_class: match
for cluster_class, match in items
if not isinstance(cluster_class, int)
}
remaining_channels = channel_pool.unclaimed_channels()
for channel in remaining_channels:
if channel.cluster.cluster_id in zha_regs.CHANNEL_ONLY_CLUSTERS:
channel_pool.claim_channels([channel])
continue
component = zha_regs.SINGLE_INPUT_CLUSTER_DEVICE_CLASS.get(
channel.cluster.cluster_id
)
if component is None:
for cluster_class, match in single_input_clusters.items():
if isinstance(channel.cluster, cluster_class):
component = match
break
self.probe_single_cluster(component, channel, channel_pool)
# until we can get rid off registries
self.handle_on_off_output_cluster_exception(channel_pool) | [
"def",
"discover_by_cluster_id",
"(",
"self",
",",
"channel_pool",
":",
"zha_typing",
".",
"ChannelPoolType",
")",
"->",
"None",
":",
"items",
"=",
"zha_regs",
".",
"SINGLE_INPUT_CLUSTER_DEVICE_CLASS",
".",
"items",
"(",
")",
"single_input_clusters",
"=",
"{",
"cluster_class",
":",
"match",
"for",
"cluster_class",
",",
"match",
"in",
"items",
"if",
"not",
"isinstance",
"(",
"cluster_class",
",",
"int",
")",
"}",
"remaining_channels",
"=",
"channel_pool",
".",
"unclaimed_channels",
"(",
")",
"for",
"channel",
"in",
"remaining_channels",
":",
"if",
"channel",
".",
"cluster",
".",
"cluster_id",
"in",
"zha_regs",
".",
"CHANNEL_ONLY_CLUSTERS",
":",
"channel_pool",
".",
"claim_channels",
"(",
"[",
"channel",
"]",
")",
"continue",
"component",
"=",
"zha_regs",
".",
"SINGLE_INPUT_CLUSTER_DEVICE_CLASS",
".",
"get",
"(",
"channel",
".",
"cluster",
".",
"cluster_id",
")",
"if",
"component",
"is",
"None",
":",
"for",
"cluster_class",
",",
"match",
"in",
"single_input_clusters",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"channel",
".",
"cluster",
",",
"cluster_class",
")",
":",
"component",
"=",
"match",
"break",
"self",
".",
"probe_single_cluster",
"(",
"component",
",",
"channel",
",",
"channel_pool",
")",
"# until we can get rid off registries",
"self",
".",
"handle_on_off_output_cluster_exception",
"(",
"channel_pool",
")"
] | [
87,
4
] | [
114,
65
] | python | en | ['en', 'en', 'en'] | True |
ProbeEndpoint.probe_single_cluster | (
component: str,
channel: zha_typing.ChannelType,
ep_channels: zha_typing.ChannelPoolType,
) | Probe specified cluster for specific component. | Probe specified cluster for specific component. | def probe_single_cluster(
component: str,
channel: zha_typing.ChannelType,
ep_channels: zha_typing.ChannelPoolType,
) -> None:
"""Probe specified cluster for specific component."""
if component is None or component not in zha_const.COMPONENTS:
return
channel_list = [channel]
unique_id = f"{ep_channels.unique_id}-{channel.cluster.cluster_id}"
entity_class, claimed = zha_regs.ZHA_ENTITIES.get_entity(
component, ep_channels.manufacturer, ep_channels.model, channel_list
)
if entity_class is None:
return
ep_channels.claim_channels(claimed)
ep_channels.async_new_entity(component, entity_class, unique_id, claimed) | [
"def",
"probe_single_cluster",
"(",
"component",
":",
"str",
",",
"channel",
":",
"zha_typing",
".",
"ChannelType",
",",
"ep_channels",
":",
"zha_typing",
".",
"ChannelPoolType",
",",
")",
"->",
"None",
":",
"if",
"component",
"is",
"None",
"or",
"component",
"not",
"in",
"zha_const",
".",
"COMPONENTS",
":",
"return",
"channel_list",
"=",
"[",
"channel",
"]",
"unique_id",
"=",
"f\"{ep_channels.unique_id}-{channel.cluster.cluster_id}\"",
"entity_class",
",",
"claimed",
"=",
"zha_regs",
".",
"ZHA_ENTITIES",
".",
"get_entity",
"(",
"component",
",",
"ep_channels",
".",
"manufacturer",
",",
"ep_channels",
".",
"model",
",",
"channel_list",
")",
"if",
"entity_class",
"is",
"None",
":",
"return",
"ep_channels",
".",
"claim_channels",
"(",
"claimed",
")",
"ep_channels",
".",
"async_new_entity",
"(",
"component",
",",
"entity_class",
",",
"unique_id",
",",
"claimed",
")"
] | [
117,
4
] | [
134,
81
] | python | en | ['en', 'en', 'en'] | True |
ProbeEndpoint.handle_on_off_output_cluster_exception | (
self, ep_channels: zha_typing.ChannelPoolType
) | Process output clusters of the endpoint. | Process output clusters of the endpoint. | def handle_on_off_output_cluster_exception(
self, ep_channels: zha_typing.ChannelPoolType
) -> None:
"""Process output clusters of the endpoint."""
profile_id = ep_channels.endpoint.profile_id
device_type = ep_channels.endpoint.device_type
if device_type in zha_regs.REMOTE_DEVICE_TYPES.get(profile_id, []):
return
for cluster_id, cluster in ep_channels.endpoint.out_clusters.items():
component = zha_regs.SINGLE_OUTPUT_CLUSTER_DEVICE_CLASS.get(
cluster.cluster_id
)
if component is None:
continue
channel_class = zha_regs.ZIGBEE_CHANNEL_REGISTRY.get(
cluster_id, base.ZigbeeChannel
)
channel = channel_class(cluster, ep_channels)
self.probe_single_cluster(component, channel, ep_channels) | [
"def",
"handle_on_off_output_cluster_exception",
"(",
"self",
",",
"ep_channels",
":",
"zha_typing",
".",
"ChannelPoolType",
")",
"->",
"None",
":",
"profile_id",
"=",
"ep_channels",
".",
"endpoint",
".",
"profile_id",
"device_type",
"=",
"ep_channels",
".",
"endpoint",
".",
"device_type",
"if",
"device_type",
"in",
"zha_regs",
".",
"REMOTE_DEVICE_TYPES",
".",
"get",
"(",
"profile_id",
",",
"[",
"]",
")",
":",
"return",
"for",
"cluster_id",
",",
"cluster",
"in",
"ep_channels",
".",
"endpoint",
".",
"out_clusters",
".",
"items",
"(",
")",
":",
"component",
"=",
"zha_regs",
".",
"SINGLE_OUTPUT_CLUSTER_DEVICE_CLASS",
".",
"get",
"(",
"cluster",
".",
"cluster_id",
")",
"if",
"component",
"is",
"None",
":",
"continue",
"channel_class",
"=",
"zha_regs",
".",
"ZIGBEE_CHANNEL_REGISTRY",
".",
"get",
"(",
"cluster_id",
",",
"base",
".",
"ZigbeeChannel",
")",
"channel",
"=",
"channel_class",
"(",
"cluster",
",",
"ep_channels",
")",
"self",
".",
"probe_single_cluster",
"(",
"component",
",",
"channel",
",",
"ep_channels",
")"
] | [
136,
4
] | [
157,
70
] | python | en | ['en', 'en', 'en'] | True |
ProbeEndpoint.initialize | (self, hass: HomeAssistantType) | Update device overrides config. | Update device overrides config. | def initialize(self, hass: HomeAssistantType) -> None:
"""Update device overrides config."""
zha_config = hass.data[zha_const.DATA_ZHA].get(zha_const.DATA_ZHA_CONFIG, {})
overrides = zha_config.get(zha_const.CONF_DEVICE_CONFIG)
if overrides:
self._device_configs.update(overrides) | [
"def",
"initialize",
"(",
"self",
",",
"hass",
":",
"HomeAssistantType",
")",
"->",
"None",
":",
"zha_config",
"=",
"hass",
".",
"data",
"[",
"zha_const",
".",
"DATA_ZHA",
"]",
".",
"get",
"(",
"zha_const",
".",
"DATA_ZHA_CONFIG",
",",
"{",
"}",
")",
"overrides",
"=",
"zha_config",
".",
"get",
"(",
"zha_const",
".",
"CONF_DEVICE_CONFIG",
")",
"if",
"overrides",
":",
"self",
".",
"_device_configs",
".",
"update",
"(",
"overrides",
")"
] | [
159,
4
] | [
164,
50
] | python | en | ['fr', 'en', 'en'] | True |
GroupProbe.__init__ | (self) | Initialize instance. | Initialize instance. | def __init__(self):
"""Initialize instance."""
self._hass = None
self._unsubs = [] | [
"def",
"__init__",
"(",
"self",
")",
":",
"self",
".",
"_hass",
"=",
"None",
"self",
".",
"_unsubs",
"=",
"[",
"]"
] | [
170,
4
] | [
173,
25
] | python | en | ['en', 'en', 'it'] | False |
GroupProbe.initialize | (self, hass: HomeAssistantType) | Initialize the group probe. | Initialize the group probe. | def initialize(self, hass: HomeAssistantType) -> None:
"""Initialize the group probe."""
self._hass = hass
self._unsubs.append(
async_dispatcher_connect(
hass, zha_const.SIGNAL_GROUP_ENTITY_REMOVED, self._reprobe_group
)
) | [
"def",
"initialize",
"(",
"self",
",",
"hass",
":",
"HomeAssistantType",
")",
"->",
"None",
":",
"self",
".",
"_hass",
"=",
"hass",
"self",
".",
"_unsubs",
".",
"append",
"(",
"async_dispatcher_connect",
"(",
"hass",
",",
"zha_const",
".",
"SIGNAL_GROUP_ENTITY_REMOVED",
",",
"self",
".",
"_reprobe_group",
")",
")"
] | [
175,
4
] | [
182,
9
] | python | en | ['en', 'en', 'en'] | True |
GroupProbe.cleanup | (self) | Clean up on when zha shuts down. | Clean up on when zha shuts down. | def cleanup(self):
"""Clean up on when zha shuts down."""
for unsub in self._unsubs[:]:
unsub()
self._unsubs.remove(unsub) | [
"def",
"cleanup",
"(",
"self",
")",
":",
"for",
"unsub",
"in",
"self",
".",
"_unsubs",
"[",
":",
"]",
":",
"unsub",
"(",
")",
"self",
".",
"_unsubs",
".",
"remove",
"(",
"unsub",
")"
] | [
184,
4
] | [
188,
38
] | python | en | ['en', 'en', 'en'] | True |
GroupProbe._reprobe_group | (self, group_id: int) | Reprobe a group for entities after its members change. | Reprobe a group for entities after its members change. | def _reprobe_group(self, group_id: int) -> None:
"""Reprobe a group for entities after its members change."""
zha_gateway = self._hass.data[zha_const.DATA_ZHA][zha_const.DATA_ZHA_GATEWAY]
zha_group = zha_gateway.groups.get(group_id)
if zha_group is None:
return
self.discover_group_entities(zha_group) | [
"def",
"_reprobe_group",
"(",
"self",
",",
"group_id",
":",
"int",
")",
"->",
"None",
":",
"zha_gateway",
"=",
"self",
".",
"_hass",
".",
"data",
"[",
"zha_const",
".",
"DATA_ZHA",
"]",
"[",
"zha_const",
".",
"DATA_ZHA_GATEWAY",
"]",
"zha_group",
"=",
"zha_gateway",
".",
"groups",
".",
"get",
"(",
"group_id",
")",
"if",
"zha_group",
"is",
"None",
":",
"return",
"self",
".",
"discover_group_entities",
"(",
"zha_group",
")"
] | [
190,
4
] | [
196,
47
] | python | en | ['en', 'en', 'en'] | True |
GroupProbe.discover_group_entities | (self, group: zha_typing.ZhaGroupType) | Process a group and create any entities that are needed. | Process a group and create any entities that are needed. | def discover_group_entities(self, group: zha_typing.ZhaGroupType) -> None:
"""Process a group and create any entities that are needed."""
# only create a group entity if there are 2 or more members in a group
if len(group.members) < 2:
_LOGGER.debug(
"Group: %s:0x%04x has less than 2 members - skipping entity discovery",
group.name,
group.group_id,
)
return
entity_domains = GroupProbe.determine_entity_domains(self._hass, group)
if not entity_domains:
return
zha_gateway = self._hass.data[zha_const.DATA_ZHA][zha_const.DATA_ZHA_GATEWAY]
for domain in entity_domains:
entity_class = zha_regs.ZHA_ENTITIES.get_group_entity(domain)
if entity_class is None:
continue
self._hass.data[zha_const.DATA_ZHA][domain].append(
(
entity_class,
(
group.get_domain_entity_ids(domain),
f"{domain}_zha_group_0x{group.group_id:04x}",
group.group_id,
zha_gateway.coordinator_zha_device,
),
)
)
async_dispatcher_send(self._hass, zha_const.SIGNAL_ADD_ENTITIES) | [
"def",
"discover_group_entities",
"(",
"self",
",",
"group",
":",
"zha_typing",
".",
"ZhaGroupType",
")",
"->",
"None",
":",
"# only create a group entity if there are 2 or more members in a group",
"if",
"len",
"(",
"group",
".",
"members",
")",
"<",
"2",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Group: %s:0x%04x has less than 2 members - skipping entity discovery\"",
",",
"group",
".",
"name",
",",
"group",
".",
"group_id",
",",
")",
"return",
"entity_domains",
"=",
"GroupProbe",
".",
"determine_entity_domains",
"(",
"self",
".",
"_hass",
",",
"group",
")",
"if",
"not",
"entity_domains",
":",
"return",
"zha_gateway",
"=",
"self",
".",
"_hass",
".",
"data",
"[",
"zha_const",
".",
"DATA_ZHA",
"]",
"[",
"zha_const",
".",
"DATA_ZHA_GATEWAY",
"]",
"for",
"domain",
"in",
"entity_domains",
":",
"entity_class",
"=",
"zha_regs",
".",
"ZHA_ENTITIES",
".",
"get_group_entity",
"(",
"domain",
")",
"if",
"entity_class",
"is",
"None",
":",
"continue",
"self",
".",
"_hass",
".",
"data",
"[",
"zha_const",
".",
"DATA_ZHA",
"]",
"[",
"domain",
"]",
".",
"append",
"(",
"(",
"entity_class",
",",
"(",
"group",
".",
"get_domain_entity_ids",
"(",
"domain",
")",
",",
"f\"{domain}_zha_group_0x{group.group_id:04x}\"",
",",
"group",
".",
"group_id",
",",
"zha_gateway",
".",
"coordinator_zha_device",
",",
")",
",",
")",
")",
"async_dispatcher_send",
"(",
"self",
".",
"_hass",
",",
"zha_const",
".",
"SIGNAL_ADD_ENTITIES",
")"
] | [
199,
4
] | [
231,
72
] | python | en | ['en', 'en', 'en'] | True |
GroupProbe.determine_entity_domains | (
hass: HomeAssistantType, group: zha_typing.ZhaGroupType
) | Determine the entity domains for this group. | Determine the entity domains for this group. | def determine_entity_domains(
hass: HomeAssistantType, group: zha_typing.ZhaGroupType
) -> List[str]:
"""Determine the entity domains for this group."""
entity_domains: List[str] = []
zha_gateway = hass.data[zha_const.DATA_ZHA][zha_const.DATA_ZHA_GATEWAY]
all_domain_occurrences = []
for member in group.members:
if member.device.is_coordinator:
continue
entities = async_entries_for_device(
zha_gateway.ha_entity_registry, member.device.device_id
)
all_domain_occurrences.extend(
[
entity.domain
for entity in entities
if entity.domain in zha_regs.GROUP_ENTITY_DOMAINS
]
)
if not all_domain_occurrences:
return entity_domains
# get all domains we care about if there are more than 2 entities of this domain
counts = Counter(all_domain_occurrences)
entity_domains = [domain[0] for domain in counts.items() if domain[1] >= 2]
_LOGGER.debug(
"The entity domains are: %s for group: %s:0x%04x",
entity_domains,
group.name,
group.group_id,
)
return entity_domains | [
"def",
"determine_entity_domains",
"(",
"hass",
":",
"HomeAssistantType",
",",
"group",
":",
"zha_typing",
".",
"ZhaGroupType",
")",
"->",
"List",
"[",
"str",
"]",
":",
"entity_domains",
":",
"List",
"[",
"str",
"]",
"=",
"[",
"]",
"zha_gateway",
"=",
"hass",
".",
"data",
"[",
"zha_const",
".",
"DATA_ZHA",
"]",
"[",
"zha_const",
".",
"DATA_ZHA_GATEWAY",
"]",
"all_domain_occurrences",
"=",
"[",
"]",
"for",
"member",
"in",
"group",
".",
"members",
":",
"if",
"member",
".",
"device",
".",
"is_coordinator",
":",
"continue",
"entities",
"=",
"async_entries_for_device",
"(",
"zha_gateway",
".",
"ha_entity_registry",
",",
"member",
".",
"device",
".",
"device_id",
")",
"all_domain_occurrences",
".",
"extend",
"(",
"[",
"entity",
".",
"domain",
"for",
"entity",
"in",
"entities",
"if",
"entity",
".",
"domain",
"in",
"zha_regs",
".",
"GROUP_ENTITY_DOMAINS",
"]",
")",
"if",
"not",
"all_domain_occurrences",
":",
"return",
"entity_domains",
"# get all domains we care about if there are more than 2 entities of this domain",
"counts",
"=",
"Counter",
"(",
"all_domain_occurrences",
")",
"entity_domains",
"=",
"[",
"domain",
"[",
"0",
"]",
"for",
"domain",
"in",
"counts",
".",
"items",
"(",
")",
"if",
"domain",
"[",
"1",
"]",
">=",
"2",
"]",
"_LOGGER",
".",
"debug",
"(",
"\"The entity domains are: %s for group: %s:0x%04x\"",
",",
"entity_domains",
",",
"group",
".",
"name",
",",
"group",
".",
"group_id",
",",
")",
"return",
"entity_domains"
] | [
234,
4
] | [
265,
29
] | python | en | ['en', 'en', 'en'] | True |
mock_successful_connection | (*args, **kwargs) | Return a successful connection. | Return a successful connection. | async def mock_successful_connection(*args, **kwargs):
"""Return a successful connection."""
return True | [
"async",
"def",
"mock_successful_connection",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"True"
] | [
56,
0
] | [
58,
15
] | python | en | ['en', 'en', 'en'] | True |
mock_failed_connection | (*args, **kwargs) | Return a failed connection. | Return a failed connection. | async def mock_failed_connection(*args, **kwargs):
"""Return a failed connection."""
raise ConnectionError("Connection failed") | [
"async",
"def",
"mock_failed_connection",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"raise",
"ConnectionError",
"(",
"\"Connection failed\"",
")"
] | [
61,
0
] | [
63,
46
] | python | en | ['en', 'ga', 'en'] | True |
_init_form | (hass, modem_type) | Run the user form. | Run the user form. | async def _init_form(hass, modem_type):
"""Run the user form."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
assert result["errors"] == {}
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
{MODEM_TYPE: modem_type},
)
return result2 | [
"async",
"def",
"_init_form",
"(",
"hass",
",",
"modem_type",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"config_entries",
".",
"SOURCE_USER",
"}",
")",
"assert",
"result",
"[",
"\"type\"",
"]",
"==",
"data_entry_flow",
".",
"RESULT_TYPE_FORM",
"assert",
"result",
"[",
"\"errors\"",
"]",
"==",
"{",
"}",
"result2",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_configure",
"(",
"result",
"[",
"\"flow_id\"",
"]",
",",
"{",
"MODEM_TYPE",
":",
"modem_type",
"}",
",",
")",
"return",
"result2"
] | [
66,
0
] | [
78,
18
] | python | en | ['en', 'en', 'en'] | True |
_device_form | (hass, flow_id, connection, user_input) | Test the PLM, Hub v1 or Hub v2 form. | Test the PLM, Hub v1 or Hub v2 form. | async def _device_form(hass, flow_id, connection, user_input):
"""Test the PLM, Hub v1 or Hub v2 form."""
with patch(PATCH_CONNECTION, new=connection,), patch(
PATCH_ASYNC_SETUP, return_value=True
) as mock_setup, patch(
PATCH_ASYNC_SETUP_ENTRY,
return_value=True,
) as mock_setup_entry:
result = await hass.config_entries.flow.async_configure(flow_id, user_input)
await hass.async_block_till_done()
return result, mock_setup, mock_setup_entry | [
"async",
"def",
"_device_form",
"(",
"hass",
",",
"flow_id",
",",
"connection",
",",
"user_input",
")",
":",
"with",
"patch",
"(",
"PATCH_CONNECTION",
",",
"new",
"=",
"connection",
",",
")",
",",
"patch",
"(",
"PATCH_ASYNC_SETUP",
",",
"return_value",
"=",
"True",
")",
"as",
"mock_setup",
",",
"patch",
"(",
"PATCH_ASYNC_SETUP_ENTRY",
",",
"return_value",
"=",
"True",
",",
")",
"as",
"mock_setup_entry",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_configure",
"(",
"flow_id",
",",
"user_input",
")",
"await",
"hass",
".",
"async_block_till_done",
"(",
")",
"return",
"result",
",",
"mock_setup",
",",
"mock_setup_entry"
] | [
81,
0
] | [
91,
47
] | python | en | ['en', 'da', 'en'] | True |
test_form_select_modem | (hass: HomeAssistantType) | Test we get a modem form. | Test we get a modem form. | async def test_form_select_modem(hass: HomeAssistantType):
"""Test we get a modem form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await _init_form(hass, HUB2)
assert result["step_id"] == STEP_HUB_V2
assert result["type"] == "form" | [
"async",
"def",
"test_form_select_modem",
"(",
"hass",
":",
"HomeAssistantType",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"result",
"=",
"await",
"_init_form",
"(",
"hass",
",",
"HUB2",
")",
"assert",
"result",
"[",
"\"step_id\"",
"]",
"==",
"STEP_HUB_V2",
"assert",
"result",
"[",
"\"type\"",
"]",
"==",
"\"form\""
] | [
94,
0
] | [
99,
35
] | python | da | ['de', 'da', 'en'] | False |
test_fail_on_existing | (hass: HomeAssistantType) | Test we fail if the integration is already configured. | Test we fail if the integration is already configured. | async def test_fail_on_existing(hass: HomeAssistantType):
"""Test we fail if the integration is already configured."""
config_entry = MockConfigEntry(
domain=DOMAIN,
entry_id="abcde12345",
data={**MOCK_USER_INPUT_HUB_V2, CONF_HUB_VERSION: 2},
options={},
)
config_entry.add_to_hass(hass)
assert config_entry.state == config_entries.ENTRY_STATE_NOT_LOADED
result = await hass.config_entries.flow.async_init(
DOMAIN,
data={**MOCK_USER_INPUT_HUB_V2, CONF_HUB_VERSION: 2},
context={"source": config_entries.SOURCE_USER},
)
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
assert result["reason"] == "single_instance_allowed" | [
"async",
"def",
"test_fail_on_existing",
"(",
"hass",
":",
"HomeAssistantType",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"entry_id",
"=",
"\"abcde12345\"",
",",
"data",
"=",
"{",
"*",
"*",
"MOCK_USER_INPUT_HUB_V2",
",",
"CONF_HUB_VERSION",
":",
"2",
"}",
",",
"options",
"=",
"{",
"}",
",",
")",
"config_entry",
".",
"add_to_hass",
"(",
"hass",
")",
"assert",
"config_entry",
".",
"state",
"==",
"config_entries",
".",
"ENTRY_STATE_NOT_LOADED",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"data",
"=",
"{",
"*",
"*",
"MOCK_USER_INPUT_HUB_V2",
",",
"CONF_HUB_VERSION",
":",
"2",
"}",
",",
"context",
"=",
"{",
"\"source\"",
":",
"config_entries",
".",
"SOURCE_USER",
"}",
",",
")",
"assert",
"result",
"[",
"\"type\"",
"]",
"==",
"data_entry_flow",
".",
"RESULT_TYPE_ABORT",
"assert",
"result",
"[",
"\"reason\"",
"]",
"==",
"\"single_instance_allowed\""
] | [
102,
0
] | [
119,
56
] | python | en | ['en', 'en', 'en'] | True |
test_form_select_plm | (hass: HomeAssistantType) | Test we set up the PLM correctly. | Test we set up the PLM correctly. | async def test_form_select_plm(hass: HomeAssistantType):
"""Test we set up the PLM correctly."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await _init_form(hass, PLM)
result2, mock_setup, mock_setup_entry = await _device_form(
hass, result["flow_id"], mock_successful_connection, MOCK_USER_INPUT_PLM
)
assert result2["type"] == "create_entry"
assert result2["data"] == MOCK_USER_INPUT_PLM
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1 | [
"async",
"def",
"test_form_select_plm",
"(",
"hass",
":",
"HomeAssistantType",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"result",
"=",
"await",
"_init_form",
"(",
"hass",
",",
"PLM",
")",
"result2",
",",
"mock_setup",
",",
"mock_setup_entry",
"=",
"await",
"_device_form",
"(",
"hass",
",",
"result",
"[",
"\"flow_id\"",
"]",
",",
"mock_successful_connection",
",",
"MOCK_USER_INPUT_PLM",
")",
"assert",
"result2",
"[",
"\"type\"",
"]",
"==",
"\"create_entry\"",
"assert",
"result2",
"[",
"\"data\"",
"]",
"==",
"MOCK_USER_INPUT_PLM",
"assert",
"len",
"(",
"mock_setup",
".",
"mock_calls",
")",
"==",
"1",
"assert",
"len",
"(",
"mock_setup_entry",
".",
"mock_calls",
")",
"==",
"1"
] | [
122,
0
] | [
134,
48
] | python | en | ['en', 'zu', 'en'] | True |
test_form_select_hub_v1 | (hass: HomeAssistantType) | Test we set up the Hub v1 correctly. | Test we set up the Hub v1 correctly. | async def test_form_select_hub_v1(hass: HomeAssistantType):
"""Test we set up the Hub v1 correctly."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await _init_form(hass, HUB1)
result2, mock_setup, mock_setup_entry = await _device_form(
hass, result["flow_id"], mock_successful_connection, MOCK_USER_INPUT_HUB_V1
)
assert result2["type"] == "create_entry"
assert result2["data"] == {
**MOCK_USER_INPUT_HUB_V1,
CONF_HUB_VERSION: 1,
}
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1 | [
"async",
"def",
"test_form_select_hub_v1",
"(",
"hass",
":",
"HomeAssistantType",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"result",
"=",
"await",
"_init_form",
"(",
"hass",
",",
"HUB1",
")",
"result2",
",",
"mock_setup",
",",
"mock_setup_entry",
"=",
"await",
"_device_form",
"(",
"hass",
",",
"result",
"[",
"\"flow_id\"",
"]",
",",
"mock_successful_connection",
",",
"MOCK_USER_INPUT_HUB_V1",
")",
"assert",
"result2",
"[",
"\"type\"",
"]",
"==",
"\"create_entry\"",
"assert",
"result2",
"[",
"\"data\"",
"]",
"==",
"{",
"*",
"*",
"MOCK_USER_INPUT_HUB_V1",
",",
"CONF_HUB_VERSION",
":",
"1",
",",
"}",
"assert",
"len",
"(",
"mock_setup",
".",
"mock_calls",
")",
"==",
"1",
"assert",
"len",
"(",
"mock_setup_entry",
".",
"mock_calls",
")",
"==",
"1"
] | [
137,
0
] | [
152,
48
] | python | en | ['en', 'zu', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.