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 |
---|---|---|---|---|---|---|---|---|---|---|---|
get_capabilities | (capabilities: Sequence[str]) | Return all capabilities supported if minimum required are present. | Return all capabilities supported if minimum required are present. | def get_capabilities(capabilities: Sequence[str]) -> Optional[Sequence[str]]:
"""Return all capabilities supported if minimum required are present."""
return [
capability for capability in CAPABILITY_TO_ATTRIB if capability in capabilities
] | [
"def",
"get_capabilities",
"(",
"capabilities",
":",
"Sequence",
"[",
"str",
"]",
")",
"->",
"Optional",
"[",
"Sequence",
"[",
"str",
"]",
"]",
":",
"return",
"[",
"capability",
"for",
"capability",
"in",
"CAPABILITY_TO_ATTRIB",
"if",
"capability",
"in",
"capabilities",
"]"
] | [
54,
0
] | [
58,
5
] | python | en | ['en', 'en', 'en'] | True |
SmartThingsBinarySensor.__init__ | (self, device, attribute) | Init the class. | Init the class. | def __init__(self, device, attribute):
"""Init the class."""
super().__init__(device)
self._attribute = attribute | [
"def",
"__init__",
"(",
"self",
",",
"device",
",",
"attribute",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"device",
")",
"self",
".",
"_attribute",
"=",
"attribute"
] | [
64,
4
] | [
67,
35
] | python | en | ['en', 'en', 'en'] | True |
SmartThingsBinarySensor.name | (self) | Return the name of the binary sensor. | Return the name of the binary sensor. | def name(self) -> str:
"""Return the name of the binary sensor."""
return f"{self._device.label} {self._attribute}" | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"return",
"f\"{self._device.label} {self._attribute}\""
] | [
70,
4
] | [
72,
56
] | python | en | ['en', 'mi', 'en'] | True |
SmartThingsBinarySensor.unique_id | (self) | Return a unique ID. | Return a unique ID. | def unique_id(self) -> str:
"""Return a unique ID."""
return f"{self._device.device_id}.{self._attribute}" | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"str",
":",
"return",
"f\"{self._device.device_id}.{self._attribute}\""
] | [
75,
4
] | [
77,
60
] | python | ca | ['fr', 'ca', 'en'] | False |
SmartThingsBinarySensor.is_on | (self) | Return true if the binary sensor is on. | Return true if the binary sensor is on. | def is_on(self):
"""Return true if the binary sensor is on."""
return self._device.status.is_on(self._attribute) | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device",
".",
"status",
".",
"is_on",
"(",
"self",
".",
"_attribute",
")"
] | [
80,
4
] | [
82,
57
] | python | en | ['en', 'fy', 'en'] | True |
SmartThingsBinarySensor.device_class | (self) | Return the class of this device. | Return the class of this device. | def device_class(self):
"""Return the class of this device."""
return ATTRIB_TO_CLASS[self._attribute] | [
"def",
"device_class",
"(",
"self",
")",
":",
"return",
"ATTRIB_TO_CLASS",
"[",
"self",
".",
"_attribute",
"]"
] | [
85,
4
] | [
87,
47
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass, config) | Activate Smart Home functionality of Alexa component.
This is optional, triggered by having a `smart_home:` sub-section in the
alexa configuration.
Even if that's disabled, the functionality in this module may still be used
by the cloud component which will call async_handle_message directly.
| Activate Smart Home functionality of Alexa component. | async def async_setup(hass, config):
"""Activate Smart Home functionality of Alexa component.
This is optional, triggered by having a `smart_home:` sub-section in the
alexa configuration.
Even if that's disabled, the functionality in this module may still be used
by the cloud component which will call async_handle_message directly.
"""
smart_home_config = AlexaConfig(hass, config)
hass.http.register_view(SmartHomeView(smart_home_config))
if smart_home_config.should_report_state:
await async_enable_proactive_mode(hass, smart_home_config) | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"smart_home_config",
"=",
"AlexaConfig",
"(",
"hass",
",",
"config",
")",
"hass",
".",
"http",
".",
"register_view",
"(",
"SmartHomeView",
"(",
"smart_home_config",
")",
")",
"if",
"smart_home_config",
".",
"should_report_state",
":",
"await",
"async_enable_proactive_mode",
"(",
"hass",
",",
"smart_home_config",
")"
] | [
73,
0
] | [
86,
66
] | python | en | ['en', 'en', 'en'] | True |
AlexaConfig.__init__ | (self, hass, config) | Initialize Alexa config. | Initialize Alexa config. | def __init__(self, hass, config):
"""Initialize Alexa config."""
super().__init__(hass)
self._config = config
if config.get(CONF_CLIENT_ID) and config.get(CONF_CLIENT_SECRET):
self._auth = Auth(hass, config[CONF_CLIENT_ID], config[CONF_CLIENT_SECRET])
else:
self._auth = None | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"config",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"hass",
")",
"self",
".",
"_config",
"=",
"config",
"if",
"config",
".",
"get",
"(",
"CONF_CLIENT_ID",
")",
"and",
"config",
".",
"get",
"(",
"CONF_CLIENT_SECRET",
")",
":",
"self",
".",
"_auth",
"=",
"Auth",
"(",
"hass",
",",
"config",
"[",
"CONF_CLIENT_ID",
"]",
",",
"config",
"[",
"CONF_CLIENT_SECRET",
"]",
")",
"else",
":",
"self",
".",
"_auth",
"=",
"None"
] | [
20,
4
] | [
28,
29
] | python | it | ['ro', 'pt', 'it'] | False |
AlexaConfig.supports_auth | (self) | Return if config supports auth. | Return if config supports auth. | def supports_auth(self):
"""Return if config supports auth."""
return self._auth is not None | [
"def",
"supports_auth",
"(",
"self",
")",
":",
"return",
"self",
".",
"_auth",
"is",
"not",
"None"
] | [
31,
4
] | [
33,
37
] | python | en | ['en', 'en', 'en'] | True |
AlexaConfig.should_report_state | (self) | Return if we should proactively report states. | Return if we should proactively report states. | def should_report_state(self):
"""Return if we should proactively report states."""
return self._auth is not None | [
"def",
"should_report_state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_auth",
"is",
"not",
"None"
] | [
36,
4
] | [
38,
37
] | python | en | ['en', 'en', 'en'] | True |
AlexaConfig.endpoint | (self) | Endpoint for report state. | Endpoint for report state. | def endpoint(self):
"""Endpoint for report state."""
return self._config.get(CONF_ENDPOINT) | [
"def",
"endpoint",
"(",
"self",
")",
":",
"return",
"self",
".",
"_config",
".",
"get",
"(",
"CONF_ENDPOINT",
")"
] | [
41,
4
] | [
43,
46
] | python | en | ['en', 'en', 'en'] | True |
AlexaConfig.entity_config | (self) | Return entity config. | Return entity config. | def entity_config(self):
"""Return entity config."""
return self._config.get(CONF_ENTITY_CONFIG) or {} | [
"def",
"entity_config",
"(",
"self",
")",
":",
"return",
"self",
".",
"_config",
".",
"get",
"(",
"CONF_ENTITY_CONFIG",
")",
"or",
"{",
"}"
] | [
46,
4
] | [
48,
57
] | python | en | ['en', 'cy', 'en'] | True |
AlexaConfig.locale | (self) | Return config locale. | Return config locale. | def locale(self):
"""Return config locale."""
return self._config.get(CONF_LOCALE) | [
"def",
"locale",
"(",
"self",
")",
":",
"return",
"self",
".",
"_config",
".",
"get",
"(",
"CONF_LOCALE",
")"
] | [
51,
4
] | [
53,
44
] | python | de | ['de', 'la', 'en'] | False |
AlexaConfig.should_expose | (self, entity_id) | If an entity should be exposed. | If an entity should be exposed. | def should_expose(self, entity_id):
"""If an entity should be exposed."""
return self._config[CONF_FILTER](entity_id) | [
"def",
"should_expose",
"(",
"self",
",",
"entity_id",
")",
":",
"return",
"self",
".",
"_config",
"[",
"CONF_FILTER",
"]",
"(",
"entity_id",
")"
] | [
55,
4
] | [
57,
51
] | python | en | ['en', 'en', 'en'] | True |
AlexaConfig.async_invalidate_access_token | (self) | Invalidate access token. | Invalidate access token. | def async_invalidate_access_token(self):
"""Invalidate access token."""
self._auth.async_invalidate_access_token() | [
"def",
"async_invalidate_access_token",
"(",
"self",
")",
":",
"self",
".",
"_auth",
".",
"async_invalidate_access_token",
"(",
")"
] | [
60,
4
] | [
62,
50
] | python | en | ['en', 'fi', 'en'] | True |
AlexaConfig.async_get_access_token | (self) | Get an access token. | Get an access token. | async def async_get_access_token(self):
"""Get an access token."""
return await self._auth.async_get_access_token() | [
"async",
"def",
"async_get_access_token",
"(",
"self",
")",
":",
"return",
"await",
"self",
".",
"_auth",
".",
"async_get_access_token",
"(",
")"
] | [
64,
4
] | [
66,
56
] | python | en | ['en', 'lb', 'en'] | True |
AlexaConfig.async_accept_grant | (self, code) | Accept a grant. | Accept a grant. | async def async_accept_grant(self, code):
"""Accept a grant."""
return await self._auth.async_do_auth(code) | [
"async",
"def",
"async_accept_grant",
"(",
"self",
",",
"code",
")",
":",
"return",
"await",
"self",
".",
"_auth",
".",
"async_do_auth",
"(",
"code",
")"
] | [
68,
4
] | [
70,
51
] | python | en | ['en', 'it', 'en'] | True |
SmartHomeView.__init__ | (self, smart_home_config) | Initialize. | Initialize. | def __init__(self, smart_home_config):
"""Initialize."""
self.smart_home_config = smart_home_config | [
"def",
"__init__",
"(",
"self",
",",
"smart_home_config",
")",
":",
"self",
".",
"smart_home_config",
"=",
"smart_home_config"
] | [
95,
4
] | [
97,
50
] | python | en | ['en', 'en', 'it'] | False |
SmartHomeView.post | (self, request) | Handle Alexa Smart Home requests.
The Smart Home API requires the endpoint to be implemented in AWS
Lambda, which will need to forward the requests to here and pass back
the response.
| Handle Alexa Smart Home requests. | async def post(self, request):
"""Handle Alexa Smart Home requests.
The Smart Home API requires the endpoint to be implemented in AWS
Lambda, which will need to forward the requests to here and pass back
the response.
"""
hass = request.app["hass"]
user = request["hass_user"]
message = await request.json()
_LOGGER.debug("Received Alexa Smart Home request: %s", message)
response = await async_handle_message(
hass, self.smart_home_config, message, context=core.Context(user_id=user.id)
)
_LOGGER.debug("Sending Alexa Smart Home response: %s", response)
return b"" if response is None else self.json(response) | [
"async",
"def",
"post",
"(",
"self",
",",
"request",
")",
":",
"hass",
"=",
"request",
".",
"app",
"[",
"\"hass\"",
"]",
"user",
"=",
"request",
"[",
"\"hass_user\"",
"]",
"message",
"=",
"await",
"request",
".",
"json",
"(",
")",
"_LOGGER",
".",
"debug",
"(",
"\"Received Alexa Smart Home request: %s\"",
",",
"message",
")",
"response",
"=",
"await",
"async_handle_message",
"(",
"hass",
",",
"self",
".",
"smart_home_config",
",",
"message",
",",
"context",
"=",
"core",
".",
"Context",
"(",
"user_id",
"=",
"user",
".",
"id",
")",
")",
"_LOGGER",
".",
"debug",
"(",
"\"Sending Alexa Smart Home response: %s\"",
",",
"response",
")",
"return",
"b\"\"",
"if",
"response",
"is",
"None",
"else",
"self",
".",
"json",
"(",
"response",
")"
] | [
99,
4
] | [
116,
63
] | python | en | ['ro', 'nl', 'en'] | False |
patch_load_json | () | Prevent load JSON being used. | Prevent load JSON being used. | def patch_load_json():
"""Prevent load JSON being used."""
with patch("homeassistant.components.ps4.load_json", return_value={}) as mock_load:
yield mock_load | [
"def",
"patch_load_json",
"(",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.ps4.load_json\"",
",",
"return_value",
"=",
"{",
"}",
")",
"as",
"mock_load",
":",
"yield",
"mock_load"
] | [
7,
0
] | [
10,
23
] | python | en | ['de', 'en', 'en'] | True |
patch_save_json | () | Prevent save JSON being used. | Prevent save JSON being used. | def patch_save_json():
"""Prevent save JSON being used."""
with patch("homeassistant.components.ps4.save_json") as mock_save:
yield mock_save | [
"def",
"patch_save_json",
"(",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.ps4.save_json\"",
")",
"as",
"mock_save",
":",
"yield",
"mock_save"
] | [
14,
0
] | [
17,
23
] | python | en | ['en', 'en', 'en'] | True |
patch_io | (patch_load_json, patch_save_json) | Prevent PS4 doing I/O. | Prevent PS4 doing I/O. | def patch_io(patch_load_json, patch_save_json):
"""Prevent PS4 doing I/O.""" | [
"def",
"patch_io",
"(",
"patch_load_json",
",",
"patch_save_json",
")",
":"
] | [
21,
0
] | [
22,
32
] | python | en | ['en', 'no', 'en'] | True |
mock_history | (hass) | Mock history component loaded. | Mock history component loaded. | def mock_history(hass):
"""Mock history component loaded."""
hass.config.components.add("history") | [
"def",
"mock_history",
"(",
"hass",
")",
":",
"hass",
".",
"config",
".",
"components",
".",
"add",
"(",
"\"history\"",
")"
] | [
13,
0
] | [
15,
41
] | python | en | ['en', 'en', 'en'] | True |
demo_cleanup | (hass) | Clean up device tracker demo file. | Clean up device tracker demo file. | def demo_cleanup(hass):
"""Clean up device tracker demo file."""
yield
try:
os.remove(hass.config.path(YAML_DEVICES))
except FileNotFoundError:
pass | [
"def",
"demo_cleanup",
"(",
"hass",
")",
":",
"yield",
"try",
":",
"os",
".",
"remove",
"(",
"hass",
".",
"config",
".",
"path",
"(",
"YAML_DEVICES",
")",
")",
"except",
"FileNotFoundError",
":",
"pass"
] | [
19,
0
] | [
25,
12
] | python | en | ['nl', 'en', 'en'] | True |
test_setting_up_demo | (hass) | Test if we can set up the demo and dump it to JSON. | Test if we can set up the demo and dump it to JSON. | async def test_setting_up_demo(hass):
"""Test if we can set up the demo and dump it to JSON."""
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {}})
await hass.async_block_till_done()
await hass.async_start()
# This is done to make sure entity components don't accidentally store
# non-JSON-serializable data in the state machine.
try:
json.dumps(hass.states.async_all(), cls=JSONEncoder)
except Exception: # pylint: disable=broad-except
pytest.fail(
"Unable to convert all demo entities to JSON. "
"Wrong data in state machine!"
) | [
"async",
"def",
"test_setting_up_demo",
"(",
"hass",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"DOMAIN",
",",
"{",
"DOMAIN",
":",
"{",
"}",
"}",
")",
"await",
"hass",
".",
"async_block_till_done",
"(",
")",
"await",
"hass",
".",
"async_start",
"(",
")",
"# This is done to make sure entity components don't accidentally store",
"# non-JSON-serializable data in the state machine.",
"try",
":",
"json",
".",
"dumps",
"(",
"hass",
".",
"states",
".",
"async_all",
"(",
")",
",",
"cls",
"=",
"JSONEncoder",
")",
"except",
"Exception",
":",
"# pylint: disable=broad-except",
"pytest",
".",
"fail",
"(",
"\"Unable to convert all demo entities to JSON. \"",
"\"Wrong data in state machine!\"",
")"
] | [
28,
0
] | [
42,
9
] | python | en | ['en', 'en', 'en'] | True |
test_manually_configured_platform | (hass) | Test that we do not set up an access point. | Test that we do not set up an access point. | async def test_manually_configured_platform(hass):
"""Test that we do not set up an access point."""
assert await async_setup_component(
hass,
BINARY_SENSOR_DOMAIN,
{BINARY_SENSOR_DOMAIN: {"platform": HMIPC_DOMAIN}},
)
assert not hass.data.get(HMIPC_DOMAIN) | [
"async",
"def",
"test_manually_configured_platform",
"(",
"hass",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"BINARY_SENSOR_DOMAIN",
",",
"{",
"BINARY_SENSOR_DOMAIN",
":",
"{",
"\"platform\"",
":",
"HMIPC_DOMAIN",
"}",
"}",
",",
")",
"assert",
"not",
"hass",
".",
"data",
".",
"get",
"(",
"HMIPC_DOMAIN",
")"
] | [
30,
0
] | [
37,
42
] | python | en | ['en', 'en', 'en'] | True |
test_hmip_home_cloud_connection_sensor | (hass, default_mock_hap_factory) | Test HomematicipCloudConnectionSensor. | Test HomematicipCloudConnectionSensor. | async def test_hmip_home_cloud_connection_sensor(hass, default_mock_hap_factory):
"""Test HomematicipCloudConnectionSensor."""
entity_id = "binary_sensor.cloud_connection"
entity_name = "Cloud Connection"
device_model = None
mock_hap = await default_mock_hap_factory.async_get_mock_hap(
test_devices=[entity_name]
)
ha_state, hmip_device = get_and_check_entity_basics(
hass, mock_hap, entity_id, entity_name, device_model
)
assert ha_state.state == STATE_ON
await async_manipulate_test_data(hass, mock_hap.home, "connected", False)
ha_state = hass.states.get(entity_id)
assert ha_state.state == STATE_OFF | [
"async",
"def",
"test_hmip_home_cloud_connection_sensor",
"(",
"hass",
",",
"default_mock_hap_factory",
")",
":",
"entity_id",
"=",
"\"binary_sensor.cloud_connection\"",
"entity_name",
"=",
"\"Cloud Connection\"",
"device_model",
"=",
"None",
"mock_hap",
"=",
"await",
"default_mock_hap_factory",
".",
"async_get_mock_hap",
"(",
"test_devices",
"=",
"[",
"entity_name",
"]",
")",
"ha_state",
",",
"hmip_device",
"=",
"get_and_check_entity_basics",
"(",
"hass",
",",
"mock_hap",
",",
"entity_id",
",",
"entity_name",
",",
"device_model",
")",
"assert",
"ha_state",
".",
"state",
"==",
"STATE_ON",
"await",
"async_manipulate_test_data",
"(",
"hass",
",",
"mock_hap",
".",
"home",
",",
"\"connected\"",
",",
"False",
")",
"ha_state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"entity_id",
")",
"assert",
"ha_state",
".",
"state",
"==",
"STATE_OFF"
] | [
40,
0
] | [
58,
38
] | python | en | ['en', 'fr', 'en'] | False |
test_hmip_acceleration_sensor | (hass, default_mock_hap_factory) | Test HomematicipAccelerationSensor. | Test HomematicipAccelerationSensor. | async def test_hmip_acceleration_sensor(hass, default_mock_hap_factory):
"""Test HomematicipAccelerationSensor."""
entity_id = "binary_sensor.garagentor"
entity_name = "Garagentor"
device_model = "HmIP-SAM"
mock_hap = await default_mock_hap_factory.async_get_mock_hap(
test_devices=[entity_name]
)
ha_state, hmip_device = get_and_check_entity_basics(
hass, mock_hap, entity_id, entity_name, device_model
)
assert ha_state.state == STATE_ON
assert ha_state.attributes[ATTR_ACCELERATION_SENSOR_MODE] == "FLAT_DECT"
assert ha_state.attributes[ATTR_ACCELERATION_SENSOR_NEUTRAL_POSITION] == "VERTICAL"
assert (
ha_state.attributes[ATTR_ACCELERATION_SENSOR_SENSITIVITY] == "SENSOR_RANGE_4G"
)
assert ha_state.attributes[ATTR_ACCELERATION_SENSOR_TRIGGER_ANGLE] == 45
service_call_counter = len(hmip_device.mock_calls)
await async_manipulate_test_data(
hass, hmip_device, "accelerationSensorTriggered", False
)
ha_state = hass.states.get(entity_id)
assert ha_state.state == STATE_OFF
assert len(hmip_device.mock_calls) == service_call_counter + 1
await async_manipulate_test_data(
hass, hmip_device, "accelerationSensorTriggered", True
)
ha_state = hass.states.get(entity_id)
assert ha_state.state == STATE_ON
assert len(hmip_device.mock_calls) == service_call_counter + 2 | [
"async",
"def",
"test_hmip_acceleration_sensor",
"(",
"hass",
",",
"default_mock_hap_factory",
")",
":",
"entity_id",
"=",
"\"binary_sensor.garagentor\"",
"entity_name",
"=",
"\"Garagentor\"",
"device_model",
"=",
"\"HmIP-SAM\"",
"mock_hap",
"=",
"await",
"default_mock_hap_factory",
".",
"async_get_mock_hap",
"(",
"test_devices",
"=",
"[",
"entity_name",
"]",
")",
"ha_state",
",",
"hmip_device",
"=",
"get_and_check_entity_basics",
"(",
"hass",
",",
"mock_hap",
",",
"entity_id",
",",
"entity_name",
",",
"device_model",
")",
"assert",
"ha_state",
".",
"state",
"==",
"STATE_ON",
"assert",
"ha_state",
".",
"attributes",
"[",
"ATTR_ACCELERATION_SENSOR_MODE",
"]",
"==",
"\"FLAT_DECT\"",
"assert",
"ha_state",
".",
"attributes",
"[",
"ATTR_ACCELERATION_SENSOR_NEUTRAL_POSITION",
"]",
"==",
"\"VERTICAL\"",
"assert",
"(",
"ha_state",
".",
"attributes",
"[",
"ATTR_ACCELERATION_SENSOR_SENSITIVITY",
"]",
"==",
"\"SENSOR_RANGE_4G\"",
")",
"assert",
"ha_state",
".",
"attributes",
"[",
"ATTR_ACCELERATION_SENSOR_TRIGGER_ANGLE",
"]",
"==",
"45",
"service_call_counter",
"=",
"len",
"(",
"hmip_device",
".",
"mock_calls",
")",
"await",
"async_manipulate_test_data",
"(",
"hass",
",",
"hmip_device",
",",
"\"accelerationSensorTriggered\"",
",",
"False",
")",
"ha_state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"entity_id",
")",
"assert",
"ha_state",
".",
"state",
"==",
"STATE_OFF",
"assert",
"len",
"(",
"hmip_device",
".",
"mock_calls",
")",
"==",
"service_call_counter",
"+",
"1",
"await",
"async_manipulate_test_data",
"(",
"hass",
",",
"hmip_device",
",",
"\"accelerationSensorTriggered\"",
",",
"True",
")",
"ha_state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"entity_id",
")",
"assert",
"ha_state",
".",
"state",
"==",
"STATE_ON",
"assert",
"len",
"(",
"hmip_device",
".",
"mock_calls",
")",
"==",
"service_call_counter",
"+",
"2"
] | [
61,
0
] | [
95,
66
] | python | en | ['ro', 'lb', 'en'] | False |
test_hmip_tilt_vibration_sensor | (hass, default_mock_hap_factory) | Test HomematicipTiltVibrationSensor. | Test HomematicipTiltVibrationSensor. | async def test_hmip_tilt_vibration_sensor(hass, default_mock_hap_factory):
"""Test HomematicipTiltVibrationSensor."""
entity_id = "binary_sensor.garage_neigungs_und_erschutterungssensor"
entity_name = "Garage Neigungs- und Erschütterungssensor"
device_model = "HmIP-STV"
mock_hap = await default_mock_hap_factory.async_get_mock_hap(
test_devices=[entity_name]
)
ha_state, hmip_device = get_and_check_entity_basics(
hass, mock_hap, entity_id, entity_name, device_model
)
assert ha_state.state == STATE_ON
assert ha_state.attributes[ATTR_ACCELERATION_SENSOR_MODE] == "FLAT_DECT"
assert (
ha_state.attributes[ATTR_ACCELERATION_SENSOR_SENSITIVITY] == "SENSOR_RANGE_2G"
)
assert ha_state.attributes[ATTR_ACCELERATION_SENSOR_TRIGGER_ANGLE] == 45
service_call_counter = len(hmip_device.mock_calls)
await async_manipulate_test_data(
hass, hmip_device, "accelerationSensorTriggered", False
)
ha_state = hass.states.get(entity_id)
assert ha_state.state == STATE_OFF
assert len(hmip_device.mock_calls) == service_call_counter + 1
await async_manipulate_test_data(
hass, hmip_device, "accelerationSensorTriggered", True
)
ha_state = hass.states.get(entity_id)
assert ha_state.state == STATE_ON
assert len(hmip_device.mock_calls) == service_call_counter + 2 | [
"async",
"def",
"test_hmip_tilt_vibration_sensor",
"(",
"hass",
",",
"default_mock_hap_factory",
")",
":",
"entity_id",
"=",
"\"binary_sensor.garage_neigungs_und_erschutterungssensor\"",
"entity_name",
"=",
"\"Garage Neigungs- und Erschütterungssensor\"",
"device_model",
"=",
"\"HmIP-STV\"",
"mock_hap",
"=",
"await",
"default_mock_hap_factory",
".",
"async_get_mock_hap",
"(",
"test_devices",
"=",
"[",
"entity_name",
"]",
")",
"ha_state",
",",
"hmip_device",
"=",
"get_and_check_entity_basics",
"(",
"hass",
",",
"mock_hap",
",",
"entity_id",
",",
"entity_name",
",",
"device_model",
")",
"assert",
"ha_state",
".",
"state",
"==",
"STATE_ON",
"assert",
"ha_state",
".",
"attributes",
"[",
"ATTR_ACCELERATION_SENSOR_MODE",
"]",
"==",
"\"FLAT_DECT\"",
"assert",
"(",
"ha_state",
".",
"attributes",
"[",
"ATTR_ACCELERATION_SENSOR_SENSITIVITY",
"]",
"==",
"\"SENSOR_RANGE_2G\"",
")",
"assert",
"ha_state",
".",
"attributes",
"[",
"ATTR_ACCELERATION_SENSOR_TRIGGER_ANGLE",
"]",
"==",
"45",
"service_call_counter",
"=",
"len",
"(",
"hmip_device",
".",
"mock_calls",
")",
"await",
"async_manipulate_test_data",
"(",
"hass",
",",
"hmip_device",
",",
"\"accelerationSensorTriggered\"",
",",
"False",
")",
"ha_state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"entity_id",
")",
"assert",
"ha_state",
".",
"state",
"==",
"STATE_OFF",
"assert",
"len",
"(",
"hmip_device",
".",
"mock_calls",
")",
"==",
"service_call_counter",
"+",
"1",
"await",
"async_manipulate_test_data",
"(",
"hass",
",",
"hmip_device",
",",
"\"accelerationSensorTriggered\"",
",",
"True",
")",
"ha_state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"entity_id",
")",
"assert",
"ha_state",
".",
"state",
"==",
"STATE_ON",
"assert",
"len",
"(",
"hmip_device",
".",
"mock_calls",
")",
"==",
"service_call_counter",
"+",
"2"
] | [
98,
0
] | [
131,
66
] | python | en | ['es', 'no', 'en'] | False |
test_hmip_contact_interface | (hass, default_mock_hap_factory) | Test HomematicipContactInterface. | Test HomematicipContactInterface. | async def test_hmip_contact_interface(hass, default_mock_hap_factory):
"""Test HomematicipContactInterface."""
entity_id = "binary_sensor.kontakt_schnittstelle_unterputz_1_fach"
entity_name = "Kontakt-Schnittstelle Unterputz – 1-fach"
device_model = "HmIP-FCI1"
mock_hap = await default_mock_hap_factory.async_get_mock_hap(
test_devices=[entity_name]
)
ha_state, hmip_device = get_and_check_entity_basics(
hass, mock_hap, entity_id, entity_name, device_model
)
assert ha_state.state == STATE_OFF
await async_manipulate_test_data(hass, hmip_device, "windowState", WindowState.OPEN)
ha_state = hass.states.get(entity_id)
assert ha_state.state == STATE_ON
await async_manipulate_test_data(hass, hmip_device, "windowState", None)
ha_state = hass.states.get(entity_id)
assert ha_state.state == STATE_OFF | [
"async",
"def",
"test_hmip_contact_interface",
"(",
"hass",
",",
"default_mock_hap_factory",
")",
":",
"entity_id",
"=",
"\"binary_sensor.kontakt_schnittstelle_unterputz_1_fach\"",
"entity_name",
"=",
"\"Kontakt-Schnittstelle Unterputz – 1-fach\"",
"device_model",
"=",
"\"HmIP-FCI1\"",
"mock_hap",
"=",
"await",
"default_mock_hap_factory",
".",
"async_get_mock_hap",
"(",
"test_devices",
"=",
"[",
"entity_name",
"]",
")",
"ha_state",
",",
"hmip_device",
"=",
"get_and_check_entity_basics",
"(",
"hass",
",",
"mock_hap",
",",
"entity_id",
",",
"entity_name",
",",
"device_model",
")",
"assert",
"ha_state",
".",
"state",
"==",
"STATE_OFF",
"await",
"async_manipulate_test_data",
"(",
"hass",
",",
"hmip_device",
",",
"\"windowState\"",
",",
"WindowState",
".",
"OPEN",
")",
"ha_state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"entity_id",
")",
"assert",
"ha_state",
".",
"state",
"==",
"STATE_ON",
"await",
"async_manipulate_test_data",
"(",
"hass",
",",
"hmip_device",
",",
"\"windowState\"",
",",
"None",
")",
"ha_state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"entity_id",
")",
"assert",
"ha_state",
".",
"state",
"==",
"STATE_OFF"
] | [
134,
0
] | [
154,
38
] | python | en | ['es', 'gl', 'en'] | False |
test_hmip_shutter_contact | (hass, default_mock_hap_factory) | Test HomematicipShutterContact. | Test HomematicipShutterContact. | async def test_hmip_shutter_contact(hass, default_mock_hap_factory):
"""Test HomematicipShutterContact."""
entity_id = "binary_sensor.fenstergriffsensor"
entity_name = "Fenstergriffsensor"
device_model = "HmIP-SRH"
mock_hap = await default_mock_hap_factory.async_get_mock_hap(
test_devices=[entity_name]
)
ha_state, hmip_device = get_and_check_entity_basics(
hass, mock_hap, entity_id, entity_name, device_model
)
assert ha_state.state == STATE_ON
assert ha_state.attributes[ATTR_WINDOW_STATE] == WindowState.TILTED
await async_manipulate_test_data(hass, hmip_device, "windowState", WindowState.OPEN)
ha_state = hass.states.get(entity_id)
assert ha_state.state == STATE_ON
assert ha_state.attributes[ATTR_WINDOW_STATE] == WindowState.OPEN
await async_manipulate_test_data(
hass, hmip_device, "windowState", WindowState.CLOSED
)
ha_state = hass.states.get(entity_id)
assert ha_state.state == STATE_OFF
assert not ha_state.attributes.get(ATTR_WINDOW_STATE)
await async_manipulate_test_data(hass, hmip_device, "windowState", None)
ha_state = hass.states.get(entity_id)
assert ha_state.state == STATE_OFF
# test common attributes
assert ha_state.attributes[ATTR_RSSI_DEVICE] == -54
assert not ha_state.attributes.get(ATTR_SABOTAGE)
await async_manipulate_test_data(hass, hmip_device, "sabotage", True)
ha_state = hass.states.get(entity_id)
assert ha_state.attributes[ATTR_SABOTAGE] | [
"async",
"def",
"test_hmip_shutter_contact",
"(",
"hass",
",",
"default_mock_hap_factory",
")",
":",
"entity_id",
"=",
"\"binary_sensor.fenstergriffsensor\"",
"entity_name",
"=",
"\"Fenstergriffsensor\"",
"device_model",
"=",
"\"HmIP-SRH\"",
"mock_hap",
"=",
"await",
"default_mock_hap_factory",
".",
"async_get_mock_hap",
"(",
"test_devices",
"=",
"[",
"entity_name",
"]",
")",
"ha_state",
",",
"hmip_device",
"=",
"get_and_check_entity_basics",
"(",
"hass",
",",
"mock_hap",
",",
"entity_id",
",",
"entity_name",
",",
"device_model",
")",
"assert",
"ha_state",
".",
"state",
"==",
"STATE_ON",
"assert",
"ha_state",
".",
"attributes",
"[",
"ATTR_WINDOW_STATE",
"]",
"==",
"WindowState",
".",
"TILTED",
"await",
"async_manipulate_test_data",
"(",
"hass",
",",
"hmip_device",
",",
"\"windowState\"",
",",
"WindowState",
".",
"OPEN",
")",
"ha_state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"entity_id",
")",
"assert",
"ha_state",
".",
"state",
"==",
"STATE_ON",
"assert",
"ha_state",
".",
"attributes",
"[",
"ATTR_WINDOW_STATE",
"]",
"==",
"WindowState",
".",
"OPEN",
"await",
"async_manipulate_test_data",
"(",
"hass",
",",
"hmip_device",
",",
"\"windowState\"",
",",
"WindowState",
".",
"CLOSED",
")",
"ha_state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"entity_id",
")",
"assert",
"ha_state",
".",
"state",
"==",
"STATE_OFF",
"assert",
"not",
"ha_state",
".",
"attributes",
".",
"get",
"(",
"ATTR_WINDOW_STATE",
")",
"await",
"async_manipulate_test_data",
"(",
"hass",
",",
"hmip_device",
",",
"\"windowState\"",
",",
"None",
")",
"ha_state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"entity_id",
")",
"assert",
"ha_state",
".",
"state",
"==",
"STATE_OFF",
"# test common attributes",
"assert",
"ha_state",
".",
"attributes",
"[",
"ATTR_RSSI_DEVICE",
"]",
"==",
"-",
"54",
"assert",
"not",
"ha_state",
".",
"attributes",
".",
"get",
"(",
"ATTR_SABOTAGE",
")",
"await",
"async_manipulate_test_data",
"(",
"hass",
",",
"hmip_device",
",",
"\"sabotage\"",
",",
"True",
")",
"ha_state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"entity_id",
")",
"assert",
"ha_state",
".",
"attributes",
"[",
"ATTR_SABOTAGE",
"]"
] | [
157,
0
] | [
194,
45
] | python | en | ['es', 'lb', 'en'] | False |
test_hmip_shutter_contact_optical | (hass, default_mock_hap_factory) | Test HomematicipShutterContact. | Test HomematicipShutterContact. | async def test_hmip_shutter_contact_optical(hass, default_mock_hap_factory):
"""Test HomematicipShutterContact."""
entity_id = "binary_sensor.sitzplatzture"
entity_name = "Sitzplatzt\u00fcre"
device_model = "HmIP-SWDO-PL"
mock_hap = await default_mock_hap_factory.async_get_mock_hap(
test_devices=[entity_name]
)
ha_state, hmip_device = get_and_check_entity_basics(
hass, mock_hap, entity_id, entity_name, device_model
)
assert ha_state.state == STATE_OFF
await async_manipulate_test_data(hass, hmip_device, "windowState", WindowState.OPEN)
ha_state = hass.states.get(entity_id)
assert ha_state.state == STATE_ON
await async_manipulate_test_data(hass, hmip_device, "windowState", None)
ha_state = hass.states.get(entity_id)
assert ha_state.state == STATE_OFF
# test common attributes
assert ha_state.attributes[ATTR_RSSI_DEVICE] == -72
assert not ha_state.attributes.get(ATTR_SABOTAGE)
await async_manipulate_test_data(hass, hmip_device, "sabotage", True)
ha_state = hass.states.get(entity_id)
assert ha_state.attributes[ATTR_SABOTAGE] | [
"async",
"def",
"test_hmip_shutter_contact_optical",
"(",
"hass",
",",
"default_mock_hap_factory",
")",
":",
"entity_id",
"=",
"\"binary_sensor.sitzplatzture\"",
"entity_name",
"=",
"\"Sitzplatzt\\u00fcre\"",
"device_model",
"=",
"\"HmIP-SWDO-PL\"",
"mock_hap",
"=",
"await",
"default_mock_hap_factory",
".",
"async_get_mock_hap",
"(",
"test_devices",
"=",
"[",
"entity_name",
"]",
")",
"ha_state",
",",
"hmip_device",
"=",
"get_and_check_entity_basics",
"(",
"hass",
",",
"mock_hap",
",",
"entity_id",
",",
"entity_name",
",",
"device_model",
")",
"assert",
"ha_state",
".",
"state",
"==",
"STATE_OFF",
"await",
"async_manipulate_test_data",
"(",
"hass",
",",
"hmip_device",
",",
"\"windowState\"",
",",
"WindowState",
".",
"OPEN",
")",
"ha_state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"entity_id",
")",
"assert",
"ha_state",
".",
"state",
"==",
"STATE_ON",
"await",
"async_manipulate_test_data",
"(",
"hass",
",",
"hmip_device",
",",
"\"windowState\"",
",",
"None",
")",
"ha_state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"entity_id",
")",
"assert",
"ha_state",
".",
"state",
"==",
"STATE_OFF",
"# test common attributes",
"assert",
"ha_state",
".",
"attributes",
"[",
"ATTR_RSSI_DEVICE",
"]",
"==",
"-",
"72",
"assert",
"not",
"ha_state",
".",
"attributes",
".",
"get",
"(",
"ATTR_SABOTAGE",
")",
"await",
"async_manipulate_test_data",
"(",
"hass",
",",
"hmip_device",
",",
"\"sabotage\"",
",",
"True",
")",
"ha_state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"entity_id",
")",
"assert",
"ha_state",
".",
"attributes",
"[",
"ATTR_SABOTAGE",
"]"
] | [
197,
0
] | [
224,
45
] | python | en | ['es', 'lb', 'en'] | False |
test_hmip_motion_detector | (hass, default_mock_hap_factory) | Test HomematicipMotionDetector. | Test HomematicipMotionDetector. | async def test_hmip_motion_detector(hass, default_mock_hap_factory):
"""Test HomematicipMotionDetector."""
entity_id = "binary_sensor.bewegungsmelder_fur_55er_rahmen_innen"
entity_name = "Bewegungsmelder für 55er Rahmen – innen"
device_model = "HmIP-SMI55"
mock_hap = await default_mock_hap_factory.async_get_mock_hap(
test_devices=[entity_name]
)
ha_state, hmip_device = get_and_check_entity_basics(
hass, mock_hap, entity_id, entity_name, device_model
)
assert ha_state.state == STATE_OFF
await async_manipulate_test_data(hass, hmip_device, "motionDetected", True)
ha_state = hass.states.get(entity_id)
assert ha_state.state == STATE_ON | [
"async",
"def",
"test_hmip_motion_detector",
"(",
"hass",
",",
"default_mock_hap_factory",
")",
":",
"entity_id",
"=",
"\"binary_sensor.bewegungsmelder_fur_55er_rahmen_innen\"",
"entity_name",
"=",
"\"Bewegungsmelder für 55er Rahmen – innen\"",
"device_model",
"=",
"\"HmIP-SMI55\"",
"mock_hap",
"=",
"await",
"default_mock_hap_factory",
".",
"async_get_mock_hap",
"(",
"test_devices",
"=",
"[",
"entity_name",
"]",
")",
"ha_state",
",",
"hmip_device",
"=",
"get_and_check_entity_basics",
"(",
"hass",
",",
"mock_hap",
",",
"entity_id",
",",
"entity_name",
",",
"device_model",
")",
"assert",
"ha_state",
".",
"state",
"==",
"STATE_OFF",
"await",
"async_manipulate_test_data",
"(",
"hass",
",",
"hmip_device",
",",
"\"motionDetected\"",
",",
"True",
")",
"ha_state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"entity_id",
")",
"assert",
"ha_state",
".",
"state",
"==",
"STATE_ON"
] | [
227,
0
] | [
243,
37
] | python | en | ['en', 'en', 'en'] | False |
test_hmip_presence_detector | (hass, default_mock_hap_factory) | Test HomematicipPresenceDetector. | Test HomematicipPresenceDetector. | async def test_hmip_presence_detector(hass, default_mock_hap_factory):
"""Test HomematicipPresenceDetector."""
entity_id = "binary_sensor.spi_1"
entity_name = "SPI_1"
device_model = "HmIP-SPI"
mock_hap = await default_mock_hap_factory.async_get_mock_hap(
test_devices=[entity_name]
)
ha_state, hmip_device = get_and_check_entity_basics(
hass, mock_hap, entity_id, entity_name, device_model
)
assert ha_state.state == STATE_OFF
await async_manipulate_test_data(hass, hmip_device, "presenceDetected", True)
ha_state = hass.states.get(entity_id)
assert ha_state.state == STATE_ON
assert not ha_state.attributes.get(ATTR_EVENT_DELAY)
await async_manipulate_test_data(hass, hmip_device, "eventDelay", True)
ha_state = hass.states.get(entity_id)
assert ha_state.attributes[ATTR_EVENT_DELAY] | [
"async",
"def",
"test_hmip_presence_detector",
"(",
"hass",
",",
"default_mock_hap_factory",
")",
":",
"entity_id",
"=",
"\"binary_sensor.spi_1\"",
"entity_name",
"=",
"\"SPI_1\"",
"device_model",
"=",
"\"HmIP-SPI\"",
"mock_hap",
"=",
"await",
"default_mock_hap_factory",
".",
"async_get_mock_hap",
"(",
"test_devices",
"=",
"[",
"entity_name",
"]",
")",
"ha_state",
",",
"hmip_device",
"=",
"get_and_check_entity_basics",
"(",
"hass",
",",
"mock_hap",
",",
"entity_id",
",",
"entity_name",
",",
"device_model",
")",
"assert",
"ha_state",
".",
"state",
"==",
"STATE_OFF",
"await",
"async_manipulate_test_data",
"(",
"hass",
",",
"hmip_device",
",",
"\"presenceDetected\"",
",",
"True",
")",
"ha_state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"entity_id",
")",
"assert",
"ha_state",
".",
"state",
"==",
"STATE_ON",
"assert",
"not",
"ha_state",
".",
"attributes",
".",
"get",
"(",
"ATTR_EVENT_DELAY",
")",
"await",
"async_manipulate_test_data",
"(",
"hass",
",",
"hmip_device",
",",
"\"eventDelay\"",
",",
"True",
")",
"ha_state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"entity_id",
")",
"assert",
"ha_state",
".",
"attributes",
"[",
"ATTR_EVENT_DELAY",
"]"
] | [
246,
0
] | [
267,
48
] | python | en | ['en', 'it', 'en'] | False |
test_hmip_pluggable_mains_failure_surveillance_sensor | (
hass, default_mock_hap_factory
) | Test HomematicipPresenceDetector. | Test HomematicipPresenceDetector. | async def test_hmip_pluggable_mains_failure_surveillance_sensor(
hass, default_mock_hap_factory
):
"""Test HomematicipPresenceDetector."""
entity_id = "binary_sensor.netzausfalluberwachung"
entity_name = "Netzausfallüberwachung"
device_model = "HmIP-PMFS"
mock_hap = await default_mock_hap_factory.async_get_mock_hap(
test_devices=[entity_name]
)
ha_state, hmip_device = get_and_check_entity_basics(
hass, mock_hap, entity_id, entity_name, device_model
)
assert ha_state.state == STATE_ON
await async_manipulate_test_data(hass, hmip_device, "powerMainsFailure", True)
ha_state = hass.states.get(entity_id)
assert ha_state.state == STATE_OFF | [
"async",
"def",
"test_hmip_pluggable_mains_failure_surveillance_sensor",
"(",
"hass",
",",
"default_mock_hap_factory",
")",
":",
"entity_id",
"=",
"\"binary_sensor.netzausfalluberwachung\"",
"entity_name",
"=",
"\"Netzausfallüberwachung\"",
"device_model",
"=",
"\"HmIP-PMFS\"",
"mock_hap",
"=",
"await",
"default_mock_hap_factory",
".",
"async_get_mock_hap",
"(",
"test_devices",
"=",
"[",
"entity_name",
"]",
")",
"ha_state",
",",
"hmip_device",
"=",
"get_and_check_entity_basics",
"(",
"hass",
",",
"mock_hap",
",",
"entity_id",
",",
"entity_name",
",",
"device_model",
")",
"assert",
"ha_state",
".",
"state",
"==",
"STATE_ON",
"await",
"async_manipulate_test_data",
"(",
"hass",
",",
"hmip_device",
",",
"\"powerMainsFailure\"",
",",
"True",
")",
"ha_state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"entity_id",
")",
"assert",
"ha_state",
".",
"state",
"==",
"STATE_OFF"
] | [
270,
0
] | [
288,
38
] | python | en | ['en', 'it', 'en'] | False |
test_hmip_smoke_detector | (hass, default_mock_hap_factory) | Test HomematicipSmokeDetector. | Test HomematicipSmokeDetector. | async def test_hmip_smoke_detector(hass, default_mock_hap_factory):
"""Test HomematicipSmokeDetector."""
entity_id = "binary_sensor.rauchwarnmelder"
entity_name = "Rauchwarnmelder"
device_model = "HmIP-SWSD"
mock_hap = await default_mock_hap_factory.async_get_mock_hap(
test_devices=[entity_name]
)
ha_state, hmip_device = get_and_check_entity_basics(
hass, mock_hap, entity_id, entity_name, device_model
)
assert ha_state.state == STATE_OFF
await async_manipulate_test_data(
hass,
hmip_device,
"smokeDetectorAlarmType",
SmokeDetectorAlarmType.PRIMARY_ALARM,
)
ha_state = hass.states.get(entity_id)
assert ha_state.state == STATE_ON
await async_manipulate_test_data(
hass,
hmip_device,
"smokeDetectorAlarmType",
None,
)
ha_state = hass.states.get(entity_id)
assert ha_state.state == STATE_OFF | [
"async",
"def",
"test_hmip_smoke_detector",
"(",
"hass",
",",
"default_mock_hap_factory",
")",
":",
"entity_id",
"=",
"\"binary_sensor.rauchwarnmelder\"",
"entity_name",
"=",
"\"Rauchwarnmelder\"",
"device_model",
"=",
"\"HmIP-SWSD\"",
"mock_hap",
"=",
"await",
"default_mock_hap_factory",
".",
"async_get_mock_hap",
"(",
"test_devices",
"=",
"[",
"entity_name",
"]",
")",
"ha_state",
",",
"hmip_device",
"=",
"get_and_check_entity_basics",
"(",
"hass",
",",
"mock_hap",
",",
"entity_id",
",",
"entity_name",
",",
"device_model",
")",
"assert",
"ha_state",
".",
"state",
"==",
"STATE_OFF",
"await",
"async_manipulate_test_data",
"(",
"hass",
",",
"hmip_device",
",",
"\"smokeDetectorAlarmType\"",
",",
"SmokeDetectorAlarmType",
".",
"PRIMARY_ALARM",
",",
")",
"ha_state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"entity_id",
")",
"assert",
"ha_state",
".",
"state",
"==",
"STATE_ON",
"await",
"async_manipulate_test_data",
"(",
"hass",
",",
"hmip_device",
",",
"\"smokeDetectorAlarmType\"",
",",
"None",
",",
")",
"ha_state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"entity_id",
")",
"assert",
"ha_state",
".",
"state",
"==",
"STATE_OFF"
] | [
291,
0
] | [
320,
38
] | python | en | ['en', 'sr', 'en'] | False |
test_hmip_water_detector | (hass, default_mock_hap_factory) | Test HomematicipWaterDetector. | Test HomematicipWaterDetector. | async def test_hmip_water_detector(hass, default_mock_hap_factory):
"""Test HomematicipWaterDetector."""
entity_id = "binary_sensor.wassersensor"
entity_name = "Wassersensor"
device_model = "HmIP-SWD"
mock_hap = await default_mock_hap_factory.async_get_mock_hap(
test_devices=[entity_name]
)
ha_state, hmip_device = get_and_check_entity_basics(
hass, mock_hap, entity_id, entity_name, device_model
)
assert ha_state.state == STATE_OFF
await async_manipulate_test_data(hass, hmip_device, "waterlevelDetected", True)
await async_manipulate_test_data(hass, hmip_device, "moistureDetected", False)
ha_state = hass.states.get(entity_id)
assert ha_state.state == STATE_ON
await async_manipulate_test_data(hass, hmip_device, "waterlevelDetected", True)
await async_manipulate_test_data(hass, hmip_device, "moistureDetected", True)
ha_state = hass.states.get(entity_id)
assert ha_state.state == STATE_ON
await async_manipulate_test_data(hass, hmip_device, "waterlevelDetected", False)
await async_manipulate_test_data(hass, hmip_device, "moistureDetected", True)
ha_state = hass.states.get(entity_id)
assert ha_state.state == STATE_ON
await async_manipulate_test_data(hass, hmip_device, "waterlevelDetected", False)
await async_manipulate_test_data(hass, hmip_device, "moistureDetected", False)
ha_state = hass.states.get(entity_id)
assert ha_state.state == STATE_OFF | [
"async",
"def",
"test_hmip_water_detector",
"(",
"hass",
",",
"default_mock_hap_factory",
")",
":",
"entity_id",
"=",
"\"binary_sensor.wassersensor\"",
"entity_name",
"=",
"\"Wassersensor\"",
"device_model",
"=",
"\"HmIP-SWD\"",
"mock_hap",
"=",
"await",
"default_mock_hap_factory",
".",
"async_get_mock_hap",
"(",
"test_devices",
"=",
"[",
"entity_name",
"]",
")",
"ha_state",
",",
"hmip_device",
"=",
"get_and_check_entity_basics",
"(",
"hass",
",",
"mock_hap",
",",
"entity_id",
",",
"entity_name",
",",
"device_model",
")",
"assert",
"ha_state",
".",
"state",
"==",
"STATE_OFF",
"await",
"async_manipulate_test_data",
"(",
"hass",
",",
"hmip_device",
",",
"\"waterlevelDetected\"",
",",
"True",
")",
"await",
"async_manipulate_test_data",
"(",
"hass",
",",
"hmip_device",
",",
"\"moistureDetected\"",
",",
"False",
")",
"ha_state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"entity_id",
")",
"assert",
"ha_state",
".",
"state",
"==",
"STATE_ON",
"await",
"async_manipulate_test_data",
"(",
"hass",
",",
"hmip_device",
",",
"\"waterlevelDetected\"",
",",
"True",
")",
"await",
"async_manipulate_test_data",
"(",
"hass",
",",
"hmip_device",
",",
"\"moistureDetected\"",
",",
"True",
")",
"ha_state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"entity_id",
")",
"assert",
"ha_state",
".",
"state",
"==",
"STATE_ON",
"await",
"async_manipulate_test_data",
"(",
"hass",
",",
"hmip_device",
",",
"\"waterlevelDetected\"",
",",
"False",
")",
"await",
"async_manipulate_test_data",
"(",
"hass",
",",
"hmip_device",
",",
"\"moistureDetected\"",
",",
"True",
")",
"ha_state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"entity_id",
")",
"assert",
"ha_state",
".",
"state",
"==",
"STATE_ON",
"await",
"async_manipulate_test_data",
"(",
"hass",
",",
"hmip_device",
",",
"\"waterlevelDetected\"",
",",
"False",
")",
"await",
"async_manipulate_test_data",
"(",
"hass",
",",
"hmip_device",
",",
"\"moistureDetected\"",
",",
"False",
")",
"ha_state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"entity_id",
")",
"assert",
"ha_state",
".",
"state",
"==",
"STATE_OFF"
] | [
323,
0
] | [
355,
38
] | python | en | ['en', 'nl', 'en'] | False |
test_hmip_storm_sensor | (hass, default_mock_hap_factory) | Test HomematicipStormSensor. | Test HomematicipStormSensor. | async def test_hmip_storm_sensor(hass, default_mock_hap_factory):
"""Test HomematicipStormSensor."""
entity_id = "binary_sensor.weather_sensor_plus_storm"
entity_name = "Weather Sensor – plus Storm"
device_model = "HmIP-SWO-PL"
mock_hap = await default_mock_hap_factory.async_get_mock_hap(
test_devices=["Weather Sensor – plus"]
)
ha_state, hmip_device = get_and_check_entity_basics(
hass, mock_hap, entity_id, entity_name, device_model
)
assert ha_state.state == STATE_OFF
await async_manipulate_test_data(hass, hmip_device, "storm", True)
ha_state = hass.states.get(entity_id)
assert ha_state.state == STATE_ON | [
"async",
"def",
"test_hmip_storm_sensor",
"(",
"hass",
",",
"default_mock_hap_factory",
")",
":",
"entity_id",
"=",
"\"binary_sensor.weather_sensor_plus_storm\"",
"entity_name",
"=",
"\"Weather Sensor – plus Storm\"",
"device_model",
"=",
"\"HmIP-SWO-PL\"",
"mock_hap",
"=",
"await",
"default_mock_hap_factory",
".",
"async_get_mock_hap",
"(",
"test_devices",
"=",
"[",
"\"Weather Sensor – plus\"]",
"",
")",
"ha_state",
",",
"hmip_device",
"=",
"get_and_check_entity_basics",
"(",
"hass",
",",
"mock_hap",
",",
"entity_id",
",",
"entity_name",
",",
"device_model",
")",
"assert",
"ha_state",
".",
"state",
"==",
"STATE_OFF",
"await",
"async_manipulate_test_data",
"(",
"hass",
",",
"hmip_device",
",",
"\"storm\"",
",",
"True",
")",
"ha_state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"entity_id",
")",
"assert",
"ha_state",
".",
"state",
"==",
"STATE_ON"
] | [
358,
0
] | [
374,
37
] | python | es | ['es', 'pt', 'it'] | False |
test_hmip_rain_sensor | (hass, default_mock_hap_factory) | Test HomematicipRainSensor. | Test HomematicipRainSensor. | async def test_hmip_rain_sensor(hass, default_mock_hap_factory):
"""Test HomematicipRainSensor."""
entity_id = "binary_sensor.wettersensor_pro_raining"
entity_name = "Wettersensor - pro Raining"
device_model = "HmIP-SWO-PR"
mock_hap = await default_mock_hap_factory.async_get_mock_hap(
test_devices=["Wettersensor - pro"]
)
ha_state, hmip_device = get_and_check_entity_basics(
hass, mock_hap, entity_id, entity_name, device_model
)
assert ha_state.state == STATE_OFF
await async_manipulate_test_data(hass, hmip_device, "raining", True)
ha_state = hass.states.get(entity_id)
assert ha_state.state == STATE_ON | [
"async",
"def",
"test_hmip_rain_sensor",
"(",
"hass",
",",
"default_mock_hap_factory",
")",
":",
"entity_id",
"=",
"\"binary_sensor.wettersensor_pro_raining\"",
"entity_name",
"=",
"\"Wettersensor - pro Raining\"",
"device_model",
"=",
"\"HmIP-SWO-PR\"",
"mock_hap",
"=",
"await",
"default_mock_hap_factory",
".",
"async_get_mock_hap",
"(",
"test_devices",
"=",
"[",
"\"Wettersensor - pro\"",
"]",
")",
"ha_state",
",",
"hmip_device",
"=",
"get_and_check_entity_basics",
"(",
"hass",
",",
"mock_hap",
",",
"entity_id",
",",
"entity_name",
",",
"device_model",
")",
"assert",
"ha_state",
".",
"state",
"==",
"STATE_OFF",
"await",
"async_manipulate_test_data",
"(",
"hass",
",",
"hmip_device",
",",
"\"raining\"",
",",
"True",
")",
"ha_state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"entity_id",
")",
"assert",
"ha_state",
".",
"state",
"==",
"STATE_ON"
] | [
377,
0
] | [
393,
37
] | python | en | ['es', 'no', 'en'] | False |
test_hmip_sunshine_sensor | (hass, default_mock_hap_factory) | Test HomematicipSunshineSensor. | Test HomematicipSunshineSensor. | async def test_hmip_sunshine_sensor(hass, default_mock_hap_factory):
"""Test HomematicipSunshineSensor."""
entity_id = "binary_sensor.wettersensor_pro_sunshine"
entity_name = "Wettersensor - pro Sunshine"
device_model = "HmIP-SWO-PR"
mock_hap = await default_mock_hap_factory.async_get_mock_hap(
test_devices=["Wettersensor - pro"]
)
ha_state, hmip_device = get_and_check_entity_basics(
hass, mock_hap, entity_id, entity_name, device_model
)
assert ha_state.state == STATE_ON
assert ha_state.attributes["today_sunshine_duration_in_minutes"] == 100
await async_manipulate_test_data(hass, hmip_device, "sunshine", False)
ha_state = hass.states.get(entity_id)
assert ha_state.state == STATE_OFF | [
"async",
"def",
"test_hmip_sunshine_sensor",
"(",
"hass",
",",
"default_mock_hap_factory",
")",
":",
"entity_id",
"=",
"\"binary_sensor.wettersensor_pro_sunshine\"",
"entity_name",
"=",
"\"Wettersensor - pro Sunshine\"",
"device_model",
"=",
"\"HmIP-SWO-PR\"",
"mock_hap",
"=",
"await",
"default_mock_hap_factory",
".",
"async_get_mock_hap",
"(",
"test_devices",
"=",
"[",
"\"Wettersensor - pro\"",
"]",
")",
"ha_state",
",",
"hmip_device",
"=",
"get_and_check_entity_basics",
"(",
"hass",
",",
"mock_hap",
",",
"entity_id",
",",
"entity_name",
",",
"device_model",
")",
"assert",
"ha_state",
".",
"state",
"==",
"STATE_ON",
"assert",
"ha_state",
".",
"attributes",
"[",
"\"today_sunshine_duration_in_minutes\"",
"]",
"==",
"100",
"await",
"async_manipulate_test_data",
"(",
"hass",
",",
"hmip_device",
",",
"\"sunshine\"",
",",
"False",
")",
"ha_state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"entity_id",
")",
"assert",
"ha_state",
".",
"state",
"==",
"STATE_OFF"
] | [
396,
0
] | [
413,
38
] | python | en | ['en', 'no', 'en'] | False |
test_hmip_battery_sensor | (hass, default_mock_hap_factory) | Test HomematicipSunshineSensor. | Test HomematicipSunshineSensor. | async def test_hmip_battery_sensor(hass, default_mock_hap_factory):
"""Test HomematicipSunshineSensor."""
entity_id = "binary_sensor.wohnungsture_battery"
entity_name = "Wohnungstüre Battery"
device_model = "HMIP-SWDO"
mock_hap = await default_mock_hap_factory.async_get_mock_hap(
test_devices=["Wohnungstüre"]
)
ha_state, hmip_device = get_and_check_entity_basics(
hass, mock_hap, entity_id, entity_name, device_model
)
assert ha_state.state == STATE_OFF
await async_manipulate_test_data(hass, hmip_device, "lowBat", True)
ha_state = hass.states.get(entity_id)
assert ha_state.state == STATE_ON | [
"async",
"def",
"test_hmip_battery_sensor",
"(",
"hass",
",",
"default_mock_hap_factory",
")",
":",
"entity_id",
"=",
"\"binary_sensor.wohnungsture_battery\"",
"entity_name",
"=",
"\"Wohnungstüre Battery\"",
"device_model",
"=",
"\"HMIP-SWDO\"",
"mock_hap",
"=",
"await",
"default_mock_hap_factory",
".",
"async_get_mock_hap",
"(",
"test_devices",
"=",
"[",
"\"Wohnungstüre\"]",
"",
")",
"ha_state",
",",
"hmip_device",
"=",
"get_and_check_entity_basics",
"(",
"hass",
",",
"mock_hap",
",",
"entity_id",
",",
"entity_name",
",",
"device_model",
")",
"assert",
"ha_state",
".",
"state",
"==",
"STATE_OFF",
"await",
"async_manipulate_test_data",
"(",
"hass",
",",
"hmip_device",
",",
"\"lowBat\"",
",",
"True",
")",
"ha_state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"entity_id",
")",
"assert",
"ha_state",
".",
"state",
"==",
"STATE_ON"
] | [
416,
0
] | [
432,
37
] | python | en | ['en', 'no', 'en'] | False |
test_hmip_security_zone_sensor_group | (hass, default_mock_hap_factory) | Test HomematicipSecurityZoneSensorGroup. | Test HomematicipSecurityZoneSensorGroup. | async def test_hmip_security_zone_sensor_group(hass, default_mock_hap_factory):
"""Test HomematicipSecurityZoneSensorGroup."""
entity_id = "binary_sensor.internal_securityzone"
entity_name = "INTERNAL SecurityZone"
device_model = "HmIP-SecurityZone"
mock_hap = await default_mock_hap_factory.async_get_mock_hap(
test_groups=["INTERNAL"]
)
ha_state, hmip_device = get_and_check_entity_basics(
hass, mock_hap, entity_id, entity_name, device_model
)
assert ha_state.state == STATE_OFF
assert not ha_state.attributes.get(ATTR_MOTION_DETECTED)
assert not ha_state.attributes.get(ATTR_PRESENCE_DETECTED)
assert not ha_state.attributes.get(ATTR_GROUP_MEMBER_UNREACHABLE)
assert not ha_state.attributes.get(ATTR_SABOTAGE)
assert not ha_state.attributes.get(ATTR_WINDOW_STATE)
await async_manipulate_test_data(hass, hmip_device, "motionDetected", True)
await async_manipulate_test_data(hass, hmip_device, "presenceDetected", True)
await async_manipulate_test_data(hass, hmip_device, "unreach", True)
await async_manipulate_test_data(hass, hmip_device, "sabotage", True)
await async_manipulate_test_data(hass, hmip_device, "windowState", WindowState.OPEN)
ha_state = hass.states.get(entity_id)
assert ha_state.state == STATE_ON
assert ha_state.attributes[ATTR_MOTION_DETECTED]
assert ha_state.attributes[ATTR_PRESENCE_DETECTED]
assert ha_state.attributes[ATTR_GROUP_MEMBER_UNREACHABLE]
assert ha_state.attributes[ATTR_SABOTAGE]
assert ha_state.attributes[ATTR_WINDOW_STATE] == WindowState.OPEN | [
"async",
"def",
"test_hmip_security_zone_sensor_group",
"(",
"hass",
",",
"default_mock_hap_factory",
")",
":",
"entity_id",
"=",
"\"binary_sensor.internal_securityzone\"",
"entity_name",
"=",
"\"INTERNAL SecurityZone\"",
"device_model",
"=",
"\"HmIP-SecurityZone\"",
"mock_hap",
"=",
"await",
"default_mock_hap_factory",
".",
"async_get_mock_hap",
"(",
"test_groups",
"=",
"[",
"\"INTERNAL\"",
"]",
")",
"ha_state",
",",
"hmip_device",
"=",
"get_and_check_entity_basics",
"(",
"hass",
",",
"mock_hap",
",",
"entity_id",
",",
"entity_name",
",",
"device_model",
")",
"assert",
"ha_state",
".",
"state",
"==",
"STATE_OFF",
"assert",
"not",
"ha_state",
".",
"attributes",
".",
"get",
"(",
"ATTR_MOTION_DETECTED",
")",
"assert",
"not",
"ha_state",
".",
"attributes",
".",
"get",
"(",
"ATTR_PRESENCE_DETECTED",
")",
"assert",
"not",
"ha_state",
".",
"attributes",
".",
"get",
"(",
"ATTR_GROUP_MEMBER_UNREACHABLE",
")",
"assert",
"not",
"ha_state",
".",
"attributes",
".",
"get",
"(",
"ATTR_SABOTAGE",
")",
"assert",
"not",
"ha_state",
".",
"attributes",
".",
"get",
"(",
"ATTR_WINDOW_STATE",
")",
"await",
"async_manipulate_test_data",
"(",
"hass",
",",
"hmip_device",
",",
"\"motionDetected\"",
",",
"True",
")",
"await",
"async_manipulate_test_data",
"(",
"hass",
",",
"hmip_device",
",",
"\"presenceDetected\"",
",",
"True",
")",
"await",
"async_manipulate_test_data",
"(",
"hass",
",",
"hmip_device",
",",
"\"unreach\"",
",",
"True",
")",
"await",
"async_manipulate_test_data",
"(",
"hass",
",",
"hmip_device",
",",
"\"sabotage\"",
",",
"True",
")",
"await",
"async_manipulate_test_data",
"(",
"hass",
",",
"hmip_device",
",",
"\"windowState\"",
",",
"WindowState",
".",
"OPEN",
")",
"ha_state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"entity_id",
")",
"assert",
"ha_state",
".",
"state",
"==",
"STATE_ON",
"assert",
"ha_state",
".",
"attributes",
"[",
"ATTR_MOTION_DETECTED",
"]",
"assert",
"ha_state",
".",
"attributes",
"[",
"ATTR_PRESENCE_DETECTED",
"]",
"assert",
"ha_state",
".",
"attributes",
"[",
"ATTR_GROUP_MEMBER_UNREACHABLE",
"]",
"assert",
"ha_state",
".",
"attributes",
"[",
"ATTR_SABOTAGE",
"]",
"assert",
"ha_state",
".",
"attributes",
"[",
"ATTR_WINDOW_STATE",
"]",
"==",
"WindowState",
".",
"OPEN"
] | [
435,
0
] | [
467,
69
] | python | en | ['es', 'xh', 'en'] | False |
test_hmip_security_sensor_group | (hass, default_mock_hap_factory) | Test HomematicipSecuritySensorGroup. | Test HomematicipSecuritySensorGroup. | async def test_hmip_security_sensor_group(hass, default_mock_hap_factory):
"""Test HomematicipSecuritySensorGroup."""
entity_id = "binary_sensor.buro_sensors"
entity_name = "Büro Sensors"
device_model = None
mock_hap = await default_mock_hap_factory.async_get_mock_hap(test_groups=["Büro"])
ha_state, hmip_device = get_and_check_entity_basics(
hass, mock_hap, entity_id, entity_name, device_model
)
await async_manipulate_test_data(
hass,
hmip_device,
"smokeDetectorAlarmType",
SmokeDetectorAlarmType.PRIMARY_ALARM,
)
ha_state = hass.states.get(entity_id)
assert ha_state.state == STATE_ON
assert (
ha_state.attributes["smoke_detector_alarm"]
== SmokeDetectorAlarmType.PRIMARY_ALARM
)
await async_manipulate_test_data(
hass, hmip_device, "smokeDetectorAlarmType", SmokeDetectorAlarmType.IDLE_OFF
)
ha_state = hass.states.get(entity_id)
assert ha_state.state == STATE_OFF
assert not ha_state.attributes.get(ATTR_LOW_BATTERY)
assert not ha_state.attributes.get(ATTR_MOTION_DETECTED)
assert not ha_state.attributes.get(ATTR_PRESENCE_DETECTED)
assert not ha_state.attributes.get(ATTR_POWER_MAINS_FAILURE)
assert not ha_state.attributes.get(ATTR_MOISTURE_DETECTED)
assert not ha_state.attributes.get(ATTR_WATER_LEVEL_DETECTED)
assert not ha_state.attributes.get(ATTR_GROUP_MEMBER_UNREACHABLE)
assert not ha_state.attributes.get(ATTR_SABOTAGE)
assert not ha_state.attributes.get(ATTR_WINDOW_STATE)
await async_manipulate_test_data(hass, hmip_device, "lowBat", True)
await async_manipulate_test_data(hass, hmip_device, "motionDetected", True)
await async_manipulate_test_data(hass, hmip_device, "presenceDetected", True)
await async_manipulate_test_data(hass, hmip_device, "powerMainsFailure", True)
await async_manipulate_test_data(hass, hmip_device, "moistureDetected", True)
await async_manipulate_test_data(hass, hmip_device, "waterlevelDetected", True)
await async_manipulate_test_data(hass, hmip_device, "unreach", True)
await async_manipulate_test_data(hass, hmip_device, "sabotage", True)
await async_manipulate_test_data(hass, hmip_device, "windowState", WindowState.OPEN)
ha_state = hass.states.get(entity_id)
assert ha_state.state == STATE_ON
assert ha_state.attributes[ATTR_LOW_BATTERY]
assert ha_state.attributes[ATTR_MOTION_DETECTED]
assert ha_state.attributes[ATTR_PRESENCE_DETECTED]
assert ha_state.attributes[ATTR_POWER_MAINS_FAILURE]
assert ha_state.attributes[ATTR_MOISTURE_DETECTED]
assert ha_state.attributes[ATTR_WATER_LEVEL_DETECTED]
assert ha_state.attributes[ATTR_GROUP_MEMBER_UNREACHABLE]
assert ha_state.attributes[ATTR_SABOTAGE]
assert ha_state.attributes[ATTR_WINDOW_STATE] == WindowState.OPEN
await async_manipulate_test_data(
hass,
hmip_device,
"smokeDetectorAlarmType",
SmokeDetectorAlarmType.INTRUSION_ALARM,
)
ha_state = hass.states.get(entity_id)
assert ha_state.state == STATE_ON | [
"async",
"def",
"test_hmip_security_sensor_group",
"(",
"hass",
",",
"default_mock_hap_factory",
")",
":",
"entity_id",
"=",
"\"binary_sensor.buro_sensors\"",
"entity_name",
"=",
"\"Büro Sensors\"",
"device_model",
"=",
"None",
"mock_hap",
"=",
"await",
"default_mock_hap_factory",
".",
"async_get_mock_hap",
"(",
"test_groups",
"=",
"[",
"\"Büro\"]",
")",
"",
"ha_state",
",",
"hmip_device",
"=",
"get_and_check_entity_basics",
"(",
"hass",
",",
"mock_hap",
",",
"entity_id",
",",
"entity_name",
",",
"device_model",
")",
"await",
"async_manipulate_test_data",
"(",
"hass",
",",
"hmip_device",
",",
"\"smokeDetectorAlarmType\"",
",",
"SmokeDetectorAlarmType",
".",
"PRIMARY_ALARM",
",",
")",
"ha_state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"entity_id",
")",
"assert",
"ha_state",
".",
"state",
"==",
"STATE_ON",
"assert",
"(",
"ha_state",
".",
"attributes",
"[",
"\"smoke_detector_alarm\"",
"]",
"==",
"SmokeDetectorAlarmType",
".",
"PRIMARY_ALARM",
")",
"await",
"async_manipulate_test_data",
"(",
"hass",
",",
"hmip_device",
",",
"\"smokeDetectorAlarmType\"",
",",
"SmokeDetectorAlarmType",
".",
"IDLE_OFF",
")",
"ha_state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"entity_id",
")",
"assert",
"ha_state",
".",
"state",
"==",
"STATE_OFF",
"assert",
"not",
"ha_state",
".",
"attributes",
".",
"get",
"(",
"ATTR_LOW_BATTERY",
")",
"assert",
"not",
"ha_state",
".",
"attributes",
".",
"get",
"(",
"ATTR_MOTION_DETECTED",
")",
"assert",
"not",
"ha_state",
".",
"attributes",
".",
"get",
"(",
"ATTR_PRESENCE_DETECTED",
")",
"assert",
"not",
"ha_state",
".",
"attributes",
".",
"get",
"(",
"ATTR_POWER_MAINS_FAILURE",
")",
"assert",
"not",
"ha_state",
".",
"attributes",
".",
"get",
"(",
"ATTR_MOISTURE_DETECTED",
")",
"assert",
"not",
"ha_state",
".",
"attributes",
".",
"get",
"(",
"ATTR_WATER_LEVEL_DETECTED",
")",
"assert",
"not",
"ha_state",
".",
"attributes",
".",
"get",
"(",
"ATTR_GROUP_MEMBER_UNREACHABLE",
")",
"assert",
"not",
"ha_state",
".",
"attributes",
".",
"get",
"(",
"ATTR_SABOTAGE",
")",
"assert",
"not",
"ha_state",
".",
"attributes",
".",
"get",
"(",
"ATTR_WINDOW_STATE",
")",
"await",
"async_manipulate_test_data",
"(",
"hass",
",",
"hmip_device",
",",
"\"lowBat\"",
",",
"True",
")",
"await",
"async_manipulate_test_data",
"(",
"hass",
",",
"hmip_device",
",",
"\"motionDetected\"",
",",
"True",
")",
"await",
"async_manipulate_test_data",
"(",
"hass",
",",
"hmip_device",
",",
"\"presenceDetected\"",
",",
"True",
")",
"await",
"async_manipulate_test_data",
"(",
"hass",
",",
"hmip_device",
",",
"\"powerMainsFailure\"",
",",
"True",
")",
"await",
"async_manipulate_test_data",
"(",
"hass",
",",
"hmip_device",
",",
"\"moistureDetected\"",
",",
"True",
")",
"await",
"async_manipulate_test_data",
"(",
"hass",
",",
"hmip_device",
",",
"\"waterlevelDetected\"",
",",
"True",
")",
"await",
"async_manipulate_test_data",
"(",
"hass",
",",
"hmip_device",
",",
"\"unreach\"",
",",
"True",
")",
"await",
"async_manipulate_test_data",
"(",
"hass",
",",
"hmip_device",
",",
"\"sabotage\"",
",",
"True",
")",
"await",
"async_manipulate_test_data",
"(",
"hass",
",",
"hmip_device",
",",
"\"windowState\"",
",",
"WindowState",
".",
"OPEN",
")",
"ha_state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"entity_id",
")",
"assert",
"ha_state",
".",
"state",
"==",
"STATE_ON",
"assert",
"ha_state",
".",
"attributes",
"[",
"ATTR_LOW_BATTERY",
"]",
"assert",
"ha_state",
".",
"attributes",
"[",
"ATTR_MOTION_DETECTED",
"]",
"assert",
"ha_state",
".",
"attributes",
"[",
"ATTR_PRESENCE_DETECTED",
"]",
"assert",
"ha_state",
".",
"attributes",
"[",
"ATTR_POWER_MAINS_FAILURE",
"]",
"assert",
"ha_state",
".",
"attributes",
"[",
"ATTR_MOISTURE_DETECTED",
"]",
"assert",
"ha_state",
".",
"attributes",
"[",
"ATTR_WATER_LEVEL_DETECTED",
"]",
"assert",
"ha_state",
".",
"attributes",
"[",
"ATTR_GROUP_MEMBER_UNREACHABLE",
"]",
"assert",
"ha_state",
".",
"attributes",
"[",
"ATTR_SABOTAGE",
"]",
"assert",
"ha_state",
".",
"attributes",
"[",
"ATTR_WINDOW_STATE",
"]",
"==",
"WindowState",
".",
"OPEN",
"await",
"async_manipulate_test_data",
"(",
"hass",
",",
"hmip_device",
",",
"\"smokeDetectorAlarmType\"",
",",
"SmokeDetectorAlarmType",
".",
"INTRUSION_ALARM",
",",
")",
"ha_state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"entity_id",
")",
"assert",
"ha_state",
".",
"state",
"==",
"STATE_ON"
] | [
470,
0
] | [
539,
37
] | python | en | ['es', 'en', 'en'] | False |
test_hmip_wired_multi_contact_interface | (hass, default_mock_hap_factory) | Test HomematicipMultiContactInterface. | Test HomematicipMultiContactInterface. | async def test_hmip_wired_multi_contact_interface(hass, default_mock_hap_factory):
"""Test HomematicipMultiContactInterface."""
entity_id = "binary_sensor.wired_eingangsmodul_32_fach_channel5"
entity_name = "Wired Eingangsmodul – 32-fach Channel5"
device_model = "HmIPW-DRI32"
mock_hap = await default_mock_hap_factory.async_get_mock_hap(
test_devices=["Wired Eingangsmodul – 32-fach"]
)
ha_state, hmip_device = get_and_check_entity_basics(
hass, mock_hap, entity_id, entity_name, device_model
)
assert ha_state.state == STATE_OFF
await async_manipulate_test_data(
hass, hmip_device, "windowState", WindowState.OPEN, channel=5
)
ha_state = hass.states.get(entity_id)
assert ha_state.state == STATE_ON
await async_manipulate_test_data(hass, hmip_device, "windowState", None, channel=5)
ha_state = hass.states.get(entity_id)
assert ha_state.state == STATE_OFF | [
"async",
"def",
"test_hmip_wired_multi_contact_interface",
"(",
"hass",
",",
"default_mock_hap_factory",
")",
":",
"entity_id",
"=",
"\"binary_sensor.wired_eingangsmodul_32_fach_channel5\"",
"entity_name",
"=",
"\"Wired Eingangsmodul – 32-fach Channel5\"",
"device_model",
"=",
"\"HmIPW-DRI32\"",
"mock_hap",
"=",
"await",
"default_mock_hap_factory",
".",
"async_get_mock_hap",
"(",
"test_devices",
"=",
"[",
"\"Wired Eingangsmodul – 32-fach\"]",
"",
")",
"ha_state",
",",
"hmip_device",
"=",
"get_and_check_entity_basics",
"(",
"hass",
",",
"mock_hap",
",",
"entity_id",
",",
"entity_name",
",",
"device_model",
")",
"assert",
"ha_state",
".",
"state",
"==",
"STATE_OFF",
"await",
"async_manipulate_test_data",
"(",
"hass",
",",
"hmip_device",
",",
"\"windowState\"",
",",
"WindowState",
".",
"OPEN",
",",
"channel",
"=",
"5",
")",
"ha_state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"entity_id",
")",
"assert",
"ha_state",
".",
"state",
"==",
"STATE_ON",
"await",
"async_manipulate_test_data",
"(",
"hass",
",",
"hmip_device",
",",
"\"windowState\"",
",",
"None",
",",
"channel",
"=",
"5",
")",
"ha_state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"entity_id",
")",
"assert",
"ha_state",
".",
"state",
"==",
"STATE_OFF"
] | [
542,
0
] | [
564,
38
] | python | en | ['es', 'en', 'en'] | False |
async_setup_recorder | (hass) | Only here so Provider Registry works. | Only here so Provider Registry works. | def async_setup_recorder(hass):
"""Only here so Provider Registry works.""" | [
"def",
"async_setup_recorder",
"(",
"hass",
")",
":"
] | [
13,
0
] | [
14,
47
] | python | en | ['en', 'en', 'en'] | True |
recorder_save_worker | (file_out: str, segments: List[Segment], container_format: str) | Handle saving stream. | Handle saving stream. | def recorder_save_worker(file_out: str, segments: List[Segment], container_format: str):
"""Handle saving stream."""
if not os.path.exists(os.path.dirname(file_out)):
os.makedirs(os.path.dirname(file_out), exist_ok=True)
first_pts = {"video": None, "audio": None}
output = av.open(file_out, "w", format=container_format)
output_v = None
output_a = None
# Get first_pts values from first segment
if len(segments) > 0:
segment = segments[0]
source = av.open(segment.segment, "r", format=container_format)
source_v = source.streams.video[0]
first_pts["video"] = source_v.start_time
if len(source.streams.audio) > 0:
source_a = source.streams.audio[0]
first_pts["audio"] = int(
source_v.start_time * source_v.time_base / source_a.time_base
)
source.close()
for segment in segments:
# Open segment
source = av.open(segment.segment, "r", format=container_format)
source_v = source.streams.video[0]
# Add output streams
if not output_v:
output_v = output.add_stream(template=source_v)
context = output_v.codec_context
context.flags |= "GLOBAL_HEADER"
if not output_a and len(source.streams.audio) > 0:
source_a = source.streams.audio[0]
output_a = output.add_stream(template=source_a)
# Remux video
for packet in source.demux():
if packet.dts is None:
continue
packet.pts -= first_pts[packet.stream.type]
packet.dts -= first_pts[packet.stream.type]
packet.stream = output_v if packet.stream.type == "video" else output_a
output.mux(packet)
source.close()
output.close() | [
"def",
"recorder_save_worker",
"(",
"file_out",
":",
"str",
",",
"segments",
":",
"List",
"[",
"Segment",
"]",
",",
"container_format",
":",
"str",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"file_out",
")",
")",
":",
"os",
".",
"makedirs",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"file_out",
")",
",",
"exist_ok",
"=",
"True",
")",
"first_pts",
"=",
"{",
"\"video\"",
":",
"None",
",",
"\"audio\"",
":",
"None",
"}",
"output",
"=",
"av",
".",
"open",
"(",
"file_out",
",",
"\"w\"",
",",
"format",
"=",
"container_format",
")",
"output_v",
"=",
"None",
"output_a",
"=",
"None",
"# Get first_pts values from first segment",
"if",
"len",
"(",
"segments",
")",
">",
"0",
":",
"segment",
"=",
"segments",
"[",
"0",
"]",
"source",
"=",
"av",
".",
"open",
"(",
"segment",
".",
"segment",
",",
"\"r\"",
",",
"format",
"=",
"container_format",
")",
"source_v",
"=",
"source",
".",
"streams",
".",
"video",
"[",
"0",
"]",
"first_pts",
"[",
"\"video\"",
"]",
"=",
"source_v",
".",
"start_time",
"if",
"len",
"(",
"source",
".",
"streams",
".",
"audio",
")",
">",
"0",
":",
"source_a",
"=",
"source",
".",
"streams",
".",
"audio",
"[",
"0",
"]",
"first_pts",
"[",
"\"audio\"",
"]",
"=",
"int",
"(",
"source_v",
".",
"start_time",
"*",
"source_v",
".",
"time_base",
"/",
"source_a",
".",
"time_base",
")",
"source",
".",
"close",
"(",
")",
"for",
"segment",
"in",
"segments",
":",
"# Open segment",
"source",
"=",
"av",
".",
"open",
"(",
"segment",
".",
"segment",
",",
"\"r\"",
",",
"format",
"=",
"container_format",
")",
"source_v",
"=",
"source",
".",
"streams",
".",
"video",
"[",
"0",
"]",
"# Add output streams",
"if",
"not",
"output_v",
":",
"output_v",
"=",
"output",
".",
"add_stream",
"(",
"template",
"=",
"source_v",
")",
"context",
"=",
"output_v",
".",
"codec_context",
"context",
".",
"flags",
"|=",
"\"GLOBAL_HEADER\"",
"if",
"not",
"output_a",
"and",
"len",
"(",
"source",
".",
"streams",
".",
"audio",
")",
">",
"0",
":",
"source_a",
"=",
"source",
".",
"streams",
".",
"audio",
"[",
"0",
"]",
"output_a",
"=",
"output",
".",
"add_stream",
"(",
"template",
"=",
"source_a",
")",
"# Remux video",
"for",
"packet",
"in",
"source",
".",
"demux",
"(",
")",
":",
"if",
"packet",
".",
"dts",
"is",
"None",
":",
"continue",
"packet",
".",
"pts",
"-=",
"first_pts",
"[",
"packet",
".",
"stream",
".",
"type",
"]",
"packet",
".",
"dts",
"-=",
"first_pts",
"[",
"packet",
".",
"stream",
".",
"type",
"]",
"packet",
".",
"stream",
"=",
"output_v",
"if",
"packet",
".",
"stream",
".",
"type",
"==",
"\"video\"",
"else",
"output_a",
"output",
".",
"mux",
"(",
"packet",
")",
"source",
".",
"close",
"(",
")",
"output",
".",
"close",
"(",
")"
] | [
17,
0
] | [
64,
18
] | python | en | ['en', 'iw', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Import Awair configuration from YAML. | Import Awair configuration from YAML. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Import Awair configuration from YAML."""
LOGGER.warning(
"Loading Awair via platform setup is deprecated. Please remove it from your configuration."
)
hass.async_create_task(
hass.config_entries.flow.async_init(
DOMAIN,
context={"source": SOURCE_IMPORT},
data=config,
)
) | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"LOGGER",
".",
"warning",
"(",
"\"Loading Awair via platform setup is deprecated. Please remove it from your configuration.\"",
")",
"hass",
".",
"async_create_task",
"(",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"SOURCE_IMPORT",
"}",
",",
"data",
"=",
"config",
",",
")",
")"
] | [
40,
0
] | [
51,
5
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (
hass: HomeAssistantType,
config_entry: ConfigType,
async_add_entities: Callable[[List[Entity], bool], None],
) | Set up Awair sensor entity based on a config entry. | Set up Awair sensor entity based on a config entry. | async def async_setup_entry(
hass: HomeAssistantType,
config_entry: ConfigType,
async_add_entities: Callable[[List[Entity], bool], None],
):
"""Set up Awair sensor entity based on a config entry."""
coordinator = hass.data[DOMAIN][config_entry.entry_id]
sensors = []
data: List[AwairResult] = coordinator.data.values()
for result in data:
if result.air_data:
sensors.append(AwairSensor(API_SCORE, result.device, coordinator))
device_sensors = result.air_data.sensors.keys()
for sensor in device_sensors:
if sensor in SENSOR_TYPES:
sensors.append(AwairSensor(sensor, result.device, coordinator))
# The "DUST" sensor for Awair is a combo pm2.5/pm10 sensor only
# present on first-gen devices in lieu of separate pm2.5/pm10 sensors.
# We handle that by creating fake pm2.5/pm10 sensors that will always
# report identical values, and we let users decide how they want to use
# that data - because we can't really tell what kind of particles the
# "DUST" sensor actually detected. However, it's still useful data.
if API_DUST in device_sensors:
for alias_kind in DUST_ALIASES:
sensors.append(AwairSensor(alias_kind, result.device, coordinator))
async_add_entities(sensors) | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistantType",
",",
"config_entry",
":",
"ConfigType",
",",
"async_add_entities",
":",
"Callable",
"[",
"[",
"List",
"[",
"Entity",
"]",
",",
"bool",
"]",
",",
"None",
"]",
",",
")",
":",
"coordinator",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"config_entry",
".",
"entry_id",
"]",
"sensors",
"=",
"[",
"]",
"data",
":",
"List",
"[",
"AwairResult",
"]",
"=",
"coordinator",
".",
"data",
".",
"values",
"(",
")",
"for",
"result",
"in",
"data",
":",
"if",
"result",
".",
"air_data",
":",
"sensors",
".",
"append",
"(",
"AwairSensor",
"(",
"API_SCORE",
",",
"result",
".",
"device",
",",
"coordinator",
")",
")",
"device_sensors",
"=",
"result",
".",
"air_data",
".",
"sensors",
".",
"keys",
"(",
")",
"for",
"sensor",
"in",
"device_sensors",
":",
"if",
"sensor",
"in",
"SENSOR_TYPES",
":",
"sensors",
".",
"append",
"(",
"AwairSensor",
"(",
"sensor",
",",
"result",
".",
"device",
",",
"coordinator",
")",
")",
"# The \"DUST\" sensor for Awair is a combo pm2.5/pm10 sensor only",
"# present on first-gen devices in lieu of separate pm2.5/pm10 sensors.",
"# We handle that by creating fake pm2.5/pm10 sensors that will always",
"# report identical values, and we let users decide how they want to use",
"# that data - because we can't really tell what kind of particles the",
"# \"DUST\" sensor actually detected. However, it's still useful data.",
"if",
"API_DUST",
"in",
"device_sensors",
":",
"for",
"alias_kind",
"in",
"DUST_ALIASES",
":",
"sensors",
".",
"append",
"(",
"AwairSensor",
"(",
"alias_kind",
",",
"result",
".",
"device",
",",
"coordinator",
")",
")",
"async_add_entities",
"(",
"sensors",
")"
] | [
54,
0
] | [
82,
31
] | python | en | ['en', 'en', 'en'] | True |
AwairSensor.__init__ | (
self,
kind: str,
device: AwairDevice,
coordinator: AwairDataUpdateCoordinator,
) | Set up an individual AwairSensor. | Set up an individual AwairSensor. | def __init__(
self,
kind: str,
device: AwairDevice,
coordinator: AwairDataUpdateCoordinator,
) -> None:
"""Set up an individual AwairSensor."""
super().__init__(coordinator)
self._kind = kind
self._device = device | [
"def",
"__init__",
"(",
"self",
",",
"kind",
":",
"str",
",",
"device",
":",
"AwairDevice",
",",
"coordinator",
":",
"AwairDataUpdateCoordinator",
",",
")",
"->",
"None",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"coordinator",
")",
"self",
".",
"_kind",
"=",
"kind",
"self",
".",
"_device",
"=",
"device"
] | [
88,
4
] | [
97,
29
] | python | en | ['en', 'su', 'en'] | True |
AwairSensor.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self) -> str:
"""Return the name of the sensor."""
name = SENSOR_TYPES[self._kind][ATTR_LABEL]
if self._device.name:
name = f"{self._device.name} {name}"
return name | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"name",
"=",
"SENSOR_TYPES",
"[",
"self",
".",
"_kind",
"]",
"[",
"ATTR_LABEL",
"]",
"if",
"self",
".",
"_device",
".",
"name",
":",
"name",
"=",
"f\"{self._device.name} {name}\"",
"return",
"name"
] | [
100,
4
] | [
106,
19
] | python | en | ['en', 'mi', 'en'] | True |
AwairSensor.unique_id | (self) | Return the uuid as the unique_id. | Return the uuid as the unique_id. | def unique_id(self) -> str:
"""Return the uuid as the unique_id."""
unique_id_tag = SENSOR_TYPES[self._kind][ATTR_UNIQUE_ID]
# This integration used to create a sensor that was labelled as a "PM2.5"
# sensor for first-gen Awair devices, but its unique_id reflected the truth:
# under the hood, it was a "DUST" sensor. So we preserve that specific unique_id
# for users with first-gen devices that are upgrading.
if self._kind == API_PM25 and API_DUST in self._air_data.sensors:
unique_id_tag = "DUST"
return f"{self._device.uuid}_{unique_id_tag}" | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"str",
":",
"unique_id_tag",
"=",
"SENSOR_TYPES",
"[",
"self",
".",
"_kind",
"]",
"[",
"ATTR_UNIQUE_ID",
"]",
"# This integration used to create a sensor that was labelled as a \"PM2.5\"",
"# sensor for first-gen Awair devices, but its unique_id reflected the truth:",
"# under the hood, it was a \"DUST\" sensor. So we preserve that specific unique_id",
"# for users with first-gen devices that are upgrading.",
"if",
"self",
".",
"_kind",
"==",
"API_PM25",
"and",
"API_DUST",
"in",
"self",
".",
"_air_data",
".",
"sensors",
":",
"unique_id_tag",
"=",
"\"DUST\"",
"return",
"f\"{self._device.uuid}_{unique_id_tag}\""
] | [
109,
4
] | [
120,
53
] | python | en | ['en', 'en', 'en'] | True |
AwairSensor.available | (self) | Determine if the sensor is available based on API results. | Determine if the sensor is available based on API results. | def available(self) -> bool:
"""Determine if the sensor is available based on API results."""
# If the last update was successful...
if self.coordinator.last_update_success and self._air_data:
# and the results included our sensor type...
if self._kind in self._air_data.sensors:
# then we are available.
return True
# or, we're a dust alias
if self._kind in DUST_ALIASES and API_DUST in self._air_data.sensors:
return True
# or we are API_SCORE
if self._kind == API_SCORE:
# then we are available.
return True
# Otherwise, we are not.
return False | [
"def",
"available",
"(",
"self",
")",
"->",
"bool",
":",
"# If the last update was successful...",
"if",
"self",
".",
"coordinator",
".",
"last_update_success",
"and",
"self",
".",
"_air_data",
":",
"# and the results included our sensor type...",
"if",
"self",
".",
"_kind",
"in",
"self",
".",
"_air_data",
".",
"sensors",
":",
"# then we are available.",
"return",
"True",
"# or, we're a dust alias",
"if",
"self",
".",
"_kind",
"in",
"DUST_ALIASES",
"and",
"API_DUST",
"in",
"self",
".",
"_air_data",
".",
"sensors",
":",
"return",
"True",
"# or we are API_SCORE",
"if",
"self",
".",
"_kind",
"==",
"API_SCORE",
":",
"# then we are available.",
"return",
"True",
"# Otherwise, we are not.",
"return",
"False"
] | [
123,
4
] | [
142,
20
] | python | en | ['en', 'en', 'en'] | True |
AwairSensor.state | (self) | Return the state, rounding off to reasonable values. | Return the state, rounding off to reasonable values. | def state(self) -> float:
"""Return the state, rounding off to reasonable values."""
state: float
# Special-case for "SCORE", which we treat as the AQI
if self._kind == API_SCORE:
state = self._air_data.score
elif self._kind in DUST_ALIASES and API_DUST in self._air_data.sensors:
state = self._air_data.sensors.dust
else:
state = self._air_data.sensors[self._kind]
if self._kind == API_VOC or self._kind == API_SCORE:
return round(state)
if self._kind == API_TEMP:
return round(state, 1)
return round(state, 2) | [
"def",
"state",
"(",
"self",
")",
"->",
"float",
":",
"state",
":",
"float",
"# Special-case for \"SCORE\", which we treat as the AQI",
"if",
"self",
".",
"_kind",
"==",
"API_SCORE",
":",
"state",
"=",
"self",
".",
"_air_data",
".",
"score",
"elif",
"self",
".",
"_kind",
"in",
"DUST_ALIASES",
"and",
"API_DUST",
"in",
"self",
".",
"_air_data",
".",
"sensors",
":",
"state",
"=",
"self",
".",
"_air_data",
".",
"sensors",
".",
"dust",
"else",
":",
"state",
"=",
"self",
".",
"_air_data",
".",
"sensors",
"[",
"self",
".",
"_kind",
"]",
"if",
"self",
".",
"_kind",
"==",
"API_VOC",
"or",
"self",
".",
"_kind",
"==",
"API_SCORE",
":",
"return",
"round",
"(",
"state",
")",
"if",
"self",
".",
"_kind",
"==",
"API_TEMP",
":",
"return",
"round",
"(",
"state",
",",
"1",
")",
"return",
"round",
"(",
"state",
",",
"2",
")"
] | [
145,
4
] | [
163,
30
] | python | en | ['en', 'en', 'en'] | True |
AwairSensor.icon | (self) | Return the icon. | Return the icon. | def icon(self) -> str:
"""Return the icon."""
return SENSOR_TYPES[self._kind][ATTR_ICON] | [
"def",
"icon",
"(",
"self",
")",
"->",
"str",
":",
"return",
"SENSOR_TYPES",
"[",
"self",
".",
"_kind",
"]",
"[",
"ATTR_ICON",
"]"
] | [
166,
4
] | [
168,
50
] | python | en | ['en', 'sr', 'en'] | True |
AwairSensor.device_class | (self) | Return the device_class. | Return the device_class. | def device_class(self) -> str:
"""Return the device_class."""
return SENSOR_TYPES[self._kind][ATTR_DEVICE_CLASS] | [
"def",
"device_class",
"(",
"self",
")",
"->",
"str",
":",
"return",
"SENSOR_TYPES",
"[",
"self",
".",
"_kind",
"]",
"[",
"ATTR_DEVICE_CLASS",
"]"
] | [
171,
4
] | [
173,
58
] | python | en | ['en', 'en', 'en'] | True |
AwairSensor.unit_of_measurement | (self) | Return the unit the value is expressed in. | Return the unit the value is expressed in. | def unit_of_measurement(self) -> str:
"""Return the unit the value is expressed in."""
return SENSOR_TYPES[self._kind][ATTR_UNIT] | [
"def",
"unit_of_measurement",
"(",
"self",
")",
"->",
"str",
":",
"return",
"SENSOR_TYPES",
"[",
"self",
".",
"_kind",
"]",
"[",
"ATTR_UNIT",
"]"
] | [
176,
4
] | [
178,
50
] | python | en | ['en', 'en', 'en'] | True |
AwairSensor.device_state_attributes | (self) | Return the Awair Index alongside state attributes.
The Awair Index is a subjective score ranging from 0-4 (inclusive) that
is is used by the Awair app when displaying the relative "safety" of a
given measurement. Each value is mapped to a color indicating the safety:
0: green
1: yellow
2: light-orange
3: orange
4: red
The API indicates that both positive and negative values may be returned,
but the negative values are mapped to identical colors as the positive values.
Knowing that, we just return the absolute value of a given index so that
users don't have to handle positive/negative values that ultimately "mean"
the same thing.
https://docs.developer.getawair.com/?version=latest#awair-score-and-index
| Return the Awair Index alongside state attributes. | def device_state_attributes(self) -> dict:
"""Return the Awair Index alongside state attributes.
The Awair Index is a subjective score ranging from 0-4 (inclusive) that
is is used by the Awair app when displaying the relative "safety" of a
given measurement. Each value is mapped to a color indicating the safety:
0: green
1: yellow
2: light-orange
3: orange
4: red
The API indicates that both positive and negative values may be returned,
but the negative values are mapped to identical colors as the positive values.
Knowing that, we just return the absolute value of a given index so that
users don't have to handle positive/negative values that ultimately "mean"
the same thing.
https://docs.developer.getawair.com/?version=latest#awair-score-and-index
"""
attrs = {ATTR_ATTRIBUTION: ATTRIBUTION}
if self._kind in self._air_data.indices:
attrs["awair_index"] = abs(self._air_data.indices[self._kind])
elif self._kind in DUST_ALIASES and API_DUST in self._air_data.indices:
attrs["awair_index"] = abs(self._air_data.indices.dust)
return attrs | [
"def",
"device_state_attributes",
"(",
"self",
")",
"->",
"dict",
":",
"attrs",
"=",
"{",
"ATTR_ATTRIBUTION",
":",
"ATTRIBUTION",
"}",
"if",
"self",
".",
"_kind",
"in",
"self",
".",
"_air_data",
".",
"indices",
":",
"attrs",
"[",
"\"awair_index\"",
"]",
"=",
"abs",
"(",
"self",
".",
"_air_data",
".",
"indices",
"[",
"self",
".",
"_kind",
"]",
")",
"elif",
"self",
".",
"_kind",
"in",
"DUST_ALIASES",
"and",
"API_DUST",
"in",
"self",
".",
"_air_data",
".",
"indices",
":",
"attrs",
"[",
"\"awair_index\"",
"]",
"=",
"abs",
"(",
"self",
".",
"_air_data",
".",
"indices",
".",
"dust",
")",
"return",
"attrs"
] | [
181,
4
] | [
208,
20
] | python | en | ['en', 'en', 'en'] | True |
AwairSensor.device_info | (self) | Device information. | Device information. | def device_info(self) -> dict:
"""Device information."""
info = {
"identifiers": {(DOMAIN, self._device.uuid)},
"manufacturer": "Awair",
"model": self._device.model,
}
if self._device.name:
info["name"] = self._device.name
if self._device.mac_address:
info["connections"] = {
(dr.CONNECTION_NETWORK_MAC, self._device.mac_address)
}
return info | [
"def",
"device_info",
"(",
"self",
")",
"->",
"dict",
":",
"info",
"=",
"{",
"\"identifiers\"",
":",
"{",
"(",
"DOMAIN",
",",
"self",
".",
"_device",
".",
"uuid",
")",
"}",
",",
"\"manufacturer\"",
":",
"\"Awair\"",
",",
"\"model\"",
":",
"self",
".",
"_device",
".",
"model",
",",
"}",
"if",
"self",
".",
"_device",
".",
"name",
":",
"info",
"[",
"\"name\"",
"]",
"=",
"self",
".",
"_device",
".",
"name",
"if",
"self",
".",
"_device",
".",
"mac_address",
":",
"info",
"[",
"\"connections\"",
"]",
"=",
"{",
"(",
"dr",
".",
"CONNECTION_NETWORK_MAC",
",",
"self",
".",
"_device",
".",
"mac_address",
")",
"}",
"return",
"info"
] | [
211,
4
] | [
227,
19
] | python | en | ['en', 'en', 'en'] | False |
AwairSensor._air_data | (self) | Return the latest data for our device, or None. | Return the latest data for our device, or None. | def _air_data(self) -> Optional[AwairResult]:
"""Return the latest data for our device, or None."""
result: Optional[AwairResult] = self.coordinator.data.get(self._device.uuid)
if result:
return result.air_data
return None | [
"def",
"_air_data",
"(",
"self",
")",
"->",
"Optional",
"[",
"AwairResult",
"]",
":",
"result",
":",
"Optional",
"[",
"AwairResult",
"]",
"=",
"self",
".",
"coordinator",
".",
"data",
".",
"get",
"(",
"self",
".",
"_device",
".",
"uuid",
")",
"if",
"result",
":",
"return",
"result",
".",
"air_data",
"return",
"None"
] | [
230,
4
] | [
236,
19
] | python | en | ['en', 'en', 'en'] | True |
test_update_app | (hass, app) | Test update_app does not save if app is current. | Test update_app does not save if app is current. | async def test_update_app(hass, app):
"""Test update_app does not save if app is current."""
await smartapp.update_app(hass, app)
assert app.save.call_count == 0 | [
"async",
"def",
"test_update_app",
"(",
"hass",
",",
"app",
")",
":",
"await",
"smartapp",
".",
"update_app",
"(",
"hass",
",",
"app",
")",
"assert",
"app",
".",
"save",
".",
"call_count",
"==",
"0"
] | [
16,
0
] | [
19,
35
] | python | en | ['en', 'en', 'en'] | True |
test_update_app_updated_needed | (hass, app) | Test update_app updates when an app is needed. | Test update_app updates when an app is needed. | async def test_update_app_updated_needed(hass, app):
"""Test update_app updates when an app is needed."""
mock_app = Mock(AppEntity)
mock_app.app_name = "Test"
await smartapp.update_app(hass, mock_app)
assert mock_app.save.call_count == 1
assert mock_app.app_name == "Test"
assert mock_app.display_name == app.display_name
assert mock_app.description == app.description
assert mock_app.webhook_target_url == app.webhook_target_url
assert mock_app.app_type == app.app_type
assert mock_app.single_instance == app.single_instance
assert mock_app.classifications == app.classifications | [
"async",
"def",
"test_update_app_updated_needed",
"(",
"hass",
",",
"app",
")",
":",
"mock_app",
"=",
"Mock",
"(",
"AppEntity",
")",
"mock_app",
".",
"app_name",
"=",
"\"Test\"",
"await",
"smartapp",
".",
"update_app",
"(",
"hass",
",",
"mock_app",
")",
"assert",
"mock_app",
".",
"save",
".",
"call_count",
"==",
"1",
"assert",
"mock_app",
".",
"app_name",
"==",
"\"Test\"",
"assert",
"mock_app",
".",
"display_name",
"==",
"app",
".",
"display_name",
"assert",
"mock_app",
".",
"description",
"==",
"app",
".",
"description",
"assert",
"mock_app",
".",
"webhook_target_url",
"==",
"app",
".",
"webhook_target_url",
"assert",
"mock_app",
".",
"app_type",
"==",
"app",
".",
"app_type",
"assert",
"mock_app",
".",
"single_instance",
"==",
"app",
".",
"single_instance",
"assert",
"mock_app",
".",
"classifications",
"==",
"app",
".",
"classifications"
] | [
22,
0
] | [
36,
58
] | python | en | ['en', 'de', 'en'] | True |
test_smartapp_update_saves_token | (
hass, smartthings_mock, location, device_factory
) | Test update saves token. | Test update saves token. | async def test_smartapp_update_saves_token(
hass, smartthings_mock, location, device_factory
):
"""Test update saves token."""
# Arrange
entry = MockConfigEntry(
domain=DOMAIN, data={"installed_app_id": str(uuid4()), "app_id": str(uuid4())}
)
entry.add_to_hass(hass)
app = Mock()
app.app_id = entry.data["app_id"]
request = Mock()
request.installed_app_id = entry.data["installed_app_id"]
request.auth_token = str(uuid4())
request.refresh_token = str(uuid4())
request.location_id = location.location_id
# Act
await smartapp.smartapp_update(hass, request, None, app)
# Assert
assert entry.data[CONF_REFRESH_TOKEN] == request.refresh_token | [
"async",
"def",
"test_smartapp_update_saves_token",
"(",
"hass",
",",
"smartthings_mock",
",",
"location",
",",
"device_factory",
")",
":",
"# Arrange",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"data",
"=",
"{",
"\"installed_app_id\"",
":",
"str",
"(",
"uuid4",
"(",
")",
")",
",",
"\"app_id\"",
":",
"str",
"(",
"uuid4",
"(",
")",
")",
"}",
")",
"entry",
".",
"add_to_hass",
"(",
"hass",
")",
"app",
"=",
"Mock",
"(",
")",
"app",
".",
"app_id",
"=",
"entry",
".",
"data",
"[",
"\"app_id\"",
"]",
"request",
"=",
"Mock",
"(",
")",
"request",
".",
"installed_app_id",
"=",
"entry",
".",
"data",
"[",
"\"installed_app_id\"",
"]",
"request",
".",
"auth_token",
"=",
"str",
"(",
"uuid4",
"(",
")",
")",
"request",
".",
"refresh_token",
"=",
"str",
"(",
"uuid4",
"(",
")",
")",
"request",
".",
"location_id",
"=",
"location",
".",
"location_id",
"# Act",
"await",
"smartapp",
".",
"smartapp_update",
"(",
"hass",
",",
"request",
",",
"None",
",",
"app",
")",
"# Assert",
"assert",
"entry",
".",
"data",
"[",
"CONF_REFRESH_TOKEN",
"]",
"==",
"request",
".",
"refresh_token"
] | [
39,
0
] | [
59,
66
] | python | en | ['en', 'de', 'en'] | True |
test_smartapp_uninstall | (hass, config_entry) | Test the config entry is unloaded when the app is uninstalled. | Test the config entry is unloaded when the app is uninstalled. | async def test_smartapp_uninstall(hass, config_entry):
"""Test the config entry is unloaded when the app is uninstalled."""
config_entry.add_to_hass(hass)
app = Mock()
app.app_id = config_entry.data["app_id"]
request = Mock()
request.installed_app_id = config_entry.data["installed_app_id"]
with patch.object(hass.config_entries, "async_remove") as remove:
await smartapp.smartapp_uninstall(hass, request, None, app)
assert remove.call_count == 1 | [
"async",
"def",
"test_smartapp_uninstall",
"(",
"hass",
",",
"config_entry",
")",
":",
"config_entry",
".",
"add_to_hass",
"(",
"hass",
")",
"app",
"=",
"Mock",
"(",
")",
"app",
".",
"app_id",
"=",
"config_entry",
".",
"data",
"[",
"\"app_id\"",
"]",
"request",
"=",
"Mock",
"(",
")",
"request",
".",
"installed_app_id",
"=",
"config_entry",
".",
"data",
"[",
"\"installed_app_id\"",
"]",
"with",
"patch",
".",
"object",
"(",
"hass",
".",
"config_entries",
",",
"\"async_remove\"",
")",
"as",
"remove",
":",
"await",
"smartapp",
".",
"smartapp_uninstall",
"(",
"hass",
",",
"request",
",",
"None",
",",
"app",
")",
"assert",
"remove",
".",
"call_count",
"==",
"1"
] | [
62,
0
] | [
72,
37
] | python | en | ['en', 'en', 'en'] | True |
test_smartapp_webhook | (hass) | Test the smartapp webhook calls the manager. | Test the smartapp webhook calls the manager. | async def test_smartapp_webhook(hass):
"""Test the smartapp webhook calls the manager."""
manager = Mock()
manager.handle_request = AsyncMock(return_value={})
hass.data[DOMAIN][DATA_MANAGER] = manager
request = Mock()
request.headers = []
request.json = AsyncMock(return_value={})
result = await smartapp.smartapp_webhook(hass, "", request)
assert result.body == b"{}" | [
"async",
"def",
"test_smartapp_webhook",
"(",
"hass",
")",
":",
"manager",
"=",
"Mock",
"(",
")",
"manager",
".",
"handle_request",
"=",
"AsyncMock",
"(",
"return_value",
"=",
"{",
"}",
")",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"DATA_MANAGER",
"]",
"=",
"manager",
"request",
"=",
"Mock",
"(",
")",
"request",
".",
"headers",
"=",
"[",
"]",
"request",
".",
"json",
"=",
"AsyncMock",
"(",
"return_value",
"=",
"{",
"}",
")",
"result",
"=",
"await",
"smartapp",
".",
"smartapp_webhook",
"(",
"hass",
",",
"\"\"",
",",
"request",
")",
"assert",
"result",
".",
"body",
"==",
"b\"{}\""
] | [
75,
0
] | [
85,
31
] | python | en | ['en', 'en', 'en'] | True |
test_smartapp_sync_subscriptions | (
hass, smartthings_mock, device_factory, subscription_factory
) | Test synchronization adds and removes and ignores unused. | Test synchronization adds and removes and ignores unused. | async def test_smartapp_sync_subscriptions(
hass, smartthings_mock, device_factory, subscription_factory
):
"""Test synchronization adds and removes and ignores unused."""
smartthings_mock.subscriptions.return_value = [
subscription_factory(Capability.thermostat),
subscription_factory(Capability.switch),
subscription_factory(Capability.switch_level),
]
devices = [
device_factory("", [Capability.battery, "ping"]),
device_factory("", [Capability.switch, Capability.switch_level]),
device_factory("", [Capability.switch, Capability.execute]),
]
await smartapp.smartapp_sync_subscriptions(
hass, str(uuid4()), str(uuid4()), str(uuid4()), devices
)
assert smartthings_mock.subscriptions.call_count == 1
assert smartthings_mock.delete_subscription.call_count == 1
assert smartthings_mock.create_subscription.call_count == 1 | [
"async",
"def",
"test_smartapp_sync_subscriptions",
"(",
"hass",
",",
"smartthings_mock",
",",
"device_factory",
",",
"subscription_factory",
")",
":",
"smartthings_mock",
".",
"subscriptions",
".",
"return_value",
"=",
"[",
"subscription_factory",
"(",
"Capability",
".",
"thermostat",
")",
",",
"subscription_factory",
"(",
"Capability",
".",
"switch",
")",
",",
"subscription_factory",
"(",
"Capability",
".",
"switch_level",
")",
",",
"]",
"devices",
"=",
"[",
"device_factory",
"(",
"\"\"",
",",
"[",
"Capability",
".",
"battery",
",",
"\"ping\"",
"]",
")",
",",
"device_factory",
"(",
"\"\"",
",",
"[",
"Capability",
".",
"switch",
",",
"Capability",
".",
"switch_level",
"]",
")",
",",
"device_factory",
"(",
"\"\"",
",",
"[",
"Capability",
".",
"switch",
",",
"Capability",
".",
"execute",
"]",
")",
",",
"]",
"await",
"smartapp",
".",
"smartapp_sync_subscriptions",
"(",
"hass",
",",
"str",
"(",
"uuid4",
"(",
")",
")",
",",
"str",
"(",
"uuid4",
"(",
")",
")",
",",
"str",
"(",
"uuid4",
"(",
")",
")",
",",
"devices",
")",
"assert",
"smartthings_mock",
".",
"subscriptions",
".",
"call_count",
"==",
"1",
"assert",
"smartthings_mock",
".",
"delete_subscription",
".",
"call_count",
"==",
"1",
"assert",
"smartthings_mock",
".",
"create_subscription",
".",
"call_count",
"==",
"1"
] | [
88,
0
] | [
109,
63
] | python | en | ['en', 'en', 'en'] | True |
test_smartapp_sync_subscriptions_up_to_date | (
hass, smartthings_mock, device_factory, subscription_factory
) | Test synchronization does nothing when current. | Test synchronization does nothing when current. | async def test_smartapp_sync_subscriptions_up_to_date(
hass, smartthings_mock, device_factory, subscription_factory
):
"""Test synchronization does nothing when current."""
smartthings_mock.subscriptions.return_value = [
subscription_factory(Capability.battery),
subscription_factory(Capability.switch),
subscription_factory(Capability.switch_level),
]
devices = [
device_factory("", [Capability.battery, "ping"]),
device_factory("", [Capability.switch, Capability.switch_level]),
device_factory("", [Capability.switch]),
]
await smartapp.smartapp_sync_subscriptions(
hass, str(uuid4()), str(uuid4()), str(uuid4()), devices
)
assert smartthings_mock.subscriptions.call_count == 1
assert smartthings_mock.delete_subscription.call_count == 0
assert smartthings_mock.create_subscription.call_count == 0 | [
"async",
"def",
"test_smartapp_sync_subscriptions_up_to_date",
"(",
"hass",
",",
"smartthings_mock",
",",
"device_factory",
",",
"subscription_factory",
")",
":",
"smartthings_mock",
".",
"subscriptions",
".",
"return_value",
"=",
"[",
"subscription_factory",
"(",
"Capability",
".",
"battery",
")",
",",
"subscription_factory",
"(",
"Capability",
".",
"switch",
")",
",",
"subscription_factory",
"(",
"Capability",
".",
"switch_level",
")",
",",
"]",
"devices",
"=",
"[",
"device_factory",
"(",
"\"\"",
",",
"[",
"Capability",
".",
"battery",
",",
"\"ping\"",
"]",
")",
",",
"device_factory",
"(",
"\"\"",
",",
"[",
"Capability",
".",
"switch",
",",
"Capability",
".",
"switch_level",
"]",
")",
",",
"device_factory",
"(",
"\"\"",
",",
"[",
"Capability",
".",
"switch",
"]",
")",
",",
"]",
"await",
"smartapp",
".",
"smartapp_sync_subscriptions",
"(",
"hass",
",",
"str",
"(",
"uuid4",
"(",
")",
")",
",",
"str",
"(",
"uuid4",
"(",
")",
")",
",",
"str",
"(",
"uuid4",
"(",
")",
")",
",",
"devices",
")",
"assert",
"smartthings_mock",
".",
"subscriptions",
".",
"call_count",
"==",
"1",
"assert",
"smartthings_mock",
".",
"delete_subscription",
".",
"call_count",
"==",
"0",
"assert",
"smartthings_mock",
".",
"create_subscription",
".",
"call_count",
"==",
"0"
] | [
112,
0
] | [
133,
63
] | python | en | ['en', 'en', 'en'] | True |
test_smartapp_sync_subscriptions_limit_warning | (
hass, smartthings_mock, device_factory, subscription_factory, caplog
) | Test synchronization over the limit logs a warning. | Test synchronization over the limit logs a warning. | async def test_smartapp_sync_subscriptions_limit_warning(
hass, smartthings_mock, device_factory, subscription_factory, caplog
):
"""Test synchronization over the limit logs a warning."""
smartthings_mock.subscriptions.return_value = []
devices = [
device_factory("", CAPABILITIES),
]
await smartapp.smartapp_sync_subscriptions(
hass, str(uuid4()), str(uuid4()), str(uuid4()), devices
)
assert (
"Some device attributes may not receive push updates and there may be "
"subscription creation failures" in caplog.text
) | [
"async",
"def",
"test_smartapp_sync_subscriptions_limit_warning",
"(",
"hass",
",",
"smartthings_mock",
",",
"device_factory",
",",
"subscription_factory",
",",
"caplog",
")",
":",
"smartthings_mock",
".",
"subscriptions",
".",
"return_value",
"=",
"[",
"]",
"devices",
"=",
"[",
"device_factory",
"(",
"\"\"",
",",
"CAPABILITIES",
")",
",",
"]",
"await",
"smartapp",
".",
"smartapp_sync_subscriptions",
"(",
"hass",
",",
"str",
"(",
"uuid4",
"(",
")",
")",
",",
"str",
"(",
"uuid4",
"(",
")",
")",
",",
"str",
"(",
"uuid4",
"(",
")",
")",
",",
"devices",
")",
"assert",
"(",
"\"Some device attributes may not receive push updates and there may be \"",
"\"subscription creation failures\"",
"in",
"caplog",
".",
"text",
")"
] | [
136,
0
] | [
152,
5
] | python | en | ['en', 'en', 'en'] | True |
test_smartapp_sync_subscriptions_handles_exceptions | (
hass, smartthings_mock, device_factory, subscription_factory
) | Test synchronization does nothing when current. | Test synchronization does nothing when current. | async def test_smartapp_sync_subscriptions_handles_exceptions(
hass, smartthings_mock, device_factory, subscription_factory
):
"""Test synchronization does nothing when current."""
smartthings_mock.delete_subscription.side_effect = Exception
smartthings_mock.create_subscription.side_effect = Exception
smartthings_mock.subscriptions.return_value = [
subscription_factory(Capability.battery),
subscription_factory(Capability.switch),
subscription_factory(Capability.switch_level),
]
devices = [
device_factory("", [Capability.thermostat, "ping"]),
device_factory("", [Capability.switch, Capability.switch_level]),
device_factory("", [Capability.switch]),
]
await smartapp.smartapp_sync_subscriptions(
hass, str(uuid4()), str(uuid4()), str(uuid4()), devices
)
assert smartthings_mock.subscriptions.call_count == 1
assert smartthings_mock.delete_subscription.call_count == 1
assert smartthings_mock.create_subscription.call_count == 1 | [
"async",
"def",
"test_smartapp_sync_subscriptions_handles_exceptions",
"(",
"hass",
",",
"smartthings_mock",
",",
"device_factory",
",",
"subscription_factory",
")",
":",
"smartthings_mock",
".",
"delete_subscription",
".",
"side_effect",
"=",
"Exception",
"smartthings_mock",
".",
"create_subscription",
".",
"side_effect",
"=",
"Exception",
"smartthings_mock",
".",
"subscriptions",
".",
"return_value",
"=",
"[",
"subscription_factory",
"(",
"Capability",
".",
"battery",
")",
",",
"subscription_factory",
"(",
"Capability",
".",
"switch",
")",
",",
"subscription_factory",
"(",
"Capability",
".",
"switch_level",
")",
",",
"]",
"devices",
"=",
"[",
"device_factory",
"(",
"\"\"",
",",
"[",
"Capability",
".",
"thermostat",
",",
"\"ping\"",
"]",
")",
",",
"device_factory",
"(",
"\"\"",
",",
"[",
"Capability",
".",
"switch",
",",
"Capability",
".",
"switch_level",
"]",
")",
",",
"device_factory",
"(",
"\"\"",
",",
"[",
"Capability",
".",
"switch",
"]",
")",
",",
"]",
"await",
"smartapp",
".",
"smartapp_sync_subscriptions",
"(",
"hass",
",",
"str",
"(",
"uuid4",
"(",
")",
")",
",",
"str",
"(",
"uuid4",
"(",
")",
")",
",",
"str",
"(",
"uuid4",
"(",
")",
")",
",",
"devices",
")",
"assert",
"smartthings_mock",
".",
"subscriptions",
".",
"call_count",
"==",
"1",
"assert",
"smartthings_mock",
".",
"delete_subscription",
".",
"call_count",
"==",
"1",
"assert",
"smartthings_mock",
".",
"create_subscription",
".",
"call_count",
"==",
"1"
] | [
155,
0
] | [
178,
63
] | python | en | ['en', 'en', 'en'] | True |
legacy_thermostat_fixture | (device_factory) | Fixture returns a legacy thermostat. | Fixture returns a legacy thermostat. | def legacy_thermostat_fixture(device_factory):
"""Fixture returns a legacy thermostat."""
device = device_factory(
"Legacy Thermostat",
capabilities=[Capability.thermostat],
status={
Attribute.cooling_setpoint: 74,
Attribute.heating_setpoint: 68,
Attribute.thermostat_fan_mode: "auto",
Attribute.supported_thermostat_fan_modes: ["auto", "on"],
Attribute.thermostat_mode: "auto",
Attribute.supported_thermostat_modes: climate.MODE_TO_STATE.keys(),
Attribute.thermostat_operating_state: "idle",
},
)
device.status.attributes[Attribute.temperature] = Status(70, "F", None)
return device | [
"def",
"legacy_thermostat_fixture",
"(",
"device_factory",
")",
":",
"device",
"=",
"device_factory",
"(",
"\"Legacy Thermostat\"",
",",
"capabilities",
"=",
"[",
"Capability",
".",
"thermostat",
"]",
",",
"status",
"=",
"{",
"Attribute",
".",
"cooling_setpoint",
":",
"74",
",",
"Attribute",
".",
"heating_setpoint",
":",
"68",
",",
"Attribute",
".",
"thermostat_fan_mode",
":",
"\"auto\"",
",",
"Attribute",
".",
"supported_thermostat_fan_modes",
":",
"[",
"\"auto\"",
",",
"\"on\"",
"]",
",",
"Attribute",
".",
"thermostat_mode",
":",
"\"auto\"",
",",
"Attribute",
".",
"supported_thermostat_modes",
":",
"climate",
".",
"MODE_TO_STATE",
".",
"keys",
"(",
")",
",",
"Attribute",
".",
"thermostat_operating_state",
":",
"\"idle\"",
",",
"}",
",",
")",
"device",
".",
"status",
".",
"attributes",
"[",
"Attribute",
".",
"temperature",
"]",
"=",
"Status",
"(",
"70",
",",
"\"F\"",
",",
"None",
")",
"return",
"device"
] | [
51,
0
] | [
67,
17
] | python | en | ['en', 'en', 'en'] | True |
basic_thermostat_fixture | (device_factory) | Fixture returns a basic thermostat. | Fixture returns a basic thermostat. | def basic_thermostat_fixture(device_factory):
"""Fixture returns a basic thermostat."""
device = device_factory(
"Basic Thermostat",
capabilities=[
Capability.temperature_measurement,
Capability.thermostat_cooling_setpoint,
Capability.thermostat_heating_setpoint,
Capability.thermostat_mode,
],
status={
Attribute.cooling_setpoint: 74,
Attribute.heating_setpoint: 68,
Attribute.thermostat_mode: "off",
Attribute.supported_thermostat_modes: ["off", "auto", "heat", "cool"],
},
)
device.status.attributes[Attribute.temperature] = Status(70, "F", None)
return device | [
"def",
"basic_thermostat_fixture",
"(",
"device_factory",
")",
":",
"device",
"=",
"device_factory",
"(",
"\"Basic Thermostat\"",
",",
"capabilities",
"=",
"[",
"Capability",
".",
"temperature_measurement",
",",
"Capability",
".",
"thermostat_cooling_setpoint",
",",
"Capability",
".",
"thermostat_heating_setpoint",
",",
"Capability",
".",
"thermostat_mode",
",",
"]",
",",
"status",
"=",
"{",
"Attribute",
".",
"cooling_setpoint",
":",
"74",
",",
"Attribute",
".",
"heating_setpoint",
":",
"68",
",",
"Attribute",
".",
"thermostat_mode",
":",
"\"off\"",
",",
"Attribute",
".",
"supported_thermostat_modes",
":",
"[",
"\"off\"",
",",
"\"auto\"",
",",
"\"heat\"",
",",
"\"cool\"",
"]",
",",
"}",
",",
")",
"device",
".",
"status",
".",
"attributes",
"[",
"Attribute",
".",
"temperature",
"]",
"=",
"Status",
"(",
"70",
",",
"\"F\"",
",",
"None",
")",
"return",
"device"
] | [
71,
0
] | [
89,
17
] | python | en | ['en', 'en', 'en'] | True |
thermostat_fixture | (device_factory) | Fixture returns a fully-featured thermostat. | Fixture returns a fully-featured thermostat. | def thermostat_fixture(device_factory):
"""Fixture returns a fully-featured thermostat."""
device = device_factory(
"Thermostat",
capabilities=[
Capability.temperature_measurement,
Capability.relative_humidity_measurement,
Capability.thermostat_cooling_setpoint,
Capability.thermostat_heating_setpoint,
Capability.thermostat_mode,
Capability.thermostat_operating_state,
Capability.thermostat_fan_mode,
],
status={
Attribute.cooling_setpoint: 74,
Attribute.heating_setpoint: 68,
Attribute.thermostat_fan_mode: "on",
Attribute.supported_thermostat_fan_modes: ["auto", "on"],
Attribute.thermostat_mode: "heat",
Attribute.supported_thermostat_modes: [
"auto",
"heat",
"cool",
"off",
"eco",
],
Attribute.thermostat_operating_state: "idle",
Attribute.humidity: 34,
},
)
device.status.attributes[Attribute.temperature] = Status(70, "F", None)
return device | [
"def",
"thermostat_fixture",
"(",
"device_factory",
")",
":",
"device",
"=",
"device_factory",
"(",
"\"Thermostat\"",
",",
"capabilities",
"=",
"[",
"Capability",
".",
"temperature_measurement",
",",
"Capability",
".",
"relative_humidity_measurement",
",",
"Capability",
".",
"thermostat_cooling_setpoint",
",",
"Capability",
".",
"thermostat_heating_setpoint",
",",
"Capability",
".",
"thermostat_mode",
",",
"Capability",
".",
"thermostat_operating_state",
",",
"Capability",
".",
"thermostat_fan_mode",
",",
"]",
",",
"status",
"=",
"{",
"Attribute",
".",
"cooling_setpoint",
":",
"74",
",",
"Attribute",
".",
"heating_setpoint",
":",
"68",
",",
"Attribute",
".",
"thermostat_fan_mode",
":",
"\"on\"",
",",
"Attribute",
".",
"supported_thermostat_fan_modes",
":",
"[",
"\"auto\"",
",",
"\"on\"",
"]",
",",
"Attribute",
".",
"thermostat_mode",
":",
"\"heat\"",
",",
"Attribute",
".",
"supported_thermostat_modes",
":",
"[",
"\"auto\"",
",",
"\"heat\"",
",",
"\"cool\"",
",",
"\"off\"",
",",
"\"eco\"",
",",
"]",
",",
"Attribute",
".",
"thermostat_operating_state",
":",
"\"idle\"",
",",
"Attribute",
".",
"humidity",
":",
"34",
",",
"}",
",",
")",
"device",
".",
"status",
".",
"attributes",
"[",
"Attribute",
".",
"temperature",
"]",
"=",
"Status",
"(",
"70",
",",
"\"F\"",
",",
"None",
")",
"return",
"device"
] | [
93,
0
] | [
124,
17
] | python | en | ['en', 'en', 'en'] | True |
buggy_thermostat_fixture | (device_factory) | Fixture returns a buggy thermostat. | Fixture returns a buggy thermostat. | def buggy_thermostat_fixture(device_factory):
"""Fixture returns a buggy thermostat."""
device = device_factory(
"Buggy Thermostat",
capabilities=[
Capability.temperature_measurement,
Capability.thermostat_cooling_setpoint,
Capability.thermostat_heating_setpoint,
Capability.thermostat_mode,
],
status={
Attribute.thermostat_mode: "heating",
Attribute.cooling_setpoint: 74,
Attribute.heating_setpoint: 68,
},
)
device.status.attributes[Attribute.temperature] = Status(70, "F", None)
return device | [
"def",
"buggy_thermostat_fixture",
"(",
"device_factory",
")",
":",
"device",
"=",
"device_factory",
"(",
"\"Buggy Thermostat\"",
",",
"capabilities",
"=",
"[",
"Capability",
".",
"temperature_measurement",
",",
"Capability",
".",
"thermostat_cooling_setpoint",
",",
"Capability",
".",
"thermostat_heating_setpoint",
",",
"Capability",
".",
"thermostat_mode",
",",
"]",
",",
"status",
"=",
"{",
"Attribute",
".",
"thermostat_mode",
":",
"\"heating\"",
",",
"Attribute",
".",
"cooling_setpoint",
":",
"74",
",",
"Attribute",
".",
"heating_setpoint",
":",
"68",
",",
"}",
",",
")",
"device",
".",
"status",
".",
"attributes",
"[",
"Attribute",
".",
"temperature",
"]",
"=",
"Status",
"(",
"70",
",",
"\"F\"",
",",
"None",
")",
"return",
"device"
] | [
128,
0
] | [
145,
17
] | python | en | ['en', 'en', 'en'] | True |
air_conditioner_fixture | (device_factory) | Fixture returns a air conditioner. | Fixture returns a air conditioner. | def air_conditioner_fixture(device_factory):
"""Fixture returns a air conditioner."""
device = device_factory(
"Air Conditioner",
capabilities=[
Capability.air_conditioner_mode,
Capability.demand_response_load_control,
Capability.air_conditioner_fan_mode,
Capability.power_consumption_report,
Capability.switch,
Capability.temperature_measurement,
Capability.thermostat_cooling_setpoint,
],
status={
Attribute.air_conditioner_mode: "auto",
Attribute.supported_ac_modes: [
"cool",
"dry",
"wind",
"auto",
"heat",
"fanOnly",
],
Attribute.drlc_status: {
"duration": 0,
"drlcLevel": -1,
"start": "1970-01-01T00:00:00Z",
"override": False,
},
Attribute.fan_mode: "medium",
Attribute.supported_ac_fan_modes: [
"auto",
"low",
"medium",
"high",
"turbo",
],
Attribute.power_consumption: {
"start": "2019-02-24T21:03:04Z",
"power": 0,
"energy": 500,
"end": "2019-02-26T02:05:55Z",
},
Attribute.switch: "on",
Attribute.cooling_setpoint: 23,
},
)
device.status.attributes[Attribute.temperature] = Status(24, "C", None)
return device | [
"def",
"air_conditioner_fixture",
"(",
"device_factory",
")",
":",
"device",
"=",
"device_factory",
"(",
"\"Air Conditioner\"",
",",
"capabilities",
"=",
"[",
"Capability",
".",
"air_conditioner_mode",
",",
"Capability",
".",
"demand_response_load_control",
",",
"Capability",
".",
"air_conditioner_fan_mode",
",",
"Capability",
".",
"power_consumption_report",
",",
"Capability",
".",
"switch",
",",
"Capability",
".",
"temperature_measurement",
",",
"Capability",
".",
"thermostat_cooling_setpoint",
",",
"]",
",",
"status",
"=",
"{",
"Attribute",
".",
"air_conditioner_mode",
":",
"\"auto\"",
",",
"Attribute",
".",
"supported_ac_modes",
":",
"[",
"\"cool\"",
",",
"\"dry\"",
",",
"\"wind\"",
",",
"\"auto\"",
",",
"\"heat\"",
",",
"\"fanOnly\"",
",",
"]",
",",
"Attribute",
".",
"drlc_status",
":",
"{",
"\"duration\"",
":",
"0",
",",
"\"drlcLevel\"",
":",
"-",
"1",
",",
"\"start\"",
":",
"\"1970-01-01T00:00:00Z\"",
",",
"\"override\"",
":",
"False",
",",
"}",
",",
"Attribute",
".",
"fan_mode",
":",
"\"medium\"",
",",
"Attribute",
".",
"supported_ac_fan_modes",
":",
"[",
"\"auto\"",
",",
"\"low\"",
",",
"\"medium\"",
",",
"\"high\"",
",",
"\"turbo\"",
",",
"]",
",",
"Attribute",
".",
"power_consumption",
":",
"{",
"\"start\"",
":",
"\"2019-02-24T21:03:04Z\"",
",",
"\"power\"",
":",
"0",
",",
"\"energy\"",
":",
"500",
",",
"\"end\"",
":",
"\"2019-02-26T02:05:55Z\"",
",",
"}",
",",
"Attribute",
".",
"switch",
":",
"\"on\"",
",",
"Attribute",
".",
"cooling_setpoint",
":",
"23",
",",
"}",
",",
")",
"device",
".",
"status",
".",
"attributes",
"[",
"Attribute",
".",
"temperature",
"]",
"=",
"Status",
"(",
"24",
",",
"\"C\"",
",",
"None",
")",
"return",
"device"
] | [
149,
0
] | [
197,
17
] | python | en | ['en', 'ca', 'en'] | True |
test_legacy_thermostat_entity_state | (hass, legacy_thermostat) | Tests the state attributes properly match the thermostat type. | Tests the state attributes properly match the thermostat type. | async def test_legacy_thermostat_entity_state(hass, legacy_thermostat):
"""Tests the state attributes properly match the thermostat type."""
await setup_platform(hass, CLIMATE_DOMAIN, devices=[legacy_thermostat])
state = hass.states.get("climate.legacy_thermostat")
assert state.state == HVAC_MODE_HEAT_COOL
assert (
state.attributes[ATTR_SUPPORTED_FEATURES]
== SUPPORT_FAN_MODE
| SUPPORT_TARGET_TEMPERATURE_RANGE
| SUPPORT_TARGET_TEMPERATURE
)
assert state.attributes[ATTR_HVAC_ACTION] == CURRENT_HVAC_IDLE
assert sorted(state.attributes[ATTR_HVAC_MODES]) == [
HVAC_MODE_AUTO,
HVAC_MODE_COOL,
HVAC_MODE_HEAT,
HVAC_MODE_HEAT_COOL,
HVAC_MODE_OFF,
]
assert state.attributes[ATTR_FAN_MODE] == "auto"
assert state.attributes[ATTR_FAN_MODES] == ["auto", "on"]
assert state.attributes[ATTR_TARGET_TEMP_LOW] == 20 # celsius
assert state.attributes[ATTR_TARGET_TEMP_HIGH] == 23.3 # celsius
assert state.attributes[ATTR_CURRENT_TEMPERATURE] == 21.1 | [
"async",
"def",
"test_legacy_thermostat_entity_state",
"(",
"hass",
",",
"legacy_thermostat",
")",
":",
"await",
"setup_platform",
"(",
"hass",
",",
"CLIMATE_DOMAIN",
",",
"devices",
"=",
"[",
"legacy_thermostat",
"]",
")",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"\"climate.legacy_thermostat\"",
")",
"assert",
"state",
".",
"state",
"==",
"HVAC_MODE_HEAT_COOL",
"assert",
"(",
"state",
".",
"attributes",
"[",
"ATTR_SUPPORTED_FEATURES",
"]",
"==",
"SUPPORT_FAN_MODE",
"|",
"SUPPORT_TARGET_TEMPERATURE_RANGE",
"|",
"SUPPORT_TARGET_TEMPERATURE",
")",
"assert",
"state",
".",
"attributes",
"[",
"ATTR_HVAC_ACTION",
"]",
"==",
"CURRENT_HVAC_IDLE",
"assert",
"sorted",
"(",
"state",
".",
"attributes",
"[",
"ATTR_HVAC_MODES",
"]",
")",
"==",
"[",
"HVAC_MODE_AUTO",
",",
"HVAC_MODE_COOL",
",",
"HVAC_MODE_HEAT",
",",
"HVAC_MODE_HEAT_COOL",
",",
"HVAC_MODE_OFF",
",",
"]",
"assert",
"state",
".",
"attributes",
"[",
"ATTR_FAN_MODE",
"]",
"==",
"\"auto\"",
"assert",
"state",
".",
"attributes",
"[",
"ATTR_FAN_MODES",
"]",
"==",
"[",
"\"auto\"",
",",
"\"on\"",
"]",
"assert",
"state",
".",
"attributes",
"[",
"ATTR_TARGET_TEMP_LOW",
"]",
"==",
"20",
"# celsius",
"assert",
"state",
".",
"attributes",
"[",
"ATTR_TARGET_TEMP_HIGH",
"]",
"==",
"23.3",
"# celsius",
"assert",
"state",
".",
"attributes",
"[",
"ATTR_CURRENT_TEMPERATURE",
"]",
"==",
"21.1"
] | [
200,
0
] | [
223,
61
] | python | en | ['en', 'en', 'en'] | True |
test_basic_thermostat_entity_state | (hass, basic_thermostat) | Tests the state attributes properly match the thermostat type. | Tests the state attributes properly match the thermostat type. | async def test_basic_thermostat_entity_state(hass, basic_thermostat):
"""Tests the state attributes properly match the thermostat type."""
await setup_platform(hass, CLIMATE_DOMAIN, devices=[basic_thermostat])
state = hass.states.get("climate.basic_thermostat")
assert state.state == HVAC_MODE_OFF
assert (
state.attributes[ATTR_SUPPORTED_FEATURES]
== SUPPORT_TARGET_TEMPERATURE_RANGE | SUPPORT_TARGET_TEMPERATURE
)
assert ATTR_HVAC_ACTION not in state.attributes
assert sorted(state.attributes[ATTR_HVAC_MODES]) == [
HVAC_MODE_COOL,
HVAC_MODE_HEAT,
HVAC_MODE_HEAT_COOL,
HVAC_MODE_OFF,
]
assert state.attributes[ATTR_CURRENT_TEMPERATURE] == 21.1 | [
"async",
"def",
"test_basic_thermostat_entity_state",
"(",
"hass",
",",
"basic_thermostat",
")",
":",
"await",
"setup_platform",
"(",
"hass",
",",
"CLIMATE_DOMAIN",
",",
"devices",
"=",
"[",
"basic_thermostat",
"]",
")",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"\"climate.basic_thermostat\"",
")",
"assert",
"state",
".",
"state",
"==",
"HVAC_MODE_OFF",
"assert",
"(",
"state",
".",
"attributes",
"[",
"ATTR_SUPPORTED_FEATURES",
"]",
"==",
"SUPPORT_TARGET_TEMPERATURE_RANGE",
"|",
"SUPPORT_TARGET_TEMPERATURE",
")",
"assert",
"ATTR_HVAC_ACTION",
"not",
"in",
"state",
".",
"attributes",
"assert",
"sorted",
"(",
"state",
".",
"attributes",
"[",
"ATTR_HVAC_MODES",
"]",
")",
"==",
"[",
"HVAC_MODE_COOL",
",",
"HVAC_MODE_HEAT",
",",
"HVAC_MODE_HEAT_COOL",
",",
"HVAC_MODE_OFF",
",",
"]",
"assert",
"state",
".",
"attributes",
"[",
"ATTR_CURRENT_TEMPERATURE",
"]",
"==",
"21.1"
] | [
226,
0
] | [
242,
61
] | python | en | ['en', 'en', 'en'] | True |
test_thermostat_entity_state | (hass, thermostat) | Tests the state attributes properly match the thermostat type. | Tests the state attributes properly match the thermostat type. | async def test_thermostat_entity_state(hass, thermostat):
"""Tests the state attributes properly match the thermostat type."""
await setup_platform(hass, CLIMATE_DOMAIN, devices=[thermostat])
state = hass.states.get("climate.thermostat")
assert state.state == HVAC_MODE_HEAT
assert (
state.attributes[ATTR_SUPPORTED_FEATURES]
== SUPPORT_FAN_MODE
| SUPPORT_TARGET_TEMPERATURE_RANGE
| SUPPORT_TARGET_TEMPERATURE
)
assert state.attributes[ATTR_HVAC_ACTION] == CURRENT_HVAC_IDLE
assert sorted(state.attributes[ATTR_HVAC_MODES]) == [
HVAC_MODE_AUTO,
HVAC_MODE_COOL,
HVAC_MODE_HEAT,
HVAC_MODE_HEAT_COOL,
HVAC_MODE_OFF,
]
assert state.attributes[ATTR_FAN_MODE] == "on"
assert state.attributes[ATTR_FAN_MODES] == ["auto", "on"]
assert state.attributes[ATTR_TEMPERATURE] == 20 # celsius
assert state.attributes[ATTR_CURRENT_TEMPERATURE] == 21.1 # celsius
assert state.attributes[ATTR_CURRENT_HUMIDITY] == 34 | [
"async",
"def",
"test_thermostat_entity_state",
"(",
"hass",
",",
"thermostat",
")",
":",
"await",
"setup_platform",
"(",
"hass",
",",
"CLIMATE_DOMAIN",
",",
"devices",
"=",
"[",
"thermostat",
"]",
")",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"\"climate.thermostat\"",
")",
"assert",
"state",
".",
"state",
"==",
"HVAC_MODE_HEAT",
"assert",
"(",
"state",
".",
"attributes",
"[",
"ATTR_SUPPORTED_FEATURES",
"]",
"==",
"SUPPORT_FAN_MODE",
"|",
"SUPPORT_TARGET_TEMPERATURE_RANGE",
"|",
"SUPPORT_TARGET_TEMPERATURE",
")",
"assert",
"state",
".",
"attributes",
"[",
"ATTR_HVAC_ACTION",
"]",
"==",
"CURRENT_HVAC_IDLE",
"assert",
"sorted",
"(",
"state",
".",
"attributes",
"[",
"ATTR_HVAC_MODES",
"]",
")",
"==",
"[",
"HVAC_MODE_AUTO",
",",
"HVAC_MODE_COOL",
",",
"HVAC_MODE_HEAT",
",",
"HVAC_MODE_HEAT_COOL",
",",
"HVAC_MODE_OFF",
",",
"]",
"assert",
"state",
".",
"attributes",
"[",
"ATTR_FAN_MODE",
"]",
"==",
"\"on\"",
"assert",
"state",
".",
"attributes",
"[",
"ATTR_FAN_MODES",
"]",
"==",
"[",
"\"auto\"",
",",
"\"on\"",
"]",
"assert",
"state",
".",
"attributes",
"[",
"ATTR_TEMPERATURE",
"]",
"==",
"20",
"# celsius",
"assert",
"state",
".",
"attributes",
"[",
"ATTR_CURRENT_TEMPERATURE",
"]",
"==",
"21.1",
"# celsius",
"assert",
"state",
".",
"attributes",
"[",
"ATTR_CURRENT_HUMIDITY",
"]",
"==",
"34"
] | [
245,
0
] | [
268,
56
] | python | en | ['en', 'en', 'en'] | True |
test_buggy_thermostat_entity_state | (hass, buggy_thermostat) | Tests the state attributes properly match the thermostat type. | Tests the state attributes properly match the thermostat type. | async def test_buggy_thermostat_entity_state(hass, buggy_thermostat):
"""Tests the state attributes properly match the thermostat type."""
await setup_platform(hass, CLIMATE_DOMAIN, devices=[buggy_thermostat])
state = hass.states.get("climate.buggy_thermostat")
assert state.state == STATE_UNKNOWN
assert (
state.attributes[ATTR_SUPPORTED_FEATURES]
== SUPPORT_TARGET_TEMPERATURE_RANGE | SUPPORT_TARGET_TEMPERATURE
)
assert state.state is STATE_UNKNOWN
assert state.attributes[ATTR_TEMPERATURE] is None
assert state.attributes[ATTR_CURRENT_TEMPERATURE] == 21.1 # celsius
assert state.attributes[ATTR_HVAC_MODES] == [] | [
"async",
"def",
"test_buggy_thermostat_entity_state",
"(",
"hass",
",",
"buggy_thermostat",
")",
":",
"await",
"setup_platform",
"(",
"hass",
",",
"CLIMATE_DOMAIN",
",",
"devices",
"=",
"[",
"buggy_thermostat",
"]",
")",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"\"climate.buggy_thermostat\"",
")",
"assert",
"state",
".",
"state",
"==",
"STATE_UNKNOWN",
"assert",
"(",
"state",
".",
"attributes",
"[",
"ATTR_SUPPORTED_FEATURES",
"]",
"==",
"SUPPORT_TARGET_TEMPERATURE_RANGE",
"|",
"SUPPORT_TARGET_TEMPERATURE",
")",
"assert",
"state",
".",
"state",
"is",
"STATE_UNKNOWN",
"assert",
"state",
".",
"attributes",
"[",
"ATTR_TEMPERATURE",
"]",
"is",
"None",
"assert",
"state",
".",
"attributes",
"[",
"ATTR_CURRENT_TEMPERATURE",
"]",
"==",
"21.1",
"# celsius",
"assert",
"state",
".",
"attributes",
"[",
"ATTR_HVAC_MODES",
"]",
"==",
"[",
"]"
] | [
271,
0
] | [
283,
50
] | python | en | ['en', 'en', 'en'] | True |
test_buggy_thermostat_invalid_mode | (hass, buggy_thermostat) | Tests when an invalid operation mode is included. | Tests when an invalid operation mode is included. | async def test_buggy_thermostat_invalid_mode(hass, buggy_thermostat):
"""Tests when an invalid operation mode is included."""
buggy_thermostat.status.update_attribute_value(
Attribute.supported_thermostat_modes, ["heat", "emergency heat", "other"]
)
await setup_platform(hass, CLIMATE_DOMAIN, devices=[buggy_thermostat])
state = hass.states.get("climate.buggy_thermostat")
assert state.attributes[ATTR_HVAC_MODES] == [HVAC_MODE_HEAT] | [
"async",
"def",
"test_buggy_thermostat_invalid_mode",
"(",
"hass",
",",
"buggy_thermostat",
")",
":",
"buggy_thermostat",
".",
"status",
".",
"update_attribute_value",
"(",
"Attribute",
".",
"supported_thermostat_modes",
",",
"[",
"\"heat\"",
",",
"\"emergency heat\"",
",",
"\"other\"",
"]",
")",
"await",
"setup_platform",
"(",
"hass",
",",
"CLIMATE_DOMAIN",
",",
"devices",
"=",
"[",
"buggy_thermostat",
"]",
")",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"\"climate.buggy_thermostat\"",
")",
"assert",
"state",
".",
"attributes",
"[",
"ATTR_HVAC_MODES",
"]",
"==",
"[",
"HVAC_MODE_HEAT",
"]"
] | [
286,
0
] | [
293,
64
] | python | en | ['en', 'en', 'en'] | True |
test_air_conditioner_entity_state | (hass, air_conditioner) | Tests when an invalid operation mode is included. | Tests when an invalid operation mode is included. | async def test_air_conditioner_entity_state(hass, air_conditioner):
"""Tests when an invalid operation mode is included."""
await setup_platform(hass, CLIMATE_DOMAIN, devices=[air_conditioner])
state = hass.states.get("climate.air_conditioner")
assert state.state == HVAC_MODE_HEAT_COOL
assert (
state.attributes[ATTR_SUPPORTED_FEATURES]
== SUPPORT_FAN_MODE | SUPPORT_TARGET_TEMPERATURE
)
assert sorted(state.attributes[ATTR_HVAC_MODES]) == [
HVAC_MODE_COOL,
HVAC_MODE_DRY,
HVAC_MODE_FAN_ONLY,
HVAC_MODE_HEAT,
HVAC_MODE_HEAT_COOL,
HVAC_MODE_OFF,
]
assert state.attributes[ATTR_FAN_MODE] == "medium"
assert sorted(state.attributes[ATTR_FAN_MODES]) == [
"auto",
"high",
"low",
"medium",
"turbo",
]
assert state.attributes[ATTR_TEMPERATURE] == 23
assert state.attributes[ATTR_CURRENT_TEMPERATURE] == 24
assert state.attributes["drlc_status_duration"] == 0
assert state.attributes["drlc_status_level"] == -1
assert state.attributes["drlc_status_start"] == "1970-01-01T00:00:00Z"
assert state.attributes["drlc_status_override"] is False
assert state.attributes["power_consumption_start"] == "2019-02-24T21:03:04Z"
assert state.attributes["power_consumption_power"] == 0
assert state.attributes["power_consumption_energy"] == 500
assert state.attributes["power_consumption_end"] == "2019-02-26T02:05:55Z" | [
"async",
"def",
"test_air_conditioner_entity_state",
"(",
"hass",
",",
"air_conditioner",
")",
":",
"await",
"setup_platform",
"(",
"hass",
",",
"CLIMATE_DOMAIN",
",",
"devices",
"=",
"[",
"air_conditioner",
"]",
")",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"\"climate.air_conditioner\"",
")",
"assert",
"state",
".",
"state",
"==",
"HVAC_MODE_HEAT_COOL",
"assert",
"(",
"state",
".",
"attributes",
"[",
"ATTR_SUPPORTED_FEATURES",
"]",
"==",
"SUPPORT_FAN_MODE",
"|",
"SUPPORT_TARGET_TEMPERATURE",
")",
"assert",
"sorted",
"(",
"state",
".",
"attributes",
"[",
"ATTR_HVAC_MODES",
"]",
")",
"==",
"[",
"HVAC_MODE_COOL",
",",
"HVAC_MODE_DRY",
",",
"HVAC_MODE_FAN_ONLY",
",",
"HVAC_MODE_HEAT",
",",
"HVAC_MODE_HEAT_COOL",
",",
"HVAC_MODE_OFF",
",",
"]",
"assert",
"state",
".",
"attributes",
"[",
"ATTR_FAN_MODE",
"]",
"==",
"\"medium\"",
"assert",
"sorted",
"(",
"state",
".",
"attributes",
"[",
"ATTR_FAN_MODES",
"]",
")",
"==",
"[",
"\"auto\"",
",",
"\"high\"",
",",
"\"low\"",
",",
"\"medium\"",
",",
"\"turbo\"",
",",
"]",
"assert",
"state",
".",
"attributes",
"[",
"ATTR_TEMPERATURE",
"]",
"==",
"23",
"assert",
"state",
".",
"attributes",
"[",
"ATTR_CURRENT_TEMPERATURE",
"]",
"==",
"24",
"assert",
"state",
".",
"attributes",
"[",
"\"drlc_status_duration\"",
"]",
"==",
"0",
"assert",
"state",
".",
"attributes",
"[",
"\"drlc_status_level\"",
"]",
"==",
"-",
"1",
"assert",
"state",
".",
"attributes",
"[",
"\"drlc_status_start\"",
"]",
"==",
"\"1970-01-01T00:00:00Z\"",
"assert",
"state",
".",
"attributes",
"[",
"\"drlc_status_override\"",
"]",
"is",
"False",
"assert",
"state",
".",
"attributes",
"[",
"\"power_consumption_start\"",
"]",
"==",
"\"2019-02-24T21:03:04Z\"",
"assert",
"state",
".",
"attributes",
"[",
"\"power_consumption_power\"",
"]",
"==",
"0",
"assert",
"state",
".",
"attributes",
"[",
"\"power_consumption_energy\"",
"]",
"==",
"500",
"assert",
"state",
".",
"attributes",
"[",
"\"power_consumption_end\"",
"]",
"==",
"\"2019-02-26T02:05:55Z\""
] | [
296,
0
] | [
330,
78
] | python | en | ['en', 'en', 'en'] | True |
test_set_fan_mode | (hass, thermostat, air_conditioner) | Test the fan mode is set successfully. | Test the fan mode is set successfully. | async def test_set_fan_mode(hass, thermostat, air_conditioner):
"""Test the fan mode is set successfully."""
await setup_platform(hass, CLIMATE_DOMAIN, devices=[thermostat, air_conditioner])
entity_ids = ["climate.thermostat", "climate.air_conditioner"]
await hass.services.async_call(
CLIMATE_DOMAIN,
SERVICE_SET_FAN_MODE,
{ATTR_ENTITY_ID: entity_ids, ATTR_FAN_MODE: "auto"},
blocking=True,
)
for entity_id in entity_ids:
state = hass.states.get(entity_id)
assert state.attributes[ATTR_FAN_MODE] == "auto", entity_id | [
"async",
"def",
"test_set_fan_mode",
"(",
"hass",
",",
"thermostat",
",",
"air_conditioner",
")",
":",
"await",
"setup_platform",
"(",
"hass",
",",
"CLIMATE_DOMAIN",
",",
"devices",
"=",
"[",
"thermostat",
",",
"air_conditioner",
"]",
")",
"entity_ids",
"=",
"[",
"\"climate.thermostat\"",
",",
"\"climate.air_conditioner\"",
"]",
"await",
"hass",
".",
"services",
".",
"async_call",
"(",
"CLIMATE_DOMAIN",
",",
"SERVICE_SET_FAN_MODE",
",",
"{",
"ATTR_ENTITY_ID",
":",
"entity_ids",
",",
"ATTR_FAN_MODE",
":",
"\"auto\"",
"}",
",",
"blocking",
"=",
"True",
",",
")",
"for",
"entity_id",
"in",
"entity_ids",
":",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"entity_id",
")",
"assert",
"state",
".",
"attributes",
"[",
"ATTR_FAN_MODE",
"]",
"==",
"\"auto\"",
",",
"entity_id"
] | [
333,
0
] | [
345,
67
] | python | en | ['en', 'fy', 'en'] | True |
test_set_hvac_mode | (hass, thermostat, air_conditioner) | Test the hvac mode is set successfully. | Test the hvac mode is set successfully. | async def test_set_hvac_mode(hass, thermostat, air_conditioner):
"""Test the hvac mode is set successfully."""
await setup_platform(hass, CLIMATE_DOMAIN, devices=[thermostat, air_conditioner])
entity_ids = ["climate.thermostat", "climate.air_conditioner"]
await hass.services.async_call(
CLIMATE_DOMAIN,
SERVICE_SET_HVAC_MODE,
{ATTR_ENTITY_ID: entity_ids, ATTR_HVAC_MODE: HVAC_MODE_COOL},
blocking=True,
)
for entity_id in entity_ids:
state = hass.states.get(entity_id)
assert state.state == HVAC_MODE_COOL, entity_id | [
"async",
"def",
"test_set_hvac_mode",
"(",
"hass",
",",
"thermostat",
",",
"air_conditioner",
")",
":",
"await",
"setup_platform",
"(",
"hass",
",",
"CLIMATE_DOMAIN",
",",
"devices",
"=",
"[",
"thermostat",
",",
"air_conditioner",
"]",
")",
"entity_ids",
"=",
"[",
"\"climate.thermostat\"",
",",
"\"climate.air_conditioner\"",
"]",
"await",
"hass",
".",
"services",
".",
"async_call",
"(",
"CLIMATE_DOMAIN",
",",
"SERVICE_SET_HVAC_MODE",
",",
"{",
"ATTR_ENTITY_ID",
":",
"entity_ids",
",",
"ATTR_HVAC_MODE",
":",
"HVAC_MODE_COOL",
"}",
",",
"blocking",
"=",
"True",
",",
")",
"for",
"entity_id",
"in",
"entity_ids",
":",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"entity_id",
")",
"assert",
"state",
".",
"state",
"==",
"HVAC_MODE_COOL",
",",
"entity_id"
] | [
348,
0
] | [
361,
55
] | python | en | ['en', 'en', 'en'] | True |
test_ac_set_hvac_mode_from_off | (hass, air_conditioner) | Test setting HVAC mode when the unit is off. | Test setting HVAC mode when the unit is off. | async def test_ac_set_hvac_mode_from_off(hass, air_conditioner):
"""Test setting HVAC mode when the unit is off."""
air_conditioner.status.update_attribute_value(
Attribute.air_conditioner_mode, "heat"
)
air_conditioner.status.update_attribute_value(Attribute.switch, "off")
await setup_platform(hass, CLIMATE_DOMAIN, devices=[air_conditioner])
state = hass.states.get("climate.air_conditioner")
assert state.state == HVAC_MODE_OFF
await hass.services.async_call(
CLIMATE_DOMAIN,
SERVICE_SET_HVAC_MODE,
{
ATTR_ENTITY_ID: "climate.air_conditioner",
ATTR_HVAC_MODE: HVAC_MODE_HEAT_COOL,
},
blocking=True,
)
state = hass.states.get("climate.air_conditioner")
assert state.state == HVAC_MODE_HEAT_COOL | [
"async",
"def",
"test_ac_set_hvac_mode_from_off",
"(",
"hass",
",",
"air_conditioner",
")",
":",
"air_conditioner",
".",
"status",
".",
"update_attribute_value",
"(",
"Attribute",
".",
"air_conditioner_mode",
",",
"\"heat\"",
")",
"air_conditioner",
".",
"status",
".",
"update_attribute_value",
"(",
"Attribute",
".",
"switch",
",",
"\"off\"",
")",
"await",
"setup_platform",
"(",
"hass",
",",
"CLIMATE_DOMAIN",
",",
"devices",
"=",
"[",
"air_conditioner",
"]",
")",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"\"climate.air_conditioner\"",
")",
"assert",
"state",
".",
"state",
"==",
"HVAC_MODE_OFF",
"await",
"hass",
".",
"services",
".",
"async_call",
"(",
"CLIMATE_DOMAIN",
",",
"SERVICE_SET_HVAC_MODE",
",",
"{",
"ATTR_ENTITY_ID",
":",
"\"climate.air_conditioner\"",
",",
"ATTR_HVAC_MODE",
":",
"HVAC_MODE_HEAT_COOL",
",",
"}",
",",
"blocking",
"=",
"True",
",",
")",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"\"climate.air_conditioner\"",
")",
"assert",
"state",
".",
"state",
"==",
"HVAC_MODE_HEAT_COOL"
] | [
364,
0
] | [
383,
45
] | python | en | ['en', 'en', 'en'] | True |
test_ac_set_hvac_mode_off | (hass, air_conditioner) | Test the AC HVAC mode can be turned off set successfully. | Test the AC HVAC mode can be turned off set successfully. | async def test_ac_set_hvac_mode_off(hass, air_conditioner):
"""Test the AC HVAC mode can be turned off set successfully."""
await setup_platform(hass, CLIMATE_DOMAIN, devices=[air_conditioner])
state = hass.states.get("climate.air_conditioner")
assert state.state != HVAC_MODE_OFF
await hass.services.async_call(
CLIMATE_DOMAIN,
SERVICE_SET_HVAC_MODE,
{ATTR_ENTITY_ID: "climate.air_conditioner", ATTR_HVAC_MODE: HVAC_MODE_OFF},
blocking=True,
)
state = hass.states.get("climate.air_conditioner")
assert state.state == HVAC_MODE_OFF | [
"async",
"def",
"test_ac_set_hvac_mode_off",
"(",
"hass",
",",
"air_conditioner",
")",
":",
"await",
"setup_platform",
"(",
"hass",
",",
"CLIMATE_DOMAIN",
",",
"devices",
"=",
"[",
"air_conditioner",
"]",
")",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"\"climate.air_conditioner\"",
")",
"assert",
"state",
".",
"state",
"!=",
"HVAC_MODE_OFF",
"await",
"hass",
".",
"services",
".",
"async_call",
"(",
"CLIMATE_DOMAIN",
",",
"SERVICE_SET_HVAC_MODE",
",",
"{",
"ATTR_ENTITY_ID",
":",
"\"climate.air_conditioner\"",
",",
"ATTR_HVAC_MODE",
":",
"HVAC_MODE_OFF",
"}",
",",
"blocking",
"=",
"True",
",",
")",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"\"climate.air_conditioner\"",
")",
"assert",
"state",
".",
"state",
"==",
"HVAC_MODE_OFF"
] | [
386,
0
] | [
398,
39
] | python | en | ['en', 'en', 'en'] | True |
test_set_temperature_heat_mode | (hass, thermostat) | Test the temperature is set successfully when in heat mode. | Test the temperature is set successfully when in heat mode. | async def test_set_temperature_heat_mode(hass, thermostat):
"""Test the temperature is set successfully when in heat mode."""
thermostat.status.thermostat_mode = "heat"
await setup_platform(hass, CLIMATE_DOMAIN, devices=[thermostat])
await hass.services.async_call(
CLIMATE_DOMAIN,
SERVICE_SET_TEMPERATURE,
{ATTR_ENTITY_ID: "climate.thermostat", ATTR_TEMPERATURE: 21},
blocking=True,
)
state = hass.states.get("climate.thermostat")
assert state.state == HVAC_MODE_HEAT
assert state.attributes[ATTR_TEMPERATURE] == 21
assert thermostat.status.heating_setpoint == 69.8 | [
"async",
"def",
"test_set_temperature_heat_mode",
"(",
"hass",
",",
"thermostat",
")",
":",
"thermostat",
".",
"status",
".",
"thermostat_mode",
"=",
"\"heat\"",
"await",
"setup_platform",
"(",
"hass",
",",
"CLIMATE_DOMAIN",
",",
"devices",
"=",
"[",
"thermostat",
"]",
")",
"await",
"hass",
".",
"services",
".",
"async_call",
"(",
"CLIMATE_DOMAIN",
",",
"SERVICE_SET_TEMPERATURE",
",",
"{",
"ATTR_ENTITY_ID",
":",
"\"climate.thermostat\"",
",",
"ATTR_TEMPERATURE",
":",
"21",
"}",
",",
"blocking",
"=",
"True",
",",
")",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"\"climate.thermostat\"",
")",
"assert",
"state",
".",
"state",
"==",
"HVAC_MODE_HEAT",
"assert",
"state",
".",
"attributes",
"[",
"ATTR_TEMPERATURE",
"]",
"==",
"21",
"assert",
"thermostat",
".",
"status",
".",
"heating_setpoint",
"==",
"69.8"
] | [
401,
0
] | [
414,
53
] | python | en | ['en', 'en', 'en'] | True |
test_set_temperature_cool_mode | (hass, thermostat) | Test the temperature is set successfully when in cool mode. | Test the temperature is set successfully when in cool mode. | async def test_set_temperature_cool_mode(hass, thermostat):
"""Test the temperature is set successfully when in cool mode."""
thermostat.status.thermostat_mode = "cool"
await setup_platform(hass, CLIMATE_DOMAIN, devices=[thermostat])
await hass.services.async_call(
CLIMATE_DOMAIN,
SERVICE_SET_TEMPERATURE,
{ATTR_ENTITY_ID: "climate.thermostat", ATTR_TEMPERATURE: 21},
blocking=True,
)
state = hass.states.get("climate.thermostat")
assert state.attributes[ATTR_TEMPERATURE] == 21 | [
"async",
"def",
"test_set_temperature_cool_mode",
"(",
"hass",
",",
"thermostat",
")",
":",
"thermostat",
".",
"status",
".",
"thermostat_mode",
"=",
"\"cool\"",
"await",
"setup_platform",
"(",
"hass",
",",
"CLIMATE_DOMAIN",
",",
"devices",
"=",
"[",
"thermostat",
"]",
")",
"await",
"hass",
".",
"services",
".",
"async_call",
"(",
"CLIMATE_DOMAIN",
",",
"SERVICE_SET_TEMPERATURE",
",",
"{",
"ATTR_ENTITY_ID",
":",
"\"climate.thermostat\"",
",",
"ATTR_TEMPERATURE",
":",
"21",
"}",
",",
"blocking",
"=",
"True",
",",
")",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"\"climate.thermostat\"",
")",
"assert",
"state",
".",
"attributes",
"[",
"ATTR_TEMPERATURE",
"]",
"==",
"21"
] | [
417,
0
] | [
428,
51
] | python | en | ['en', 'en', 'en'] | True |
test_set_temperature | (hass, thermostat) | Test the temperature is set successfully. | Test the temperature is set successfully. | async def test_set_temperature(hass, thermostat):
"""Test the temperature is set successfully."""
thermostat.status.thermostat_mode = "auto"
await setup_platform(hass, CLIMATE_DOMAIN, devices=[thermostat])
await hass.services.async_call(
CLIMATE_DOMAIN,
SERVICE_SET_TEMPERATURE,
{
ATTR_ENTITY_ID: "climate.thermostat",
ATTR_TARGET_TEMP_HIGH: 25.5,
ATTR_TARGET_TEMP_LOW: 22.2,
},
blocking=True,
)
state = hass.states.get("climate.thermostat")
assert state.attributes[ATTR_TARGET_TEMP_HIGH] == 25.5
assert state.attributes[ATTR_TARGET_TEMP_LOW] == 22.2 | [
"async",
"def",
"test_set_temperature",
"(",
"hass",
",",
"thermostat",
")",
":",
"thermostat",
".",
"status",
".",
"thermostat_mode",
"=",
"\"auto\"",
"await",
"setup_platform",
"(",
"hass",
",",
"CLIMATE_DOMAIN",
",",
"devices",
"=",
"[",
"thermostat",
"]",
")",
"await",
"hass",
".",
"services",
".",
"async_call",
"(",
"CLIMATE_DOMAIN",
",",
"SERVICE_SET_TEMPERATURE",
",",
"{",
"ATTR_ENTITY_ID",
":",
"\"climate.thermostat\"",
",",
"ATTR_TARGET_TEMP_HIGH",
":",
"25.5",
",",
"ATTR_TARGET_TEMP_LOW",
":",
"22.2",
",",
"}",
",",
"blocking",
"=",
"True",
",",
")",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"\"climate.thermostat\"",
")",
"assert",
"state",
".",
"attributes",
"[",
"ATTR_TARGET_TEMP_HIGH",
"]",
"==",
"25.5",
"assert",
"state",
".",
"attributes",
"[",
"ATTR_TARGET_TEMP_LOW",
"]",
"==",
"22.2"
] | [
431,
0
] | [
447,
57
] | python | en | ['en', 'en', 'en'] | True |
test_set_temperature_ac | (hass, air_conditioner) | Test the temperature is set successfully. | Test the temperature is set successfully. | async def test_set_temperature_ac(hass, air_conditioner):
"""Test the temperature is set successfully."""
await setup_platform(hass, CLIMATE_DOMAIN, devices=[air_conditioner])
await hass.services.async_call(
CLIMATE_DOMAIN,
SERVICE_SET_TEMPERATURE,
{ATTR_ENTITY_ID: "climate.air_conditioner", ATTR_TEMPERATURE: 27},
blocking=True,
)
state = hass.states.get("climate.air_conditioner")
assert state.attributes[ATTR_TEMPERATURE] == 27 | [
"async",
"def",
"test_set_temperature_ac",
"(",
"hass",
",",
"air_conditioner",
")",
":",
"await",
"setup_platform",
"(",
"hass",
",",
"CLIMATE_DOMAIN",
",",
"devices",
"=",
"[",
"air_conditioner",
"]",
")",
"await",
"hass",
".",
"services",
".",
"async_call",
"(",
"CLIMATE_DOMAIN",
",",
"SERVICE_SET_TEMPERATURE",
",",
"{",
"ATTR_ENTITY_ID",
":",
"\"climate.air_conditioner\"",
",",
"ATTR_TEMPERATURE",
":",
"27",
"}",
",",
"blocking",
"=",
"True",
",",
")",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"\"climate.air_conditioner\"",
")",
"assert",
"state",
".",
"attributes",
"[",
"ATTR_TEMPERATURE",
"]",
"==",
"27"
] | [
450,
0
] | [
460,
51
] | python | en | ['en', 'en', 'en'] | True |
test_set_temperature_ac_with_mode | (hass, air_conditioner) | Test the temperature is set successfully. | Test the temperature is set successfully. | async def test_set_temperature_ac_with_mode(hass, air_conditioner):
"""Test the temperature is set successfully."""
await setup_platform(hass, CLIMATE_DOMAIN, devices=[air_conditioner])
await hass.services.async_call(
CLIMATE_DOMAIN,
SERVICE_SET_TEMPERATURE,
{
ATTR_ENTITY_ID: "climate.air_conditioner",
ATTR_TEMPERATURE: 27,
ATTR_HVAC_MODE: HVAC_MODE_COOL,
},
blocking=True,
)
state = hass.states.get("climate.air_conditioner")
assert state.attributes[ATTR_TEMPERATURE] == 27
assert state.state == HVAC_MODE_COOL | [
"async",
"def",
"test_set_temperature_ac_with_mode",
"(",
"hass",
",",
"air_conditioner",
")",
":",
"await",
"setup_platform",
"(",
"hass",
",",
"CLIMATE_DOMAIN",
",",
"devices",
"=",
"[",
"air_conditioner",
"]",
")",
"await",
"hass",
".",
"services",
".",
"async_call",
"(",
"CLIMATE_DOMAIN",
",",
"SERVICE_SET_TEMPERATURE",
",",
"{",
"ATTR_ENTITY_ID",
":",
"\"climate.air_conditioner\"",
",",
"ATTR_TEMPERATURE",
":",
"27",
",",
"ATTR_HVAC_MODE",
":",
"HVAC_MODE_COOL",
",",
"}",
",",
"blocking",
"=",
"True",
",",
")",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"\"climate.air_conditioner\"",
")",
"assert",
"state",
".",
"attributes",
"[",
"ATTR_TEMPERATURE",
"]",
"==",
"27",
"assert",
"state",
".",
"state",
"==",
"HVAC_MODE_COOL"
] | [
463,
0
] | [
478,
40
] | python | en | ['en', 'en', 'en'] | True |
test_set_temperature_ac_with_mode_from_off | (hass, air_conditioner) | Test the temp and mode is set successfully when the unit is off. | Test the temp and mode is set successfully when the unit is off. | async def test_set_temperature_ac_with_mode_from_off(hass, air_conditioner):
"""Test the temp and mode is set successfully when the unit is off."""
air_conditioner.status.update_attribute_value(
Attribute.air_conditioner_mode, "heat"
)
air_conditioner.status.update_attribute_value(Attribute.switch, "off")
await setup_platform(hass, CLIMATE_DOMAIN, devices=[air_conditioner])
assert hass.states.get("climate.air_conditioner").state == HVAC_MODE_OFF
await hass.services.async_call(
CLIMATE_DOMAIN,
SERVICE_SET_TEMPERATURE,
{
ATTR_ENTITY_ID: "climate.air_conditioner",
ATTR_TEMPERATURE: 27,
ATTR_HVAC_MODE: HVAC_MODE_COOL,
},
blocking=True,
)
state = hass.states.get("climate.air_conditioner")
assert state.attributes[ATTR_TEMPERATURE] == 27
assert state.state == HVAC_MODE_COOL | [
"async",
"def",
"test_set_temperature_ac_with_mode_from_off",
"(",
"hass",
",",
"air_conditioner",
")",
":",
"air_conditioner",
".",
"status",
".",
"update_attribute_value",
"(",
"Attribute",
".",
"air_conditioner_mode",
",",
"\"heat\"",
")",
"air_conditioner",
".",
"status",
".",
"update_attribute_value",
"(",
"Attribute",
".",
"switch",
",",
"\"off\"",
")",
"await",
"setup_platform",
"(",
"hass",
",",
"CLIMATE_DOMAIN",
",",
"devices",
"=",
"[",
"air_conditioner",
"]",
")",
"assert",
"hass",
".",
"states",
".",
"get",
"(",
"\"climate.air_conditioner\"",
")",
".",
"state",
"==",
"HVAC_MODE_OFF",
"await",
"hass",
".",
"services",
".",
"async_call",
"(",
"CLIMATE_DOMAIN",
",",
"SERVICE_SET_TEMPERATURE",
",",
"{",
"ATTR_ENTITY_ID",
":",
"\"climate.air_conditioner\"",
",",
"ATTR_TEMPERATURE",
":",
"27",
",",
"ATTR_HVAC_MODE",
":",
"HVAC_MODE_COOL",
",",
"}",
",",
"blocking",
"=",
"True",
",",
")",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"\"climate.air_conditioner\"",
")",
"assert",
"state",
".",
"attributes",
"[",
"ATTR_TEMPERATURE",
"]",
"==",
"27",
"assert",
"state",
".",
"state",
"==",
"HVAC_MODE_COOL"
] | [
481,
0
] | [
501,
40
] | python | en | ['en', 'en', 'en'] | True |
test_set_temperature_ac_with_mode_to_off | (hass, air_conditioner) | Test the temp and mode is set successfully to turn off the unit. | Test the temp and mode is set successfully to turn off the unit. | async def test_set_temperature_ac_with_mode_to_off(hass, air_conditioner):
"""Test the temp and mode is set successfully to turn off the unit."""
await setup_platform(hass, CLIMATE_DOMAIN, devices=[air_conditioner])
assert hass.states.get("climate.air_conditioner").state != HVAC_MODE_OFF
await hass.services.async_call(
CLIMATE_DOMAIN,
SERVICE_SET_TEMPERATURE,
{
ATTR_ENTITY_ID: "climate.air_conditioner",
ATTR_TEMPERATURE: 27,
ATTR_HVAC_MODE: HVAC_MODE_OFF,
},
blocking=True,
)
state = hass.states.get("climate.air_conditioner")
assert state.attributes[ATTR_TEMPERATURE] == 27
assert state.state == HVAC_MODE_OFF | [
"async",
"def",
"test_set_temperature_ac_with_mode_to_off",
"(",
"hass",
",",
"air_conditioner",
")",
":",
"await",
"setup_platform",
"(",
"hass",
",",
"CLIMATE_DOMAIN",
",",
"devices",
"=",
"[",
"air_conditioner",
"]",
")",
"assert",
"hass",
".",
"states",
".",
"get",
"(",
"\"climate.air_conditioner\"",
")",
".",
"state",
"!=",
"HVAC_MODE_OFF",
"await",
"hass",
".",
"services",
".",
"async_call",
"(",
"CLIMATE_DOMAIN",
",",
"SERVICE_SET_TEMPERATURE",
",",
"{",
"ATTR_ENTITY_ID",
":",
"\"climate.air_conditioner\"",
",",
"ATTR_TEMPERATURE",
":",
"27",
",",
"ATTR_HVAC_MODE",
":",
"HVAC_MODE_OFF",
",",
"}",
",",
"blocking",
"=",
"True",
",",
")",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"\"climate.air_conditioner\"",
")",
"assert",
"state",
".",
"attributes",
"[",
"ATTR_TEMPERATURE",
"]",
"==",
"27",
"assert",
"state",
".",
"state",
"==",
"HVAC_MODE_OFF"
] | [
504,
0
] | [
520,
39
] | python | en | ['en', 'en', 'en'] | True |
test_set_temperature_with_mode | (hass, thermostat) | Test the temperature and mode is set successfully. | Test the temperature and mode is set successfully. | async def test_set_temperature_with_mode(hass, thermostat):
"""Test the temperature and mode is set successfully."""
await setup_platform(hass, CLIMATE_DOMAIN, devices=[thermostat])
await hass.services.async_call(
CLIMATE_DOMAIN,
SERVICE_SET_TEMPERATURE,
{
ATTR_ENTITY_ID: "climate.thermostat",
ATTR_TARGET_TEMP_HIGH: 25.5,
ATTR_TARGET_TEMP_LOW: 22.2,
ATTR_HVAC_MODE: HVAC_MODE_HEAT_COOL,
},
blocking=True,
)
state = hass.states.get("climate.thermostat")
assert state.attributes[ATTR_TARGET_TEMP_HIGH] == 25.5
assert state.attributes[ATTR_TARGET_TEMP_LOW] == 22.2
assert state.state == HVAC_MODE_HEAT_COOL | [
"async",
"def",
"test_set_temperature_with_mode",
"(",
"hass",
",",
"thermostat",
")",
":",
"await",
"setup_platform",
"(",
"hass",
",",
"CLIMATE_DOMAIN",
",",
"devices",
"=",
"[",
"thermostat",
"]",
")",
"await",
"hass",
".",
"services",
".",
"async_call",
"(",
"CLIMATE_DOMAIN",
",",
"SERVICE_SET_TEMPERATURE",
",",
"{",
"ATTR_ENTITY_ID",
":",
"\"climate.thermostat\"",
",",
"ATTR_TARGET_TEMP_HIGH",
":",
"25.5",
",",
"ATTR_TARGET_TEMP_LOW",
":",
"22.2",
",",
"ATTR_HVAC_MODE",
":",
"HVAC_MODE_HEAT_COOL",
",",
"}",
",",
"blocking",
"=",
"True",
",",
")",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"\"climate.thermostat\"",
")",
"assert",
"state",
".",
"attributes",
"[",
"ATTR_TARGET_TEMP_HIGH",
"]",
"==",
"25.5",
"assert",
"state",
".",
"attributes",
"[",
"ATTR_TARGET_TEMP_LOW",
"]",
"==",
"22.2",
"assert",
"state",
".",
"state",
"==",
"HVAC_MODE_HEAT_COOL"
] | [
523,
0
] | [
540,
45
] | python | en | ['en', 'en', 'en'] | True |
test_set_turn_off | (hass, air_conditioner) | Test the a/c is turned off successfully. | Test the a/c is turned off successfully. | async def test_set_turn_off(hass, air_conditioner):
"""Test the a/c is turned off successfully."""
await setup_platform(hass, CLIMATE_DOMAIN, devices=[air_conditioner])
state = hass.states.get("climate.air_conditioner")
assert state.state == HVAC_MODE_HEAT_COOL
await hass.services.async_call(
CLIMATE_DOMAIN, SERVICE_TURN_OFF, {"entity_id": "all"}, blocking=True
)
state = hass.states.get("climate.air_conditioner")
assert state.state == HVAC_MODE_OFF | [
"async",
"def",
"test_set_turn_off",
"(",
"hass",
",",
"air_conditioner",
")",
":",
"await",
"setup_platform",
"(",
"hass",
",",
"CLIMATE_DOMAIN",
",",
"devices",
"=",
"[",
"air_conditioner",
"]",
")",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"\"climate.air_conditioner\"",
")",
"assert",
"state",
".",
"state",
"==",
"HVAC_MODE_HEAT_COOL",
"await",
"hass",
".",
"services",
".",
"async_call",
"(",
"CLIMATE_DOMAIN",
",",
"SERVICE_TURN_OFF",
",",
"{",
"\"entity_id\"",
":",
"\"all\"",
"}",
",",
"blocking",
"=",
"True",
")",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"\"climate.air_conditioner\"",
")",
"assert",
"state",
".",
"state",
"==",
"HVAC_MODE_OFF"
] | [
543,
0
] | [
552,
39
] | python | en | ['en', 'en', 'en'] | True |
test_set_turn_on | (hass, air_conditioner) | Test the a/c is turned on successfully. | Test the a/c is turned on successfully. | async def test_set_turn_on(hass, air_conditioner):
"""Test the a/c is turned on successfully."""
air_conditioner.status.update_attribute_value(Attribute.switch, "off")
await setup_platform(hass, CLIMATE_DOMAIN, devices=[air_conditioner])
state = hass.states.get("climate.air_conditioner")
assert state.state == HVAC_MODE_OFF
await hass.services.async_call(
CLIMATE_DOMAIN, SERVICE_TURN_ON, {"entity_id": "all"}, blocking=True
)
state = hass.states.get("climate.air_conditioner")
assert state.state == HVAC_MODE_HEAT_COOL | [
"async",
"def",
"test_set_turn_on",
"(",
"hass",
",",
"air_conditioner",
")",
":",
"air_conditioner",
".",
"status",
".",
"update_attribute_value",
"(",
"Attribute",
".",
"switch",
",",
"\"off\"",
")",
"await",
"setup_platform",
"(",
"hass",
",",
"CLIMATE_DOMAIN",
",",
"devices",
"=",
"[",
"air_conditioner",
"]",
")",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"\"climate.air_conditioner\"",
")",
"assert",
"state",
".",
"state",
"==",
"HVAC_MODE_OFF",
"await",
"hass",
".",
"services",
".",
"async_call",
"(",
"CLIMATE_DOMAIN",
",",
"SERVICE_TURN_ON",
",",
"{",
"\"entity_id\"",
":",
"\"all\"",
"}",
",",
"blocking",
"=",
"True",
")",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"\"climate.air_conditioner\"",
")",
"assert",
"state",
".",
"state",
"==",
"HVAC_MODE_HEAT_COOL"
] | [
555,
0
] | [
565,
45
] | python | en | ['en', 'en', 'en'] | True |
test_entity_and_device_attributes | (hass, thermostat) | Test the attributes of the entries are correct. | Test the attributes of the entries are correct. | async def test_entity_and_device_attributes(hass, thermostat):
"""Test the attributes of the entries are correct."""
await setup_platform(hass, CLIMATE_DOMAIN, devices=[thermostat])
entity_registry = await hass.helpers.entity_registry.async_get_registry()
device_registry = await hass.helpers.device_registry.async_get_registry()
entry = entity_registry.async_get("climate.thermostat")
assert entry
assert entry.unique_id == thermostat.device_id
entry = device_registry.async_get_device({(DOMAIN, thermostat.device_id)}, [])
assert entry
assert entry.name == thermostat.label
assert entry.model == thermostat.device_type_name
assert entry.manufacturer == "Unavailable" | [
"async",
"def",
"test_entity_and_device_attributes",
"(",
"hass",
",",
"thermostat",
")",
":",
"await",
"setup_platform",
"(",
"hass",
",",
"CLIMATE_DOMAIN",
",",
"devices",
"=",
"[",
"thermostat",
"]",
")",
"entity_registry",
"=",
"await",
"hass",
".",
"helpers",
".",
"entity_registry",
".",
"async_get_registry",
"(",
")",
"device_registry",
"=",
"await",
"hass",
".",
"helpers",
".",
"device_registry",
".",
"async_get_registry",
"(",
")",
"entry",
"=",
"entity_registry",
".",
"async_get",
"(",
"\"climate.thermostat\"",
")",
"assert",
"entry",
"assert",
"entry",
".",
"unique_id",
"==",
"thermostat",
".",
"device_id",
"entry",
"=",
"device_registry",
".",
"async_get_device",
"(",
"{",
"(",
"DOMAIN",
",",
"thermostat",
".",
"device_id",
")",
"}",
",",
"[",
"]",
")",
"assert",
"entry",
"assert",
"entry",
".",
"name",
"==",
"thermostat",
".",
"label",
"assert",
"entry",
".",
"model",
"==",
"thermostat",
".",
"device_type_name",
"assert",
"entry",
".",
"manufacturer",
"==",
"\"Unavailable\""
] | [
568,
0
] | [
582,
46
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the available BloomSky weather binary sensors. | Set up the available BloomSky weather binary sensors. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the available BloomSky weather binary sensors."""
# Default needed in case of discovery
if discovery_info is not None:
return
sensors = config[CONF_MONITORED_CONDITIONS]
bloomsky = hass.data[DOMAIN]
for device in bloomsky.devices.values():
for variable in sensors:
add_entities([BloomSkySensor(bloomsky, device, variable)], True) | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"# Default needed in case of discovery",
"if",
"discovery_info",
"is",
"not",
"None",
":",
"return",
"sensors",
"=",
"config",
"[",
"CONF_MONITORED_CONDITIONS",
"]",
"bloomsky",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"for",
"device",
"in",
"bloomsky",
".",
"devices",
".",
"values",
"(",
")",
":",
"for",
"variable",
"in",
"sensors",
":",
"add_entities",
"(",
"[",
"BloomSkySensor",
"(",
"bloomsky",
",",
"device",
",",
"variable",
")",
"]",
",",
"True",
")"
] | [
24,
0
] | [
35,
76
] | python | en | ['en', 'en', 'en'] | True |
BloomSkySensor.__init__ | (self, bs, device, sensor_name) | Initialize a BloomSky binary sensor. | Initialize a BloomSky binary sensor. | def __init__(self, bs, device, sensor_name):
"""Initialize a BloomSky binary sensor."""
self._bloomsky = bs
self._device_id = device["DeviceID"]
self._sensor_name = sensor_name
self._name = f"{device['DeviceName']} {sensor_name}"
self._state = None
self._unique_id = f"{self._device_id}-{self._sensor_name}" | [
"def",
"__init__",
"(",
"self",
",",
"bs",
",",
"device",
",",
"sensor_name",
")",
":",
"self",
".",
"_bloomsky",
"=",
"bs",
"self",
".",
"_device_id",
"=",
"device",
"[",
"\"DeviceID\"",
"]",
"self",
".",
"_sensor_name",
"=",
"sensor_name",
"self",
".",
"_name",
"=",
"f\"{device['DeviceName']} {sensor_name}\"",
"self",
".",
"_state",
"=",
"None",
"self",
".",
"_unique_id",
"=",
"f\"{self._device_id}-{self._sensor_name}\""
] | [
41,
4
] | [
48,
66
] | python | en | ['en', 'cs', 'en'] | True |
BloomSkySensor.unique_id | (self) | Return a unique ID. | Return a unique ID. | def unique_id(self):
"""Return a unique ID."""
return self._unique_id | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unique_id"
] | [
51,
4
] | [
53,
30
] | python | ca | ['fr', 'ca', 'en'] | False |
BloomSkySensor.name | (self) | Return the name of the BloomSky device and this sensor. | Return the name of the BloomSky device and this sensor. | def name(self):
"""Return the name of the BloomSky device and this sensor."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
56,
4
] | [
58,
25
] | python | en | ['en', 'en', 'en'] | True |
BloomSkySensor.device_class | (self) | Return the class of this sensor, from DEVICE_CLASSES. | Return the class of this sensor, from DEVICE_CLASSES. | def device_class(self):
"""Return the class of this sensor, from DEVICE_CLASSES."""
return SENSOR_TYPES.get(self._sensor_name) | [
"def",
"device_class",
"(",
"self",
")",
":",
"return",
"SENSOR_TYPES",
".",
"get",
"(",
"self",
".",
"_sensor_name",
")"
] | [
61,
4
] | [
63,
50
] | python | en | ['en', 'en', 'en'] | True |
BloomSkySensor.is_on | (self) | Return true if binary sensor is on. | Return true if binary sensor is on. | def is_on(self):
"""Return true if binary sensor is on."""
return self._state | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
66,
4
] | [
68,
26
] | python | en | ['en', 'fy', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.