Search is not available for this dataset
identifier stringlengths 1 155 | parameters stringlengths 2 6.09k | docstring stringlengths 11 63.4k | docstring_summary stringlengths 0 63.4k | function stringlengths 29 99.8k | function_tokens list | start_point list | end_point list | language stringclasses 1
value | docstring_language stringlengths 2 7 | docstring_language_predictions stringlengths 18 23 | is_langid_reliable stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
EcoalTempSensor.unit_of_measurement | (self) | Return the unit of measurement. | Return the unit of measurement. | def unit_of_measurement(self):
"""Return the unit of measurement."""
return TEMP_CELSIUS | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"TEMP_CELSIUS"
] | [
40,
4
] | [
42,
27
] | python | en | ['en', 'la', 'en'] | True |
EcoalTempSensor.update | (self) | Fetch new state data for the sensor.
This is the only method that should fetch new data for Home Assistant.
| Fetch new state data for the sensor. | def update(self):
"""Fetch new state data for the sensor.
This is the only method that should fetch new data for Home Assistant.
"""
# Old values read 0.5 back can still be used
status = self._ecoal_contr.get_cached_status()
self._state = getattr(status, self._status_att... | [
"def",
"update",
"(",
"self",
")",
":",
"# Old values read 0.5 back can still be used",
"status",
"=",
"self",
".",
"_ecoal_contr",
".",
"get_cached_status",
"(",
")",
"self",
".",
"_state",
"=",
"getattr",
"(",
"status",
",",
"self",
".",
"_status_attr",
")"
] | [
44,
4
] | [
51,
56
] | python | en | ['en', 'en', 'en'] | True |
validate_input | (hass: core.HomeAssistant, data) | Validate the user input allows us to connect.
Data has the keys from DATA_SCHEMA with values provided by the user.
| Validate the user input allows us to connect. | async def validate_input(hass: core.HomeAssistant, data):
"""Validate the user input allows us to connect.
Data has the keys from DATA_SCHEMA with values provided by the user.
"""
rachio = Rachio(data[CONF_API_KEY])
username = None
try:
data = await hass.async_add_executor_job(rachio.pe... | [
"async",
"def",
"validate_input",
"(",
"hass",
":",
"core",
".",
"HomeAssistant",
",",
"data",
")",
":",
"rachio",
"=",
"Rachio",
"(",
"data",
"[",
"CONF_API_KEY",
"]",
")",
"username",
"=",
"None",
"try",
":",
"data",
"=",
"await",
"hass",
".",
"async... | [
25,
0
] | [
50,
30
] | python | en | ['en', 'en', 'en'] | True |
ConfigFlow.async_step_user | (self, user_input=None) | Handle the initial step. | Handle the initial step. | async def async_step_user(self, user_input=None):
"""Handle the initial step."""
errors = {}
if user_input is not None:
await self.async_set_unique_id(user_input[CONF_API_KEY])
self._abort_if_unique_id_configured()
try:
info = await validate_in... | [
"async",
"def",
"async_step_user",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"errors",
"=",
"{",
"}",
"if",
"user_input",
"is",
"not",
"None",
":",
"await",
"self",
".",
"async_set_unique_id",
"(",
"user_input",
"[",
"CONF_API_KEY",
"]",
")",
... | [
59,
4
] | [
78,
9
] | python | en | ['en', 'en', 'en'] | True |
ConfigFlow.async_step_homekit | (self, homekit_info) | Handle HomeKit discovery. | Handle HomeKit discovery. | async def async_step_homekit(self, homekit_info):
"""Handle HomeKit discovery."""
if self._async_current_entries():
# We can see rachio on the network to tell them to configure
# it, but since the device will not give up the account it is
# bound to and there can be m... | [
"async",
"def",
"async_step_homekit",
"(",
"self",
",",
"homekit_info",
")",
":",
"if",
"self",
".",
"_async_current_entries",
"(",
")",
":",
"# We can see rachio on the network to tell them to configure",
"# it, but since the device will not give up the account it is",
"# bound ... | [
80,
4
] | [
94,
43
] | python | en | ['fr', 'xh', 'en'] | False |
ConfigFlow.async_step_import | (self, user_input) | Handle import. | Handle import. | async def async_step_import(self, user_input):
"""Handle import."""
return await self.async_step_user(user_input) | [
"async",
"def",
"async_step_import",
"(",
"self",
",",
"user_input",
")",
":",
"return",
"await",
"self",
".",
"async_step_user",
"(",
"user_input",
")"
] | [
96,
4
] | [
98,
53
] | python | en | ['en', 'ja', 'en'] | False |
ConfigFlow.async_get_options_flow | (config_entry) | Get the options flow for this handler. | Get the options flow for this handler. | def async_get_options_flow(config_entry):
"""Get the options flow for this handler."""
return OptionsFlowHandler(config_entry) | [
"def",
"async_get_options_flow",
"(",
"config_entry",
")",
":",
"return",
"OptionsFlowHandler",
"(",
"config_entry",
")"
] | [
102,
4
] | [
104,
47
] | python | en | ['en', 'en', 'en'] | True |
OptionsFlowHandler.__init__ | (self, config_entry: config_entries.ConfigEntry) | Initialize options flow. | Initialize options flow. | def __init__(self, config_entry: config_entries.ConfigEntry):
"""Initialize options flow."""
self.config_entry = config_entry | [
"def",
"__init__",
"(",
"self",
",",
"config_entry",
":",
"config_entries",
".",
"ConfigEntry",
")",
":",
"self",
".",
"config_entry",
"=",
"config_entry"
] | [
110,
4
] | [
112,
40
] | python | en | ['en', 'en', 'en'] | True |
OptionsFlowHandler.async_step_init | (self, user_input=None) | Handle options flow. | Handle options flow. | async def async_step_init(self, user_input=None):
"""Handle options flow."""
if user_input is not None:
return self.async_create_entry(title="", data=user_input)
data_schema = vol.Schema(
{
vol.Optional(
CONF_MANUAL_RUN_MINS,
... | [
"async",
"def",
"async_step_init",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"if",
"user_input",
"is",
"not",
"None",
":",
"return",
"self",
".",
"async_create_entry",
"(",
"title",
"=",
"\"\"",
",",
"data",
"=",
"user_input",
")",
"data_schem... | [
114,
4
] | [
129,
76
] | python | en | ['en', 'nl', 'en'] | True |
test_setup | (
hass: HomeAssistantType, aioclient_mock: AiohttpClientMocker
) | Test setup with basic config. | Test setup with basic config. | async def test_setup(
hass: HomeAssistantType, aioclient_mock: AiohttpClientMocker
) -> None:
"""Test setup with basic config."""
await setup_integration(hass, aioclient_mock)
assert hass.states.get(MAIN_ENTITY_ID) | [
"async",
"def",
"test_setup",
"(",
"hass",
":",
"HomeAssistantType",
",",
"aioclient_mock",
":",
"AiohttpClientMocker",
")",
"->",
"None",
":",
"await",
"setup_integration",
"(",
"hass",
",",
"aioclient_mock",
")",
"assert",
"hass",
".",
"states",
".",
"get",
... | [
18,
0
] | [
23,
42
] | python | en | ['en', 'zu', 'en'] | True |
test_unique_id | (
hass: HomeAssistantType, aioclient_mock: AiohttpClientMocker
) | Test unique id. | Test unique id. | async def test_unique_id(
hass: HomeAssistantType, aioclient_mock: AiohttpClientMocker
) -> None:
"""Test unique id."""
await setup_integration(hass, aioclient_mock)
entity_registry = await hass.helpers.entity_registry.async_get_registry()
main = entity_registry.async_get(MAIN_ENTITY_ID)
asser... | [
"async",
"def",
"test_unique_id",
"(",
"hass",
":",
"HomeAssistantType",
",",
"aioclient_mock",
":",
"AiohttpClientMocker",
")",
"->",
"None",
":",
"await",
"setup_integration",
"(",
"hass",
",",
"aioclient_mock",
")",
"entity_registry",
"=",
"await",
"hass",
".",... | [
26,
0
] | [
35,
40
] | python | en | ['fr', 'la', 'en'] | False |
test_main_services | (
hass: HomeAssistantType, aioclient_mock: AiohttpClientMocker
) | Test platform services. | Test platform services. | async def test_main_services(
hass: HomeAssistantType, aioclient_mock: AiohttpClientMocker
) -> None:
"""Test platform services."""
await setup_integration(hass, aioclient_mock)
with patch("homeassistant.components.roku.Roku.remote") as remote_mock:
await hass.services.async_call(
R... | [
"async",
"def",
"test_main_services",
"(",
"hass",
":",
"HomeAssistantType",
",",
"aioclient_mock",
":",
"AiohttpClientMocker",
")",
"->",
"None",
":",
"await",
"setup_integration",
"(",
"hass",
",",
"aioclient_mock",
")",
"with",
"patch",
"(",
"\"homeassistant.comp... | [
38,
0
] | [
69,
51
] | python | en | ['en', 'da', 'en'] | True |
setup | (hass, config) | Set up the Ecovacs component. | Set up the Ecovacs component. | def setup(hass, config):
"""Set up the Ecovacs component."""
_LOGGER.debug("Creating new Ecovacs component")
hass.data[ECOVACS_DEVICES] = []
ecovacs_api = EcoVacsAPI(
ECOVACS_API_DEVICEID,
config[DOMAIN].get(CONF_USERNAME),
EcoVacsAPI.md5(config[DOMAIN].get(CONF_PASSWORD)),
... | [
"def",
"setup",
"(",
"hass",
",",
"config",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Creating new Ecovacs component\"",
")",
"hass",
".",
"data",
"[",
"ECOVACS_DEVICES",
"]",
"=",
"[",
"]",
"ecovacs_api",
"=",
"EcoVacsAPI",
"(",
"ECOVACS_API_DEVICEID",
",",
... | [
41,
0
] | [
90,
15
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up the Smarty Binary Sensor Platform. | Set up the Smarty Binary Sensor Platform. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the Smarty Binary Sensor Platform."""
smarty = hass.data[DOMAIN]["api"]
name = hass.data[DOMAIN]["name"]
sensors = [
AlarmSensor(name, smarty),
WarningSensor(name, smarty),
BoostSens... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"smarty",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"\"api\"",
"]",
"name",
"=",
"hass",
".",
"data",
"[... | [
16,
0
] | [
27,
37
] | python | en | ['en', 'pt', 'en'] | True |
SmartyBinarySensor.__init__ | (self, name, device_class, smarty) | Initialize the entity. | Initialize the entity. | def __init__(self, name, device_class, smarty):
"""Initialize the entity."""
self._name = name
self._state = None
self._sensor_type = device_class
self._smarty = smarty | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"device_class",
",",
"smarty",
")",
":",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"_state",
"=",
"None",
"self",
".",
"_sensor_type",
"=",
"device_class",
"self",
".",
"_smarty",
"=",
"smarty"
] | [
33,
4
] | [
38,
29
] | python | en | ['en', 'en', 'en'] | True |
SmartyBinarySensor.device_class | (self) | Return the class of the sensor. | Return the class of the sensor. | def device_class(self):
"""Return the class of the sensor."""
return self._sensor_type | [
"def",
"device_class",
"(",
"self",
")",
":",
"return",
"self",
".",
"_sensor_type"
] | [
41,
4
] | [
43,
32
] | python | en | ['en', 'pt', 'en'] | True |
SmartyBinarySensor.should_poll | (self) | Do not poll. | Do not poll. | def should_poll(self) -> bool:
"""Do not poll."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"False"
] | [
46,
4
] | [
48,
20
] | python | en | ['en', 'lb', 'en'] | True |
SmartyBinarySensor.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
51,
4
] | [
53,
25
] | python | en | ['en', 'mi', 'en'] | True |
SmartyBinarySensor.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._state | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
56,
4
] | [
58,
26
] | python | en | ['en', 'fy', 'en'] | True |
SmartyBinarySensor.async_added_to_hass | (self) | Call to update. | Call to update. | async def async_added_to_hass(self):
"""Call to update."""
async_dispatcher_connect(self.hass, SIGNAL_UPDATE_SMARTY, self._update_callback) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"async_dispatcher_connect",
"(",
"self",
".",
"hass",
",",
"SIGNAL_UPDATE_SMARTY",
",",
"self",
".",
"_update_callback",
")"
] | [
60,
4
] | [
62,
88
] | python | en | ['en', 'en', 'en'] | True |
SmartyBinarySensor._update_callback | (self) | Call update method. | Call update method. | def _update_callback(self):
"""Call update method."""
self.async_schedule_update_ha_state(True) | [
"def",
"_update_callback",
"(",
"self",
")",
":",
"self",
".",
"async_schedule_update_ha_state",
"(",
"True",
")"
] | [
65,
4
] | [
67,
49
] | python | en | ['en', 'sn', 'en'] | True |
BoostSensor.__init__ | (self, name, smarty) | Alarm Sensor Init. | Alarm Sensor Init. | def __init__(self, name, smarty):
"""Alarm Sensor Init."""
super().__init__(name=f"{name} Boost State", device_class=None, smarty=smarty) | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"smarty",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"name",
"=",
"f\"{name} Boost State\"",
",",
"device_class",
"=",
"None",
",",
"smarty",
"=",
"smarty",
")"
] | [
73,
4
] | [
75,
86
] | python | en | ['en', 'uz', 'it'] | False |
BoostSensor.update | (self) | Update state. | Update state. | def update(self) -> None:
"""Update state."""
_LOGGER.debug("Updating sensor %s", self._name)
self._state = self._smarty.boost | [
"def",
"update",
"(",
"self",
")",
"->",
"None",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Updating sensor %s\"",
",",
"self",
".",
"_name",
")",
"self",
".",
"_state",
"=",
"self",
".",
"_smarty",
".",
"boost"
] | [
77,
4
] | [
80,
40
] | python | en | ['en', 'co', 'en'] | False |
AlarmSensor.__init__ | (self, name, smarty) | Alarm Sensor Init. | Alarm Sensor Init. | def __init__(self, name, smarty):
"""Alarm Sensor Init."""
super().__init__(
name=f"{name} Alarm", device_class=DEVICE_CLASS_PROBLEM, smarty=smarty
) | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"smarty",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"name",
"=",
"f\"{name} Alarm\"",
",",
"device_class",
"=",
"DEVICE_CLASS_PROBLEM",
",",
"smarty",
"=",
"smarty",
")"
] | [
86,
4
] | [
90,
9
] | python | en | ['en', 'uz', 'it'] | False |
AlarmSensor.update | (self) | Update state. | Update state. | def update(self) -> None:
"""Update state."""
_LOGGER.debug("Updating sensor %s", self._name)
self._state = self._smarty.alarm | [
"def",
"update",
"(",
"self",
")",
"->",
"None",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Updating sensor %s\"",
",",
"self",
".",
"_name",
")",
"self",
".",
"_state",
"=",
"self",
".",
"_smarty",
".",
"alarm"
] | [
92,
4
] | [
95,
40
] | python | en | ['en', 'co', 'en'] | False |
WarningSensor.__init__ | (self, name, smarty) | Warning Sensor Init. | Warning Sensor Init. | def __init__(self, name, smarty):
"""Warning Sensor Init."""
super().__init__(
name=f"{name} Warning", device_class=DEVICE_CLASS_PROBLEM, smarty=smarty
) | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"smarty",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"name",
"=",
"f\"{name} Warning\"",
",",
"device_class",
"=",
"DEVICE_CLASS_PROBLEM",
",",
"smarty",
"=",
"smarty",
")"
] | [
101,
4
] | [
105,
9
] | python | en | ['en', 'uz', 'en'] | True |
WarningSensor.update | (self) | Update state. | Update state. | def update(self) -> None:
"""Update state."""
_LOGGER.debug("Updating sensor %s", self._name)
self._state = self._smarty.warning | [
"def",
"update",
"(",
"self",
")",
"->",
"None",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Updating sensor %s\"",
",",
"self",
".",
"_name",
")",
"self",
".",
"_state",
"=",
"self",
".",
"_smarty",
".",
"warning"
] | [
107,
4
] | [
110,
42
] | python | en | ['en', 'co', 'en'] | False |
test_setup_comp | (hass) | Set up demo component. | Set up demo component. | async def test_setup_comp(hass):
"""Set up demo component."""
assert await async_setup_component(hass, stt.DOMAIN, {"stt": {}}) | [
"async",
"def",
"test_setup_comp",
"(",
"hass",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"stt",
".",
"DOMAIN",
",",
"{",
"\"stt\"",
":",
"{",
"}",
"}",
")"
] | [
7,
0
] | [
9,
69
] | python | en | ['en', 'da', 'en'] | True |
test_demo_settings_not_exists | (hass, hass_client) | Test retrieve settings from demo provider. | Test retrieve settings from demo provider. | async def test_demo_settings_not_exists(hass, hass_client):
"""Test retrieve settings from demo provider."""
assert await async_setup_component(hass, stt.DOMAIN, {"stt": {}})
client = await hass_client()
response = await client.get("/api/stt/beer")
assert response.status == HTTP_NOT_FOUND | [
"async",
"def",
"test_demo_settings_not_exists",
"(",
"hass",
",",
"hass_client",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"stt",
".",
"DOMAIN",
",",
"{",
"\"stt\"",
":",
"{",
"}",
"}",
")",
"client",
"=",
"await",
"hass_client... | [
12,
0
] | [
19,
44
] | python | en | ['en', 'en', 'en'] | True |
test_demo_speech_not_exists | (hass, hass_client) | Test retrieve settings from demo provider. | Test retrieve settings from demo provider. | async def test_demo_speech_not_exists(hass, hass_client):
"""Test retrieve settings from demo provider."""
assert await async_setup_component(hass, stt.DOMAIN, {"stt": {}})
client = await hass_client()
response = await client.post("/api/stt/beer", data=b"test")
assert response.status == HTTP_NOT_F... | [
"async",
"def",
"test_demo_speech_not_exists",
"(",
"hass",
",",
"hass_client",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"stt",
".",
"DOMAIN",
",",
"{",
"\"stt\"",
":",
"{",
"}",
"}",
")",
"client",
"=",
"await",
"hass_client",... | [
22,
0
] | [
29,
44
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the ThinkingCleaner platform. | Set up the ThinkingCleaner platform. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the ThinkingCleaner platform."""
host = config.get(CONF_HOST)
if host:
devices = [ThinkingCleaner(host, "unknown")]
else:
discovery = Discovery()
devices = discovery.discover()
@util.Throttle(MIN... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"host",
"=",
"config",
".",
"get",
"(",
"CONF_HOST",
")",
"if",
"host",
":",
"devices",
"=",
"[",
"ThinkingCleaner",
"(",
"host",
",",... | [
51,
0
] | [
72,
21
] | python | en | ['en', 'zu', 'en'] | True |
ThinkingCleanerSensor.__init__ | (self, tc_object, sensor_type, update_devices) | Initialize the ThinkingCleaner. | Initialize the ThinkingCleaner. | def __init__(self, tc_object, sensor_type, update_devices):
"""Initialize the ThinkingCleaner."""
self.type = sensor_type
self._tc_object = tc_object
self._update_devices = update_devices
self._unit_of_measurement = SENSOR_TYPES[sensor_type][1]
self._state = None | [
"def",
"__init__",
"(",
"self",
",",
"tc_object",
",",
"sensor_type",
",",
"update_devices",
")",
":",
"self",
".",
"type",
"=",
"sensor_type",
"self",
".",
"_tc_object",
"=",
"tc_object",
"self",
".",
"_update_devices",
"=",
"update_devices",
"self",
".",
"... | [
78,
4
] | [
85,
26
] | python | en | ['en', 'en', 'en'] | True |
ThinkingCleanerSensor.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
return "{} {}".format(self._tc_object.name, SENSOR_TYPES[self.type][0]) | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"\"{} {}\"",
".",
"format",
"(",
"self",
".",
"_tc_object",
".",
"name",
",",
"SENSOR_TYPES",
"[",
"self",
".",
"type",
"]",
"[",
"0",
"]",
")"
] | [
88,
4
] | [
90,
79
] | python | en | ['en', 'mi', 'en'] | True |
ThinkingCleanerSensor.icon | (self) | Icon to use in the frontend, if any. | Icon to use in the frontend, if any. | def icon(self):
"""Icon to use in the frontend, if any."""
return SENSOR_TYPES[self.type][2] | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"SENSOR_TYPES",
"[",
"self",
".",
"type",
"]",
"[",
"2",
"]"
] | [
93,
4
] | [
95,
41
] | python | en | ['en', 'en', 'en'] | True |
ThinkingCleanerSensor.state | (self) | Return the state of the device. | Return the state of the device. | def state(self):
"""Return the state of the device."""
return self._state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
98,
4
] | [
100,
26
] | python | en | ['en', 'en', 'en'] | True |
ThinkingCleanerSensor.unit_of_measurement | (self) | Return the unit of measurement of this entity, if any. | Return the unit of measurement of this entity, if any. | def unit_of_measurement(self):
"""Return the unit of measurement of this entity, if any."""
return self._unit_of_measurement | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unit_of_measurement"
] | [
103,
4
] | [
105,
40
] | python | en | ['en', 'en', 'en'] | True |
ThinkingCleanerSensor.update | (self) | Update the sensor. | Update the sensor. | def update(self):
"""Update the sensor."""
self._update_devices()
if self.type == "battery":
self._state = self._tc_object.battery
elif self.type == "state":
self._state = STATES[self._tc_object.status]
elif self.type == "capacity":
self._stat... | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"_update_devices",
"(",
")",
"if",
"self",
".",
"type",
"==",
"\"battery\"",
":",
"self",
".",
"_state",
"=",
"self",
".",
"_tc_object",
".",
"battery",
"elif",
"self",
".",
"type",
"==",
"\"state\""... | [
107,
4
] | [
116,
50
] | python | en | ['en', 'nl', 'en'] | True |
mock_camera_fixture | (hass) | Initialize a demo camera platform. | Initialize a demo camera platform. | async def mock_camera_fixture(hass):
"""Initialize a demo camera platform."""
assert await async_setup_component(
hass, "camera", {camera.DOMAIN: {"platform": "demo"}}
)
await hass.async_block_till_done()
with patch(
"homeassistant.components.demo.camera.Path.read_bytes",
re... | [
"async",
"def",
"mock_camera_fixture",
"(",
"hass",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"camera\"",
",",
"{",
"camera",
".",
"DOMAIN",
":",
"{",
"\"platform\"",
":",
"\"demo\"",
"}",
"}",
")",
"await",
"hass",
".",
"as... | [
21,
0
] | [
32,
13
] | python | en | ['es', 'pt', 'en'] | False |
mock_stream_fixture | (hass) | Initialize a demo camera platform with streaming. | Initialize a demo camera platform with streaming. | def mock_stream_fixture(hass):
"""Initialize a demo camera platform with streaming."""
assert hass.loop.run_until_complete(
async_setup_component(hass, "stream", {"stream": {}})
) | [
"def",
"mock_stream_fixture",
"(",
"hass",
")",
":",
"assert",
"hass",
".",
"loop",
".",
"run_until_complete",
"(",
"async_setup_component",
"(",
"hass",
",",
"\"stream\"",
",",
"{",
"\"stream\"",
":",
"{",
"}",
"}",
")",
")"
] | [
36,
0
] | [
40,
5
] | python | en | ['en', 'en', 'en'] | True |
setup_camera_prefs_fixture | (hass) | Initialize HTTP API. | Initialize HTTP API. | def setup_camera_prefs_fixture(hass):
"""Initialize HTTP API."""
return common.mock_camera_prefs(hass, "camera.demo_camera") | [
"def",
"setup_camera_prefs_fixture",
"(",
"hass",
")",
":",
"return",
"common",
".",
"mock_camera_prefs",
"(",
"hass",
",",
"\"camera.demo_camera\"",
")"
] | [
44,
0
] | [
46,
63
] | python | en | ['en', 'en', 'it'] | True |
image_mock_url_fixture | (hass) | Fixture for get_image tests. | Fixture for get_image tests. | async def image_mock_url_fixture(hass):
"""Fixture for get_image tests."""
await async_setup_component(
hass, camera.DOMAIN, {camera.DOMAIN: {"platform": "demo"}}
)
await hass.async_block_till_done() | [
"async",
"def",
"image_mock_url_fixture",
"(",
"hass",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"camera",
".",
"DOMAIN",
",",
"{",
"camera",
".",
"DOMAIN",
":",
"{",
"\"platform\"",
":",
"\"demo\"",
"}",
"}",
")",
"await",
"hass",
".",... | [
50,
0
] | [
55,
38
] | python | en | ['da', 'en', 'en'] | True |
test_get_image_from_camera | (hass, image_mock_url) | Grab an image from camera entity. | Grab an image from camera entity. | async def test_get_image_from_camera(hass, image_mock_url):
"""Grab an image from camera entity."""
with patch(
"homeassistant.components.demo.camera.Path.read_bytes",
autospec=True,
return_value=b"Test",
) as mock_camera:
image = await camera.async_get_image(hass, "camera.d... | [
"async",
"def",
"test_get_image_from_camera",
"(",
"hass",
",",
"image_mock_url",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.demo.camera.Path.read_bytes\"",
",",
"autospec",
"=",
"True",
",",
"return_value",
"=",
"b\"Test\"",
",",
")",
"as",
"mock_cam... | [
58,
0
] | [
69,
35
] | python | en | ['en', 'en', 'en'] | True |
test_get_stream_source_from_camera | (hass, mock_camera) | Fetch stream source from camera entity. | Fetch stream source from camera entity. | async def test_get_stream_source_from_camera(hass, mock_camera):
"""Fetch stream source from camera entity."""
with patch(
"homeassistant.components.camera.Camera.stream_source",
return_value="rtsp://127.0.0.1/stream",
) as mock_camera_stream_source:
stream_source = await camera.asy... | [
"async",
"def",
"test_get_stream_source_from_camera",
"(",
"hass",
",",
"mock_camera",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.camera.Camera.stream_source\"",
",",
"return_value",
"=",
"\"rtsp://127.0.0.1/stream\"",
",",
")",
"as",
"mock_camera_stream_sour... | [
72,
0
] | [
82,
53
] | python | en | ['en', 'en', 'en'] | True |
test_get_image_without_exists_camera | (hass, image_mock_url) | Try to get image without exists camera. | Try to get image without exists camera. | async def test_get_image_without_exists_camera(hass, image_mock_url):
"""Try to get image without exists camera."""
with patch(
"homeassistant.helpers.entity_component.EntityComponent.get_entity",
return_value=None,
), pytest.raises(HomeAssistantError):
await camera.async_get_image(h... | [
"async",
"def",
"test_get_image_without_exists_camera",
"(",
"hass",
",",
"image_mock_url",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.helpers.entity_component.EntityComponent.get_entity\"",
",",
"return_value",
"=",
"None",
",",
")",
",",
"pytest",
".",
"raises",
... | [
85,
0
] | [
91,
64
] | python | en | ['en', 'en', 'en'] | True |
test_get_image_with_timeout | (hass, image_mock_url) | Try to get image with timeout. | Try to get image with timeout. | async def test_get_image_with_timeout(hass, image_mock_url):
"""Try to get image with timeout."""
with patch(
"homeassistant.components.demo.camera.DemoCamera.async_camera_image",
side_effect=asyncio.TimeoutError,
), pytest.raises(HomeAssistantError):
await camera.async_get_image(has... | [
"async",
"def",
"test_get_image_with_timeout",
"(",
"hass",
",",
"image_mock_url",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.demo.camera.DemoCamera.async_camera_image\"",
",",
"side_effect",
"=",
"asyncio",
".",
"TimeoutError",
",",
")",
",",
"pytest",
... | [
94,
0
] | [
100,
64
] | python | en | ['en', 'en', 'en'] | True |
test_get_image_fails | (hass, image_mock_url) | Try to get image with timeout. | Try to get image with timeout. | async def test_get_image_fails(hass, image_mock_url):
"""Try to get image with timeout."""
with patch(
"homeassistant.components.demo.camera.DemoCamera.async_camera_image",
return_value=None,
), pytest.raises(HomeAssistantError):
await camera.async_get_image(hass, "camera.demo_camera... | [
"async",
"def",
"test_get_image_fails",
"(",
"hass",
",",
"image_mock_url",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.demo.camera.DemoCamera.async_camera_image\"",
",",
"return_value",
"=",
"None",
",",
")",
",",
"pytest",
".",
"raises",
"(",
"HomeAs... | [
103,
0
] | [
109,
64
] | python | en | ['en', 'en', 'en'] | True |
test_snapshot_service | (hass, mock_camera) | Test snapshot service. | Test snapshot service. | async def test_snapshot_service(hass, mock_camera):
"""Test snapshot service."""
mopen = mock_open()
with patch("homeassistant.components.camera.open", mopen, create=True), patch(
"homeassistant.components.camera.os.path.exists",
Mock(spec="os.path.exists", return_value=True),
), patch.... | [
"async",
"def",
"test_snapshot_service",
"(",
"hass",
",",
"mock_camera",
")",
":",
"mopen",
"=",
"mock_open",
"(",
")",
"with",
"patch",
"(",
"\"homeassistant.components.camera.open\"",
",",
"mopen",
",",
"create",
"=",
"True",
")",
",",
"patch",
"(",
"\"home... | [
112,
0
] | [
133,
56
] | python | en | ['en', 'de', 'en'] | True |
test_websocket_camera_thumbnail | (hass, hass_ws_client, mock_camera) | Test camera_thumbnail websocket command. | Test camera_thumbnail websocket command. | async def test_websocket_camera_thumbnail(hass, hass_ws_client, mock_camera):
"""Test camera_thumbnail websocket command."""
await async_setup_component(hass, "camera", {})
client = await hass_ws_client(hass)
await client.send_json(
{"id": 5, "type": "camera_thumbnail", "entity_id": "camera.dem... | [
"async",
"def",
"test_websocket_camera_thumbnail",
"(",
"hass",
",",
"hass_ws_client",
",",
"mock_camera",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"camera\"",
",",
"{",
"}",
")",
"client",
"=",
"await",
"hass_ws_client",
"(",
"hass",
")",... | [
136,
0
] | [
151,
80
] | python | en | ['en', 'hu', 'sw'] | False |
test_websocket_stream_no_source | (
hass, hass_ws_client, mock_camera, mock_stream
) | Test camera/stream websocket command. | Test camera/stream websocket command. | async def test_websocket_stream_no_source(
hass, hass_ws_client, mock_camera, mock_stream
):
"""Test camera/stream websocket command."""
await async_setup_component(hass, "camera", {})
with patch(
"homeassistant.components.camera.request_stream",
return_value="http://home.assistant/play... | [
"async",
"def",
"test_websocket_stream_no_source",
"(",
"hass",
",",
"hass_ws_client",
",",
"mock_camera",
",",
"mock_stream",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"camera\"",
",",
"{",
"}",
")",
"with",
"patch",
"(",
"\"homeassistant.co... | [
154,
0
] | [
175,
33
] | python | en | ['en', 'sv', 'en'] | True |
test_websocket_camera_stream | (hass, hass_ws_client, mock_camera, mock_stream) | Test camera/stream websocket command. | Test camera/stream websocket command. | async def test_websocket_camera_stream(hass, hass_ws_client, mock_camera, mock_stream):
"""Test camera/stream websocket command."""
await async_setup_component(hass, "camera", {})
with patch(
"homeassistant.components.camera.request_stream",
return_value="http://home.assistant/playlist.m3u8... | [
"async",
"def",
"test_websocket_camera_stream",
"(",
"hass",
",",
"hass_ws_client",
",",
"mock_camera",
",",
"mock_stream",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"camera\"",
",",
"{",
"}",
")",
"with",
"patch",
"(",
"\"homeassistant.compo... | [
178,
0
] | [
201,
60
] | python | en | ['en', 'sv', 'en'] | True |
test_websocket_get_prefs | (hass, hass_ws_client, mock_camera) | Test get camera preferences websocket command. | Test get camera preferences websocket command. | async def test_websocket_get_prefs(hass, hass_ws_client, mock_camera):
"""Test get camera preferences websocket command."""
await async_setup_component(hass, "camera", {})
# Request preferences through websocket
client = await hass_ws_client(hass)
await client.send_json(
{"id": 7, "type": "... | [
"async",
"def",
"test_websocket_get_prefs",
"(",
"hass",
",",
"hass_ws_client",
",",
"mock_camera",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"camera\"",
",",
"{",
"}",
")",
"# Request preferences through websocket",
"client",
"=",
"await",
"ha... | [
204,
0
] | [
216,
25
] | python | da | ['nl', 'da', 'en'] | False |
test_websocket_update_prefs | (
hass, hass_ws_client, mock_camera, setup_camera_prefs
) | Test updating preference. | Test updating preference. | async def test_websocket_update_prefs(
hass, hass_ws_client, mock_camera, setup_camera_prefs
):
"""Test updating preference."""
await async_setup_component(hass, "camera", {})
assert setup_camera_prefs[PREF_PRELOAD_STREAM]
client = await hass_ws_client(hass)
await client.send_json(
{
... | [
"async",
"def",
"test_websocket_update_prefs",
"(",
"hass",
",",
"hass_ws_client",
",",
"mock_camera",
",",
"setup_camera_prefs",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"camera\"",
",",
"{",
"}",
")",
"assert",
"setup_camera_prefs",
"[",
"... | [
219,
0
] | [
241,
5
] | python | en | ['en', 'en', 'en'] | True |
test_play_stream_service_no_source | (hass, mock_camera, mock_stream) | Test camera play_stream service. | Test camera play_stream service. | async def test_play_stream_service_no_source(hass, mock_camera, mock_stream):
"""Test camera play_stream service."""
data = {
ATTR_ENTITY_ID: "camera.demo_camera",
camera.ATTR_MEDIA_PLAYER: "media_player.test",
}
with patch("homeassistant.components.camera.request_stream"), pytest.raises... | [
"async",
"def",
"test_play_stream_service_no_source",
"(",
"hass",
",",
"mock_camera",
",",
"mock_stream",
")",
":",
"data",
"=",
"{",
"ATTR_ENTITY_ID",
":",
"\"camera.demo_camera\"",
",",
"camera",
".",
"ATTR_MEDIA_PLAYER",
":",
"\"media_player.test\"",
",",
"}",
"... | [
244,
0
] | [
256,
9
] | python | en | ['es', 'zh', 'en'] | False |
test_handle_play_stream_service | (hass, mock_camera, mock_stream) | Test camera play_stream service. | Test camera play_stream service. | async def test_handle_play_stream_service(hass, mock_camera, mock_stream):
"""Test camera play_stream service."""
await async_process_ha_core_config(
hass,
{"external_url": "https://example.com"},
)
await async_setup_component(hass, "media_player", {})
with patch(
"homeassist... | [
"async",
"def",
"test_handle_play_stream_service",
"(",
"hass",
",",
"mock_camera",
",",
"mock_stream",
")",
":",
"await",
"async_process_ha_core_config",
"(",
"hass",
",",
"{",
"\"external_url\"",
":",
"\"https://example.com\"",
"}",
",",
")",
"await",
"async_setup_c... | [
259,
0
] | [
284,
41
] | python | en | ['es', 'zh', 'en'] | False |
test_no_preload_stream | (hass, mock_stream) | Test camera preload preference. | Test camera preload preference. | async def test_no_preload_stream(hass, mock_stream):
"""Test camera preload preference."""
demo_prefs = CameraEntityPreferences({PREF_PRELOAD_STREAM: False})
with patch(
"homeassistant.components.camera.request_stream"
) as mock_request_stream, patch(
"homeassistant.components.camera.pre... | [
"async",
"def",
"test_no_preload_stream",
"(",
"hass",
",",
"mock_stream",
")",
":",
"demo_prefs",
"=",
"CameraEntityPreferences",
"(",
"{",
"PREF_PRELOAD_STREAM",
":",
"False",
"}",
")",
"with",
"patch",
"(",
"\"homeassistant.components.camera.request_stream\"",
")",
... | [
287,
0
] | [
303,
45
] | python | en | ['es', 'sl', 'en'] | False |
test_preload_stream | (hass, mock_stream) | Test camera preload preference. | Test camera preload preference. | async def test_preload_stream(hass, mock_stream):
"""Test camera preload preference."""
demo_prefs = CameraEntityPreferences({PREF_PRELOAD_STREAM: True})
with patch(
"homeassistant.components.camera.request_stream"
) as mock_request_stream, patch(
"homeassistant.components.camera.prefs.C... | [
"async",
"def",
"test_preload_stream",
"(",
"hass",
",",
"mock_stream",
")",
":",
"demo_prefs",
"=",
"CameraEntityPreferences",
"(",
"{",
"PREF_PRELOAD_STREAM",
":",
"True",
"}",
")",
"with",
"patch",
"(",
"\"homeassistant.components.camera.request_stream\"",
")",
"as... | [
306,
0
] | [
324,
41
] | python | en | ['es', 'sl', 'en'] | False |
test_record_service_invalid_path | (hass, mock_camera) | Test record service with invalid path. | Test record service with invalid path. | async def test_record_service_invalid_path(hass, mock_camera):
"""Test record service with invalid path."""
with patch.object(
hass.config, "is_allowed_path", return_value=False
), pytest.raises(HomeAssistantError):
# Call service
await hass.services.async_call(
camera.DO... | [
"async",
"def",
"test_record_service_invalid_path",
"(",
"hass",
",",
"mock_camera",
")",
":",
"with",
"patch",
".",
"object",
"(",
"hass",
".",
"config",
",",
"\"is_allowed_path\"",
",",
"return_value",
"=",
"False",
")",
",",
"pytest",
".",
"raises",
"(",
... | [
327,
0
] | [
341,
9
] | python | en | ['en', 'en', 'en'] | True |
test_record_service | (hass, mock_camera, mock_stream) | Test record service. | Test record service. | async def test_record_service(hass, mock_camera, mock_stream):
"""Test record service."""
with patch(
"homeassistant.components.demo.camera.DemoCamera.stream_source",
return_value="http://example.com",
), patch(
"homeassistant.components.stream.async_handle_record_service",
) as ... | [
"async",
"def",
"test_record_service",
"(",
"hass",
",",
"mock_camera",
",",
"mock_stream",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.demo.camera.DemoCamera.stream_source\"",
",",
"return_value",
"=",
"\"http://example.com\"",
",",
")",
",",
"patch",
"... | [
344,
0
] | [
363,
41
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up Tasmota sensor dynamically through discovery. | Set up Tasmota sensor dynamically through discovery. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up Tasmota sensor dynamically through discovery."""
async def async_discover_sensor(tasmota_entity, discovery_hash):
"""Discover and add a Tasmota sensor."""
async_add_entities(
[
TasmotaSens... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"async",
"def",
"async_discover_sensor",
"(",
"tasmota_entity",
",",
"discovery_hash",
")",
":",
"\"\"\"Discover and add a Tasmota sensor.\"\"\"",
"async_add_entities... | [
194,
0
] | [
213,
5
] | python | en | ['en', 'pt', 'en'] | True |
TasmotaSensor.__init__ | (self, **kwds) | Initialize the Tasmota sensor. | Initialize the Tasmota sensor. | def __init__(self, **kwds):
"""Initialize the Tasmota sensor."""
self._state = None
super().__init__(
discovery_update=self.discovery_update,
**kwds,
) | [
"def",
"__init__",
"(",
"self",
",",
"*",
"*",
"kwds",
")",
":",
"self",
".",
"_state",
"=",
"None",
"super",
"(",
")",
".",
"__init__",
"(",
"discovery_update",
"=",
"self",
".",
"discovery_update",
",",
"*",
"*",
"kwds",
",",
")"
] | [
219,
4
] | [
226,
9
] | python | en | ['en', 'sq', 'en'] | True |
TasmotaSensor.state_updated | (self, state, **kwargs) | Handle state updates. | Handle state updates. | def state_updated(self, state, **kwargs):
"""Handle state updates."""
self._state = state
self.async_write_ha_state() | [
"def",
"state_updated",
"(",
"self",
",",
"state",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_state",
"=",
"state",
"self",
".",
"async_write_ha_state",
"(",
")"
] | [
229,
4
] | [
232,
35
] | python | en | ['en', 'en', 'en'] | True |
TasmotaSensor.device_class | (self) | Return the device class of the sensor. | Return the device class of the sensor. | def device_class(self) -> Optional[str]:
"""Return the device class of the sensor."""
class_or_icon = SENSOR_DEVICE_CLASS_ICON_MAP.get(
self._tasmota_entity.quantity, {}
)
return class_or_icon.get(DEVICE_CLASS) | [
"def",
"device_class",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"class_or_icon",
"=",
"SENSOR_DEVICE_CLASS_ICON_MAP",
".",
"get",
"(",
"self",
".",
"_tasmota_entity",
".",
"quantity",
",",
"{",
"}",
")",
"return",
"class_or_icon",
".",
"get"... | [
235,
4
] | [
240,
46
] | python | en | ['en', 'en', 'en'] | True |
TasmotaSensor.entity_registry_enabled_default | (self) | Return if the entity should be enabled when first added to the entity registry. | Return if the entity should be enabled when first added to the entity registry. | def entity_registry_enabled_default(self) -> bool:
"""Return if the entity should be enabled when first added to the entity registry."""
# Hide status sensors to not overwhelm users
if self._tasmota_entity.quantity in status_sensor.SENSORS:
return False
return True | [
"def",
"entity_registry_enabled_default",
"(",
"self",
")",
"->",
"bool",
":",
"# Hide status sensors to not overwhelm users",
"if",
"self",
".",
"_tasmota_entity",
".",
"quantity",
"in",
"status_sensor",
".",
"SENSORS",
":",
"return",
"False",
"return",
"True"
] | [
243,
4
] | [
248,
19
] | python | en | ['en', 'en', 'en'] | True |
TasmotaSensor.icon | (self) | Return the icon. | Return the icon. | def icon(self):
"""Return the icon."""
class_or_icon = SENSOR_DEVICE_CLASS_ICON_MAP.get(
self._tasmota_entity.quantity, {}
)
return class_or_icon.get(ICON) | [
"def",
"icon",
"(",
"self",
")",
":",
"class_or_icon",
"=",
"SENSOR_DEVICE_CLASS_ICON_MAP",
".",
"get",
"(",
"self",
".",
"_tasmota_entity",
".",
"quantity",
",",
"{",
"}",
")",
"return",
"class_or_icon",
".",
"get",
"(",
"ICON",
")"
] | [
251,
4
] | [
256,
38
] | python | en | ['en', 'sr', 'en'] | True |
TasmotaSensor.state | (self) | Return the state of the entity. | Return the state of the entity. | def state(self):
"""Return the state of the entity."""
if self._state and self.device_class == DEVICE_CLASS_TIMESTAMP:
return self._state.isoformat()
return self._state | [
"def",
"state",
"(",
"self",
")",
":",
"if",
"self",
".",
"_state",
"and",
"self",
".",
"device_class",
"==",
"DEVICE_CLASS_TIMESTAMP",
":",
"return",
"self",
".",
"_state",
".",
"isoformat",
"(",
")",
"return",
"self",
".",
"_state"
] | [
259,
4
] | [
263,
26
] | python | en | ['en', 'en', 'en'] | True |
TasmotaSensor.unit_of_measurement | (self) | Return the unit this state is expressed in. | Return the unit this state is expressed in. | def unit_of_measurement(self):
"""Return the unit this state is expressed in."""
return SENSOR_UNIT_MAP.get(self._tasmota_entity.unit, self._tasmota_entity.unit) | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"SENSOR_UNIT_MAP",
".",
"get",
"(",
"self",
".",
"_tasmota_entity",
".",
"unit",
",",
"self",
".",
"_tasmota_entity",
".",
"unit",
")"
] | [
266,
4
] | [
268,
88
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up SmartHab lights from a config entry. | Set up SmartHab lights from a config entry. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up SmartHab lights from a config entry."""
hub = hass.data[DOMAIN][config_entry.entry_id][DATA_HUB]
entities = (
SmartHabLight(light)
for light in await hub.async_get_device_list()
if isinstance(light, pysma... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"hub",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"config_entry",
".",
"entry_id",
"]",
"[",
"DATA_HUB",
"]",
"entities",
"=",
"(",
"SmartHa... | [
16,
0
] | [
26,
38
] | python | en | ['en', 'en', 'en'] | True |
SmartHabLight.__init__ | (self, light) | Initialize a SmartHabLight. | Initialize a SmartHabLight. | def __init__(self, light):
"""Initialize a SmartHabLight."""
self._light = light | [
"def",
"__init__",
"(",
"self",
",",
"light",
")",
":",
"self",
".",
"_light",
"=",
"light"
] | [
32,
4
] | [
34,
27
] | python | en | ['en', 'en', 'en'] | True |
SmartHabLight.unique_id | (self) | Return a unique ID. | Return a unique ID. | def unique_id(self) -> str:
"""Return a unique ID."""
return self._light.device_id | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_light",
".",
"device_id"
] | [
37,
4
] | [
39,
36
] | python | ca | ['fr', 'ca', 'en'] | False |
SmartHabLight.name | (self) | Return the display name of this light. | Return the display name of this light. | def name(self) -> str:
"""Return the display name of this light."""
return self._light.label | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_light",
".",
"label"
] | [
42,
4
] | [
44,
32
] | python | en | ['en', 'en', 'en'] | True |
SmartHabLight.is_on | (self) | Return true if light is on. | Return true if light is on. | def is_on(self) -> bool:
"""Return true if light is on."""
return self._light.state | [
"def",
"is_on",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"_light",
".",
"state"
] | [
47,
4
] | [
49,
32
] | python | en | ['en', 'et', 'en'] | True |
SmartHabLight.async_turn_on | (self, **kwargs) | Instruct the light to turn on. | Instruct the light to turn on. | async def async_turn_on(self, **kwargs):
"""Instruct the light to turn on."""
await self._light.async_turn_on() | [
"async",
"def",
"async_turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"_light",
".",
"async_turn_on",
"(",
")"
] | [
51,
4
] | [
53,
41
] | python | en | ['en', 'en', 'en'] | True |
SmartHabLight.async_turn_off | (self, **kwargs) | Instruct the light to turn off. | Instruct the light to turn off. | async def async_turn_off(self, **kwargs):
"""Instruct the light to turn off."""
await self._light.async_turn_off() | [
"async",
"def",
"async_turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"_light",
".",
"async_turn_off",
"(",
")"
] | [
55,
4
] | [
57,
42
] | python | en | ['en', 'en', 'en'] | True |
SmartHabLight.async_update | (self) | Fetch new state data for this light. | Fetch new state data for this light. | async def async_update(self):
"""Fetch new state data for this light."""
try:
await self._light.async_update()
except Timeout:
_LOGGER.error(
"Reached timeout while updating light %s from API", self.entity_id
) | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"try",
":",
"await",
"self",
".",
"_light",
".",
"async_update",
"(",
")",
"except",
"Timeout",
":",
"_LOGGER",
".",
"error",
"(",
"\"Reached timeout while updating light %s from API\"",
",",
"self",
".",
... | [
59,
4
] | [
66,
13
] | python | en | ['en', 'en', 'en'] | True |
test_deprecated_base_class | (caplog) | Test deprecated base class. | Test deprecated base class. | def test_deprecated_base_class(caplog):
"""Test deprecated base class."""
class CustomWaterHeater(water_heater.WaterHeaterDevice):
pass
CustomWaterHeater()
assert "WaterHeaterDevice is deprecated, modify CustomWaterHeater" in caplog.text | [
"def",
"test_deprecated_base_class",
"(",
"caplog",
")",
":",
"class",
"CustomWaterHeater",
"(",
"water_heater",
".",
"WaterHeaterDevice",
")",
":",
"pass",
"CustomWaterHeater",
"(",
")",
"assert",
"\"WaterHeaterDevice is deprecated, modify CustomWaterHeater\"",
"in",
"capl... | [
4,
0
] | [
11,
85
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up the Shark IQ vacuum cleaner. | Set up the Shark IQ vacuum cleaner. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up the Shark IQ vacuum cleaner."""
coordinator: SharkIqUpdateCoordinator = hass.data[DOMAIN][config_entry.entry_id]
devices: Iterable["SharkIqVacuum"] = coordinator.shark_vacs.values()
device_names = [d.name for d in devices]
... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"coordinator",
":",
"SharkIqUpdateCoordinator",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"config_entry",
".",
"entry_id",
"]",
"devices",
":",
... | [
68,
0
] | [
78,
76
] | python | en | ['en', 'bg', 'en'] | True |
SharkVacuumEntity.__init__ | (self, sharkiq: SharkIqVacuum, coordinator: SharkIqUpdateCoordinator) | Create a new SharkVacuumEntity. | Create a new SharkVacuumEntity. | def __init__(self, sharkiq: SharkIqVacuum, coordinator: SharkIqUpdateCoordinator):
"""Create a new SharkVacuumEntity."""
super().__init__(coordinator)
self.sharkiq = sharkiq | [
"def",
"__init__",
"(",
"self",
",",
"sharkiq",
":",
"SharkIqVacuum",
",",
"coordinator",
":",
"SharkIqUpdateCoordinator",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"coordinator",
")",
"self",
".",
"sharkiq",
"=",
"sharkiq"
] | [
84,
4
] | [
87,
30
] | python | en | ['en', 'en', 'en'] | True |
SharkVacuumEntity.clean_spot | (self, **kwargs) | Clean a spot. Not yet implemented. | Clean a spot. Not yet implemented. | def clean_spot(self, **kwargs):
"""Clean a spot. Not yet implemented."""
raise NotImplementedError() | [
"def",
"clean_spot",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"raise",
"NotImplementedError",
"(",
")"
] | [
89,
4
] | [
91,
35
] | python | en | ['en', 'en', 'en'] | True |
SharkVacuumEntity.send_command | (self, command, params=None, **kwargs) | Send a command to the vacuum. Not yet implemented. | Send a command to the vacuum. Not yet implemented. | def send_command(self, command, params=None, **kwargs):
"""Send a command to the vacuum. Not yet implemented."""
raise NotImplementedError() | [
"def",
"send_command",
"(",
"self",
",",
"command",
",",
"params",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"raise",
"NotImplementedError",
"(",
")"
] | [
93,
4
] | [
95,
35
] | python | en | ['en', 'en', 'en'] | True |
SharkVacuumEntity.is_online | (self) | Tell us if the device is online. | Tell us if the device is online. | def is_online(self) -> bool:
"""Tell us if the device is online."""
return self.coordinator.device_is_online(self.sharkiq.serial_number) | [
"def",
"is_online",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"coordinator",
".",
"device_is_online",
"(",
"self",
".",
"sharkiq",
".",
"serial_number",
")"
] | [
98,
4
] | [
100,
76
] | python | en | ['en', 'en', 'en'] | True |
SharkVacuumEntity.name | (self) | Device name. | Device name. | def name(self) -> str:
"""Device name."""
return self.sharkiq.name | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"sharkiq",
".",
"name"
] | [
103,
4
] | [
105,
32
] | python | en | ['en', 'en', 'en'] | False |
SharkVacuumEntity.serial_number | (self) | Vacuum API serial number (DSN). | Vacuum API serial number (DSN). | def serial_number(self) -> str:
"""Vacuum API serial number (DSN)."""
return self.sharkiq.serial_number | [
"def",
"serial_number",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"sharkiq",
".",
"serial_number"
] | [
108,
4
] | [
110,
41
] | python | de | ['de', 'id', 'en'] | False |
SharkVacuumEntity.model | (self) | Vacuum model number. | Vacuum model number. | def model(self) -> str:
"""Vacuum model number."""
if self.sharkiq.vac_model_number:
return self.sharkiq.vac_model_number
return self.sharkiq.oem_model_number | [
"def",
"model",
"(",
"self",
")",
"->",
"str",
":",
"if",
"self",
".",
"sharkiq",
".",
"vac_model_number",
":",
"return",
"self",
".",
"sharkiq",
".",
"vac_model_number",
"return",
"self",
".",
"sharkiq",
".",
"oem_model_number"
] | [
113,
4
] | [
117,
44
] | python | en | ['et', 'la', 'en'] | False |
SharkVacuumEntity.device_info | (self) | Device info dictionary. | Device info dictionary. | def device_info(self) -> Dict:
"""Device info dictionary."""
return {
"identifiers": {(DOMAIN, self.serial_number)},
"name": self.name,
"manufacturer": SHARK,
"model": self.model,
"sw_version": self.sharkiq.get_property_value(
P... | [
"def",
"device_info",
"(",
"self",
")",
"->",
"Dict",
":",
"return",
"{",
"\"identifiers\"",
":",
"{",
"(",
"DOMAIN",
",",
"self",
".",
"serial_number",
")",
"}",
",",
"\"name\"",
":",
"self",
".",
"name",
",",
"\"manufacturer\"",
":",
"SHARK",
",",
"\... | [
120,
4
] | [
130,
9
] | python | it | ['it', 'en', 'it'] | True |
SharkVacuumEntity.supported_features | (self) | Flag vacuum cleaner robot features that are supported. | Flag vacuum cleaner robot features that are supported. | def supported_features(self) -> int:
"""Flag vacuum cleaner robot features that are supported."""
return SUPPORT_SHARKIQ | [
"def",
"supported_features",
"(",
"self",
")",
"->",
"int",
":",
"return",
"SUPPORT_SHARKIQ"
] | [
133,
4
] | [
135,
30
] | python | en | ['en', 'en', 'en'] | True |
SharkVacuumEntity.is_docked | (self) | Is vacuum docked. | Is vacuum docked. | def is_docked(self) -> Optional[bool]:
"""Is vacuum docked."""
return self.sharkiq.get_property_value(Properties.DOCKED_STATUS) | [
"def",
"is_docked",
"(",
"self",
")",
"->",
"Optional",
"[",
"bool",
"]",
":",
"return",
"self",
".",
"sharkiq",
".",
"get_property_value",
"(",
"Properties",
".",
"DOCKED_STATUS",
")"
] | [
138,
4
] | [
140,
72
] | python | af | ['de', 'af', 'en'] | False |
SharkVacuumEntity.error_code | (self) | Return the last observed error code (or None). | Return the last observed error code (or None). | def error_code(self) -> Optional[int]:
"""Return the last observed error code (or None)."""
return self.sharkiq.error_code | [
"def",
"error_code",
"(",
"self",
")",
"->",
"Optional",
"[",
"int",
"]",
":",
"return",
"self",
".",
"sharkiq",
".",
"error_code"
] | [
143,
4
] | [
145,
38
] | python | en | ['en', 'en', 'en'] | True |
SharkVacuumEntity.error_message | (self) | Return the last observed error message (or None). | Return the last observed error message (or None). | def error_message(self) -> Optional[str]:
"""Return the last observed error message (or None)."""
if not self.error_code:
return None
return self.sharkiq.error_text | [
"def",
"error_message",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"if",
"not",
"self",
".",
"error_code",
":",
"return",
"None",
"return",
"self",
".",
"sharkiq",
".",
"error_text"
] | [
148,
4
] | [
152,
38
] | python | en | ['en', 'en', 'en'] | True |
SharkVacuumEntity.operating_mode | (self) | Operating mode.. | Operating mode.. | def operating_mode(self) -> Optional[str]:
"""Operating mode.."""
op_mode = self.sharkiq.get_property_value(Properties.OPERATING_MODE)
return OPERATING_STATE_MAP.get(op_mode) | [
"def",
"operating_mode",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"op_mode",
"=",
"self",
".",
"sharkiq",
".",
"get_property_value",
"(",
"Properties",
".",
"OPERATING_MODE",
")",
"return",
"OPERATING_STATE_MAP",
".",
"get",
"(",
"op_mode",
... | [
155,
4
] | [
158,
47
] | python | en | ['en', 'en', 'it'] | False |
SharkVacuumEntity.recharging_to_resume | (self) | Return True if vacuum set to recharge and resume cleaning. | Return True if vacuum set to recharge and resume cleaning. | def recharging_to_resume(self) -> Optional[int]:
"""Return True if vacuum set to recharge and resume cleaning."""
return self.sharkiq.get_property_value(Properties.RECHARGING_TO_RESUME) | [
"def",
"recharging_to_resume",
"(",
"self",
")",
"->",
"Optional",
"[",
"int",
"]",
":",
"return",
"self",
".",
"sharkiq",
".",
"get_property_value",
"(",
"Properties",
".",
"RECHARGING_TO_RESUME",
")"
] | [
161,
4
] | [
163,
79
] | python | en | ['en', 'en', 'en'] | True |
SharkVacuumEntity.state | (self) |
Get the current vacuum state.
NB: Currently, we do not return an error state because they can be very, very stale.
In the app, these are (usually) handled by showing the robot as stopped and sending the
user a notification.
|
Get the current vacuum state. | def state(self):
"""
Get the current vacuum state.
NB: Currently, we do not return an error state because they can be very, very stale.
In the app, these are (usually) handled by showing the robot as stopped and sending the
user a notification.
"""
if self.is_doc... | [
"def",
"state",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_docked",
":",
"return",
"STATE_DOCKED",
"return",
"self",
".",
"operating_mode"
] | [
166,
4
] | [
176,
34
] | python | en | ['en', 'error', 'th'] | False |
SharkVacuumEntity.unique_id | (self) | Return the unique id of the vacuum cleaner. | Return the unique id of the vacuum cleaner. | def unique_id(self) -> str:
"""Return the unique id of the vacuum cleaner."""
return self.serial_number | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"serial_number"
] | [
179,
4
] | [
181,
33
] | python | en | ['en', 'la', 'en'] | True |
SharkVacuumEntity.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...
return self.coordinator.last_update_success and self.is_online | [
"def",
"available",
"(",
"self",
")",
"->",
"bool",
":",
"# If the last update was successful...",
"return",
"self",
".",
"coordinator",
".",
"last_update_success",
"and",
"self",
".",
"is_online"
] | [
184,
4
] | [
187,
70
] | python | en | ['en', 'en', 'en'] | True |
SharkVacuumEntity.battery_level | (self) | Get the current battery level. | Get the current battery level. | def battery_level(self):
"""Get the current battery level."""
return self.sharkiq.get_property_value(Properties.BATTERY_CAPACITY) | [
"def",
"battery_level",
"(",
"self",
")",
":",
"return",
"self",
".",
"sharkiq",
".",
"get_property_value",
"(",
"Properties",
".",
"BATTERY_CAPACITY",
")"
] | [
190,
4
] | [
192,
75
] | python | en | ['en', 'en', 'en'] | True |
SharkVacuumEntity.async_return_to_base | (self, **kwargs) | Have the device return to base. | Have the device return to base. | async def async_return_to_base(self, **kwargs):
"""Have the device return to base."""
await self.sharkiq.async_set_operating_mode(OperatingModes.RETURN)
await self.coordinator.async_refresh() | [
"async",
"def",
"async_return_to_base",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"sharkiq",
".",
"async_set_operating_mode",
"(",
"OperatingModes",
".",
"RETURN",
")",
"await",
"self",
".",
"coordinator",
".",
"async_refresh",
"(",... | [
194,
4
] | [
197,
46
] | python | en | ['en', 'en', 'en'] | True |
SharkVacuumEntity.async_pause | (self) | Pause the cleaning task. | Pause the cleaning task. | async def async_pause(self):
"""Pause the cleaning task."""
await self.sharkiq.async_set_operating_mode(OperatingModes.PAUSE)
await self.coordinator.async_refresh() | [
"async",
"def",
"async_pause",
"(",
"self",
")",
":",
"await",
"self",
".",
"sharkiq",
".",
"async_set_operating_mode",
"(",
"OperatingModes",
".",
"PAUSE",
")",
"await",
"self",
".",
"coordinator",
".",
"async_refresh",
"(",
")"
] | [
199,
4
] | [
202,
46
] | python | en | ['en', 'en', 'en'] | True |
SharkVacuumEntity.async_start | (self) | Start the device. | Start the device. | async def async_start(self):
"""Start the device."""
await self.sharkiq.async_set_operating_mode(OperatingModes.START)
await self.coordinator.async_refresh() | [
"async",
"def",
"async_start",
"(",
"self",
")",
":",
"await",
"self",
".",
"sharkiq",
".",
"async_set_operating_mode",
"(",
"OperatingModes",
".",
"START",
")",
"await",
"self",
".",
"coordinator",
".",
"async_refresh",
"(",
")"
] | [
204,
4
] | [
207,
46
] | python | en | ['en', 'en', 'en'] | True |
SharkVacuumEntity.async_stop | (self, **kwargs) | Stop the device. | Stop the device. | async def async_stop(self, **kwargs):
"""Stop the device."""
await self.sharkiq.async_set_operating_mode(OperatingModes.STOP)
await self.coordinator.async_refresh() | [
"async",
"def",
"async_stop",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"sharkiq",
".",
"async_set_operating_mode",
"(",
"OperatingModes",
".",
"STOP",
")",
"await",
"self",
".",
"coordinator",
".",
"async_refresh",
"(",
")"
] | [
209,
4
] | [
212,
46
] | python | en | ['en', 'en', 'en'] | True |
SharkVacuumEntity.async_locate | (self, **kwargs) | Cause the device to generate a loud chirp. | Cause the device to generate a loud chirp. | async def async_locate(self, **kwargs):
"""Cause the device to generate a loud chirp."""
await self.sharkiq.async_find_device() | [
"async",
"def",
"async_locate",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"sharkiq",
".",
"async_find_device",
"(",
")"
] | [
214,
4
] | [
216,
46
] | python | en | ['en', 'en', 'en'] | True |
SharkVacuumEntity.fan_speed | (self) | Return the current fan speed. | Return the current fan speed. | def fan_speed(self) -> str:
"""Return the current fan speed."""
fan_speed = None
speed_level = self.sharkiq.get_property_value(Properties.POWER_MODE)
for k, val in FAN_SPEEDS_MAP.items():
if val == speed_level:
fan_speed = k
return fan_speed | [
"def",
"fan_speed",
"(",
"self",
")",
"->",
"str",
":",
"fan_speed",
"=",
"None",
"speed_level",
"=",
"self",
".",
"sharkiq",
".",
"get_property_value",
"(",
"Properties",
".",
"POWER_MODE",
")",
"for",
"k",
",",
"val",
"in",
"FAN_SPEEDS_MAP",
".",
"items"... | [
219,
4
] | [
226,
24
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.