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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
SlideCover.device_state_attributes | (self) | Return device specific state attributes. | Return device specific state attributes. | def device_state_attributes(self):
"""Return device specific state attributes."""
return {ATTR_ID: self._id} | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"{",
"ATTR_ID",
":",
"self",
".",
"_id",
"}"
] | [
57,
4
] | [
59,
34
] | python | en | ['fr', 'en', 'en'] | True |
SlideCover.is_opening | (self) | Return if the cover is opening or not. | Return if the cover is opening or not. | def is_opening(self):
"""Return if the cover is opening or not."""
return self._slide["state"] == STATE_OPENING | [
"def",
"is_opening",
"(",
"self",
")",
":",
"return",
"self",
".",
"_slide",
"[",
"\"state\"",
"]",
"==",
"STATE_OPENING"
] | [
62,
4
] | [
64,
52
] | python | en | ['en', 'en', 'en'] | True |
SlideCover.is_closing | (self) | Return if the cover is closing or not. | Return if the cover is closing or not. | def is_closing(self):
"""Return if the cover is closing or not."""
return self._slide["state"] == STATE_CLOSING | [
"def",
"is_closing",
"(",
"self",
")",
":",
"return",
"self",
".",
"_slide",
"[",
"\"state\"",
"]",
"==",
"STATE_CLOSING"
] | [
67,
4
] | [
69,
52
] | python | en | ['en', 'en', 'en'] | True |
SlideCover.is_closed | (self) | Return None if status is unknown, True if closed, else False. | Return None if status is unknown, True if closed, else False. | def is_closed(self):
"""Return None if status is unknown, True if closed, else False."""
if self._slide["state"] is None:
return None
return self._slide["state"] == STATE_CLOSED | [
"def",
"is_closed",
"(",
"self",
")",
":",
"if",
"self",
".",
"_slide",
"[",
"\"state\"",
"]",
"is",
"None",
":",
"return",
"None",
"return",
"self",
".",
"_slide",
"[",
"\"state\"",
"]",
"==",
"STATE_CLOSED"
] | [
72,
4
] | [
76,
51
] | python | en | ['en', 'en', 'en'] | True |
SlideCover.available | (self) | Return False if state is not available. | Return False if state is not available. | def available(self):
"""Return False if state is not available."""
return self._slide["online"] | [
"def",
"available",
"(",
"self",
")",
":",
"return",
"self",
".",
"_slide",
"[",
"\"online\"",
"]"
] | [
79,
4
] | [
81,
36
] | python | en | ['en', 'en', 'en'] | True |
SlideCover.assumed_state | (self) | Let HA know the integration is assumed state. | Let HA know the integration is assumed state. | def assumed_state(self):
"""Let HA know the integration is assumed state."""
return True | [
"def",
"assumed_state",
"(",
"self",
")",
":",
"return",
"True"
] | [
84,
4
] | [
86,
19
] | python | en | ['en', 'en', 'en'] | True |
SlideCover.device_class | (self) | Return the device class of the cover. | Return the device class of the cover. | def device_class(self):
"""Return the device class of the cover."""
return DEVICE_CLASS_CURTAIN | [
"def",
"device_class",
"(",
"self",
")",
":",
"return",
"DEVICE_CLASS_CURTAIN"
] | [
89,
4
] | [
91,
35
] | python | en | ['en', 'en', 'en'] | True |
SlideCover.current_cover_position | (self) | Return the current position of cover shutter. | Return the current position of cover shutter. | def current_cover_position(self):
"""Return the current position of cover shutter."""
pos = self._slide["pos"]
if pos is not None:
if (1 - pos) <= DEFAULT_OFFSET or pos <= DEFAULT_OFFSET:
pos = round(pos)
if not self._invert:
pos = 1 - pos
... | [
"def",
"current_cover_position",
"(",
"self",
")",
":",
"pos",
"=",
"self",
".",
"_slide",
"[",
"\"pos\"",
"]",
"if",
"pos",
"is",
"not",
"None",
":",
"if",
"(",
"1",
"-",
"pos",
")",
"<=",
"DEFAULT_OFFSET",
"or",
"pos",
"<=",
"DEFAULT_OFFSET",
":",
... | [
94,
4
] | [
103,
18
] | python | en | ['en', 'en', 'en'] | True |
SlideCover.async_open_cover | (self, **kwargs) | Open the cover. | Open the cover. | async def async_open_cover(self, **kwargs):
"""Open the cover."""
self._slide["state"] = STATE_OPENING
await self._api.slide_open(self._id) | [
"async",
"def",
"async_open_cover",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_slide",
"[",
"\"state\"",
"]",
"=",
"STATE_OPENING",
"await",
"self",
".",
"_api",
".",
"slide_open",
"(",
"self",
".",
"_id",
")"
] | [
105,
4
] | [
108,
44
] | python | en | ['en', 'en', 'en'] | True |
SlideCover.async_close_cover | (self, **kwargs) | Close the cover. | Close the cover. | async def async_close_cover(self, **kwargs):
"""Close the cover."""
self._slide["state"] = STATE_CLOSING
await self._api.slide_close(self._id) | [
"async",
"def",
"async_close_cover",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_slide",
"[",
"\"state\"",
"]",
"=",
"STATE_CLOSING",
"await",
"self",
".",
"_api",
".",
"slide_close",
"(",
"self",
".",
"_id",
")"
] | [
110,
4
] | [
113,
45
] | python | en | ['en', 'en', 'en'] | True |
SlideCover.async_stop_cover | (self, **kwargs) | Stop the cover. | Stop the cover. | async def async_stop_cover(self, **kwargs):
"""Stop the cover."""
await self._api.slide_stop(self._id) | [
"async",
"def",
"async_stop_cover",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"_api",
".",
"slide_stop",
"(",
"self",
".",
"_id",
")"
] | [
115,
4
] | [
117,
44
] | python | en | ['en', 'en', 'en'] | True |
SlideCover.async_set_cover_position | (self, **kwargs) | Move the cover to a specific position. | Move the cover to a specific position. | async def async_set_cover_position(self, **kwargs):
"""Move the cover to a specific position."""
position = kwargs[ATTR_POSITION] / 100
if not self._invert:
position = 1 - position
if self._slide["pos"] is not None:
if position > self._slide["pos"]:
... | [
"async",
"def",
"async_set_cover_position",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"position",
"=",
"kwargs",
"[",
"ATTR_POSITION",
"]",
"/",
"100",
"if",
"not",
"self",
".",
"_invert",
":",
"position",
"=",
"1",
"-",
"position",
"if",
"self",
... | [
119,
4
] | [
131,
62
] | python | en | ['en', 'en', 'en'] | True |
test_version_sensor | (hass) | Test the Version sensor. | Test the Version sensor. | async def test_version_sensor(hass):
"""Test the Version sensor."""
config = {"sensor": {"platform": "version"}}
assert await async_setup_component(hass, "sensor", config) | [
"async",
"def",
"test_version_sensor",
"(",
"hass",
")",
":",
"config",
"=",
"{",
"\"sensor\"",
":",
"{",
"\"platform\"",
":",
"\"version\"",
"}",
"}",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"sensor\"",
",",
"config",
")"
] | [
8,
0
] | [
12,
62
] | python | en | ['en', 'da', 'en'] | True |
test_version | (hass) | Test the Version sensor. | Test the Version sensor. | async def test_version(hass):
"""Test the Version sensor."""
config = {"sensor": {"platform": "version", "name": "test"}}
with patch("homeassistant.const.__version__", MOCK_VERSION):
assert await async_setup_component(hass, "sensor", config)
await hass.async_block_till_done()
state = h... | [
"async",
"def",
"test_version",
"(",
"hass",
")",
":",
"config",
"=",
"{",
"\"sensor\"",
":",
"{",
"\"platform\"",
":",
"\"version\"",
",",
"\"name\"",
":",
"\"test\"",
"}",
"}",
"with",
"patch",
"(",
"\"homeassistant.const.__version__\"",
",",
"MOCK_VERSION",
... | [
15,
0
] | [
25,
32
] | python | en | ['en', 'da', 'en'] | True |
config_entry | () | Create a mock GDACS config entry. | Create a mock GDACS config entry. | def config_entry():
"""Create a mock GDACS config entry."""
return MockConfigEntry(
domain=DOMAIN,
data={
CONF_LATITUDE: -41.2,
CONF_LONGITUDE: 174.7,
CONF_RADIUS: 25,
CONF_UNIT_SYSTEM: "metric",
CONF_SCAN_INTERVAL: 300.0,
C... | [
"def",
"config_entry",
"(",
")",
":",
"return",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"data",
"=",
"{",
"CONF_LATITUDE",
":",
"-",
"41.2",
",",
"CONF_LONGITUDE",
":",
"174.7",
",",
"CONF_RADIUS",
":",
"25",
",",
"CONF_UNIT_SYSTEM",
":",
"\"... | [
16,
0
] | [
30,
5
] | python | en | ['en', 'gl', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Arlo Alarm Control Panels. | Set up the Arlo Alarm Control Panels. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Arlo Alarm Control Panels."""
arlo = hass.data[DATA_ARLO]
if not arlo.base_stations:
return
home_mode_name = config[CONF_HOME_MODE_NAME]
away_mode_name = config[CONF_AWAY_MODE_NAME]
night_mode_name = con... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"arlo",
"=",
"hass",
".",
"data",
"[",
"DATA_ARLO",
"]",
"if",
"not",
"arlo",
".",
"base_stations",
":",
"return",
"home_mode_name",
"="... | [
48,
0
] | [
65,
37
] | python | en | ['en', 'ja', 'en'] | True |
ArloBaseStation.__init__ | (self, data, home_mode_name, away_mode_name, night_mode_name) | Initialize the alarm control panel. | Initialize the alarm control panel. | def __init__(self, data, home_mode_name, away_mode_name, night_mode_name):
"""Initialize the alarm control panel."""
self._base_station = data
self._home_mode_name = home_mode_name
self._away_mode_name = away_mode_name
self._night_mode_name = night_mode_name
self._state =... | [
"def",
"__init__",
"(",
"self",
",",
"data",
",",
"home_mode_name",
",",
"away_mode_name",
",",
"night_mode_name",
")",
":",
"self",
".",
"_base_station",
"=",
"data",
"self",
".",
"_home_mode_name",
"=",
"home_mode_name",
"self",
".",
"_away_mode_name",
"=",
... | [
71,
4
] | [
77,
26
] | python | en | ['en', 'en', 'en'] | True |
ArloBaseStation.icon | (self) | Return icon. | Return icon. | def icon(self):
"""Return icon."""
return ICON | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"ICON"
] | [
80,
4
] | [
82,
19
] | python | en | ['en', 'la', 'en'] | False |
ArloBaseStation.async_added_to_hass | (self) | Register callbacks. | Register callbacks. | async def async_added_to_hass(self):
"""Register callbacks."""
self.async_on_remove(
async_dispatcher_connect(
self.hass, SIGNAL_UPDATE_ARLO, self._update_callback
)
) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"async_on_remove",
"(",
"async_dispatcher_connect",
"(",
"self",
".",
"hass",
",",
"SIGNAL_UPDATE_ARLO",
",",
"self",
".",
"_update_callback",
")",
")"
] | [
84,
4
] | [
90,
9
] | python | en | ['en', 'no', 'en'] | False |
ArloBaseStation._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",
")"
] | [
93,
4
] | [
95,
49
] | python | en | ['en', 'sn', 'en'] | True |
ArloBaseStation.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 |
ArloBaseStation.supported_features | (self) | Return the list of supported features. | Return the list of supported features. | def supported_features(self) -> int:
"""Return the list of supported features."""
return SUPPORT_ALARM_ARM_HOME | SUPPORT_ALARM_ARM_AWAY | SUPPORT_ALARM_ARM_NIGHT | [
"def",
"supported_features",
"(",
"self",
")",
"->",
"int",
":",
"return",
"SUPPORT_ALARM_ARM_HOME",
"|",
"SUPPORT_ALARM_ARM_AWAY",
"|",
"SUPPORT_ALARM_ARM_NIGHT"
] | [
103,
4
] | [
105,
88
] | python | en | ['en', 'en', 'en'] | True |
ArloBaseStation.update | (self) | Update the state of the device. | Update the state of the device. | def update(self):
"""Update the state of the device."""
_LOGGER.debug("Updating Arlo Alarm Control Panel %s", self.name)
mode = self._base_station.mode
if mode:
self._state = self._get_state_from_mode(mode)
else:
self._state = None | [
"def",
"update",
"(",
"self",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Updating Arlo Alarm Control Panel %s\"",
",",
"self",
".",
"name",
")",
"mode",
"=",
"self",
".",
"_base_station",
".",
"mode",
"if",
"mode",
":",
"self",
".",
"_state",
"=",
"self",
... | [
107,
4
] | [
114,
30
] | python | en | ['en', 'en', 'en'] | True |
ArloBaseStation.alarm_disarm | (self, code=None) | Send disarm command. | Send disarm command. | def alarm_disarm(self, code=None):
"""Send disarm command."""
self._base_station.mode = DISARMED | [
"def",
"alarm_disarm",
"(",
"self",
",",
"code",
"=",
"None",
")",
":",
"self",
".",
"_base_station",
".",
"mode",
"=",
"DISARMED"
] | [
116,
4
] | [
118,
42
] | python | en | ['en', 'pt', 'en'] | True |
ArloBaseStation.alarm_arm_away | (self, code=None) | Send arm away command. Uses custom mode. | Send arm away command. Uses custom mode. | def alarm_arm_away(self, code=None):
"""Send arm away command. Uses custom mode."""
self._base_station.mode = self._away_mode_name | [
"def",
"alarm_arm_away",
"(",
"self",
",",
"code",
"=",
"None",
")",
":",
"self",
".",
"_base_station",
".",
"mode",
"=",
"self",
".",
"_away_mode_name"
] | [
120,
4
] | [
122,
54
] | python | en | ['en', 'pt', 'en'] | True |
ArloBaseStation.alarm_arm_home | (self, code=None) | Send arm home command. Uses custom mode. | Send arm home command. Uses custom mode. | def alarm_arm_home(self, code=None):
"""Send arm home command. Uses custom mode."""
self._base_station.mode = self._home_mode_name | [
"def",
"alarm_arm_home",
"(",
"self",
",",
"code",
"=",
"None",
")",
":",
"self",
".",
"_base_station",
".",
"mode",
"=",
"self",
".",
"_home_mode_name"
] | [
124,
4
] | [
126,
54
] | python | en | ['en', 'pt', 'en'] | True |
ArloBaseStation.alarm_arm_night | (self, code=None) | Send arm night command. Uses custom mode. | Send arm night command. Uses custom mode. | def alarm_arm_night(self, code=None):
"""Send arm night command. Uses custom mode."""
self._base_station.mode = self._night_mode_name | [
"def",
"alarm_arm_night",
"(",
"self",
",",
"code",
"=",
"None",
")",
":",
"self",
".",
"_base_station",
".",
"mode",
"=",
"self",
".",
"_night_mode_name"
] | [
128,
4
] | [
130,
55
] | python | en | ['en', 'pt', 'en'] | True |
ArloBaseStation.name | (self) | Return the name of the base station. | Return the name of the base station. | def name(self):
"""Return the name of the base station."""
return self._base_station.name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_base_station",
".",
"name"
] | [
133,
4
] | [
135,
38
] | python | en | ['en', 'en', 'en'] | True |
ArloBaseStation.device_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def device_state_attributes(self):
"""Return the state attributes."""
return {
ATTR_ATTRIBUTION: ATTRIBUTION,
"device_id": self._base_station.device_id,
} | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"{",
"ATTR_ATTRIBUTION",
":",
"ATTRIBUTION",
",",
"\"device_id\"",
":",
"self",
".",
"_base_station",
".",
"device_id",
",",
"}"
] | [
138,
4
] | [
143,
9
] | python | en | ['en', 'en', 'en'] | True |
ArloBaseStation._get_state_from_mode | (self, mode) | Convert Arlo mode to Home Assistant state. | Convert Arlo mode to Home Assistant state. | def _get_state_from_mode(self, mode):
"""Convert Arlo mode to Home Assistant state."""
if mode == ARMED:
return STATE_ALARM_ARMED_AWAY
if mode == DISARMED:
return STATE_ALARM_DISARMED
if mode == self._home_mode_name:
return STATE_ALARM_ARMED_HOME
... | [
"def",
"_get_state_from_mode",
"(",
"self",
",",
"mode",
")",
":",
"if",
"mode",
"==",
"ARMED",
":",
"return",
"STATE_ALARM_ARMED_AWAY",
"if",
"mode",
"==",
"DISARMED",
":",
"return",
"STATE_ALARM_DISARMED",
"if",
"mode",
"==",
"self",
".",
"_home_mode_name",
... | [
145,
4
] | [
157,
19
] | python | en | ['en', 'en', 'en'] | True |
detect_radios | (dev_path: str) | Probe all radio types on the device port. | Probe all radio types on the device port. | async def detect_radios(dev_path: str) -> Optional[Dict[str, Any]]:
"""Probe all radio types on the device port."""
for radio in RadioType:
dev_config = radio.controller.SCHEMA_DEVICE({CONF_DEVICE_PATH: dev_path})
if await radio.controller.probe(dev_config):
return {CONF_RADIO_TYPE: ... | [
"async",
"def",
"detect_radios",
"(",
"dev_path",
":",
"str",
")",
"->",
"Optional",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
":",
"for",
"radio",
"in",
"RadioType",
":",
"dev_config",
"=",
"radio",
".",
"controller",
".",
"SCHEMA_DEVICE",
"(",
"... | [
125,
0
] | [
132,
15
] | python | en | ['en', 'en', 'en'] | True |
get_serial_by_id | (dev_path: str) | Return a /dev/serial/by-id match for given device if available. | Return a /dev/serial/by-id match for given device if available. | def get_serial_by_id(dev_path: str) -> str:
"""Return a /dev/serial/by-id match for given device if available."""
by_id = "/dev/serial/by-id"
if not os.path.isdir(by_id):
return dev_path
for path in (entry.path for entry in os.scandir(by_id) if entry.is_symlink()):
if os.path.realpath(p... | [
"def",
"get_serial_by_id",
"(",
"dev_path",
":",
"str",
")",
"->",
"str",
":",
"by_id",
"=",
"\"/dev/serial/by-id\"",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"by_id",
")",
":",
"return",
"dev_path",
"for",
"path",
"in",
"(",
"entry",
".",
"p... | [
135,
0
] | [
144,
19
] | python | en | ['en', 'en', 'en'] | True |
ZhaFlowHandler.__init__ | (self) | Initialize flow instance. | Initialize flow instance. | def __init__(self):
"""Initialize flow instance."""
self._device_path = None
self._radio_type = None | [
"def",
"__init__",
"(",
"self",
")",
":",
"self",
".",
"_device_path",
"=",
"None",
"self",
".",
"_radio_type",
"=",
"None"
] | [
31,
4
] | [
34,
31
] | python | en | ['en', 'pl', 'en'] | True |
ZhaFlowHandler.async_step_user | (self, user_input=None) | Handle a zha config flow start. | Handle a zha config flow start. | async def async_step_user(self, user_input=None):
"""Handle a zha config flow start."""
if self._async_current_entries():
return self.async_abort(reason="single_instance_allowed")
ports = await self.hass.async_add_executor_job(serial.tools.list_ports.comports)
list_of_ports ... | [
"async",
"def",
"async_step_user",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"if",
"self",
".",
"_async_current_entries",
"(",
")",
":",
"return",
"self",
".",
"async_abort",
"(",
"reason",
"=",
"\"single_instance_allowed\"",
")",
"ports",
"=",
... | [
36,
4
] | [
72,
71
] | python | br | ['br', 'lb', 'it'] | False |
ZhaFlowHandler.async_step_pick_radio | (self, user_input=None) | Select radio type. | Select radio type. | async def async_step_pick_radio(self, user_input=None):
"""Select radio type."""
if user_input is not None:
self._radio_type = RadioType.get_by_description(user_input[CONF_RADIO_TYPE])
return await self.async_step_port_config()
schema = {vol.Required(CONF_RADIO_TYPE): v... | [
"async",
"def",
"async_step_pick_radio",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"if",
"user_input",
"is",
"not",
"None",
":",
"self",
".",
"_radio_type",
"=",
"RadioType",
".",
"get_by_description",
"(",
"user_input",
"[",
"CONF_RADIO_TYPE",
"]... | [
74,
4
] | [
85,
9
] | python | en | ['es', 'sr', 'en'] | False |
ZhaFlowHandler.async_step_port_config | (self, user_input=None) | Enter port settings specific for this type of radio. | Enter port settings specific for this type of radio. | async def async_step_port_config(self, user_input=None):
"""Enter port settings specific for this type of radio."""
errors = {}
app_cls = RadioType[self._radio_type].controller
if user_input is not None:
self._device_path = user_input.get(CONF_DEVICE_PATH)
if awa... | [
"async",
"def",
"async_step_port_config",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"errors",
"=",
"{",
"}",
"app_cls",
"=",
"RadioType",
"[",
"self",
".",
"_radio_type",
"]",
".",
"controller",
"if",
"user_input",
"is",
"not",
"None",
":",
... | [
87,
4
] | [
122,
9
] | python | en | ['en', 'en', 'en'] | True |
async_describe_on_off_states | (
hass: HomeAssistantType, registry: GroupIntegrationRegistry
) | Describe group on off states. | Describe group on off states. | def async_describe_on_off_states(
hass: HomeAssistantType, registry: GroupIntegrationRegistry
) -> None:
"""Describe group on off states."""
registry.exclude_domain() | [
"def",
"async_describe_on_off_states",
"(",
"hass",
":",
"HomeAssistantType",
",",
"registry",
":",
"GroupIntegrationRegistry",
")",
"->",
"None",
":",
"registry",
".",
"exclude_domain",
"(",
")"
] | [
9,
0
] | [
13,
29
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass: HomeAssistant, config: dict) | Set up the OpenWeatherMap component. | Set up the OpenWeatherMap component. | async def async_setup(hass: HomeAssistant, config: dict) -> bool:
"""Set up the OpenWeatherMap component."""
hass.data.setdefault(DOMAIN, {})
return True | [
"async",
"def",
"async_setup",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"dict",
")",
"->",
"bool",
":",
"hass",
".",
"data",
".",
"setdefault",
"(",
"DOMAIN",
",",
"{",
"}",
")",
"return",
"True"
] | [
34,
0
] | [
37,
15
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass: HomeAssistant, config_entry: ConfigEntry) | Set up OpenWeatherMap as config entry. | Set up OpenWeatherMap as config entry. | async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry):
"""Set up OpenWeatherMap as config entry."""
name = config_entry.data[CONF_NAME]
api_key = config_entry.data[CONF_API_KEY]
latitude = config_entry.data.get(CONF_LATITUDE, hass.config.latitude)
longitude = config_entry.data.... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"config_entry",
":",
"ConfigEntry",
")",
":",
"name",
"=",
"config_entry",
".",
"data",
"[",
"CONF_NAME",
"]",
"api_key",
"=",
"config_entry",
".",
"data",
"[",
"CONF_API_KEY",
"]",
... | [
40,
0
] | [
75,
15
] | python | en | ['en', 'en', 'en'] | True |
async_migrate_entry | (hass, entry) | Migrate old entry. | Migrate old entry. | async def async_migrate_entry(hass, entry):
"""Migrate old entry."""
config_entries = hass.config_entries
data = entry.data
version = entry.version
_LOGGER.debug("Migrating OpenWeatherMap entry from version %s", version)
if version == 1:
mode = data[CONF_MODE]
if mode == FORECA... | [
"async",
"def",
"async_migrate_entry",
"(",
"hass",
",",
"entry",
")",
":",
"config_entries",
"=",
"hass",
".",
"config_entries",
"data",
"=",
"entry",
".",
"data",
"version",
"=",
"entry",
".",
"version",
"_LOGGER",
".",
"debug",
"(",
"\"Migrating OpenWeather... | [
78,
0
] | [
97,
15
] | python | en | ['en', 'en', 'en'] | True |
async_update_options | (hass: HomeAssistant, config_entry: ConfigEntry) | Update options. | Update options. | async def async_update_options(hass: HomeAssistant, config_entry: ConfigEntry):
"""Update options."""
await hass.config_entries.async_reload(config_entry.entry_id) | [
"async",
"def",
"async_update_options",
"(",
"hass",
":",
"HomeAssistant",
",",
"config_entry",
":",
"ConfigEntry",
")",
":",
"await",
"hass",
".",
"config_entries",
".",
"async_reload",
"(",
"config_entry",
".",
"entry_id",
")"
] | [
100,
0
] | [
102,
65
] | python | en | ['en', 'en', 'en'] | False |
async_unload_entry | (hass: HomeAssistant, config_entry: ConfigEntry) | Unload a config entry. | Unload a config entry. | async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry):
"""Unload a config entry."""
unload_ok = all(
await asyncio.gather(
*[
hass.config_entries.async_forward_entry_unload(config_entry, component)
for component in COMPONENTS
... | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"config_entry",
":",
"ConfigEntry",
")",
":",
"unload_ok",
"=",
"all",
"(",
"await",
"asyncio",
".",
"gather",
"(",
"*",
"[",
"hass",
".",
"config_entries",
".",
"async_forward_entry... | [
105,
0
] | [
120,
20
] | python | en | ['en', 'es', 'en'] | True |
_get_owm_config | (language) | Get OpenWeatherMap configuration and add language to it. | Get OpenWeatherMap configuration and add language to it. | def _get_owm_config(language):
"""Get OpenWeatherMap configuration and add language to it."""
config_dict = get_default_config()
config_dict["language"] = language
return config_dict | [
"def",
"_get_owm_config",
"(",
"language",
")",
":",
"config_dict",
"=",
"get_default_config",
"(",
")",
"config_dict",
"[",
"\"language\"",
"]",
"=",
"language",
"return",
"config_dict"
] | [
133,
0
] | [
137,
22
] | python | en | ['en', 'en', 'en'] | True |
process_timestamp | (ts) | Process a timestamp into datetime object. | Process a timestamp into datetime object. | def process_timestamp(ts):
"""Process a timestamp into datetime object."""
if ts is None:
return None
if ts.tzinfo is None:
return ts.replace(tzinfo=dt_util.UTC)
return dt_util.as_utc(ts) | [
"def",
"process_timestamp",
"(",
"ts",
")",
":",
"if",
"ts",
"is",
"None",
":",
"return",
"None",
"if",
"ts",
".",
"tzinfo",
"is",
"None",
":",
"return",
"ts",
".",
"replace",
"(",
"tzinfo",
"=",
"dt_util",
".",
"UTC",
")",
"return",
"dt_util",
".",
... | [
209,
0
] | [
216,
29
] | python | cs | ['pt', 'cs', 'en'] | False |
process_timestamp_to_utc_isoformat | (ts) | Process a timestamp into UTC isotime. | Process a timestamp into UTC isotime. | def process_timestamp_to_utc_isoformat(ts):
"""Process a timestamp into UTC isotime."""
if ts is None:
return None
if ts.tzinfo == dt_util.UTC:
return ts.isoformat()
if ts.tzinfo is None:
return f"{ts.isoformat()}{DB_TIMEZONE}"
return ts.astimezone(dt_util.UTC).isoformat() | [
"def",
"process_timestamp_to_utc_isoformat",
"(",
"ts",
")",
":",
"if",
"ts",
"is",
"None",
":",
"return",
"None",
"if",
"ts",
".",
"tzinfo",
"==",
"dt_util",
".",
"UTC",
":",
"return",
"ts",
".",
"isoformat",
"(",
")",
"if",
"ts",
".",
"tzinfo",
"is",... | [
219,
0
] | [
227,
49
] | python | en | ['en', 'mk', 'en'] | True |
Events.from_event | (event, event_data=None) | Create an event database object from a native event. | Create an event database object from a native event. | def from_event(event, event_data=None):
"""Create an event database object from a native event."""
return Events(
event_type=event.event_type,
event_data=event_data or json.dumps(event.data, cls=JSONEncoder),
origin=str(event.origin.value),
time_fired=even... | [
"def",
"from_event",
"(",
"event",
",",
"event_data",
"=",
"None",
")",
":",
"return",
"Events",
"(",
"event_type",
"=",
"event",
".",
"event_type",
",",
"event_data",
"=",
"event_data",
"or",
"json",
".",
"dumps",
"(",
"event",
".",
"data",
",",
"cls",
... | [
62,
4
] | [
72,
9
] | python | en | ['en', 'en', 'en'] | True |
Events.to_native | (self, validate_entity_id=True) | Convert to a natve HA Event. | Convert to a natve HA Event. | def to_native(self, validate_entity_id=True):
"""Convert to a natve HA Event."""
context = Context(
id=self.context_id,
user_id=self.context_user_id,
parent_id=self.context_parent_id,
)
try:
return Event(
self.event_type,
... | [
"def",
"to_native",
"(",
"self",
",",
"validate_entity_id",
"=",
"True",
")",
":",
"context",
"=",
"Context",
"(",
"id",
"=",
"self",
".",
"context_id",
",",
"user_id",
"=",
"self",
".",
"context_user_id",
",",
"parent_id",
"=",
"self",
".",
"context_paren... | [
74,
4
] | [
92,
23
] | python | ca | ['en', 'ca', 'pt'] | False |
States.from_event | (event) | Create object from a state_changed event. | Create object from a state_changed event. | def from_event(event):
"""Create object from a state_changed event."""
entity_id = event.data["entity_id"]
state = event.data.get("new_state")
dbstate = States(entity_id=entity_id)
# State got deleted
if state is None:
dbstate.state = ""
dbstate.... | [
"def",
"from_event",
"(",
"event",
")",
":",
"entity_id",
"=",
"event",
".",
"data",
"[",
"\"entity_id\"",
"]",
"state",
"=",
"event",
".",
"data",
".",
"get",
"(",
"\"new_state\"",
")",
"dbstate",
"=",
"States",
"(",
"entity_id",
"=",
"entity_id",
")",
... | [
119,
4
] | [
140,
22
] | python | en | ['en', 'en', 'en'] | True |
States.to_native | (self, validate_entity_id=True) | Convert to an HA state object. | Convert to an HA state object. | def to_native(self, validate_entity_id=True):
"""Convert to an HA state object."""
try:
return State(
self.entity_id,
self.state,
json.loads(self.attributes),
process_timestamp(self.last_changed),
process_timesta... | [
"def",
"to_native",
"(",
"self",
",",
"validate_entity_id",
"=",
"True",
")",
":",
"try",
":",
"return",
"State",
"(",
"self",
".",
"entity_id",
",",
"self",
".",
"state",
",",
"json",
".",
"loads",
"(",
"self",
".",
"attributes",
")",
",",
"process_ti... | [
142,
4
] | [
159,
23
] | python | en | ['en', 'en', 'en'] | True |
RecorderRuns.entity_ids | (self, point_in_time=None) | Return the entity ids that existed in this run.
Specify point_in_time if you want to know which existed at that point
in time inside the run.
| Return the entity ids that existed in this run. | def entity_ids(self, point_in_time=None):
"""Return the entity ids that existed in this run.
Specify point_in_time if you want to know which existed at that point
in time inside the run.
"""
session = Session.object_session(self)
assert session is not None, "RecorderRun... | [
"def",
"entity_ids",
"(",
"self",
",",
"point_in_time",
"=",
"None",
")",
":",
"session",
"=",
"Session",
".",
"object_session",
"(",
"self",
")",
"assert",
"session",
"is",
"not",
"None",
",",
"\"RecorderRuns need to be persisted\"",
"query",
"=",
"session",
... | [
174,
4
] | [
193,
40
] | python | en | ['en', 'en', 'en'] | True |
RecorderRuns.to_native | (self, validate_entity_id=True) | Return self, native format is this model. | Return self, native format is this model. | def to_native(self, validate_entity_id=True):
"""Return self, native format is this model."""
return self | [
"def",
"to_native",
"(",
"self",
",",
"validate_entity_id",
"=",
"True",
")",
":",
"return",
"self"
] | [
195,
4
] | [
197,
19
] | python | en | ['en', 'en', 'en'] | True |
get_gateway_from_config_entry | (hass, config_entry) | Return gateway with a matching bridge id. | Return gateway with a matching bridge id. | def get_gateway_from_config_entry(hass, config_entry):
"""Return gateway with a matching bridge id."""
return hass.data[DOMAIN][config_entry.unique_id] | [
"def",
"get_gateway_from_config_entry",
"(",
"hass",
",",
"config_entry",
")",
":",
"return",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"config_entry",
".",
"unique_id",
"]"
] | [
34,
0
] | [
36,
52
] | python | en | ['en', 'cy', 'en'] | True |
get_gateway | (
hass, config, async_add_device_callback, async_connection_status_callback
) | Create a gateway object and verify configuration. | Create a gateway object and verify configuration. | async def get_gateway(
hass, config, async_add_device_callback, async_connection_status_callback
) -> DeconzSession:
"""Create a gateway object and verify configuration."""
session = aiohttp_client.async_get_clientsession(hass)
deconz = DeconzSession(
session,
config[CONF_HOST],
... | [
"async",
"def",
"get_gateway",
"(",
"hass",
",",
"config",
",",
"async_add_device_callback",
",",
"async_connection_status_callback",
")",
"->",
"DeconzSession",
":",
"session",
"=",
"aiohttp_client",
".",
"async_get_clientsession",
"(",
"hass",
")",
"deconz",
"=",
... | [
274,
0
] | [
299,
36
] | python | en | ['en', 'en', 'en'] | True |
DeconzGateway.__init__ | (self, hass, config_entry) | Initialize the system. | Initialize the system. | def __init__(self, hass, config_entry) -> None:
"""Initialize the system."""
self.hass = hass
self.config_entry = config_entry
self.api = None
self.available = True
self.ignore_state_updates = False
self.deconz_ids = {}
self.entities = {}
self.e... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"config_entry",
")",
"->",
"None",
":",
"self",
".",
"hass",
"=",
"hass",
"self",
".",
"config_entry",
"=",
"config_entry",
"self",
".",
"api",
"=",
"None",
"self",
".",
"available",
"=",
"True",
"self"... | [
42,
4
] | [
58,
82
] | python | en | ['en', 'en', 'en'] | True |
DeconzGateway.bridgeid | (self) | Return the unique identifier of the gateway. | Return the unique identifier of the gateway. | def bridgeid(self) -> str:
"""Return the unique identifier of the gateway."""
return self.config_entry.unique_id | [
"def",
"bridgeid",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"config_entry",
".",
"unique_id"
] | [
61,
4
] | [
63,
42
] | python | en | ['en', 'fr', 'en'] | True |
DeconzGateway.host | (self) | Return the host of the gateway. | Return the host of the gateway. | def host(self) -> str:
"""Return the host of the gateway."""
return self.config_entry.data[CONF_HOST] | [
"def",
"host",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"config_entry",
".",
"data",
"[",
"CONF_HOST",
"]"
] | [
66,
4
] | [
68,
48
] | python | en | ['en', 'en', 'en'] | True |
DeconzGateway.master | (self) | Gateway which is used with deCONZ services without defining id. | Gateway which is used with deCONZ services without defining id. | def master(self) -> bool:
"""Gateway which is used with deCONZ services without defining id."""
return self.config_entry.options[CONF_MASTER_GATEWAY] | [
"def",
"master",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"config_entry",
".",
"options",
"[",
"CONF_MASTER_GATEWAY",
"]"
] | [
71,
4
] | [
73,
61
] | python | en | ['en', 'en', 'en'] | True |
DeconzGateway.option_allow_clip_sensor | (self) | Allow loading clip sensor from gateway. | Allow loading clip sensor from gateway. | def option_allow_clip_sensor(self) -> bool:
"""Allow loading clip sensor from gateway."""
return self.config_entry.options.get(
CONF_ALLOW_CLIP_SENSOR, DEFAULT_ALLOW_CLIP_SENSOR
) | [
"def",
"option_allow_clip_sensor",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"config_entry",
".",
"options",
".",
"get",
"(",
"CONF_ALLOW_CLIP_SENSOR",
",",
"DEFAULT_ALLOW_CLIP_SENSOR",
")"
] | [
78,
4
] | [
82,
9
] | python | en | ['en', 'fy', 'en'] | True |
DeconzGateway.option_allow_deconz_groups | (self) | Allow loading deCONZ groups from gateway. | Allow loading deCONZ groups from gateway. | def option_allow_deconz_groups(self) -> bool:
"""Allow loading deCONZ groups from gateway."""
return self.config_entry.options.get(
CONF_ALLOW_DECONZ_GROUPS, DEFAULT_ALLOW_DECONZ_GROUPS
) | [
"def",
"option_allow_deconz_groups",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"config_entry",
".",
"options",
".",
"get",
"(",
"CONF_ALLOW_DECONZ_GROUPS",
",",
"DEFAULT_ALLOW_DECONZ_GROUPS",
")"
] | [
85,
4
] | [
89,
9
] | python | en | ['en', 'en', 'en'] | True |
DeconzGateway.option_allow_new_devices | (self) | Allow automatic adding of new devices. | Allow automatic adding of new devices. | def option_allow_new_devices(self) -> bool:
"""Allow automatic adding of new devices."""
return self.config_entry.options.get(
CONF_ALLOW_NEW_DEVICES, DEFAULT_ALLOW_NEW_DEVICES
) | [
"def",
"option_allow_new_devices",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"config_entry",
".",
"options",
".",
"get",
"(",
"CONF_ALLOW_NEW_DEVICES",
",",
"DEFAULT_ALLOW_NEW_DEVICES",
")"
] | [
92,
4
] | [
96,
9
] | python | en | ['en', 'en', 'en'] | True |
DeconzGateway.signal_reachable | (self) | Gateway specific event to signal a change in connection status. | Gateway specific event to signal a change in connection status. | def signal_reachable(self) -> str:
"""Gateway specific event to signal a change in connection status."""
return f"deconz-reachable-{self.bridgeid}" | [
"def",
"signal_reachable",
"(",
"self",
")",
"->",
"str",
":",
"return",
"f\"deconz-reachable-{self.bridgeid}\""
] | [
101,
4
] | [
103,
50
] | python | en | ['en', 'en', 'en'] | True |
DeconzGateway.async_signal_new_device | (self, device_type) | Gateway specific event to signal new device. | Gateway specific event to signal new device. | def async_signal_new_device(self, device_type) -> str:
"""Gateway specific event to signal new device."""
new_device = {
NEW_GROUP: f"deconz_new_group_{self.bridgeid}",
NEW_LIGHT: f"deconz_new_light_{self.bridgeid}",
NEW_SCENE: f"deconz_new_scene_{self.bridgeid}",
... | [
"def",
"async_signal_new_device",
"(",
"self",
",",
"device_type",
")",
"->",
"str",
":",
"new_device",
"=",
"{",
"NEW_GROUP",
":",
"f\"deconz_new_group_{self.bridgeid}\"",
",",
"NEW_LIGHT",
":",
"f\"deconz_new_light_{self.bridgeid}\"",
",",
"NEW_SCENE",
":",
"f\"deconz... | [
106,
4
] | [
114,
38
] | python | en | ['en', 'en', 'en'] | True |
DeconzGateway.async_connection_status_callback | (self, available) | Handle signals of gateway connection status. | Handle signals of gateway connection status. | def async_connection_status_callback(self, available) -> None:
"""Handle signals of gateway connection status."""
self.available = available
self.ignore_state_updates = False
async_dispatcher_send(self.hass, self.signal_reachable, True) | [
"def",
"async_connection_status_callback",
"(",
"self",
",",
"available",
")",
"->",
"None",
":",
"self",
".",
"available",
"=",
"available",
"self",
".",
"ignore_state_updates",
"=",
"False",
"async_dispatcher_send",
"(",
"self",
".",
"hass",
",",
"self",
".",
... | [
119,
4
] | [
123,
69
] | python | en | ['en', 'en', 'en'] | True |
DeconzGateway.async_add_device_callback | (self, device_type, device) | Handle event of new device creation in deCONZ. | Handle event of new device creation in deCONZ. | def async_add_device_callback(self, device_type, device) -> None:
"""Handle event of new device creation in deCONZ."""
if not self.option_allow_new_devices:
return
if not isinstance(device, list):
device = [device]
async_dispatcher_send(
self.hass, s... | [
"def",
"async_add_device_callback",
"(",
"self",
",",
"device_type",
",",
"device",
")",
"->",
"None",
":",
"if",
"not",
"self",
".",
"option_allow_new_devices",
":",
"return",
"if",
"not",
"isinstance",
"(",
"device",
",",
"list",
")",
":",
"device",
"=",
... | [
126,
4
] | [
136,
9
] | python | en | ['en', 'en', 'en'] | True |
DeconzGateway.async_update_device_registry | (self) | Update device registry. | Update device registry. | async def async_update_device_registry(self) -> None:
"""Update device registry."""
device_registry = await self.hass.helpers.device_registry.async_get_registry()
# Host device
device_registry.async_get_or_create(
config_entry_id=self.config_entry.entry_id,
conne... | [
"async",
"def",
"async_update_device_registry",
"(",
"self",
")",
"->",
"None",
":",
"device_registry",
"=",
"await",
"self",
".",
"hass",
".",
"helpers",
".",
"device_registry",
".",
"async_get_registry",
"(",
")",
"# Host device",
"device_registry",
".",
"async_... | [
138,
4
] | [
157,
9
] | python | en | ['fr', 'fy', 'en'] | False |
DeconzGateway.async_setup | (self) | Set up a deCONZ gateway. | Set up a deCONZ gateway. | async def async_setup(self) -> bool:
"""Set up a deCONZ gateway."""
try:
self.api = await get_gateway(
self.hass,
self.config_entry.data,
self.async_add_device_callback,
self.async_connection_status_callback,
)
... | [
"async",
"def",
"async_setup",
"(",
"self",
")",
"->",
"bool",
":",
"try",
":",
"self",
".",
"api",
"=",
"await",
"get_gateway",
"(",
"self",
".",
"hass",
",",
"self",
".",
"config_entry",
".",
"data",
",",
"self",
".",
"async_add_device_callback",
",",
... | [
159,
4
] | [
189,
19
] | python | en | ['en', 'lb', 'en'] | True |
DeconzGateway.async_config_entry_updated | (hass, entry) | Handle signals of config entry being updated.
This is a static method because a class method (bound method), can not be used with weak references.
Causes for this is either discovery updating host address or config entry options changing.
| Handle signals of config entry being updated. | async def async_config_entry_updated(hass, entry) -> None:
"""Handle signals of config entry being updated.
This is a static method because a class method (bound method), can not be used with weak references.
Causes for this is either discovery updating host address or config entry options chan... | [
"async",
"def",
"async_config_entry_updated",
"(",
"hass",
",",
"entry",
")",
"->",
"None",
":",
"gateway",
"=",
"get_gateway_from_config_entry",
"(",
"hass",
",",
"entry",
")",
"if",
"gateway",
".",
"api",
".",
"host",
"!=",
"gateway",
".",
"host",
":",
"... | [
192,
4
] | [
206,
39
] | python | en | ['en', 'en', 'en'] | True |
DeconzGateway.options_updated | (self) | Manage entities affected by config entry options. | Manage entities affected by config entry options. | async def options_updated(self):
"""Manage entities affected by config entry options."""
deconz_ids = []
if self._current_option_allow_clip_sensor != self.option_allow_clip_sensor:
self._current_option_allow_clip_sensor = self.option_allow_clip_sensor
sensors = [
... | [
"async",
"def",
"options_updated",
"(",
"self",
")",
":",
"deconz_ids",
"=",
"[",
"]",
"if",
"self",
".",
"_current_option_allow_clip_sensor",
"!=",
"self",
".",
"option_allow_clip_sensor",
":",
"self",
".",
"_current_option_allow_clip_sensor",
"=",
"self",
".",
"... | [
208,
4
] | [
244,
55
] | python | en | ['en', 'en', 'en'] | True |
DeconzGateway.shutdown | (self, event) | Wrap the call to deconz.close.
Used as an argument to EventBus.async_listen_once.
| Wrap the call to deconz.close. | def shutdown(self, event) -> None:
"""Wrap the call to deconz.close.
Used as an argument to EventBus.async_listen_once.
"""
self.api.close() | [
"def",
"shutdown",
"(",
"self",
",",
"event",
")",
"->",
"None",
":",
"self",
".",
"api",
".",
"close",
"(",
")"
] | [
247,
4
] | [
252,
24
] | python | en | ['en', 'pt', 'en'] | True |
DeconzGateway.async_reset | (self) | Reset this gateway to default state. | Reset this gateway to default state. | async def async_reset(self):
"""Reset this gateway to default state."""
self.api.async_connection_status_callback = None
self.api.close()
for component in SUPPORTED_PLATFORMS:
await self.hass.config_entries.async_forward_entry_unload(
self.config_entry, compo... | [
"async",
"def",
"async_reset",
"(",
"self",
")",
":",
"self",
".",
"api",
".",
"async_connection_status_callback",
"=",
"None",
"self",
".",
"api",
".",
"close",
"(",
")",
"for",
"component",
"in",
"SUPPORTED_PLATFORMS",
":",
"await",
"self",
".",
"hass",
... | [
254,
4
] | [
271,
19
] | python | en | ['en', 'en', 'en'] | True |
update_probability | (prior, prob_given_true, prob_given_false) | Update probability using Bayes' rule. | Update probability using Bayes' rule. | def update_probability(prior, prob_given_true, prob_given_false):
"""Update probability using Bayes' rule."""
numerator = prob_given_true * prior
denominator = numerator + prob_given_false * (1 - prior)
return numerator / denominator | [
"def",
"update_probability",
"(",
"prior",
",",
"prob_given_true",
",",
"prob_given_false",
")",
":",
"numerator",
"=",
"prob_given_true",
"*",
"prior",
"denominator",
"=",
"numerator",
"+",
"prob_given_false",
"*",
"(",
"1",
"-",
"prior",
")",
"return",
"numera... | [
102,
0
] | [
106,
34
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up the Bayesian Binary sensor. | Set up the Bayesian Binary sensor. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the Bayesian Binary sensor."""
await async_setup_reload_service(hass, DOMAIN, PLATFORMS)
name = config[CONF_NAME]
observations = config[CONF_OBSERVATIONS]
prior = config[CONF_PRIOR]
probability_thre... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"await",
"async_setup_reload_service",
"(",
"hass",
",",
"DOMAIN",
",",
"PLATFORMS",
")",
"name",
"=",
"config",
"[",
"... | [
109,
0
] | [
125,
5
] | python | en | ['en', 'haw', 'en'] | True |
BayesianBinarySensor.__init__ | (self, name, prior, observations, probability_threshold, device_class) | Initialize the Bayesian sensor. | Initialize the Bayesian sensor. | def __init__(self, name, prior, observations, probability_threshold, device_class):
"""Initialize the Bayesian sensor."""
self._name = name
self._observations = observations
self._probability_threshold = probability_threshold
self._device_class = device_class
self._deviat... | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"prior",
",",
"observations",
",",
"probability_threshold",
",",
"device_class",
")",
":",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"_observations",
"=",
"observations",
"self",
".",
"_probability_thresh... | [
131,
4
] | [
151,
9
] | python | en | ['en', 'zh-Latn', 'en'] | True |
BayesianBinarySensor.async_added_to_hass | (self) |
Call when entity about to be added.
All relevant update logic for instance attributes occurs within this closure.
Other methods in this class are designed to avoid directly modifying instance
attributes, by instead focusing on returning relevant data back to this method.
The g... |
Call when entity about to be added. | async def async_added_to_hass(self):
"""
Call when entity about to be added.
All relevant update logic for instance attributes occurs within this closure.
Other methods in this class are designed to avoid directly modifying instance
attributes, by instead focusing on returning r... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"@",
"callback",
"def",
"async_threshold_sensor_state_listener",
"(",
"event",
")",
":",
"\"\"\"\n Handle sensor state changes.\n\n When a state changes, we must update our list of current observations,... | [
153,
4
] | [
240,
79
] | python | en | ['en', 'error', 'th'] | False |
BayesianBinarySensor._build_observations_by_entity | (self) |
Build and return data structure of the form below.
{
"sensor.sensor1": [{"id": 0, ...}, {"id": 1, ...}],
"sensor.sensor2": [{"id": 2, ...}],
...
}
Each "observation" must be recognized uniquely, and it should be possible
for all relevant obs... |
Build and return data structure of the form below. | def _build_observations_by_entity(self):
"""
Build and return data structure of the form below.
{
"sensor.sensor1": [{"id": 0, ...}, {"id": 1, ...}],
"sensor.sensor2": [{"id": 2, ...}],
...
}
Each "observation" must be recognized uniquely, an... | [
"def",
"_build_observations_by_entity",
"(",
"self",
")",
":",
"observations_by_entity",
"=",
"{",
"}",
"for",
"ind",
",",
"obs",
"in",
"enumerate",
"(",
"self",
".",
"_observations",
")",
":",
"obs",
"[",
"\"id\"",
"]",
"=",
"ind",
"if",
"\"entity_id\"",
... | [
284,
4
] | [
310,
37
] | python | en | ['en', 'error', 'th'] | False |
BayesianBinarySensor._build_observations_by_template | (self) |
Build and return data structure of the form below.
{
"template": [{"id": 0, ...}, {"id": 1, ...}],
"template2": [{"id": 2, ...}],
...
}
Each "observation" must be recognized uniquely, and it should be possible
for all relevant observations t... |
Build and return data structure of the form below. | def _build_observations_by_template(self):
"""
Build and return data structure of the form below.
{
"template": [{"id": 0, ...}, {"id": 1, ...}],
"template2": [{"id": 2, ...}],
...
}
Each "observation" must be recognized uniquely, and it shou... | [
"def",
"_build_observations_by_template",
"(",
"self",
")",
":",
"observations_by_template",
"=",
"{",
"}",
"for",
"ind",
",",
"obs",
"in",
"enumerate",
"(",
"self",
".",
"_observations",
")",
":",
"obs",
"[",
"\"id\"",
"]",
"=",
"ind",
"if",
"\"value_templa... | [
312,
4
] | [
336,
39
] | python | en | ['en', 'error', 'th'] | False |
BayesianBinarySensor._process_numeric_state | (self, entity_observation) | Return True if numeric condition is met. | Return True if numeric condition is met. | def _process_numeric_state(self, entity_observation):
"""Return True if numeric condition is met."""
entity = entity_observation["entity_id"]
return condition.async_numeric_state(
self.hass,
entity,
entity_observation.get("below"),
entity_observat... | [
"def",
"_process_numeric_state",
"(",
"self",
",",
"entity_observation",
")",
":",
"entity",
"=",
"entity_observation",
"[",
"\"entity_id\"",
"]",
"return",
"condition",
".",
"async_numeric_state",
"(",
"self",
".",
"hass",
",",
"entity",
",",
"entity_observation",
... | [
338,
4
] | [
349,
9
] | python | en | ['en', 'la', 'en'] | True |
BayesianBinarySensor._process_state | (self, entity_observation) | Return True if state conditions are met. | Return True if state conditions are met. | def _process_state(self, entity_observation):
"""Return True if state conditions are met."""
entity = entity_observation["entity_id"]
return condition.state(self.hass, entity, entity_observation.get("to_state")) | [
"def",
"_process_state",
"(",
"self",
",",
"entity_observation",
")",
":",
"entity",
"=",
"entity_observation",
"[",
"\"entity_id\"",
"]",
"return",
"condition",
".",
"state",
"(",
"self",
".",
"hass",
",",
"entity",
",",
"entity_observation",
".",
"get",
"(",... | [
351,
4
] | [
355,
85
] | python | en | ['en', 'en', 'en'] | True |
BayesianBinarySensor.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"
] | [
358,
4
] | [
360,
25
] | python | en | ['en', 'mi', 'en'] | True |
BayesianBinarySensor.is_on | (self) | Return true if sensor is on. | Return true if sensor is on. | def is_on(self):
"""Return true if sensor is on."""
return self._deviation | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_deviation"
] | [
363,
4
] | [
365,
30
] | python | en | ['en', 'et', 'en'] | True |
BayesianBinarySensor.should_poll | (self) | No polling needed. | No polling needed. | def should_poll(self):
"""No polling needed."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
368,
4
] | [
370,
20
] | python | en | ['en', 'en', 'en'] | True |
BayesianBinarySensor.device_class | (self) | Return the sensor class of the sensor. | Return the sensor class of the sensor. | def device_class(self):
"""Return the sensor class of the sensor."""
return self._device_class | [
"def",
"device_class",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device_class"
] | [
373,
4
] | [
375,
33
] | python | en | ['en', 'sq', 'en'] | True |
BayesianBinarySensor.device_state_attributes | (self) | Return the state attributes of the sensor. | Return the state attributes of the sensor. | def device_state_attributes(self):
"""Return the state attributes of the sensor."""
attr_observations_list = [
obs.copy() for obs in self.current_observations.values() if obs is not None
]
for item in attr_observations_list:
item.pop("value_template", None)
... | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"attr_observations_list",
"=",
"[",
"obs",
".",
"copy",
"(",
")",
"for",
"obs",
"in",
"self",
".",
"current_observations",
".",
"values",
"(",
")",
"if",
"obs",
"is",
"not",
"None",
"]",
"for",
"it... | [
378,
4
] | [
399,
9
] | python | en | ['en', 'en', 'en'] | True |
BayesianBinarySensor.async_update | (self) | Get the latest data and update the states. | Get the latest data and update the states. | async def async_update(self):
"""Get the latest data and update the states."""
if not self._callbacks:
self._recalculate_and_write_state()
return
# Force recalc of the templates. The states will
# update automatically.
for call in self._callbacks:
... | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_callbacks",
":",
"self",
".",
"_recalculate_and_write_state",
"(",
")",
"return",
"# Force recalc of the templates. The states will",
"# update automatically.",
"for",
"call",
"in",
"se... | [
401,
4
] | [
409,
32
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up Homekit fans. | Set up Homekit fans. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up Homekit fans."""
hkid = config_entry.data["AccessoryPairingID"]
conn = hass.data[KNOWN_DEVICES][hkid]
@callback
def async_add_service(service):
entity_class = ENTITY_TYPES.get(service.short_type)
if not e... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"hkid",
"=",
"config_entry",
".",
"data",
"[",
"\"AccessoryPairingID\"",
"]",
"conn",
"=",
"hass",
".",
"data",
"[",
"KNOWN_DEVICES",
"]",
"[",
"hkid",
... | [
169,
0
] | [
183,
40
] | python | en | ['en', 'lb', 'en'] | True |
BaseHomeKitFan.get_characteristic_types | (self) | Define the homekit characteristics the entity cares about. | Define the homekit characteristics the entity cares about. | def get_characteristic_types(self):
"""Define the homekit characteristics the entity cares about."""
return [
CharacteristicsTypes.SWING_MODE,
CharacteristicsTypes.ROTATION_DIRECTION,
CharacteristicsTypes.ROTATION_SPEED,
self.on_characteristic,
] | [
"def",
"get_characteristic_types",
"(",
"self",
")",
":",
"return",
"[",
"CharacteristicsTypes",
".",
"SWING_MODE",
",",
"CharacteristicsTypes",
".",
"ROTATION_DIRECTION",
",",
"CharacteristicsTypes",
".",
"ROTATION_SPEED",
",",
"self",
".",
"on_characteristic",
",",
... | [
43,
4
] | [
50,
9
] | python | en | ['en', 'en', 'en'] | True |
BaseHomeKitFan.is_on | (self) | Return true if device is on. | Return true if device is on. | def is_on(self):
"""Return true if device is on."""
return self.service.value(self.on_characteristic) == 1 | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"service",
".",
"value",
"(",
"self",
".",
"on_characteristic",
")",
"==",
"1"
] | [
53,
4
] | [
55,
62
] | python | en | ['en', 'fy', 'en'] | True |
BaseHomeKitFan.speed | (self) | Return the current speed. | Return the current speed. | def speed(self):
"""Return the current speed."""
if not self.is_on:
return SPEED_OFF
rotation_speed = self.service.value(CharacteristicsTypes.ROTATION_SPEED)
if rotation_speed > SPEED_TO_PCNT[SPEED_MEDIUM]:
return SPEED_HIGH
if rotation_speed > SPEED_TO... | [
"def",
"speed",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"is_on",
":",
"return",
"SPEED_OFF",
"rotation_speed",
"=",
"self",
".",
"service",
".",
"value",
"(",
"CharacteristicsTypes",
".",
"ROTATION_SPEED",
")",
"if",
"rotation_speed",
">",
"SPEED_TO... | [
58,
4
] | [
74,
24
] | python | en | ['en', 'en', 'en'] | True |
BaseHomeKitFan.speed_list | (self) | Get the list of available speeds. | Get the list of available speeds. | def speed_list(self):
"""Get the list of available speeds."""
if self.supported_features & SUPPORT_SET_SPEED:
return [SPEED_OFF, SPEED_LOW, SPEED_MEDIUM, SPEED_HIGH]
return [] | [
"def",
"speed_list",
"(",
"self",
")",
":",
"if",
"self",
".",
"supported_features",
"&",
"SUPPORT_SET_SPEED",
":",
"return",
"[",
"SPEED_OFF",
",",
"SPEED_LOW",
",",
"SPEED_MEDIUM",
",",
"SPEED_HIGH",
"]",
"return",
"[",
"]"
] | [
77,
4
] | [
81,
17
] | python | en | ['en', 'en', 'en'] | True |
BaseHomeKitFan.current_direction | (self) | Return the current direction of the fan. | Return the current direction of the fan. | def current_direction(self):
"""Return the current direction of the fan."""
direction = self.service.value(CharacteristicsTypes.ROTATION_DIRECTION)
return HK_DIRECTION_TO_HA[direction] | [
"def",
"current_direction",
"(",
"self",
")",
":",
"direction",
"=",
"self",
".",
"service",
".",
"value",
"(",
"CharacteristicsTypes",
".",
"ROTATION_DIRECTION",
")",
"return",
"HK_DIRECTION_TO_HA",
"[",
"direction",
"]"
] | [
84,
4
] | [
87,
44
] | python | en | ['en', 'en', 'en'] | True |
BaseHomeKitFan.oscillating | (self) | Return whether or not the fan is currently oscillating. | Return whether or not the fan is currently oscillating. | def oscillating(self):
"""Return whether or not the fan is currently oscillating."""
oscillating = self.service.value(CharacteristicsTypes.SWING_MODE)
return oscillating == 1 | [
"def",
"oscillating",
"(",
"self",
")",
":",
"oscillating",
"=",
"self",
".",
"service",
".",
"value",
"(",
"CharacteristicsTypes",
".",
"SWING_MODE",
")",
"return",
"oscillating",
"==",
"1"
] | [
90,
4
] | [
93,
31
] | python | en | ['en', 'en', 'en'] | True |
BaseHomeKitFan.supported_features | (self) | Flag supported features. | Flag supported features. | def supported_features(self):
"""Flag supported features."""
features = 0
if self.service.has(CharacteristicsTypes.ROTATION_DIRECTION):
features |= SUPPORT_DIRECTION
if self.service.has(CharacteristicsTypes.ROTATION_SPEED):
features |= SUPPORT_SET_SPEED
... | [
"def",
"supported_features",
"(",
"self",
")",
":",
"features",
"=",
"0",
"if",
"self",
".",
"service",
".",
"has",
"(",
"CharacteristicsTypes",
".",
"ROTATION_DIRECTION",
")",
":",
"features",
"|=",
"SUPPORT_DIRECTION",
"if",
"self",
".",
"service",
".",
"h... | [
96,
4
] | [
109,
23
] | python | en | ['da', 'en', 'en'] | True |
BaseHomeKitFan.async_set_direction | (self, direction) | Set the direction of the fan. | Set the direction of the fan. | async def async_set_direction(self, direction):
"""Set the direction of the fan."""
await self.async_put_characteristics(
{CharacteristicsTypes.ROTATION_DIRECTION: DIRECTION_TO_HK[direction]}
) | [
"async",
"def",
"async_set_direction",
"(",
"self",
",",
"direction",
")",
":",
"await",
"self",
".",
"async_put_characteristics",
"(",
"{",
"CharacteristicsTypes",
".",
"ROTATION_DIRECTION",
":",
"DIRECTION_TO_HK",
"[",
"direction",
"]",
"}",
")"
] | [
111,
4
] | [
115,
9
] | python | en | ['en', 'en', 'en'] | True |
BaseHomeKitFan.async_set_speed | (self, speed) | Set the speed of the fan. | Set the speed of the fan. | async def async_set_speed(self, speed):
"""Set the speed of the fan."""
if speed == SPEED_OFF:
return await self.async_turn_off()
await self.async_put_characteristics(
{CharacteristicsTypes.ROTATION_SPEED: SPEED_TO_PCNT[speed]}
) | [
"async",
"def",
"async_set_speed",
"(",
"self",
",",
"speed",
")",
":",
"if",
"speed",
"==",
"SPEED_OFF",
":",
"return",
"await",
"self",
".",
"async_turn_off",
"(",
")",
"await",
"self",
".",
"async_put_characteristics",
"(",
"{",
"CharacteristicsTypes",
".",... | [
117,
4
] | [
124,
9
] | python | en | ['en', 'en', 'en'] | True |
BaseHomeKitFan.async_oscillate | (self, oscillating: bool) | Oscillate the fan. | Oscillate the fan. | async def async_oscillate(self, oscillating: bool):
"""Oscillate the fan."""
await self.async_put_characteristics(
{CharacteristicsTypes.SWING_MODE: 1 if oscillating else 0}
) | [
"async",
"def",
"async_oscillate",
"(",
"self",
",",
"oscillating",
":",
"bool",
")",
":",
"await",
"self",
".",
"async_put_characteristics",
"(",
"{",
"CharacteristicsTypes",
".",
"SWING_MODE",
":",
"1",
"if",
"oscillating",
"else",
"0",
"}",
")"
] | [
126,
4
] | [
130,
9
] | python | en | ['en', 'fy', 'en'] | True |
BaseHomeKitFan.async_turn_on | (self, speed=None, **kwargs) | Turn the specified fan on. | Turn the specified fan on. | async def async_turn_on(self, speed=None, **kwargs):
"""Turn the specified fan on."""
characteristics = {}
if not self.is_on:
characteristics[self.on_characteristic] = True
if self.supported_features & SUPPORT_SET_SPEED and speed:
characteristics[Characteristic... | [
"async",
"def",
"async_turn_on",
"(",
"self",
",",
"speed",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"characteristics",
"=",
"{",
"}",
"if",
"not",
"self",
".",
"is_on",
":",
"characteristics",
"[",
"self",
".",
"on_characteristic",
"]",
"=",
"T... | [
132,
4
] | [
144,
65
] | python | en | ['en', 'fy', 'en'] | True |
BaseHomeKitFan.async_turn_off | (self, **kwargs) | Turn the specified fan off. | Turn the specified fan off. | async def async_turn_off(self, **kwargs):
"""Turn the specified fan off."""
await self.async_put_characteristics({self.on_characteristic: False}) | [
"async",
"def",
"async_turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"async_put_characteristics",
"(",
"{",
"self",
".",
"on_characteristic",
":",
"False",
"}",
")"
] | [
146,
4
] | [
148,
77
] | python | en | ['en', 'fy', 'en'] | True |
test_form | (hass) | Test we get the form. | Test we get the form. | async def test_form(hass):
"""Test we get the form."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == "form"
assert result["errors"] == {}
with patch(
"homeassistant.components.volumio.config_... | [
"async",
"def",
"test_form",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"config_entries",
".",
"SOURCE_USER",
"}",
")",
"assert",... | [
31,
0
] | [
59,
48
] | python | en | ['en', 'en', 'en'] | True |
test_form_updates_unique_id | (hass) | Test a duplicate id aborts and updates existing entry. | Test a duplicate id aborts and updates existing entry. | async def test_form_updates_unique_id(hass):
"""Test a duplicate id aborts and updates existing entry."""
entry = MockConfigEntry(
domain=DOMAIN,
unique_id=TEST_SYSTEM_INFO["id"],
data={
"host": "dummy",
"port": 11,
"name": "dummy",
"id": T... | [
"async",
"def",
"test_form_updates_unique_id",
"(",
"hass",
")",
":",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"unique_id",
"=",
"TEST_SYSTEM_INFO",
"[",
"\"id\"",
"]",
",",
"data",
"=",
"{",
"\"host\"",
":",
"\"dummy\"",
",",
"\"p... | [
62,
0
] | [
96,
64
] | python | en | ['en', 'en', 'en'] | True |
test_empty_system_info | (hass) | Test old volumio versions with empty system info. | Test old volumio versions with empty system info. | async def test_empty_system_info(hass):
"""Test old volumio versions with empty system info."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == "form"
assert result["errors"] == {}
with patch(
... | [
"async",
"def",
"test_empty_system_info",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"config_entries",
".",
"SOURCE_USER",
"}",
")"... | [
99,
0
] | [
132,
48
] | 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.