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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
AbstractConfig.async_accept_grant | (self, code) | Accept a grant. | Accept a grant. | async def async_accept_grant(self, code):
"""Accept a grant."""
raise NotImplementedError | [
"async",
"def",
"async_accept_grant",
"(",
"self",
",",
"code",
")",
":",
"raise",
"NotImplementedError"
] | [
81,
4
] | [
83,
33
] | python | en | ['en', 'it', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up the Insteon climate entities from a config entry. | Set up the Insteon climate entities from a config entry. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up the Insteon climate entities from a config entry."""
def add_entities(discovery_info=None):
"""Add the Insteon entities for the platform."""
async_add_insteon_entities(
hass,
CLIMATE_DOMAIN,
... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"def",
"add_entities",
"(",
"discovery_info",
"=",
"None",
")",
":",
"\"\"\"Add the Insteon entities for the platform.\"\"\"",
"async_add_insteon_entities",
"(",
"h... | [
63,
0
] | [
78,
18
] | python | en | ['en', 'en', 'en'] | True |
InsteonClimateEntity.supported_features | (self) | Return the supported features for this entity. | Return the supported features for this entity. | def supported_features(self):
"""Return the supported features for this entity."""
return SUPPORTED_FEATURES | [
"def",
"supported_features",
"(",
"self",
")",
":",
"return",
"SUPPORTED_FEATURES"
] | [
85,
4
] | [
87,
33
] | python | en | ['en', 'en', 'en'] | True |
InsteonClimateEntity.temperature_unit | (self) | Return the unit of measurement. | Return the unit of measurement. | def temperature_unit(self) -> str:
"""Return the unit of measurement."""
if self._insteon_device.properties[CELSIUS].value:
return TEMP_CELSIUS
return TEMP_FAHRENHEIT | [
"def",
"temperature_unit",
"(",
"self",
")",
"->",
"str",
":",
"if",
"self",
".",
"_insteon_device",
".",
"properties",
"[",
"CELSIUS",
"]",
".",
"value",
":",
"return",
"TEMP_CELSIUS",
"return",
"TEMP_FAHRENHEIT"
] | [
90,
4
] | [
94,
30
] | python | en | ['en', 'la', 'en'] | True |
InsteonClimateEntity.current_humidity | (self) | Return the current humidity. | Return the current humidity. | def current_humidity(self) -> Optional[int]:
"""Return the current humidity."""
return self._insteon_device.groups[HUMIDITY].value | [
"def",
"current_humidity",
"(",
"self",
")",
"->",
"Optional",
"[",
"int",
"]",
":",
"return",
"self",
".",
"_insteon_device",
".",
"groups",
"[",
"HUMIDITY",
"]",
".",
"value"
] | [
97,
4
] | [
99,
58
] | python | en | ['en', 'en', 'en'] | True |
InsteonClimateEntity.hvac_mode | (self) | Return hvac operation ie. heat, cool mode. | Return hvac operation ie. heat, cool mode. | def hvac_mode(self) -> str:
"""Return hvac operation ie. heat, cool mode."""
return HVAC_MODES[self._insteon_device.groups[SYSTEM_MODE].value] | [
"def",
"hvac_mode",
"(",
"self",
")",
"->",
"str",
":",
"return",
"HVAC_MODES",
"[",
"self",
".",
"_insteon_device",
".",
"groups",
"[",
"SYSTEM_MODE",
"]",
".",
"value",
"]"
] | [
102,
4
] | [
104,
73
] | python | bg | ['en', 'bg', 'bg'] | True |
InsteonClimateEntity.hvac_modes | (self) | Return the list of available hvac operation modes. | Return the list of available hvac operation modes. | def hvac_modes(self) -> List[str]:
"""Return the list of available hvac operation modes."""
return list(HVAC_MODES.values()) | [
"def",
"hvac_modes",
"(",
"self",
")",
"->",
"List",
"[",
"str",
"]",
":",
"return",
"list",
"(",
"HVAC_MODES",
".",
"values",
"(",
")",
")"
] | [
107,
4
] | [
109,
40
] | python | en | ['en', 'en', 'en'] | True |
InsteonClimateEntity.current_temperature | (self) | Return the current temperature. | Return the current temperature. | def current_temperature(self) -> Optional[float]:
"""Return the current temperature."""
return self._insteon_device.groups[TEMPERATURE].value | [
"def",
"current_temperature",
"(",
"self",
")",
"->",
"Optional",
"[",
"float",
"]",
":",
"return",
"self",
".",
"_insteon_device",
".",
"groups",
"[",
"TEMPERATURE",
"]",
".",
"value"
] | [
112,
4
] | [
114,
61
] | python | en | ['en', 'la', 'en'] | True |
InsteonClimateEntity.target_temperature | (self) | Return the temperature we try to reach. | Return the temperature we try to reach. | def target_temperature(self) -> Optional[float]:
"""Return the temperature we try to reach."""
if self._insteon_device.groups[SYSTEM_MODE].value == ThermostatMode.HEAT:
return self._insteon_device.groups[HEAT_SET_POINT].value
if self._insteon_device.groups[SYSTEM_MODE].value == Therm... | [
"def",
"target_temperature",
"(",
"self",
")",
"->",
"Optional",
"[",
"float",
"]",
":",
"if",
"self",
".",
"_insteon_device",
".",
"groups",
"[",
"SYSTEM_MODE",
"]",
".",
"value",
"==",
"ThermostatMode",
".",
"HEAT",
":",
"return",
"self",
".",
"_insteon_... | [
117,
4
] | [
123,
19
] | python | en | ['en', 'en', 'en'] | True |
InsteonClimateEntity.target_temperature_high | (self) | Return the highbound target temperature we try to reach. | Return the highbound target temperature we try to reach. | def target_temperature_high(self) -> Optional[float]:
"""Return the highbound target temperature we try to reach."""
if self._insteon_device.groups[SYSTEM_MODE].value == ThermostatMode.AUTO:
return self._insteon_device.groups[COOL_SET_POINT].value
return None | [
"def",
"target_temperature_high",
"(",
"self",
")",
"->",
"Optional",
"[",
"float",
"]",
":",
"if",
"self",
".",
"_insteon_device",
".",
"groups",
"[",
"SYSTEM_MODE",
"]",
".",
"value",
"==",
"ThermostatMode",
".",
"AUTO",
":",
"return",
"self",
".",
"_ins... | [
126,
4
] | [
130,
19
] | python | en | ['en', 'en', 'en'] | True |
InsteonClimateEntity.target_temperature_low | (self) | Return the lowbound target temperature we try to reach. | Return the lowbound target temperature we try to reach. | def target_temperature_low(self) -> Optional[float]:
"""Return the lowbound target temperature we try to reach."""
if self._insteon_device.groups[SYSTEM_MODE].value == ThermostatMode.AUTO:
return self._insteon_device.groups[HEAT_SET_POINT].value
return None | [
"def",
"target_temperature_low",
"(",
"self",
")",
"->",
"Optional",
"[",
"float",
"]",
":",
"if",
"self",
".",
"_insteon_device",
".",
"groups",
"[",
"SYSTEM_MODE",
"]",
".",
"value",
"==",
"ThermostatMode",
".",
"AUTO",
":",
"return",
"self",
".",
"_inst... | [
133,
4
] | [
137,
19
] | python | en | ['en', 'en', 'en'] | True |
InsteonClimateEntity.fan_mode | (self) | Return the fan setting. | Return the fan setting. | def fan_mode(self) -> Optional[str]:
"""Return the fan setting."""
return FAN_MODES[self._insteon_device.groups[FAN_MODE].value] | [
"def",
"fan_mode",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"return",
"FAN_MODES",
"[",
"self",
".",
"_insteon_device",
".",
"groups",
"[",
"FAN_MODE",
"]",
".",
"value",
"]"
] | [
140,
4
] | [
142,
69
] | python | en | ['en', 'fy', 'en'] | True |
InsteonClimateEntity.fan_modes | (self) | Return the list of available fan modes. | Return the list of available fan modes. | def fan_modes(self) -> Optional[List[str]]:
"""Return the list of available fan modes."""
return list(FAN_MODES.values()) | [
"def",
"fan_modes",
"(",
"self",
")",
"->",
"Optional",
"[",
"List",
"[",
"str",
"]",
"]",
":",
"return",
"list",
"(",
"FAN_MODES",
".",
"values",
"(",
")",
")"
] | [
145,
4
] | [
147,
39
] | python | en | ['en', 'en', 'en'] | True |
InsteonClimateEntity.target_humidity | (self) | Return the humidity we try to reach. | Return the humidity we try to reach. | def target_humidity(self) -> Optional[int]:
"""Return the humidity we try to reach."""
high = self._insteon_device.groups[HUMIDITY_HIGH].value
low = self._insteon_device.groups[HUMIDITY_LOW].value
# May not be loaded yet so return a default if required
return (high + low) / 2 if ... | [
"def",
"target_humidity",
"(",
"self",
")",
"->",
"Optional",
"[",
"int",
"]",
":",
"high",
"=",
"self",
".",
"_insteon_device",
".",
"groups",
"[",
"HUMIDITY_HIGH",
"]",
".",
"value",
"low",
"=",
"self",
".",
"_insteon_device",
".",
"groups",
"[",
"HUMI... | [
150,
4
] | [
155,
57
] | python | en | ['en', 'en', 'en'] | True |
InsteonClimateEntity.min_humidity | (self) | Return the minimum humidity. | Return the minimum humidity. | def min_humidity(self) -> int:
"""Return the minimum humidity."""
return 1 | [
"def",
"min_humidity",
"(",
"self",
")",
"->",
"int",
":",
"return",
"1"
] | [
158,
4
] | [
160,
16
] | python | en | ['en', 'et', 'en'] | True |
InsteonClimateEntity.hvac_action | (self) | Return the current running hvac operation if supported.
Need to be one of CURRENT_HVAC_*.
| Return the current running hvac operation if supported. | def hvac_action(self) -> Optional[str]:
"""Return the current running hvac operation if supported.
Need to be one of CURRENT_HVAC_*.
"""
if self._insteon_device.groups[COOLING].value:
return CURRENT_HVAC_COOL
if self._insteon_device.groups[HEATING].value:
... | [
"def",
"hvac_action",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"if",
"self",
".",
"_insteon_device",
".",
"groups",
"[",
"COOLING",
"]",
".",
"value",
":",
"return",
"CURRENT_HVAC_COOL",
"if",
"self",
".",
"_insteon_device",
".",
"groups",... | [
163,
4
] | [
174,
32
] | python | en | ['en', 'en', 'en'] | True |
InsteonClimateEntity.device_state_attributes | (self) | Provide attributes for display on device card. | Provide attributes for display on device card. | def device_state_attributes(self):
"""Provide attributes for display on device card."""
attr = super().device_state_attributes
humidifier = "off"
if self._insteon_device.groups[DEHUMIDIFYING].value:
humidifier = "dehumidifying"
if self._insteon_device.groups[HUMIDIFYI... | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"attr",
"=",
"super",
"(",
")",
".",
"device_state_attributes",
"humidifier",
"=",
"\"off\"",
"if",
"self",
".",
"_insteon_device",
".",
"groups",
"[",
"DEHUMIDIFYING",
"]",
".",
"value",
":",
"humidifie... | [
177,
4
] | [
186,
19
] | python | en | ['en', 'en', 'en'] | True |
InsteonClimateEntity.async_set_temperature | (self, **kwargs) | Set new target temperature. | Set new target temperature. | async def async_set_temperature(self, **kwargs) -> None:
"""Set new target temperature."""
target_temp = kwargs.get(ATTR_TEMPERATURE)
target_temp_low = kwargs.get(ATTR_TARGET_TEMP_LOW)
target_temp_high = kwargs.get(ATTR_TARGET_TEMP_HIGH)
if target_temp is not None:
if... | [
"async",
"def",
"async_set_temperature",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
"->",
"None",
":",
"target_temp",
"=",
"kwargs",
".",
"get",
"(",
"ATTR_TEMPERATURE",
")",
"target_temp_low",
"=",
"kwargs",
".",
"get",
"(",
"ATTR_TARGET_TEMP_LOW",
")",
"ta... | [
188,
4
] | [
200,
81
] | python | en | ['en', 'ca', 'en'] | True |
InsteonClimateEntity.async_set_fan_mode | (self, fan_mode: str) | Set new target fan mode. | Set new target fan mode. | async def async_set_fan_mode(self, fan_mode: str) -> None:
"""Set new target fan mode."""
mode = list(FAN_MODES)[list(FAN_MODES.values()).index(fan_mode)]
await self._insteon_device.async_set_mode(mode) | [
"async",
"def",
"async_set_fan_mode",
"(",
"self",
",",
"fan_mode",
":",
"str",
")",
"->",
"None",
":",
"mode",
"=",
"list",
"(",
"FAN_MODES",
")",
"[",
"list",
"(",
"FAN_MODES",
".",
"values",
"(",
")",
")",
".",
"index",
"(",
"fan_mode",
")",
"]",
... | [
202,
4
] | [
205,
55
] | python | en | ['sv', 'fy', 'en'] | False |
InsteonClimateEntity.async_set_hvac_mode | (self, hvac_mode: str) | Set new target hvac mode. | Set new target hvac mode. | async def async_set_hvac_mode(self, hvac_mode: str) -> None:
"""Set new target hvac mode."""
mode = list(HVAC_MODES)[list(HVAC_MODES.values()).index(hvac_mode)]
await self._insteon_device.async_set_mode(mode) | [
"async",
"def",
"async_set_hvac_mode",
"(",
"self",
",",
"hvac_mode",
":",
"str",
")",
"->",
"None",
":",
"mode",
"=",
"list",
"(",
"HVAC_MODES",
")",
"[",
"list",
"(",
"HVAC_MODES",
".",
"values",
"(",
")",
")",
".",
"index",
"(",
"hvac_mode",
")",
... | [
207,
4
] | [
210,
55
] | python | da | ['da', 'su', 'en'] | False |
InsteonClimateEntity.async_set_humidity | (self, humidity) | Set new humidity level. | Set new humidity level. | async def async_set_humidity(self, humidity):
"""Set new humidity level."""
change = humidity - self.target_humidity
high = self._insteon_device.groups[HUMIDITY_HIGH].value + change
low = self._insteon_device.groups[HUMIDITY_LOW].value + change
await self._insteon_device.async_se... | [
"async",
"def",
"async_set_humidity",
"(",
"self",
",",
"humidity",
")",
":",
"change",
"=",
"humidity",
"-",
"self",
".",
"target_humidity",
"high",
"=",
"self",
".",
"_insteon_device",
".",
"groups",
"[",
"HUMIDITY_HIGH",
"]",
".",
"value",
"+",
"change",
... | [
212,
4
] | [
218,
74
] | python | en | ['en', 'sr', 'en'] | True |
InsteonClimateEntity.async_added_to_hass | (self) | Register INSTEON update events. | Register INSTEON update events. | async def async_added_to_hass(self):
"""Register INSTEON update events."""
await super().async_added_to_hass()
await self._insteon_device.async_read_op_flags()
for group in [
COOLING,
HEATING,
DEHUMIDIFYING,
HUMIDIFYING,
HEAT_SE... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"await",
"super",
"(",
")",
".",
"async_added_to_hass",
"(",
")",
"await",
"self",
".",
"_insteon_device",
".",
"async_read_op_flags",
"(",
")",
"for",
"group",
"in",
"[",
"COOLING",
",",
"HEATING... | [
220,
4
] | [
237,
82
] | python | en | ['es', 'nl', 'en'] | False |
TestWorkdaySetup.setup_method | (self) | Set up things to be run when tests are started. | Set up things to be run when tests are started. | def setup_method(self):
"""Set up things to be run when tests are started."""
self.hass = get_test_home_assistant()
# Set valid default config for test
self.config_province = {
"binary_sensor": {"platform": "workday", "country": "DE", "province": "BW"}
}
sel... | [
"def",
"setup_method",
"(",
"self",
")",
":",
"self",
".",
"hass",
"=",
"get_test_home_assistant",
"(",
")",
"# Set valid default config for test",
"self",
".",
"config_province",
"=",
"{",
"\"binary_sensor\"",
":",
"{",
"\"platform\"",
":",
"\"workday\"",
",",
"\... | [
18,
4
] | [
97,
9
] | python | en | ['en', 'en', 'en'] | True |
TestWorkdaySetup.teardown_method | (self) | Stop everything that was started. | Stop everything that was started. | def teardown_method(self):
"""Stop everything that was started."""
self.hass.stop() | [
"def",
"teardown_method",
"(",
"self",
")",
":",
"self",
".",
"hass",
".",
"stop",
"(",
")"
] | [
99,
4
] | [
101,
24
] | python | en | ['en', 'en', 'en'] | True |
TestWorkdaySetup.test_valid_country | (self) | Test topic name/filter validation. | Test topic name/filter validation. | def test_valid_country(self):
"""Test topic name/filter validation."""
# Invalid UTF-8, must not contain U+D800 to U+DFFF
with pytest.raises(vol.Invalid):
binary_sensor.valid_country("\ud800")
with pytest.raises(vol.Invalid):
binary_sensor.valid_country("\udfff")
... | [
"def",
"test_valid_country",
"(",
"self",
")",
":",
"# Invalid UTF-8, must not contain U+D800 to U+DFFF",
"with",
"pytest",
".",
"raises",
"(",
"vol",
".",
"Invalid",
")",
":",
"binary_sensor",
".",
"valid_country",
"(",
"\"\\ud800\"",
")",
"with",
"pytest",
".",
... | [
103,
4
] | [
115,
60
] | python | en | ['en', 'en', 'en'] | True |
TestWorkdaySetup.test_setup_component_province | (self) | Set up workday component. | Set up workday component. | def test_setup_component_province(self):
"""Set up workday component."""
with assert_setup_component(1, "binary_sensor"):
setup_component(self.hass, "binary_sensor", self.config_province)
self.hass.block_till_done()
entity = self.hass.states.get("binary_sensor.workday_se... | [
"def",
"test_setup_component_province",
"(",
"self",
")",
":",
"with",
"assert_setup_component",
"(",
"1",
",",
"\"binary_sensor\"",
")",
":",
"setup_component",
"(",
"self",
".",
"hass",
",",
"\"binary_sensor\"",
",",
"self",
".",
"config_province",
")",
"self",
... | [
117,
4
] | [
124,
33
] | python | en | ['en', 'en', 'en'] | True |
TestWorkdaySetup.test_workday_province | (self, mock_date) | Test if workdays are reported correctly. | Test if workdays are reported correctly. | def test_workday_province(self, mock_date):
"""Test if workdays are reported correctly."""
with assert_setup_component(1, "binary_sensor"):
setup_component(self.hass, "binary_sensor", self.config_province)
self.hass.block_till_done()
self.hass.start()
entity = s... | [
"def",
"test_workday_province",
"(",
"self",
",",
"mock_date",
")",
":",
"with",
"assert_setup_component",
"(",
"1",
",",
"\"binary_sensor\"",
")",
":",
"setup_component",
"(",
"self",
".",
"hass",
",",
"\"binary_sensor\"",
",",
"self",
".",
"config_province",
"... | [
128,
4
] | [
137,
35
] | python | en | ['en', 'en', 'en'] | True |
TestWorkdaySetup.test_weekend_province | (self, mock_date) | Test if weekends are reported correctly. | Test if weekends are reported correctly. | def test_weekend_province(self, mock_date):
"""Test if weekends are reported correctly."""
with assert_setup_component(1, "binary_sensor"):
setup_component(self.hass, "binary_sensor", self.config_province)
self.hass.block_till_done()
self.hass.start()
entity = s... | [
"def",
"test_weekend_province",
"(",
"self",
",",
"mock_date",
")",
":",
"with",
"assert_setup_component",
"(",
"1",
",",
"\"binary_sensor\"",
")",
":",
"setup_component",
"(",
"self",
".",
"hass",
",",
"\"binary_sensor\"",
",",
"self",
".",
"config_province",
"... | [
141,
4
] | [
150,
36
] | python | en | ['en', 'en', 'en'] | True |
TestWorkdaySetup.test_public_holiday_province | (self, mock_date) | Test if public holidays are reported correctly. | Test if public holidays are reported correctly. | def test_public_holiday_province(self, mock_date):
"""Test if public holidays are reported correctly."""
with assert_setup_component(1, "binary_sensor"):
setup_component(self.hass, "binary_sensor", self.config_province)
self.hass.block_till_done()
self.hass.start()
... | [
"def",
"test_public_holiday_province",
"(",
"self",
",",
"mock_date",
")",
":",
"with",
"assert_setup_component",
"(",
"1",
",",
"\"binary_sensor\"",
")",
":",
"setup_component",
"(",
"self",
".",
"hass",
",",
"\"binary_sensor\"",
",",
"self",
".",
"config_provinc... | [
154,
4
] | [
163,
36
] | python | en | ['en', 'en', 'en'] | True |
TestWorkdaySetup.test_setup_component_noprovince | (self) | Set up workday component. | Set up workday component. | def test_setup_component_noprovince(self):
"""Set up workday component."""
with assert_setup_component(1, "binary_sensor"):
setup_component(self.hass, "binary_sensor", self.config_noprovince)
self.hass.block_till_done()
entity = self.hass.states.get("binary_sensor.workda... | [
"def",
"test_setup_component_noprovince",
"(",
"self",
")",
":",
"with",
"assert_setup_component",
"(",
"1",
",",
"\"binary_sensor\"",
")",
":",
"setup_component",
"(",
"self",
".",
"hass",
",",
"\"binary_sensor\"",
",",
"self",
".",
"config_noprovince",
")",
"sel... | [
165,
4
] | [
172,
33
] | python | en | ['en', 'en', 'en'] | True |
TestWorkdaySetup.test_public_holiday_noprovince | (self, mock_date) | Test if public holidays are reported correctly. | Test if public holidays are reported correctly. | def test_public_holiday_noprovince(self, mock_date):
"""Test if public holidays are reported correctly."""
with assert_setup_component(1, "binary_sensor"):
setup_component(self.hass, "binary_sensor", self.config_noprovince)
self.hass.block_till_done()
self.hass.start()
... | [
"def",
"test_public_holiday_noprovince",
"(",
"self",
",",
"mock_date",
")",
":",
"with",
"assert_setup_component",
"(",
"1",
",",
"\"binary_sensor\"",
")",
":",
"setup_component",
"(",
"self",
".",
"hass",
",",
"\"binary_sensor\"",
",",
"self",
".",
"config_nopro... | [
176,
4
] | [
185,
35
] | python | en | ['en', 'en', 'en'] | True |
TestWorkdaySetup.test_public_holiday_state | (self, mock_date) | Test if public holidays are reported correctly. | Test if public holidays are reported correctly. | def test_public_holiday_state(self, mock_date):
"""Test if public holidays are reported correctly."""
with assert_setup_component(1, "binary_sensor"):
setup_component(self.hass, "binary_sensor", self.config_state)
self.hass.start()
entity = self.hass.states.get("binary_sens... | [
"def",
"test_public_holiday_state",
"(",
"self",
",",
"mock_date",
")",
":",
"with",
"assert_setup_component",
"(",
"1",
",",
"\"binary_sensor\"",
")",
":",
"setup_component",
"(",
"self",
".",
"hass",
",",
"\"binary_sensor\"",
",",
"self",
".",
"config_state",
... | [
189,
4
] | [
197,
36
] | python | en | ['en', 'en', 'en'] | True |
TestWorkdaySetup.test_public_holiday_nostate | (self, mock_date) | Test if public holidays are reported correctly. | Test if public holidays are reported correctly. | def test_public_holiday_nostate(self, mock_date):
"""Test if public holidays are reported correctly."""
with assert_setup_component(1, "binary_sensor"):
setup_component(self.hass, "binary_sensor", self.config_nostate)
self.hass.start()
entity = self.hass.states.get("binary_... | [
"def",
"test_public_holiday_nostate",
"(",
"self",
",",
"mock_date",
")",
":",
"with",
"assert_setup_component",
"(",
"1",
",",
"\"binary_sensor\"",
")",
":",
"setup_component",
"(",
"self",
".",
"hass",
",",
"\"binary_sensor\"",
",",
"self",
".",
"config_nostate"... | [
201,
4
] | [
209,
35
] | python | en | ['en', 'en', 'en'] | True |
TestWorkdaySetup.test_setup_component_invalidprovince | (self) | Set up workday component. | Set up workday component. | def test_setup_component_invalidprovince(self):
"""Set up workday component."""
with assert_setup_component(1, "binary_sensor"):
setup_component(self.hass, "binary_sensor", self.config_invalidprovince)
entity = self.hass.states.get("binary_sensor.workday_sensor")
assert enti... | [
"def",
"test_setup_component_invalidprovince",
"(",
"self",
")",
":",
"with",
"assert_setup_component",
"(",
"1",
",",
"\"binary_sensor\"",
")",
":",
"setup_component",
"(",
"self",
".",
"hass",
",",
"\"binary_sensor\"",
",",
"self",
".",
"config_invalidprovince",
"... | [
211,
4
] | [
217,
29
] | python | en | ['en', 'en', 'en'] | True |
TestWorkdaySetup.test_public_holiday_includeholiday | (self, mock_date) | Test if public holidays are reported correctly. | Test if public holidays are reported correctly. | def test_public_holiday_includeholiday(self, mock_date):
"""Test if public holidays are reported correctly."""
with assert_setup_component(1, "binary_sensor"):
setup_component(self.hass, "binary_sensor", self.config_includeholiday)
self.hass.start()
entity = self.hass.state... | [
"def",
"test_public_holiday_includeholiday",
"(",
"self",
",",
"mock_date",
")",
":",
"with",
"assert_setup_component",
"(",
"1",
",",
"\"binary_sensor\"",
")",
":",
"setup_component",
"(",
"self",
".",
"hass",
",",
"\"binary_sensor\"",
",",
"self",
".",
"config_i... | [
221,
4
] | [
229,
35
] | python | en | ['en', 'en', 'en'] | True |
TestWorkdaySetup.test_tomorrow | (self, mock_date) | Test if tomorrow are reported correctly. | Test if tomorrow are reported correctly. | def test_tomorrow(self, mock_date):
"""Test if tomorrow are reported correctly."""
with assert_setup_component(1, "binary_sensor"):
setup_component(self.hass, "binary_sensor", self.config_tomorrow)
self.hass.start()
entity = self.hass.states.get("binary_sensor.workday_senso... | [
"def",
"test_tomorrow",
"(",
"self",
",",
"mock_date",
")",
":",
"with",
"assert_setup_component",
"(",
"1",
",",
"\"binary_sensor\"",
")",
":",
"setup_component",
"(",
"self",
".",
"hass",
",",
"\"binary_sensor\"",
",",
"self",
".",
"config_tomorrow",
")",
"s... | [
233,
4
] | [
241,
36
] | python | en | ['en', 'en', 'en'] | True |
TestWorkdaySetup.test_day_after_tomorrow | (self, mock_date) | Test if the day after tomorrow are reported correctly. | Test if the day after tomorrow are reported correctly. | def test_day_after_tomorrow(self, mock_date):
"""Test if the day after tomorrow are reported correctly."""
with assert_setup_component(1, "binary_sensor"):
setup_component(self.hass, "binary_sensor", self.config_day_after_tomorrow)
self.hass.start()
entity = self.hass.state... | [
"def",
"test_day_after_tomorrow",
"(",
"self",
",",
"mock_date",
")",
":",
"with",
"assert_setup_component",
"(",
"1",
",",
"\"binary_sensor\"",
")",
":",
"setup_component",
"(",
"self",
".",
"hass",
",",
"\"binary_sensor\"",
",",
"self",
".",
"config_day_after_to... | [
245,
4
] | [
253,
35
] | python | en | ['en', 'en', 'en'] | True |
TestWorkdaySetup.test_yesterday | (self, mock_date) | Test if yesterday are reported correctly. | Test if yesterday are reported correctly. | def test_yesterday(self, mock_date):
"""Test if yesterday are reported correctly."""
with assert_setup_component(1, "binary_sensor"):
setup_component(self.hass, "binary_sensor", self.config_yesterday)
self.hass.start()
entity = self.hass.states.get("binary_sensor.workday_se... | [
"def",
"test_yesterday",
"(",
"self",
",",
"mock_date",
")",
":",
"with",
"assert_setup_component",
"(",
"1",
",",
"\"binary_sensor\"",
")",
":",
"setup_component",
"(",
"self",
".",
"hass",
",",
"\"binary_sensor\"",
",",
"self",
".",
"config_yesterday",
")",
... | [
257,
4
] | [
265,
35
] | python | en | ['en', 'en', 'en'] | True |
TestWorkdaySetup.test_config_example1_holiday | (self, mock_date) | Test if public holidays are reported correctly. | Test if public holidays are reported correctly. | def test_config_example1_holiday(self, mock_date):
"""Test if public holidays are reported correctly."""
with assert_setup_component(1, "binary_sensor"):
setup_component(self.hass, "binary_sensor", self.config_example1)
self.hass.start()
entity = self.hass.states.get("binar... | [
"def",
"test_config_example1_holiday",
"(",
"self",
",",
"mock_date",
")",
":",
"with",
"assert_setup_component",
"(",
"1",
",",
"\"binary_sensor\"",
")",
":",
"setup_component",
"(",
"self",
".",
"hass",
",",
"\"binary_sensor\"",
",",
"self",
".",
"config_example... | [
270,
4
] | [
278,
35
] | python | en | ['en', 'en', 'en'] | True |
TestWorkdaySetup.test_config_example2_tue | (self, mock_date) | Test if public holidays are reported correctly. | Test if public holidays are reported correctly. | def test_config_example2_tue(self, mock_date):
"""Test if public holidays are reported correctly."""
with assert_setup_component(1, "binary_sensor"):
setup_component(self.hass, "binary_sensor", self.config_example2)
self.hass.start()
entity = self.hass.states.get("binary_se... | [
"def",
"test_config_example2_tue",
"(",
"self",
",",
"mock_date",
")",
":",
"with",
"assert_setup_component",
"(",
"1",
",",
"\"binary_sensor\"",
")",
":",
"setup_component",
"(",
"self",
".",
"hass",
",",
"\"binary_sensor\"",
",",
"self",
".",
"config_example2",
... | [
282,
4
] | [
290,
36
] | python | en | ['en', 'en', 'en'] | True |
TestWorkdaySetup.test_config_example2_add_holiday | (self, mock_date) | Test if public holidays are reported correctly. | Test if public holidays are reported correctly. | def test_config_example2_add_holiday(self, mock_date):
"""Test if public holidays are reported correctly."""
with assert_setup_component(1, "binary_sensor"):
setup_component(self.hass, "binary_sensor", self.config_example2)
self.hass.start()
entity = self.hass.states.get("b... | [
"def",
"test_config_example2_add_holiday",
"(",
"self",
",",
"mock_date",
")",
":",
"with",
"assert_setup_component",
"(",
"1",
",",
"\"binary_sensor\"",
")",
":",
"setup_component",
"(",
"self",
".",
"hass",
",",
"\"binary_sensor\"",
",",
"self",
".",
"config_exa... | [
294,
4
] | [
302,
36
] | python | en | ['en', 'en', 'en'] | True |
TestWorkdaySetup.test_day_to_string | (self) | Test if day_to_string is behaving correctly. | Test if day_to_string is behaving correctly. | def test_day_to_string(self):
"""Test if day_to_string is behaving correctly."""
assert binary_sensor.day_to_string(0) == "mon"
assert binary_sensor.day_to_string(1) == "tue"
assert binary_sensor.day_to_string(7) == "holiday"
assert binary_sensor.day_to_string(8) is None | [
"def",
"test_day_to_string",
"(",
"self",
")",
":",
"assert",
"binary_sensor",
".",
"day_to_string",
"(",
"0",
")",
"==",
"\"mon\"",
"assert",
"binary_sensor",
".",
"day_to_string",
"(",
"1",
")",
"==",
"\"tue\"",
"assert",
"binary_sensor",
".",
"day_to_string",... | [
304,
4
] | [
309,
53
] | python | en | ['en', 'en', 'en'] | True |
TestWorkdaySetup.test_config_remove_holidays_xmas | (self, mock_date) | Test if removed holidays are reported correctly. | Test if removed holidays are reported correctly. | def test_config_remove_holidays_xmas(self, mock_date):
"""Test if removed holidays are reported correctly."""
with assert_setup_component(1, "binary_sensor"):
setup_component(self.hass, "binary_sensor", self.config_remove_holidays)
self.hass.start()
entity = self.hass.state... | [
"def",
"test_config_remove_holidays_xmas",
"(",
"self",
",",
"mock_date",
")",
":",
"with",
"assert_setup_component",
"(",
"1",
",",
"\"binary_sensor\"",
")",
":",
"setup_component",
"(",
"self",
".",
"hass",
",",
"\"binary_sensor\"",
",",
"self",
".",
"config_rem... | [
313,
4
] | [
321,
35
] | python | en | ['en', 'en', 'en'] | True |
SimpleConfigFlow.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."""
if self._async_current_entries():
return self.async_abort(reason="single_instance_allowed")
if user_input is None:
return self.async_show_form(step_id="user")
return self.async_cre... | [
"async",
"def",
"async_step_user",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"if",
"self",
".",
"_async_current_entries",
"(",
")",
":",
"return",
"self",
".",
"async_abort",
"(",
"reason",
"=",
"\"single_instance_allowed\"",
")",
"if",
"user_inpu... | [
13,
4
] | [
22,
69
] | python | en | ['en', 'en', 'en'] | True |
SimpleConfigFlow.async_step_import | (self, import_info) | Handle import from config file. | Handle import from config file. | async def async_step_import(self, import_info):
"""Handle import from config file."""
return await self.async_step_user(import_info) | [
"async",
"def",
"async_step_import",
"(",
"self",
",",
"import_info",
")",
":",
"return",
"await",
"self",
".",
"async_step_user",
"(",
"import_info",
")"
] | [
24,
4
] | [
26,
54
] | python | en | ['en', 'en', 'en'] | True |
accuracy | (output, target, topk=(1,)) | Computes the precision@k for the specified values of k | Computes the precision | def accuracy(output, target, topk=(1,)):
""" Computes the precision@k for the specified values of k """
maxk = max(topk)
batch_size = target.size(0)
_, pred = output.topk(maxk, 1, True, True)
pred = pred.t()
# one-hot case
if target.ndimension() > 1:
target = target.max(1)[1]
c... | [
"def",
"accuracy",
"(",
"output",
",",
"target",
",",
"topk",
"=",
"(",
"1",
",",
")",
")",
":",
"maxk",
"=",
"max",
"(",
"topk",
")",
"batch_size",
"=",
"target",
".",
"size",
"(",
"0",
")",
"_",
",",
"pred",
"=",
"output",
".",
"topk",
"(",
... | [
8,
0
] | [
25,
14
] | python | en | ['en', 'en', 'en'] | True |
qs_devices | () | Return a set of devices as a response. | Return a set of devices as a response. | def qs_devices():
"""Return a set of devices as a response."""
return [
{
"id": "@a00001",
"name": "Switch 1",
"type": "rel",
"val": "OFF",
"time": "1522777506",
"rssi": "51%",
},
{
"id": "@a00002",
... | [
"def",
"qs_devices",
"(",
")",
":",
"return",
"[",
"{",
"\"id\"",
":",
"\"@a00001\"",
",",
"\"name\"",
":",
"\"Switch 1\"",
",",
"\"type\"",
":",
"\"rel\"",
",",
"\"val\"",
":",
"\"OFF\"",
",",
"\"time\"",
":",
"\"1522777506\"",
",",
"\"rssi\"",
":",
"\"51... | [
15,
0
] | [
42,
5
] | python | en | ['en', 'en', 'en'] | True |
test_binary_sensor_device | (hass, aioclient_mock, qs_devices) | Test a binary sensor device. | Test a binary sensor device. | async def test_binary_sensor_device(hass, aioclient_mock, qs_devices):
"""Test a binary sensor device."""
config = {
"qwikswitch": {
"sensors": {"name": "s1", "id": "@a00001", "channel": 1, "type": "imod"}
}
}
aioclient_mock.get("http://127.0.0.1:2020/&device", json=qs_device... | [
"async",
"def",
"test_binary_sensor_device",
"(",
"hass",
",",
"aioclient_mock",
",",
"qs_devices",
")",
":",
"config",
"=",
"{",
"\"qwikswitch\"",
":",
"{",
"\"sensors\"",
":",
"{",
"\"name\"",
":",
"\"s1\"",
",",
"\"id\"",
":",
"\"@a00001\"",
",",
"\"channel... | [
48,
0
] | [
84,
22
] | python | en | ['en', 'haw', 'en'] | True |
test_sensor_device | (hass, aioclient_mock, qs_devices) | Test a sensor device. | Test a sensor device. | async def test_sensor_device(hass, aioclient_mock, qs_devices):
"""Test a sensor device."""
config = {
"qwikswitch": {
"sensors": {
"name": "ss1",
"id": "@a00001",
"channel": 1,
"type": "qwikcord",
}
}
}
... | [
"async",
"def",
"test_sensor_device",
"(",
"hass",
",",
"aioclient_mock",
",",
"qs_devices",
")",
":",
"config",
"=",
"{",
"\"qwikswitch\"",
":",
"{",
"\"sensors\"",
":",
"{",
"\"name\"",
":",
"\"ss1\"",
",",
"\"id\"",
":",
"\"@a00001\"",
",",
"\"channel\"",
... | [
87,
0
] | [
118,
22
] | python | ca | ['ca', 'haw', 'en'] | False |
test_switch_device | (hass, aioclient_mock, qs_devices) | Test a switch device. | Test a switch device. | async def test_switch_device(hass, aioclient_mock, qs_devices):
"""Test a switch device."""
async def get_devices_json(method, url, data):
return AiohttpClientMockResponse(method=method, url=url, json=qs_devices)
config = {"qwikswitch": {"switches": ["@a00001"]}}
aioclient_mock.get("http://127... | [
"async",
"def",
"test_switch_device",
"(",
"hass",
",",
"aioclient_mock",
",",
"qs_devices",
")",
":",
"async",
"def",
"get_devices_json",
"(",
"method",
",",
"url",
",",
"data",
")",
":",
"return",
"AiohttpClientMockResponse",
"(",
"method",
"=",
"method",
",... | [
121,
0
] | [
179,
22
] | python | en | ['en', 'pl', 'en'] | True |
test_light_device | (hass, aioclient_mock, qs_devices) | Test a light device. | Test a light device. | async def test_light_device(hass, aioclient_mock, qs_devices):
"""Test a light device."""
async def get_devices_json(method, url, data):
return AiohttpClientMockResponse(method=method, url=url, json=qs_devices)
config = {"qwikswitch": {}}
aioclient_mock.get("http://127.0.0.1:2020/&device", sid... | [
"async",
"def",
"test_light_device",
"(",
"hass",
",",
"aioclient_mock",
",",
"qs_devices",
")",
":",
"async",
"def",
"get_devices_json",
"(",
"method",
",",
"url",
",",
"data",
")",
":",
"return",
"AiohttpClientMockResponse",
"(",
"method",
"=",
"method",
","... | [
182,
0
] | [
250,
22
] | python | ca | ['ca', 'cs', 'en'] | False |
test_button | (hass, aioclient_mock, qs_devices) | Test that buttons fire an event. | Test that buttons fire an event. | async def test_button(hass, aioclient_mock, qs_devices):
"""Test that buttons fire an event."""
async def get_devices_json(method, url, data):
return AiohttpClientMockResponse(method=method, url=url, json=qs_devices)
config = {"qwikswitch": {"button_events": "TOGGLE"}}
aioclient_mock.get("http... | [
"async",
"def",
"test_button",
"(",
"hass",
",",
"aioclient_mock",
",",
"qs_devices",
")",
":",
"async",
"def",
"get_devices_json",
"(",
"method",
",",
"url",
",",
"data",
")",
":",
"return",
"AiohttpClientMockResponse",
"(",
"method",
"=",
"method",
",",
"u... | [
253,
0
] | [
276,
22
] | python | en | ['en', 'lb', 'en'] | True |
test_failed_update_devices | (hass, aioclient_mock) | Test that code behaves correctly when unable to get the devices. | Test that code behaves correctly when unable to get the devices. | async def test_failed_update_devices(hass, aioclient_mock):
"""Test that code behaves correctly when unable to get the devices."""
config = {"qwikswitch": {}}
aioclient_mock.get("http://127.0.0.1:2020/&device", exc=ClientError())
listen_mock = MockLongPollSideEffect()
aioclient_mock.get("http://127... | [
"async",
"def",
"test_failed_update_devices",
"(",
"hass",
",",
"aioclient_mock",
")",
":",
"config",
"=",
"{",
"\"qwikswitch\"",
":",
"{",
"}",
"}",
"aioclient_mock",
".",
"get",
"(",
"\"http://127.0.0.1:2020/&device\"",
",",
"exc",
"=",
"ClientError",
"(",
")"... | [
279,
0
] | [
289,
22
] | python | en | ['en', 'en', 'en'] | True |
test_single_invalid_sensor | (hass, aioclient_mock, qs_devices) | Test that a single misconfigured sensor doesn't block the others. | Test that a single misconfigured sensor doesn't block the others. | async def test_single_invalid_sensor(hass, aioclient_mock, qs_devices):
"""Test that a single misconfigured sensor doesn't block the others."""
config = {
"qwikswitch": {
"sensors": [
{"name": "ss1", "id": "@a00001", "channel": 1, "type": "qwikcord"},
{"name"... | [
"async",
"def",
"test_single_invalid_sensor",
"(",
"hass",
",",
"aioclient_mock",
",",
"qs_devices",
")",
":",
"config",
"=",
"{",
"\"qwikswitch\"",
":",
"{",
"\"sensors\"",
":",
"[",
"{",
"\"name\"",
":",
"\"ss1\"",
",",
"\"id\"",
":",
"\"@a00001\"",
",",
"... | [
292,
0
] | [
314,
22
] | python | en | ['en', 'en', 'en'] | True |
test_non_binary_sensor_with_binary_args | (
hass, aioclient_mock, qs_devices, caplog
) | Test that the system logs a warning when a non-binary device has binary specific args. | Test that the system logs a warning when a non-binary device has binary specific args. | async def test_non_binary_sensor_with_binary_args(
hass, aioclient_mock, qs_devices, caplog
):
"""Test that the system logs a warning when a non-binary device has binary specific args."""
config = {
"qwikswitch": {
"sensors": [
{
"name": "ss1",
... | [
"async",
"def",
"test_non_binary_sensor_with_binary_args",
"(",
"hass",
",",
"aioclient_mock",
",",
"qs_devices",
",",
"caplog",
")",
":",
"config",
"=",
"{",
"\"qwikswitch\"",
":",
"{",
"\"sensors\"",
":",
"[",
"{",
"\"name\"",
":",
"\"ss1\"",
",",
"\"id\"",
... | [
317,
0
] | [
345,
22
] | python | en | ['en', 'en', 'en'] | True |
test_non_relay_switch | (hass, aioclient_mock, qs_devices, caplog) | Test that the system logs a warning when a switch is configured for a device that is not a relay. | Test that the system logs a warning when a switch is configured for a device that is not a relay. | async def test_non_relay_switch(hass, aioclient_mock, qs_devices, caplog):
"""Test that the system logs a warning when a switch is configured for a device that is not a relay."""
config = {"qwikswitch": {"switches": ["@a00003"]}}
aioclient_mock.get("http://127.0.0.1:2020/&device", json=qs_devices)
list... | [
"async",
"def",
"test_non_relay_switch",
"(",
"hass",
",",
"aioclient_mock",
",",
"qs_devices",
",",
"caplog",
")",
":",
"config",
"=",
"{",
"\"qwikswitch\"",
":",
"{",
"\"switches\"",
":",
"[",
"\"@a00003\"",
"]",
"}",
"}",
"aioclient_mock",
".",
"get",
"("... | [
348,
0
] | [
362,
22
] | python | en | ['en', 'en', 'en'] | True |
test_unknown_device | (hass, aioclient_mock, qs_devices, caplog) | Test that the system logs a warning when a network device has unknown type. | Test that the system logs a warning when a network device has unknown type. | async def test_unknown_device(hass, aioclient_mock, qs_devices, caplog):
"""Test that the system logs a warning when a network device has unknown type."""
config = {"qwikswitch": {}}
qs_devices[1]["type"] = "ERROR_TYPE"
aioclient_mock.get("http://127.0.0.1:2020/&device", json=qs_devices)
listen_moc... | [
"async",
"def",
"test_unknown_device",
"(",
"hass",
",",
"aioclient_mock",
",",
"qs_devices",
",",
"caplog",
")",
":",
"config",
"=",
"{",
"\"qwikswitch\"",
":",
"{",
"}",
"}",
"qs_devices",
"[",
"1",
"]",
"[",
"\"type\"",
"]",
"=",
"\"ERROR_TYPE\"",
"aioc... | [
365,
0
] | [
382,
22
] | python | en | ['en', 'en', 'en'] | True |
test_no_discover_info | (hass, hass_storage, aioclient_mock, caplog) | Test that discovery with no discovery_info does not result in errors. | Test that discovery with no discovery_info does not result in errors. | async def test_no_discover_info(hass, hass_storage, aioclient_mock, caplog):
"""Test that discovery with no discovery_info does not result in errors."""
config = {
"qwikswitch": {},
"light": {"platform": "qwikswitch"},
"switch": {"platform": "qwikswitch"},
"sensor": {"platform": ... | [
"async",
"def",
"test_no_discover_info",
"(",
"hass",
",",
"hass_storage",
",",
"aioclient_mock",
",",
"caplog",
")",
":",
"config",
"=",
"{",
"\"qwikswitch\"",
":",
"{",
"}",
",",
"\"light\"",
":",
"{",
"\"platform\"",
":",
"\"qwikswitch\"",
"}",
",",
"\"sw... | [
385,
0
] | [
416,
22
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (
hass: HomeAssistant,
entry: ConfigEntry,
async_add_entities: Callable[[List[Entity], bool], None],
) | Set up the sensor config entry. | Set up the sensor config entry. | async def async_setup_entry(
hass: HomeAssistant,
entry: ConfigEntry,
async_add_entities: Callable[[List[Entity], bool], None],
) -> None:
"""Set up the sensor config entry."""
controller_data = get_controller_data(hass, entry)
async_add_entities(
[
VeraLight(device, controll... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
",",
"async_add_entities",
":",
"Callable",
"[",
"[",
"List",
"[",
"Entity",
"]",
",",
"bool",
"]",
",",
"None",
"]",
",",
")",
"->",
"None",
":",
... | [
23,
0
] | [
35,
5
] | python | en | ['en', 'pt', 'en'] | True |
VeraLight.__init__ | (
self, vera_device: veraApi.VeraDimmer, controller_data: ControllerData
) | Initialize the light. | Initialize the light. | def __init__(
self, vera_device: veraApi.VeraDimmer, controller_data: ControllerData
):
"""Initialize the light."""
self._state = False
self._color = None
self._brightness = None
VeraDevice.__init__(self, vera_device, controller_data)
self.entity_id = ENTITY_I... | [
"def",
"__init__",
"(",
"self",
",",
"vera_device",
":",
"veraApi",
".",
"VeraDimmer",
",",
"controller_data",
":",
"ControllerData",
")",
":",
"self",
".",
"_state",
"=",
"False",
"self",
".",
"_color",
"=",
"None",
"self",
".",
"_brightness",
"=",
"None"... | [
41,
4
] | [
49,
62
] | python | en | ['en', 'en', 'en'] | True |
VeraLight.brightness | (self) | Return the brightness of the light. | Return the brightness of the light. | def brightness(self) -> Optional[int]:
"""Return the brightness of the light."""
return self._brightness | [
"def",
"brightness",
"(",
"self",
")",
"->",
"Optional",
"[",
"int",
"]",
":",
"return",
"self",
".",
"_brightness"
] | [
52,
4
] | [
54,
31
] | python | en | ['en', 'no', 'en'] | True |
VeraLight.hs_color | (self) | Return the color of the light. | Return the color of the light. | def hs_color(self) -> Optional[Tuple[float, float]]:
"""Return the color of the light."""
return self._color | [
"def",
"hs_color",
"(",
"self",
")",
"->",
"Optional",
"[",
"Tuple",
"[",
"float",
",",
"float",
"]",
"]",
":",
"return",
"self",
".",
"_color"
] | [
57,
4
] | [
59,
26
] | python | en | ['en', 'en', 'en'] | True |
VeraLight.supported_features | (self) | Flag supported features. | Flag supported features. | def supported_features(self) -> int:
"""Flag supported features."""
if self._color:
return SUPPORT_BRIGHTNESS | SUPPORT_COLOR
return SUPPORT_BRIGHTNESS | [
"def",
"supported_features",
"(",
"self",
")",
"->",
"int",
":",
"if",
"self",
".",
"_color",
":",
"return",
"SUPPORT_BRIGHTNESS",
"|",
"SUPPORT_COLOR",
"return",
"SUPPORT_BRIGHTNESS"
] | [
62,
4
] | [
66,
33
] | python | en | ['da', 'en', 'en'] | True |
VeraLight.turn_on | (self, **kwargs: Any) | Turn the light on. | Turn the light on. | def turn_on(self, **kwargs: Any) -> None:
"""Turn the light on."""
if ATTR_HS_COLOR in kwargs and self._color:
rgb = color_util.color_hs_to_RGB(*kwargs[ATTR_HS_COLOR])
self.vera_device.set_color(rgb)
elif ATTR_BRIGHTNESS in kwargs and self.vera_device.is_dimmable:
... | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"None",
":",
"if",
"ATTR_HS_COLOR",
"in",
"kwargs",
"and",
"self",
".",
"_color",
":",
"rgb",
"=",
"color_util",
".",
"color_hs_to_RGB",
"(",
"*",
"kwargs",
"[",
"ATTR_HS_CO... | [
68,
4
] | [
79,
43
] | python | en | ['en', 'et', 'en'] | True |
VeraLight.turn_off | (self, **kwargs: Any) | Turn the light off. | Turn the light off. | def turn_off(self, **kwargs: Any):
"""Turn the light off."""
self.vera_device.switch_off()
self._state = False
self.schedule_update_ha_state() | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
":",
"self",
".",
"vera_device",
".",
"switch_off",
"(",
")",
"self",
".",
"_state",
"=",
"False",
"self",
".",
"schedule_update_ha_state",
"(",
")"
] | [
81,
4
] | [
85,
39
] | python | en | ['en', 'zh', 'en'] | True |
VeraLight.is_on | (self) | Return true if device is on. | Return true if device is on. | def is_on(self) -> bool:
"""Return true if device is on."""
return self._state | [
"def",
"is_on",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"_state"
] | [
88,
4
] | [
90,
26
] | python | en | ['en', 'fy', 'en'] | True |
VeraLight.update | (self) | Call to update state. | Call to update state. | def update(self) -> None:
"""Call to update state."""
self._state = self.vera_device.is_switched_on()
if self.vera_device.is_dimmable:
# If it is dimmable, both functions exist. In case color
# is not supported, it will return None
self._brightness = self.vera... | [
"def",
"update",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"_state",
"=",
"self",
".",
"vera_device",
".",
"is_switched_on",
"(",
")",
"if",
"self",
".",
"vera_device",
".",
"is_dimmable",
":",
"# If it is dimmable, both functions exist. In case color",
... | [
92,
4
] | [
100,
75
] | python | en | ['en', 'en', 'en'] | True |
run | (argv=None) | The main function which creates the pipeline and runs it. | The main function which creates the pipeline and runs it. | def run(argv=None):
"""The main function which creates the pipeline and runs it."""
parser = argparse.ArgumentParser()
# Here we add some specific command line arguments we expect. Specifically
# we have the input file to load and the output table to write to.
parser.add_argument(
'--input... | [
"def",
"run",
"(",
"argv",
"=",
"None",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
")",
"# Here we add some specific command line arguments we expect. Specifically",
"# we have the input file to load and the output table to write to.",
"parser",
".",
"ad... | [
104,
0
] | [
160,
31
] | python | en | ['en', 'en', 'en'] | True |
DataTransformation.parse_method | (self, string_input) | This method translates a single line of comma separated values to a
dictionary which can be loaded into BigQuery.
Args:
string_input: A comma separated list of values in the form of
state_abbreviation,gender,year,name,count_of_babies,dataset_created_date
example stri... | This method translates a single line of comma separated values to a
dictionary which can be loaded into BigQuery. | def parse_method(self, string_input):
"""This method translates a single line of comma separated values to a
dictionary which can be loaded into BigQuery.
Args:
string_input: A comma separated list of values in the form of
state_abbreviation,gender,year,name,count_of_babies,... | [
"def",
"parse_method",
"(",
"self",
",",
"string_input",
")",
":",
"# Strip out return characters and quote characters.",
"schema",
"=",
"parse_table_schema_from_json",
"(",
"self",
".",
"schema_str",
")",
"field_map",
"=",
"[",
"f",
"for",
"f",
"in",
"schema",
".",... | [
48,
4
] | [
101,
22
] | python | en | ['en', 'en', 'en'] | True |
async_init_integration | (
hass: HomeAssistant,
skip_setup: bool = False,
) | Set up the tado integration in Home Assistant. | Set up the tado integration in Home Assistant. | async def async_init_integration(
hass: HomeAssistant,
skip_setup: bool = False,
):
"""Set up the tado integration in Home Assistant."""
token_fixture = "tado/token.json"
devices_fixture = "tado/devices.json"
me_fixture = "tado/me.json"
zones_fixture = "tado/zones.json"
# Smart AC with... | [
"async",
"def",
"async_init_integration",
"(",
"hass",
":",
"HomeAssistant",
",",
"skip_setup",
":",
"bool",
"=",
"False",
",",
")",
":",
"token_fixture",
"=",
"\"tado/token.json\"",
"devices_fixture",
"=",
"\"tado/devices.json\"",
"me_fixture",
"=",
"\"tado/me.json\"... | [
11,
0
] | [
103,
46
] | python | en | ['en', 'en', 'en'] | True |
fritz_fixture | () | Patch libraries. | Patch libraries. | def fritz_fixture() -> Mock:
"""Patch libraries."""
with patch("homeassistant.components.fritzbox.socket") as socket, patch(
"homeassistant.components.fritzbox.Fritzhome"
) as fritz, patch("homeassistant.components.fritzbox.config_flow.Fritzhome"):
socket.gethostbyname.return_value = "FAKE_I... | [
"def",
"fritz_fixture",
"(",
")",
"->",
"Mock",
":",
"with",
"patch",
"(",
"\"homeassistant.components.fritzbox.socket\"",
")",
"as",
"socket",
",",
"patch",
"(",
"\"homeassistant.components.fritzbox.Fritzhome\"",
")",
"as",
"fritz",
",",
"patch",
"(",
"\"homeassistan... | [
7,
0
] | [
13,
19
] | python | en | ['en', 'en', 'en'] | False |
init | (empty=False) | Initialize the platform with entities. | Initialize the platform with entities. | def init(empty=False):
"""Initialize the platform with entities."""
global ENTITIES
ENTITIES = (
[]
if empty
else [
MockToggleEntity("AC", STATE_ON),
MockToggleEntity("AC", STATE_OFF),
MockToggleEntity(None, STATE_OFF),
]
) | [
"def",
"init",
"(",
"empty",
"=",
"False",
")",
":",
"global",
"ENTITIES",
"ENTITIES",
"=",
"(",
"[",
"]",
"if",
"empty",
"else",
"[",
"MockToggleEntity",
"(",
"\"AC\"",
",",
"STATE_ON",
")",
",",
"MockToggleEntity",
"(",
"\"AC\"",
",",
"STATE_OFF",
")",... | [
12,
0
] | [
24,
5
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (
hass, config, async_add_entities_callback, discovery_info=None
) | Return mock entities. | Return mock entities. | async def async_setup_platform(
hass, config, async_add_entities_callback, discovery_info=None
):
"""Return mock entities."""
async_add_entities_callback(ENTITIES) | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities_callback",
",",
"discovery_info",
"=",
"None",
")",
":",
"async_add_entities_callback",
"(",
"ENTITIES",
")"
] | [
27,
0
] | [
31,
41
] | python | af | ['nl', 'af', 'en'] | False |
dummy_client_fixture | (hass) | Mock out the real client. | Mock out the real client. | def dummy_client_fixture(hass):
"""Mock out the real client."""
with patch("homeassistant.components.arcam_fmj.config_flow.Client") as client:
client.return_value.start.side_effect = AsyncMock(return_value=None)
client.return_value.stop.side_effect = AsyncMock(return_value=None)
yield cl... | [
"def",
"dummy_client_fixture",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.arcam_fmj.config_flow.Client\"",
")",
"as",
"client",
":",
"client",
".",
"return_value",
".",
"start",
".",
"side_effect",
"=",
"AsyncMock",
"(",
"return_value",
... | [
47,
0
] | [
52,
33
] | python | en | ['en', 'en', 'en'] | True |
test_ssdp | (hass, dummy_client) | Test a ssdp import flow. | Test a ssdp import flow. | async def test_ssdp(hass, dummy_client):
"""Test a ssdp import flow."""
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={CONF_SOURCE: SOURCE_SSDP},
data=MOCK_DISCOVER,
)
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
assert result["step_id"] == ... | [
"async",
"def",
"test_ssdp",
"(",
"hass",
",",
"dummy_client",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"CONF_SOURCE",
":",
"SOURCE_SSDP",
"}",
",",
"data",
... | [
55,
0
] | [
68,
46
] | python | en | ['en', 'fr', 'en'] | True |
test_ssdp_abort | (hass) | Test a ssdp import flow. | Test a ssdp import flow. | async def test_ssdp_abort(hass):
"""Test a ssdp import flow."""
entry = MockConfigEntry(
domain=DOMAIN, data=MOCK_CONFIG_ENTRY, title=MOCK_NAME, unique_id=MOCK_UUID
)
entry.add_to_hass(hass)
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={CONF_SOURCE: SO... | [
"async",
"def",
"test_ssdp_abort",
"(",
"hass",
")",
":",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"data",
"=",
"MOCK_CONFIG_ENTRY",
",",
"title",
"=",
"MOCK_NAME",
",",
"unique_id",
"=",
"MOCK_UUID",
")",
"entry",
".",
"add_to_has... | [
71,
0
] | [
84,
51
] | python | en | ['en', 'fr', 'en'] | True |
test_ssdp_unable_to_connect | (hass, dummy_client) | Test a ssdp import flow. | Test a ssdp import flow. | async def test_ssdp_unable_to_connect(hass, dummy_client):
"""Test a ssdp import flow."""
dummy_client.start.side_effect = AsyncMock(side_effect=ConnectionFailed)
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={CONF_SOURCE: SOURCE_SSDP},
data=MOCK_DISCOVER,
... | [
"async",
"def",
"test_ssdp_unable_to_connect",
"(",
"hass",
",",
"dummy_client",
")",
":",
"dummy_client",
".",
"start",
".",
"side_effect",
"=",
"AsyncMock",
"(",
"side_effect",
"=",
"ConnectionFailed",
")",
"result",
"=",
"await",
"hass",
".",
"config_entries",
... | [
87,
0
] | [
101,
47
] | python | en | ['en', 'fr', 'en'] | True |
test_ssdp_update | (hass) | Test a ssdp import flow. | Test a ssdp import flow. | async def test_ssdp_update(hass):
"""Test a ssdp import flow."""
entry = MockConfigEntry(
domain=DOMAIN,
data={CONF_HOST: "old_host", CONF_PORT: MOCK_PORT},
title=MOCK_NAME,
unique_id=MOCK_UUID,
)
entry.add_to_hass(hass)
result = await hass.config_entries.flow.async_... | [
"async",
"def",
"test_ssdp_update",
"(",
"hass",
")",
":",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"data",
"=",
"{",
"CONF_HOST",
":",
"\"old_host\"",
",",
"CONF_PORT",
":",
"MOCK_PORT",
"}",
",",
"title",
"=",
"MOCK_NAME",
",",... | [
104,
0
] | [
122,
45
] | python | en | ['en', 'fr', 'en'] | True |
test_user | (hass, aioclient_mock) | Test a manual user configuration flow. | Test a manual user configuration flow. | async def test_user(hass, aioclient_mock):
"""Test a manual user configuration flow."""
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={CONF_SOURCE: SOURCE_USER},
data=None,
)
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
assert result["step... | [
"async",
"def",
"test_user",
"(",
"hass",
",",
"aioclient_mock",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"CONF_SOURCE",
":",
"SOURCE_USER",
"}",
",",
"data",
... | [
125,
0
] | [
149,
50
] | python | en | ['en', 'en', 'en'] | True |
test_invalid_ssdp | (hass, aioclient_mock) | Test a a config flow where ssdp fails. | Test a a config flow where ssdp fails. | async def test_invalid_ssdp(hass, aioclient_mock):
"""Test a a config flow where ssdp fails."""
user_input = {
CONF_HOST: MOCK_HOST,
CONF_PORT: MOCK_PORT,
}
aioclient_mock.get(MOCK_UPNP_LOCATION, text="")
result = await hass.config_entries.flow.async_init(
DOMAIN,
co... | [
"async",
"def",
"test_invalid_ssdp",
"(",
"hass",
",",
"aioclient_mock",
")",
":",
"user_input",
"=",
"{",
"CONF_HOST",
":",
"MOCK_HOST",
",",
"CONF_PORT",
":",
"MOCK_PORT",
",",
"}",
"aioclient_mock",
".",
"get",
"(",
"MOCK_UPNP_LOCATION",
",",
"text",
"=",
... | [
152,
0
] | [
168,
45
] | python | en | ['en', 'gd', 'en'] | True |
test_user_wrong | (hass, aioclient_mock) | Test a manual user configuration flow with no ssdp response. | Test a manual user configuration flow with no ssdp response. | async def test_user_wrong(hass, aioclient_mock):
"""Test a manual user configuration flow with no ssdp response."""
user_input = {
CONF_HOST: MOCK_HOST,
CONF_PORT: MOCK_PORT,
}
aioclient_mock.get(MOCK_UPNP_LOCATION, status=404)
result = await hass.config_entries.flow.async_init(
... | [
"async",
"def",
"test_user_wrong",
"(",
"hass",
",",
"aioclient_mock",
")",
":",
"user_input",
"=",
"{",
"CONF_HOST",
":",
"MOCK_HOST",
",",
"CONF_PORT",
":",
"MOCK_PORT",
",",
"}",
"aioclient_mock",
".",
"get",
"(",
"MOCK_UPNP_LOCATION",
",",
"status",
"=",
... | [
171,
0
] | [
186,
45
] | python | en | ['en', 'en', 'en'] | True |
test_get_entry_client | (hass) | Test helper for configuration. | Test helper for configuration. | async def test_get_entry_client(hass):
"""Test helper for configuration."""
entry = MockConfigEntry(
domain=DOMAIN, data=MOCK_CONFIG_ENTRY, title=MOCK_NAME, unique_id=MOCK_UUID
)
hass.data[DOMAIN_DATA_ENTRIES] = {entry.entry_id: "dummy"}
assert get_entry_client(hass, entry) == "dummy" | [
"async",
"def",
"test_get_entry_client",
"(",
"hass",
")",
":",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"data",
"=",
"MOCK_CONFIG_ENTRY",
",",
"title",
"=",
"MOCK_NAME",
",",
"unique_id",
"=",
"MOCK_UUID",
")",
"hass",
".",
"data"... | [
189,
0
] | [
195,
51
] | python | en | ['da', 'en', 'en'] | True |
mock_device | () | Mock a Dynalite device. | Mock a Dynalite device. | def mock_device():
"""Mock a Dynalite device."""
return create_mock_device("light", DynaliteChannelLightDevice) | [
"def",
"mock_device",
"(",
")",
":",
"return",
"create_mock_device",
"(",
"\"light\"",
",",
"DynaliteChannelLightDevice",
")"
] | [
19,
0
] | [
21,
66
] | python | en | ['ro', 'ht', 'en'] | False |
test_light_setup | (hass, mock_device) | Test a successful setup. | Test a successful setup. | async def test_light_setup(hass, mock_device):
"""Test a successful setup."""
await create_entity_from_device(hass, mock_device)
entity_state = hass.states.get("light.name")
assert entity_state.attributes[ATTR_FRIENDLY_NAME] == mock_device.name
assert entity_state.attributes["brightness"] == mock_de... | [
"async",
"def",
"test_light_setup",
"(",
"hass",
",",
"mock_device",
")",
":",
"await",
"create_entity_from_device",
"(",
"hass",
",",
"mock_device",
")",
"entity_state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"\"light.name\"",
")",
"assert",
"entity_state... | [
24,
0
] | [
39,
5
] | python | en | ['en', 'co', 'en'] | True |
test_remove_entity | (hass, mock_device) | Test when an entity is removed from HA. | Test when an entity is removed from HA. | async def test_remove_entity(hass, mock_device):
"""Test when an entity is removed from HA."""
await create_entity_from_device(hass, mock_device)
assert hass.states.get("light.name")
entry_id = await get_entry_id_from_hass(hass)
assert await hass.config_entries.async_unload(entry_id)
await hass.... | [
"async",
"def",
"test_remove_entity",
"(",
"hass",
",",
"mock_device",
")",
":",
"await",
"create_entity_from_device",
"(",
"hass",
",",
"mock_device",
")",
"assert",
"hass",
".",
"states",
".",
"get",
"(",
"\"light.name\"",
")",
"entry_id",
"=",
"await",
"get... | [
42,
0
] | [
49,
44
] | python | en | ['en', 'en', 'en'] | True |
auth | (aiohttp_client) | Fixture for an AbstractAuth. | Fixture for an AbstractAuth. | async def auth(aiohttp_client):
"""Fixture for an AbstractAuth."""
auth = FakeAuth()
app = aiohttp.web.Application()
app.router.add_get("/", auth.response_handler)
app.router.add_post("/", auth.response_handler)
auth.client = await aiohttp_client(app)
return auth | [
"async",
"def",
"auth",
"(",
"aiohttp_client",
")",
":",
"auth",
"=",
"FakeAuth",
"(",
")",
"app",
"=",
"aiohttp",
".",
"web",
".",
"Application",
"(",
")",
"app",
".",
"router",
".",
"add_get",
"(",
"\"/\"",
",",
"auth",
".",
"response_handler",
")",
... | [
49,
0
] | [
56,
15
] | python | en | ['en', 'en', 'en'] | True |
FakeAuth.__init__ | (self) | Initialize FakeAuth. | Initialize FakeAuth. | def __init__(self):
"""Initialize FakeAuth."""
super().__init__(None, None) | [
"def",
"__init__",
"(",
"self",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"None",
",",
"None",
")"
] | [
26,
4
] | [
28,
36
] | python | en | ['en', 'en', 'en'] | False |
FakeAuth.async_get_access_token | (self) | Return a valid access token. | Return a valid access token. | async def async_get_access_token(self) -> str:
"""Return a valid access token."""
return "" | [
"async",
"def",
"async_get_access_token",
"(",
"self",
")",
"->",
"str",
":",
"return",
"\"\""
] | [
30,
4
] | [
32,
17
] | python | en | ['en', 'lb', 'en'] | True |
FakeAuth.request | (self, method, url, json) | Capure the request arguments for tests to assert on. | Capure the request arguments for tests to assert on. | async def request(self, method, url, json):
"""Capure the request arguments for tests to assert on."""
self.method = method
self.url = url
self.json = json
return await self.client.get("/") | [
"async",
"def",
"request",
"(",
"self",
",",
"method",
",",
"url",
",",
"json",
")",
":",
"self",
".",
"method",
"=",
"method",
"self",
".",
"url",
"=",
"url",
"self",
".",
"json",
"=",
"json",
"return",
"await",
"self",
".",
"client",
".",
"get",
... | [
34,
4
] | [
39,
41
] | python | en | ['en', 'en', 'en'] | True |
FakeAuth.response_handler | (self, request) | Handle fake responess for aiohttp_server. | Handle fake responess for aiohttp_server. | async def response_handler(self, request):
"""Handle fake responess for aiohttp_server."""
if len(self.responses) > 0:
return self.responses.pop(0)
return aiohttp.web.json_response() | [
"async",
"def",
"response_handler",
"(",
"self",
",",
"request",
")",
":",
"if",
"len",
"(",
"self",
".",
"responses",
")",
">",
"0",
":",
"return",
"self",
".",
"responses",
".",
"pop",
"(",
"0",
")",
"return",
"aiohttp",
".",
"web",
".",
"json_resp... | [
41,
4
] | [
45,
42
] | python | en | ['en', 'pt', 'en'] | True |
train | (args, train_dataset, model, tokenizer, train_highway=False) | Train the model | Train the model | def train(args, train_dataset, model, tokenizer, train_highway=False):
""" Train the model """
if args.local_rank in [-1, 0]:
tb_writer = SummaryWriter()
args.train_batch_size = args.per_gpu_train_batch_size * max(1, args.n_gpu)
train_sampler = RandomSampler(train_dataset) if args.local_rank ==... | [
"def",
"train",
"(",
"args",
",",
"train_dataset",
",",
"model",
",",
"tokenizer",
",",
"train_highway",
"=",
"False",
")",
":",
"if",
"args",
".",
"local_rank",
"in",
"[",
"-",
"1",
",",
"0",
"]",
":",
"tb_writer",
"=",
"SummaryWriter",
"(",
")",
"a... | [
71,
0
] | [
235,
45
] | python | en | ['en', 'it', 'en'] | True |
async_setup_platform | (
hass: HomeAssistantType, config: ConfigType, async_add_entities, discovery_info=None
) | Set up the Genius Hub sensor entities. | Set up the Genius Hub sensor entities. | async def async_setup_platform(
hass: HomeAssistantType, config: ConfigType, async_add_entities, discovery_info=None
) -> None:
"""Set up the Genius Hub sensor entities."""
if discovery_info is None:
return
broker = hass.data[DOMAIN]["broker"]
sensors = [
GeniusBattery(broker, d, G... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
":",
"HomeAssistantType",
",",
"config",
":",
"ConfigType",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
"->",
"None",
":",
"if",
"discovery_info",
"is",
"None",
":",
"return",
"broker",... | [
19,
0
] | [
35,
64
] | python | en | ['en', 'et', 'en'] | True |
GeniusBattery.__init__ | (self, broker, device, state_attr) | Initialize the sensor. | Initialize the sensor. | def __init__(self, broker, device, state_attr) -> None:
"""Initialize the sensor."""
super().__init__(broker, device)
self._state_attr = state_attr
self._name = f"{device.type} {device.id}" | [
"def",
"__init__",
"(",
"self",
",",
"broker",
",",
"device",
",",
"state_attr",
")",
"->",
"None",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"broker",
",",
"device",
")",
"self",
".",
"_state_attr",
"=",
"state_attr",
"self",
".",
"_name",
"=",
... | [
41,
4
] | [
47,
49
] | python | en | ['en', 'en', 'en'] | True |
GeniusBattery.icon | (self) | Return the icon of the sensor. | Return the icon of the sensor. | def icon(self) -> str:
"""Return the icon of the sensor."""
if "_state" in self._device.data: # only for v3 API
interval = timedelta(
seconds=self._device.data["_state"].get("wakeupInterval", 30 * 60)
)
if self._last_comms < dt_util.utcnow() - interva... | [
"def",
"icon",
"(",
"self",
")",
"->",
"str",
":",
"if",
"\"_state\"",
"in",
"self",
".",
"_device",
".",
"data",
":",
"# only for v3 API",
"interval",
"=",
"timedelta",
"(",
"seconds",
"=",
"self",
".",
"_device",
".",
"data",
"[",
"\"_state\"",
"]",
... | [
50,
4
] | [
69,
19
] | python | en | ['en', 'en', 'en'] | True |
GeniusBattery.device_class | (self) | Return the device class of the sensor. | Return the device class of the sensor. | def device_class(self) -> str:
"""Return the device class of the sensor."""
return DEVICE_CLASS_BATTERY | [
"def",
"device_class",
"(",
"self",
")",
"->",
"str",
":",
"return",
"DEVICE_CLASS_BATTERY"
] | [
72,
4
] | [
74,
35
] | python | en | ['en', 'en', 'en'] | True |
GeniusBattery.unit_of_measurement | (self) | Return the unit of measurement of the sensor. | Return the unit of measurement of the sensor. | def unit_of_measurement(self) -> str:
"""Return the unit of measurement of the sensor."""
return PERCENTAGE | [
"def",
"unit_of_measurement",
"(",
"self",
")",
"->",
"str",
":",
"return",
"PERCENTAGE"
] | [
77,
4
] | [
79,
25
] | python | en | ['en', 'bg', 'en'] | True |
GeniusBattery.state | (self) | Return the state of the sensor. | Return the state of the sensor. | def state(self) -> str:
"""Return the state of the sensor."""
level = self._device.data["state"][self._state_attr]
return level if level != 255 else 0 | [
"def",
"state",
"(",
"self",
")",
"->",
"str",
":",
"level",
"=",
"self",
".",
"_device",
".",
"data",
"[",
"\"state\"",
"]",
"[",
"self",
".",
"_state_attr",
"]",
"return",
"level",
"if",
"level",
"!=",
"255",
"else",
"0"
] | [
82,
4
] | [
85,
43
] | python | en | ['en', 'en', 'en'] | True |
GeniusIssue.__init__ | (self, broker, level) | Initialize the sensor. | Initialize the sensor. | def __init__(self, broker, level) -> None:
"""Initialize the sensor."""
super().__init__()
self._hub = broker.client
self._unique_id = f"{broker.hub_uid}_{GH_LEVEL_MAPPING[level]}"
self._name = f"GeniusHub {GH_LEVEL_MAPPING[level]}"
self._level = level
self._iss... | [
"def",
"__init__",
"(",
"self",
",",
"broker",
",",
"level",
")",
"->",
"None",
":",
"super",
"(",
")",
".",
"__init__",
"(",
")",
"self",
".",
"_hub",
"=",
"broker",
".",
"client",
"self",
".",
"_unique_id",
"=",
"f\"{broker.hub_uid}_{GH_LEVEL_MAPPING[lev... | [
91,
4
] | [
100,
25
] | python | en | ['en', 'en', 'en'] | True |
GeniusIssue.state | (self) | Return the number of issues. | Return the number of issues. | def state(self) -> str:
"""Return the number of issues."""
return len(self._issues) | [
"def",
"state",
"(",
"self",
")",
"->",
"str",
":",
"return",
"len",
"(",
"self",
".",
"_issues",
")"
] | [
103,
4
] | [
105,
32
] | python | en | ['en', 'en', 'en'] | True |
GeniusIssue.device_state_attributes | (self) | Return the device state attributes. | Return the device state attributes. | def device_state_attributes(self) -> Dict[str, Any]:
"""Return the device state attributes."""
return {f"{self._level}_list": self._issues} | [
"def",
"device_state_attributes",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"return",
"{",
"f\"{self._level}_list\"",
":",
"self",
".",
"_issues",
"}"
] | [
108,
4
] | [
110,
52
] | 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.