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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
async_alarm_arm_home | (hass, code=None, entity_id=ENTITY_MATCH_ALL) | Send the alarm the command for disarm. | Send the alarm the command for disarm. | async def async_alarm_arm_home(hass, code=None, entity_id=ENTITY_MATCH_ALL):
"""Send the alarm the command for disarm."""
data = {}
if code:
data[ATTR_CODE] = code
if entity_id:
data[ATTR_ENTITY_ID] = entity_id
await hass.services.async_call(DOMAIN, SERVICE_ALARM_ARM_HOME, data, blo... | [
"async",
"def",
"async_alarm_arm_home",
"(",
"hass",
",",
"code",
"=",
"None",
",",
"entity_id",
"=",
"ENTITY_MATCH_ALL",
")",
":",
"data",
"=",
"{",
"}",
"if",
"code",
":",
"data",
"[",
"ATTR_CODE",
"]",
"=",
"code",
"if",
"entity_id",
":",
"data",
"[... | [
31,
0
] | [
39,
87
] | python | en | ['en', 'en', 'en'] | True |
async_alarm_arm_away | (hass, code=None, entity_id=ENTITY_MATCH_ALL) | Send the alarm the command for disarm. | Send the alarm the command for disarm. | async def async_alarm_arm_away(hass, code=None, entity_id=ENTITY_MATCH_ALL):
"""Send the alarm the command for disarm."""
data = {}
if code:
data[ATTR_CODE] = code
if entity_id:
data[ATTR_ENTITY_ID] = entity_id
await hass.services.async_call(DOMAIN, SERVICE_ALARM_ARM_AWAY, data, blo... | [
"async",
"def",
"async_alarm_arm_away",
"(",
"hass",
",",
"code",
"=",
"None",
",",
"entity_id",
"=",
"ENTITY_MATCH_ALL",
")",
":",
"data",
"=",
"{",
"}",
"if",
"code",
":",
"data",
"[",
"ATTR_CODE",
"]",
"=",
"code",
"if",
"entity_id",
":",
"data",
"[... | [
42,
0
] | [
50,
87
] | python | en | ['en', 'en', 'en'] | True |
async_alarm_arm_night | (hass, code=None, entity_id=ENTITY_MATCH_ALL) | Send the alarm the command for disarm. | Send the alarm the command for disarm. | async def async_alarm_arm_night(hass, code=None, entity_id=ENTITY_MATCH_ALL):
"""Send the alarm the command for disarm."""
data = {}
if code:
data[ATTR_CODE] = code
if entity_id:
data[ATTR_ENTITY_ID] = entity_id
await hass.services.async_call(DOMAIN, SERVICE_ALARM_ARM_NIGHT, data, b... | [
"async",
"def",
"async_alarm_arm_night",
"(",
"hass",
",",
"code",
"=",
"None",
",",
"entity_id",
"=",
"ENTITY_MATCH_ALL",
")",
":",
"data",
"=",
"{",
"}",
"if",
"code",
":",
"data",
"[",
"ATTR_CODE",
"]",
"=",
"code",
"if",
"entity_id",
":",
"data",
"... | [
53,
0
] | [
61,
88
] | python | en | ['en', 'en', 'en'] | True |
async_alarm_arm_vacation | (hass, code=None, entity_id=ENTITY_MATCH_ALL) | Send the alarm the command for vacation mode. | Send the alarm the command for vacation mode. | async def async_alarm_arm_vacation(hass, code=None, entity_id=ENTITY_MATCH_ALL):
"""Send the alarm the command for vacation mode."""
data = {}
if code:
data[ATTR_CODE] = code
if entity_id:
data[ATTR_ENTITY_ID] = entity_id
await hass.services.async_call(
DOMAIN, SERVICE_ALARM... | [
"async",
"def",
"async_alarm_arm_vacation",
"(",
"hass",
",",
"code",
"=",
"None",
",",
"entity_id",
"=",
"ENTITY_MATCH_ALL",
")",
":",
"data",
"=",
"{",
"}",
"if",
"code",
":",
"data",
"[",
"ATTR_CODE",
"]",
"=",
"code",
"if",
"entity_id",
":",
"data",
... | [
64,
0
] | [
74,
5
] | python | en | ['en', 'en', 'en'] | True |
async_alarm_trigger | (hass, code=None, entity_id=ENTITY_MATCH_ALL) | Send the alarm the command for disarm. | Send the alarm the command for disarm. | async def async_alarm_trigger(hass, code=None, entity_id=ENTITY_MATCH_ALL):
"""Send the alarm the command for disarm."""
data = {}
if code:
data[ATTR_CODE] = code
if entity_id:
data[ATTR_ENTITY_ID] = entity_id
await hass.services.async_call(DOMAIN, SERVICE_ALARM_TRIGGER, data, block... | [
"async",
"def",
"async_alarm_trigger",
"(",
"hass",
",",
"code",
"=",
"None",
",",
"entity_id",
"=",
"ENTITY_MATCH_ALL",
")",
":",
"data",
"=",
"{",
"}",
"if",
"code",
":",
"data",
"[",
"ATTR_CODE",
"]",
"=",
"code",
"if",
"entity_id",
":",
"data",
"["... | [
77,
0
] | [
85,
86
] | python | en | ['en', 'en', 'en'] | True |
async_alarm_arm_custom_bypass | (hass, code=None, entity_id=ENTITY_MATCH_ALL) | Send the alarm the command for disarm. | Send the alarm the command for disarm. | async def async_alarm_arm_custom_bypass(hass, code=None, entity_id=ENTITY_MATCH_ALL):
"""Send the alarm the command for disarm."""
data = {}
if code:
data[ATTR_CODE] = code
if entity_id:
data[ATTR_ENTITY_ID] = entity_id
await hass.services.async_call(
DOMAIN, SERVICE_ALARM_A... | [
"async",
"def",
"async_alarm_arm_custom_bypass",
"(",
"hass",
",",
"code",
"=",
"None",
",",
"entity_id",
"=",
"ENTITY_MATCH_ALL",
")",
":",
"data",
"=",
"{",
"}",
"if",
"code",
":",
"data",
"[",
"ATTR_CODE",
"]",
"=",
"code",
"if",
"entity_id",
":",
"da... | [
88,
0
] | [
98,
5
] | python | en | ['en', 'en', 'en'] | True |
test_sync_turn_on | (hass) | Test if async turn_on calls sync turn_on. | Test if async turn_on calls sync turn_on. | async def test_sync_turn_on(hass):
"""Test if async turn_on calls sync turn_on."""
siren = MockSirenEntity()
siren.hass = hass
siren.turn_on = MagicMock()
await siren.async_turn_on()
assert siren.turn_on.called | [
"async",
"def",
"test_sync_turn_on",
"(",
"hass",
")",
":",
"siren",
"=",
"MockSirenEntity",
"(",
")",
"siren",
".",
"hass",
"=",
"hass",
"siren",
".",
"turn_on",
"=",
"MagicMock",
"(",
")",
"await",
"siren",
".",
"async_turn_on",
"(",
")",
"assert",
"si... | [
20,
0
] | [
28,
31
] | python | en | ['en', 'cy', 'en'] | True |
test_sync_turn_off | (hass) | Test if async turn_off calls sync turn_off. | Test if async turn_off calls sync turn_off. | async def test_sync_turn_off(hass):
"""Test if async turn_off calls sync turn_off."""
siren = MockSirenEntity()
siren.hass = hass
siren.turn_off = MagicMock()
await siren.async_turn_off()
assert siren.turn_off.called | [
"async",
"def",
"test_sync_turn_off",
"(",
"hass",
")",
":",
"siren",
"=",
"MockSirenEntity",
"(",
")",
"siren",
".",
"hass",
"=",
"hass",
"siren",
".",
"turn_off",
"=",
"MagicMock",
"(",
")",
"await",
"siren",
".",
"async_turn_off",
"(",
")",
"assert",
... | [
31,
0
] | [
39,
32
] | python | en | ['en', 'cy', 'en'] | True |
test_no_available_tones | (hass) | Test ValueError when siren advertises tones but has no available_tones. | Test ValueError when siren advertises tones but has no available_tones. | async def test_no_available_tones(hass):
"""Test ValueError when siren advertises tones but has no available_tones."""
siren = MockSirenEntity(SUPPORT_TONES)
siren.hass = hass
with pytest.raises(ValueError):
process_turn_on_params(siren, {"tone": "test"}) | [
"async",
"def",
"test_no_available_tones",
"(",
"hass",
")",
":",
"siren",
"=",
"MockSirenEntity",
"(",
"SUPPORT_TONES",
")",
"siren",
".",
"hass",
"=",
"hass",
"with",
"pytest",
".",
"raises",
"(",
"ValueError",
")",
":",
"process_turn_on_params",
"(",
"siren... | [
42,
0
] | [
47,
55
] | python | en | ['en', 'en', 'en'] | True |
test_available_tones_list | (hass) | Test that valid tones from tone list will get passed in. | Test that valid tones from tone list will get passed in. | async def test_available_tones_list(hass):
"""Test that valid tones from tone list will get passed in."""
siren = MockSirenEntity(SUPPORT_TONES, ["a", "b"])
siren.hass = hass
assert process_turn_on_params(siren, {"tone": "a"}) == {"tone": "a"} | [
"async",
"def",
"test_available_tones_list",
"(",
"hass",
")",
":",
"siren",
"=",
"MockSirenEntity",
"(",
"SUPPORT_TONES",
",",
"[",
"\"a\"",
",",
"\"b\"",
"]",
")",
"siren",
".",
"hass",
"=",
"hass",
"assert",
"process_turn_on_params",
"(",
"siren",
",",
"{... | [
50,
0
] | [
54,
72
] | python | en | ['en', 'en', 'en'] | True |
test_available_tones_dict | (hass) | Test that valid tones from available_tones dict will get passed in. | Test that valid tones from available_tones dict will get passed in. | async def test_available_tones_dict(hass):
"""Test that valid tones from available_tones dict will get passed in."""
siren = MockSirenEntity(SUPPORT_TONES, {1: "a", 2: "b"})
siren.hass = hass
assert process_turn_on_params(siren, {"tone": "a"}) == {"tone": 1}
assert process_turn_on_params(siren, {"to... | [
"async",
"def",
"test_available_tones_dict",
"(",
"hass",
")",
":",
"siren",
"=",
"MockSirenEntity",
"(",
"SUPPORT_TONES",
",",
"{",
"1",
":",
"\"a\"",
",",
"2",
":",
"\"b\"",
"}",
")",
"siren",
".",
"hass",
"=",
"hass",
"assert",
"process_turn_on_params",
... | [
57,
0
] | [
62,
68
] | python | en | ['en', 'en', 'en'] | True |
test_missing_tones_list | (hass) | Test ValueError when setting a tone that is missing from available_tones list. | Test ValueError when setting a tone that is missing from available_tones list. | async def test_missing_tones_list(hass):
"""Test ValueError when setting a tone that is missing from available_tones list."""
siren = MockSirenEntity(SUPPORT_TONES, ["a", "b"])
siren.hass = hass
with pytest.raises(ValueError):
process_turn_on_params(siren, {"tone": "test"}) | [
"async",
"def",
"test_missing_tones_list",
"(",
"hass",
")",
":",
"siren",
"=",
"MockSirenEntity",
"(",
"SUPPORT_TONES",
",",
"[",
"\"a\"",
",",
"\"b\"",
"]",
")",
"siren",
".",
"hass",
"=",
"hass",
"with",
"pytest",
".",
"raises",
"(",
"ValueError",
")",
... | [
65,
0
] | [
70,
55
] | python | en | ['en', 'en', 'en'] | True |
test_missing_tones_dict | (hass) | Test ValueError when setting a tone that is missing from available_tones dict. | Test ValueError when setting a tone that is missing from available_tones dict. | async def test_missing_tones_dict(hass):
"""Test ValueError when setting a tone that is missing from available_tones dict."""
siren = MockSirenEntity(SUPPORT_TONES, {1: "a", 2: "b"})
siren.hass = hass
with pytest.raises(ValueError):
process_turn_on_params(siren, {"tone": 3}) | [
"async",
"def",
"test_missing_tones_dict",
"(",
"hass",
")",
":",
"siren",
"=",
"MockSirenEntity",
"(",
"SUPPORT_TONES",
",",
"{",
"1",
":",
"\"a\"",
",",
"2",
":",
"\"b\"",
"}",
")",
"siren",
".",
"hass",
"=",
"hass",
"with",
"pytest",
".",
"raises",
... | [
73,
0
] | [
78,
50
] | python | en | ['en', 'en', 'en'] | True |
MockSirenEntity.__init__ | (self, supported_features=0, available_tones=None) | Initialize mock siren entity. | Initialize mock siren entity. | def __init__(self, supported_features=0, available_tones=None):
"""Initialize mock siren entity."""
self._attr_supported_features = supported_features
self._attr_available_tones = available_tones | [
"def",
"__init__",
"(",
"self",
",",
"supported_features",
"=",
"0",
",",
"available_tones",
"=",
"None",
")",
":",
"self",
".",
"_attr_supported_features",
"=",
"supported_features",
"self",
".",
"_attr_available_tones",
"=",
"available_tones"
] | [
14,
4
] | [
17,
52
] | python | fy | ['nl', 'fy', 'it'] | False |
async_get_scanner | (hass: HomeAssistant, config: ConfigType) | Validate the configuration and return a Nmap scanner. | Validate the configuration and return a Nmap scanner. | async def async_get_scanner(hass: HomeAssistant, config: ConfigType) -> None:
"""Validate the configuration and return a Nmap scanner."""
validated_config = config[DEVICE_TRACKER_DOMAIN]
if CONF_SCAN_INTERVAL in validated_config:
scan_interval = validated_config[CONF_SCAN_INTERVAL].total_seconds()
... | [
"async",
"def",
"async_get_scanner",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"ConfigType",
")",
"->",
"None",
":",
"validated_config",
"=",
"config",
"[",
"DEVICE_TRACKER_DOMAIN",
"]",
"if",
"CONF_SCAN_INTERVAL",
"in",
"validated_config",
":",
"scan... | [
53,
0
] | [
87,
5
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: Callable
) | Set up device tracker for Nmap Tracker component. | Set up device tracker for Nmap Tracker component. | async def async_setup_entry(
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: Callable
) -> None:
"""Set up device tracker for Nmap Tracker component."""
nmap_tracker = hass.data[DOMAIN][entry.entry_id]
@callback
def device_new(mac_address):
"""Signal a new device."""
as... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
",",
"async_add_entities",
":",
"Callable",
")",
"->",
"None",
":",
"nmap_tracker",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"entry",
".",
"... | [
90,
0
] | [
113,
5
] | python | en | ['en', 'en', 'en'] | True |
NmapTrackerEntity.__init__ | (
self, nmap_tracker: NmapDeviceScanner, mac_address: str, active: bool
) | Initialize an nmap tracker entity. | Initialize an nmap tracker entity. | def __init__(
self, nmap_tracker: NmapDeviceScanner, mac_address: str, active: bool
) -> None:
"""Initialize an nmap tracker entity."""
self._mac_address = mac_address
self._nmap_tracker = nmap_tracker
self._tracked = self._nmap_tracker.devices.tracked
self._active = ... | [
"def",
"__init__",
"(",
"self",
",",
"nmap_tracker",
":",
"NmapDeviceScanner",
",",
"mac_address",
":",
"str",
",",
"active",
":",
"bool",
")",
"->",
"None",
":",
"self",
".",
"_mac_address",
"=",
"mac_address",
"self",
".",
"_nmap_tracker",
"=",
"nmap_track... | [
119,
4
] | [
126,
29
] | python | en | ['en', 'en', 'en'] | True |
NmapTrackerEntity._device | (self) | Get latest device state. | Get latest device state. | def _device(self) -> NmapDevice:
"""Get latest device state."""
return self._tracked[self._mac_address] | [
"def",
"_device",
"(",
"self",
")",
"->",
"NmapDevice",
":",
"return",
"self",
".",
"_tracked",
"[",
"self",
".",
"_mac_address",
"]"
] | [
129,
4
] | [
131,
47
] | python | en | ['fr', 'en', 'en'] | True |
NmapTrackerEntity.is_connected | (self) | Return device status. | Return device status. | def is_connected(self) -> bool:
"""Return device status."""
return self._active | [
"def",
"is_connected",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"_active"
] | [
134,
4
] | [
136,
27
] | python | en | ['es', 'la', 'en'] | False |
NmapTrackerEntity.name | (self) | Return device name. | Return device name. | def name(self) -> str:
"""Return device name."""
return self._device.name | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_device",
".",
"name"
] | [
139,
4
] | [
141,
32
] | python | en | ['es', 'sl', 'en'] | False |
NmapTrackerEntity.unique_id | (self) | Return device unique id. | Return device unique id. | def unique_id(self) -> str:
"""Return device unique id."""
return self._mac_address | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_mac_address"
] | [
144,
4
] | [
146,
32
] | python | en | ['fr', 'it', 'en'] | False |
NmapTrackerEntity.ip_address | (self) | Return the primary ip address of the device. | Return the primary ip address of the device. | def ip_address(self) -> str:
"""Return the primary ip address of the device."""
return self._device.ipv4 | [
"def",
"ip_address",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_device",
".",
"ipv4"
] | [
149,
4
] | [
151,
32
] | python | en | ['en', 'en', 'en'] | True |
NmapTrackerEntity.mac_address | (self) | Return the mac address of the device. | Return the mac address of the device. | def mac_address(self) -> str:
"""Return the mac address of the device."""
return self._mac_address | [
"def",
"mac_address",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_mac_address"
] | [
154,
4
] | [
156,
32
] | python | en | ['en', 'en', 'en'] | True |
NmapTrackerEntity.hostname | (self) | Return hostname of the device. | Return hostname of the device. | def hostname(self) -> str | None:
"""Return hostname of the device."""
if not self._device.hostname:
return None
return short_hostname(self._device.hostname) | [
"def",
"hostname",
"(",
"self",
")",
"->",
"str",
"|",
"None",
":",
"if",
"not",
"self",
".",
"_device",
".",
"hostname",
":",
"return",
"None",
"return",
"short_hostname",
"(",
"self",
".",
"_device",
".",
"hostname",
")"
] | [
159,
4
] | [
163,
52
] | python | en | ['en', 'sl', 'en'] | True |
NmapTrackerEntity.source_type | (self) | Return tracker source type. | Return tracker source type. | def source_type(self) -> str:
"""Return tracker source type."""
return SOURCE_TYPE_ROUTER | [
"def",
"source_type",
"(",
"self",
")",
"->",
"str",
":",
"return",
"SOURCE_TYPE_ROUTER"
] | [
166,
4
] | [
168,
33
] | python | en | ['en', 'sn', 'en'] | True |
NmapTrackerEntity.device_info | (self) | Return the device information. | Return the device information. | def device_info(self) -> DeviceInfo:
"""Return the device information."""
return {
"connections": {(CONNECTION_NETWORK_MAC, self._mac_address)},
"default_manufacturer": self._device.manufacturer,
"default_name": self.name,
} | [
"def",
"device_info",
"(",
"self",
")",
"->",
"DeviceInfo",
":",
"return",
"{",
"\"connections\"",
":",
"{",
"(",
"CONNECTION_NETWORK_MAC",
",",
"self",
".",
"_mac_address",
")",
"}",
",",
"\"default_manufacturer\"",
":",
"self",
".",
"_device",
".",
"manufact... | [
171,
4
] | [
177,
9
] | python | en | ['en', 'en', 'en'] | True |
NmapTrackerEntity.should_poll | (self) | No polling needed. | No polling needed. | def should_poll(self) -> bool:
"""No polling needed."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"False"
] | [
180,
4
] | [
182,
20
] | python | en | ['en', 'en', 'en'] | True |
NmapTrackerEntity.icon | (self) | Return device icon. | Return device icon. | def icon(self) -> str:
"""Return device icon."""
return "mdi:lan-connect" if self._active else "mdi:lan-disconnect" | [
"def",
"icon",
"(",
"self",
")",
"->",
"str",
":",
"return",
"\"mdi:lan-connect\"",
"if",
"self",
".",
"_active",
"else",
"\"mdi:lan-disconnect\""
] | [
185,
4
] | [
187,
74
] | python | en | ['es', 'sr', 'en'] | False |
NmapTrackerEntity.async_process_update | (self, online: bool) | Update device. | Update device. | def async_process_update(self, online: bool) -> None:
"""Update device."""
self._active = online | [
"def",
"async_process_update",
"(",
"self",
",",
"online",
":",
"bool",
")",
"->",
"None",
":",
"self",
".",
"_active",
"=",
"online"
] | [
190,
4
] | [
192,
29
] | python | co | ['fr', 'co', 'en'] | False |
NmapTrackerEntity.extra_state_attributes | (self) | Return the attributes. | Return the attributes. | def extra_state_attributes(self) -> dict[str, Any]:
"""Return the attributes."""
return {
"last_time_reachable": self._device.last_update.isoformat(
timespec="seconds"
),
"reason": self._device.reason,
} | [
"def",
"extra_state_attributes",
"(",
"self",
")",
"->",
"dict",
"[",
"str",
",",
"Any",
"]",
":",
"return",
"{",
"\"last_time_reachable\"",
":",
"self",
".",
"_device",
".",
"last_update",
".",
"isoformat",
"(",
"timespec",
"=",
"\"seconds\"",
")",
",",
"... | [
195,
4
] | [
202,
9
] | python | en | ['en', 'la', 'en'] | True |
NmapTrackerEntity.async_on_demand_update | (self, online: bool) | Update state. | Update state. | def async_on_demand_update(self, online: bool) -> None:
"""Update state."""
self.async_process_update(online)
self.async_write_ha_state() | [
"def",
"async_on_demand_update",
"(",
"self",
",",
"online",
":",
"bool",
")",
"->",
"None",
":",
"self",
".",
"async_process_update",
"(",
"online",
")",
"self",
".",
"async_write_ha_state",
"(",
")"
] | [
205,
4
] | [
208,
35
] | python | en | ['en', 'co', 'en'] | False |
NmapTrackerEntity.async_added_to_hass | (self) | Register state update callback. | Register state update callback. | async def async_added_to_hass(self) -> None:
"""Register state update callback."""
self.async_on_remove(
async_dispatcher_connect(
self.hass,
signal_device_update(self._mac_address),
self.async_on_demand_update,
)
) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"async_on_remove",
"(",
"async_dispatcher_connect",
"(",
"self",
".",
"hass",
",",
"signal_device_update",
"(",
"self",
".",
"_mac_address",
")",
",",
"self",
".",
"async_... | [
210,
4
] | [
218,
9
] | python | en | ['en', 'co', 'en'] | True |
test_constructor_loads_info_from_config | (hass) | Test non-dev mode loads info from SERVERS constant. | Test non-dev mode loads info from SERVERS constant. | async def test_constructor_loads_info_from_config(hass):
"""Test non-dev mode loads info from SERVERS constant."""
with patch("hass_nabucasa.Cloud.initialize"):
result = await async_setup_component(
hass,
"cloud",
{
"http": {},
"cloud":... | [
"async",
"def",
"test_constructor_loads_info_from_config",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"hass_nabucasa.Cloud.initialize\"",
")",
":",
"result",
"=",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"cloud\"",
",",
"{",
"\"http\"",
":",
"{",
... | [
15,
0
] | [
54,
5
] | python | en | ['en', 'en', 'en'] | True |
test_remote_services | (hass, mock_cloud_fixture, hass_read_only_user) | Setup cloud component and test services. | Setup cloud component and test services. | async def test_remote_services(hass, mock_cloud_fixture, hass_read_only_user):
"""Setup cloud component and test services."""
cloud = hass.data[DOMAIN]
assert hass.services.has_service(DOMAIN, "remote_connect")
assert hass.services.has_service(DOMAIN, "remote_disconnect")
with patch("hass_nabucasa... | [
"async",
"def",
"test_remote_services",
"(",
"hass",
",",
"mock_cloud_fixture",
",",
"hass_read_only_user",
")",
":",
"cloud",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"assert",
"hass",
".",
"services",
".",
"has_service",
"(",
"DOMAIN",
",",
"\"remote_co... | [
57,
0
] | [
95,
42
] | python | en | ['en', 'en', 'en'] | True |
test_startup_shutdown_events | (hass, mock_cloud_fixture) | Test if the cloud will start on startup event. | Test if the cloud will start on startup event. | async def test_startup_shutdown_events(hass, mock_cloud_fixture):
"""Test if the cloud will start on startup event."""
with patch("hass_nabucasa.Cloud.stop") as mock_stop:
hass.bus.async_fire(EVENT_HOMEASSISTANT_STOP)
await hass.async_block_till_done()
assert mock_stop.called | [
"async",
"def",
"test_startup_shutdown_events",
"(",
"hass",
",",
"mock_cloud_fixture",
")",
":",
"with",
"patch",
"(",
"\"hass_nabucasa.Cloud.stop\"",
")",
"as",
"mock_stop",
":",
"hass",
".",
"bus",
".",
"async_fire",
"(",
"EVENT_HOMEASSISTANT_STOP",
")",
"await",... | [
98,
0
] | [
104,
27
] | python | en | ['en', 'en', 'en'] | True |
test_setup_existing_cloud_user | (hass, hass_storage) | Test setup with API push default data. | Test setup with API push default data. | async def test_setup_existing_cloud_user(hass, hass_storage):
"""Test setup with API push default data."""
user = await hass.auth.async_create_system_user("Cloud test")
hass_storage[STORAGE_KEY] = {"version": 1, "data": {"cloud_user": user.id}}
with patch("hass_nabucasa.Cloud.initialize"):
resul... | [
"async",
"def",
"test_setup_existing_cloud_user",
"(",
"hass",
",",
"hass_storage",
")",
":",
"user",
"=",
"await",
"hass",
".",
"auth",
".",
"async_create_system_user",
"(",
"\"Cloud test\"",
")",
"hass_storage",
"[",
"STORAGE_KEY",
"]",
"=",
"{",
"\"version\"",
... | [
107,
0
] | [
128,
69
] | python | en | ['en', 'hi-Latn', 'en'] | True |
test_on_connect | (hass, mock_cloud_fixture) | Test cloud on connect triggers. | Test cloud on connect triggers. | async def test_on_connect(hass, mock_cloud_fixture):
"""Test cloud on connect triggers."""
cl = hass.data["cloud"]
assert len(cl.iot._on_connect) == 3
assert len(hass.states.async_entity_ids("binary_sensor")) == 0
assert "async_setup" in str(cl.iot._on_connect[-1])
await cl.iot._on_connect[-1... | [
"async",
"def",
"test_on_connect",
"(",
"hass",
",",
"mock_cloud_fixture",
")",
":",
"cl",
"=",
"hass",
".",
"data",
"[",
"\"cloud\"",
"]",
"assert",
"len",
"(",
"cl",
".",
"iot",
".",
"_on_connect",
")",
"==",
"3",
"assert",
"len",
"(",
"hass",
".",
... | [
131,
0
] | [
149,
41
] | python | en | ['en', 'en', 'en'] | True |
test_remote_ui_url | (hass, mock_cloud_fixture) | Test getting remote ui url. | Test getting remote ui url. | async def test_remote_ui_url(hass, mock_cloud_fixture):
"""Test getting remote ui url."""
cl = hass.data["cloud"]
# Not logged in
with pytest.raises(cloud.CloudNotAvailable):
cloud.async_remote_ui_url(hass)
with patch.object(cloud, "async_is_logged_in", return_value=True):
# Remote... | [
"async",
"def",
"test_remote_ui_url",
"(",
"hass",
",",
"mock_cloud_fixture",
")",
":",
"cl",
"=",
"hass",
".",
"data",
"[",
"\"cloud\"",
"]",
"# Not logged in",
"with",
"pytest",
".",
"raises",
"(",
"cloud",
".",
"CloudNotAvailable",
")",
":",
"cloud",
".",... | [
152,
0
] | [
173,
71
] | python | cy | ['nl', 'cy', 'en'] | False |
validate_input | (hass: core.HomeAssistant, data) | Validate the user input allows us to connect.
Data has the keys from DATA_SCHEMA with values provided by the user.
| Validate the user input allows us to connect. | async def validate_input(hass: core.HomeAssistant, data):
"""Validate the user input allows us to connect.
Data has the keys from DATA_SCHEMA with values provided by the user.
"""
api = nuheat.NuHeat(data[CONF_USERNAME], data[CONF_PASSWORD])
try:
await hass.async_add_executor_job(api.authe... | [
"async",
"def",
"validate_input",
"(",
"hass",
":",
"core",
".",
"HomeAssistant",
",",
"data",
")",
":",
"api",
"=",
"nuheat",
".",
"NuHeat",
"(",
"data",
"[",
"CONF_USERNAME",
"]",
",",
"data",
"[",
"CONF_PASSWORD",
"]",
")",
"try",
":",
"await",
"has... | [
28,
0
] | [
59,
80
] | python | en | ['en', 'en', 'en'] | True |
ConfigFlow.async_step_user | (self, user_input=None) | Handle the initial step. | Handle the initial step. | async def async_step_user(self, user_input=None):
"""Handle the initial step."""
errors = {}
if user_input is not None:
try:
info = await validate_input(self.hass, user_input)
except CannotConnect:
errors["base"] = "cannot_connect"
... | [
"async",
"def",
"async_step_user",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"errors",
"=",
"{",
"}",
"if",
"user_input",
"is",
"not",
"None",
":",
"try",
":",
"info",
"=",
"await",
"validate_input",
"(",
"self",
".",
"hass",
",",
"user_in... | [
67,
4
] | [
90,
9
] | python | en | ['en', 'en', 'en'] | True |
test_lock_unlock | (hass, hk_driver, events) | Test if accessory and HA are updated accordingly. | Test if accessory and HA are updated accordingly. | async def test_lock_unlock(hass, hk_driver, events):
"""Test if accessory and HA are updated accordingly."""
code = "1234"
config = {ATTR_CODE: code}
entity_id = "lock.kitchen_door"
hass.states.async_set(entity_id, None)
await hass.async_block_till_done()
acc = Lock(hass, hk_driver, "Lock",... | [
"async",
"def",
"test_lock_unlock",
"(",
"hass",
",",
"hk_driver",
",",
"events",
")",
":",
"code",
"=",
"\"1234\"",
"config",
"=",
"{",
"ATTR_CODE",
":",
"code",
"}",
"entity_id",
"=",
"\"lock.kitchen_door\"",
"hass",
".",
"states",
".",
"async_set",
"(",
... | [
22,
0
] | [
94,
46
] | python | en | ['en', 'en', 'en'] | True |
test_no_code | (hass, hk_driver, config, events) | Test accessory if lock doesn't require a code. | Test accessory if lock doesn't require a code. | async def test_no_code(hass, hk_driver, config, events):
"""Test accessory if lock doesn't require a code."""
entity_id = "lock.kitchen_door"
hass.states.async_set(entity_id, None)
await hass.async_block_till_done()
acc = Lock(hass, hk_driver, "Lock", entity_id, 2, config)
# Set from HomeKit
... | [
"async",
"def",
"test_no_code",
"(",
"hass",
",",
"hk_driver",
",",
"config",
",",
"events",
")",
":",
"entity_id",
"=",
"\"lock.kitchen_door\"",
"hass",
".",
"states",
".",
"async_set",
"(",
"entity_id",
",",
"None",
")",
"await",
"hass",
".",
"async_block_... | [
98,
0
] | [
116,
46
] | python | en | ['en', 'en', 'en'] | True |
get_scanner | (hass, config) | Return a mock scanner. | Return a mock scanner. | def get_scanner(hass, config):
"""Return a mock scanner."""
return SCANNER | [
"def",
"get_scanner",
"(",
"hass",
",",
"config",
")",
":",
"return",
"SCANNER"
] | [
7,
0
] | [
9,
18
] | python | en | ['en', 'da', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up the config entry. | Set up the config entry. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up the config entry."""
entity = MockScannerEntity()
async_add_entities([entity]) | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"entity",
"=",
"MockScannerEntity",
"(",
")",
"async_add_entities",
"(",
"[",
"entity",
"]",
")"
] | [
61,
0
] | [
64,
32
] | python | en | ['en', 'en', 'en'] | True |
MockScannerEntity.source_type | (self) | Return the source type, eg gps or router, of the device. | Return the source type, eg gps or router, of the device. | def source_type(self):
"""Return the source type, eg gps or router, of the device."""
return SOURCE_TYPE_ROUTER | [
"def",
"source_type",
"(",
"self",
")",
":",
"return",
"SOURCE_TYPE_ROUTER"
] | [
23,
4
] | [
25,
33
] | python | en | ['en', 'en', 'en'] | True |
MockScannerEntity.battery_level | (self) | Return the battery level of the device.
Percentage from 0-100.
| Return the battery level of the device. | def battery_level(self):
"""Return the battery level of the device.
Percentage from 0-100.
"""
return 100 | [
"def",
"battery_level",
"(",
"self",
")",
":",
"return",
"100"
] | [
28,
4
] | [
33,
18
] | python | en | ['en', 'en', 'en'] | True |
MockScannerEntity.ip_address | (self) | Return the primary ip address of the device. | Return the primary ip address of the device. | def ip_address(self) -> str:
"""Return the primary ip address of the device."""
return self._ip_address | [
"def",
"ip_address",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_ip_address"
] | [
36,
4
] | [
38,
31
] | python | en | ['en', 'en', 'en'] | True |
MockScannerEntity.mac_address | (self) | Return the mac address of the device. | Return the mac address of the device. | def mac_address(self) -> str:
"""Return the mac address of the device."""
return self._mac_address | [
"def",
"mac_address",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_mac_address"
] | [
41,
4
] | [
43,
32
] | python | en | ['en', 'en', 'en'] | True |
MockScannerEntity.hostname | (self) | Return hostname of the device. | Return hostname of the device. | def hostname(self) -> str:
"""Return hostname of the device."""
return self._hostname | [
"def",
"hostname",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_hostname"
] | [
46,
4
] | [
48,
29
] | python | en | ['en', 'sl', 'en'] | True |
MockScannerEntity.is_connected | (self) | Return true if the device is connected to the network. | Return true if the device is connected to the network. | def is_connected(self):
"""Return true if the device is connected to the network."""
return self.connected | [
"def",
"is_connected",
"(",
"self",
")",
":",
"return",
"self",
".",
"connected"
] | [
51,
4
] | [
53,
29
] | python | en | ['en', 'en', 'en'] | True |
MockScannerEntity.set_connected | (self) | Set connected to True. | Set connected to True. | def set_connected(self):
"""Set connected to True."""
self.connected = True
self.async_schedule_update_ha_state() | [
"def",
"set_connected",
"(",
"self",
")",
":",
"self",
".",
"connected",
"=",
"True",
"self",
".",
"async_schedule_update_ha_state",
"(",
")"
] | [
55,
4
] | [
58,
45
] | python | en | ['en', 'en', 'en'] | True |
MockScanner.__init__ | (self) | Initialize the MockScanner. | Initialize the MockScanner. | def __init__(self):
"""Initialize the MockScanner."""
self.devices_home = [] | [
"def",
"__init__",
"(",
"self",
")",
":",
"self",
".",
"devices_home",
"=",
"[",
"]"
] | [
70,
4
] | [
72,
30
] | python | en | ['en', 'da', 'en'] | True |
MockScanner.come_home | (self, device) | Make a device come home. | Make a device come home. | def come_home(self, device):
"""Make a device come home."""
self.devices_home.append(device) | [
"def",
"come_home",
"(",
"self",
",",
"device",
")",
":",
"self",
".",
"devices_home",
".",
"append",
"(",
"device",
")"
] | [
74,
4
] | [
76,
40
] | python | en | ['es', 'it', 'en'] | False |
MockScanner.leave_home | (self, device) | Make a device leave the house. | Make a device leave the house. | def leave_home(self, device):
"""Make a device leave the house."""
self.devices_home.remove(device) | [
"def",
"leave_home",
"(",
"self",
",",
"device",
")",
":",
"self",
".",
"devices_home",
".",
"remove",
"(",
"device",
")"
] | [
78,
4
] | [
80,
40
] | python | en | ['en', 'en', 'en'] | True |
MockScanner.reset | (self) | Reset which devices are home. | Reset which devices are home. | def reset(self):
"""Reset which devices are home."""
self.devices_home = [] | [
"def",
"reset",
"(",
"self",
")",
":",
"self",
".",
"devices_home",
"=",
"[",
"]"
] | [
82,
4
] | [
84,
30
] | python | en | ['en', 'en', 'en'] | True |
MockScanner.scan_devices | (self) | Return a list of fake devices. | Return a list of fake devices. | def scan_devices(self):
"""Return a list of fake devices."""
return list(self.devices_home) | [
"def",
"scan_devices",
"(",
"self",
")",
":",
"return",
"list",
"(",
"self",
".",
"devices_home",
")"
] | [
86,
4
] | [
88,
38
] | python | en | ['en', 'en', 'en'] | True |
MockScanner.get_device_name | (self, device) | Return a name for a mock device.
Return None for dev1 for testing.
| Return a name for a mock device. | def get_device_name(self, device):
"""Return a name for a mock device.
Return None for dev1 for testing.
"""
return None if device == "DEV1" else device.lower() | [
"def",
"get_device_name",
"(",
"self",
",",
"device",
")",
":",
"return",
"None",
"if",
"device",
"==",
"\"DEV1\"",
"else",
"device",
".",
"lower",
"(",
")"
] | [
90,
4
] | [
95,
59
] | python | en | ['en', 'en', 'en'] | True |
load | (f, _dict=dict, decoder=None) | Parses named file or files as toml and returns a dictionary
Args:
f: Path to the file to open, array of files to read into single dict
or a file descriptor
_dict: (optional) Specifies the class of the returned toml dictionary
decoder: The decoder to use
Returns:
Pars... | Parses named file or files as toml and returns a dictionary | def load(f, _dict=dict, decoder=None):
"""Parses named file or files as toml and returns a dictionary
Args:
f: Path to the file to open, array of files to read into single dict
or a file descriptor
_dict: (optional) Specifies the class of the returned toml dictionary
decoder:... | [
"def",
"load",
"(",
"f",
",",
"_dict",
"=",
"dict",
",",
"decoder",
"=",
"None",
")",
":",
"if",
"_ispath",
"(",
"f",
")",
":",
"with",
"io",
".",
"open",
"(",
"_getpath",
"(",
"f",
")",
",",
"encoding",
"=",
"'utf-8'",
")",
"as",
"ffile",
":",... | [
112,
0
] | [
158,
35
] | python | en | ['en', 'en', 'en'] | True |
loads | (s, _dict=dict, decoder=None) | Parses string as toml
Args:
s: String to be parsed
_dict: (optional) Specifies the class of the returned toml dictionary
Returns:
Parsed toml file represented as a dictionary
Raises:
TypeError: When a non-string is passed
TomlDecodeError: Error while decoding toml
... | Parses string as toml | def loads(s, _dict=dict, decoder=None):
"""Parses string as toml
Args:
s: String to be parsed
_dict: (optional) Specifies the class of the returned toml dictionary
Returns:
Parsed toml file represented as a dictionary
Raises:
TypeError: When a non-string is passed
... | [
"def",
"loads",
"(",
"s",
",",
"_dict",
"=",
"dict",
",",
"decoder",
"=",
"None",
")",
":",
"implicitgroups",
"=",
"[",
"]",
"if",
"decoder",
"is",
"None",
":",
"decoder",
"=",
"TomlDecoder",
"(",
"_dict",
")",
"retval",
"=",
"decoder",
".",
"get_emp... | [
164,
0
] | [
515,
17
] | python | en | ['en', 'en', 'en'] | True |
_unescape | (v) | Unescape characters in a TOML string. | Unescape characters in a TOML string. | def _unescape(v):
"""Unescape characters in a TOML string."""
i = 0
backslash = False
while i < len(v):
if backslash:
backslash = False
if v[i] in _escapes:
v = v[:i - 1] + _escape_to_escapedchars[v[i]] + v[i + 1:]
elif v[i] == '\\':
... | [
"def",
"_unescape",
"(",
"v",
")",
":",
"i",
"=",
"0",
"backslash",
"=",
"False",
"while",
"i",
"<",
"len",
"(",
"v",
")",
":",
"if",
"backslash",
":",
"backslash",
"=",
"False",
"if",
"v",
"[",
"i",
"]",
"in",
"_escapes",
":",
"v",
"=",
"v",
... | [
607,
0
] | [
626,
12
] | python | en | ['en', 'en', 'en'] | True |
test_setup | (hass) | Test setup of the integration. | Test setup of the integration. | async def test_setup(hass):
"""Test setup of the integration."""
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {}})
await hass.async_block_till_done()
assert DOMAIN in hass.data | [
"async",
"def",
"test_setup",
"(",
"hass",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"DOMAIN",
",",
"{",
"DOMAIN",
":",
"{",
"}",
"}",
")",
"await",
"hass",
".",
"async_block_till_done",
"(",
")",
"assert",
"DOMAIN",
"in",
"... | [
9,
0
] | [
14,
30
] | python | en | ['en', 'da', 'en'] | True |
test_websocket | (hass, hass_ws_client, aioclient_mock) | Test websocekt commands. | Test websocekt commands. | async def test_websocket(hass, hass_ws_client, aioclient_mock):
"""Test websocekt commands."""
aioclient_mock.post(ANALYTICS_ENDPOINT_URL, status=200)
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {}})
await hass.async_block_till_done()
ws_client = await hass_ws_client(hass)
await w... | [
"async",
"def",
"test_websocket",
"(",
"hass",
",",
"hass_ws_client",
",",
"aioclient_mock",
")",
":",
"aioclient_mock",
".",
"post",
"(",
"ANALYTICS_ENDPOINT_URL",
",",
"status",
"=",
"200",
")",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"DO... | [
17,
0
] | [
40,
52
] | python | de | ['de', 'lb', 'tr'] | False |
_normalize_name | (name) | Make a name consistent regardless of source (environment or file)
| Make a name consistent regardless of source (environment or file)
| def _normalize_name(name):
# type: (str) -> str
"""Make a name consistent regardless of source (environment or file)
"""
name = name.lower().replace('_', '-')
if name.startswith('--'):
name = name[2:] # only prefer long opts
return name | [
"def",
"_normalize_name",
"(",
"name",
")",
":",
"# type: (str) -> str",
"name",
"=",
"name",
".",
"lower",
"(",
")",
".",
"replace",
"(",
"'_'",
",",
"'-'",
")",
"if",
"name",
".",
"startswith",
"(",
"'--'",
")",
":",
"name",
"=",
"name",
"[",
"2",
... | [
41,
0
] | [
48,
15
] | python | en | ['en', 'en', 'en'] | True |
Configuration.load | (self) | Loads configuration from configuration files and environment
| Loads configuration from configuration files and environment
| def load(self):
# type: () -> None
"""Loads configuration from configuration files and environment
"""
self._load_config_files()
if not self.isolated:
self._load_environment_vars() | [
"def",
"load",
"(",
"self",
")",
":",
"# type: () -> None",
"self",
".",
"_load_config_files",
"(",
")",
"if",
"not",
"self",
".",
"isolated",
":",
"self",
".",
"_load_environment_vars",
"(",
")"
] | [
142,
4
] | [
148,
41
] | python | en | ['en', 'en', 'en'] | True |
Configuration.get_file_to_edit | (self) | Returns the file with highest priority in configuration
| Returns the file with highest priority in configuration
| def get_file_to_edit(self):
# type: () -> Optional[str]
"""Returns the file with highest priority in configuration
"""
assert self.load_only is not None, \
"Need to be specified a file to be editing"
try:
return self._get_parser_to_modify()[0]
exc... | [
"def",
"get_file_to_edit",
"(",
"self",
")",
":",
"# type: () -> Optional[str]",
"assert",
"self",
".",
"load_only",
"is",
"not",
"None",
",",
"\"Need to be specified a file to be editing\"",
"try",
":",
"return",
"self",
".",
"_get_parser_to_modify",
"(",
")",
"[",
... | [
150,
4
] | [
160,
23
] | python | en | ['en', 'en', 'en'] | True |
Configuration.items | (self) | Returns key-value pairs like dict.items() representing the loaded
configuration
| Returns key-value pairs like dict.items() representing the loaded
configuration
| def items(self):
# type: () -> Iterable[Tuple[str, Any]]
"""Returns key-value pairs like dict.items() representing the loaded
configuration
"""
return self._dictionary.items() | [
"def",
"items",
"(",
"self",
")",
":",
"# type: () -> Iterable[Tuple[str, Any]]",
"return",
"self",
".",
"_dictionary",
".",
"items",
"(",
")"
] | [
162,
4
] | [
167,
39
] | python | en | ['en', 'en', 'en'] | True |
Configuration.get_value | (self, key) | Get a value from the configuration.
| Get a value from the configuration.
| def get_value(self, key):
# type: (str) -> Any
"""Get a value from the configuration.
"""
try:
return self._dictionary[key]
except KeyError:
raise ConfigurationError("No such key - {}".format(key)) | [
"def",
"get_value",
"(",
"self",
",",
"key",
")",
":",
"# type: (str) -> Any",
"try",
":",
"return",
"self",
".",
"_dictionary",
"[",
"key",
"]",
"except",
"KeyError",
":",
"raise",
"ConfigurationError",
"(",
"\"No such key - {}\"",
".",
"format",
"(",
"key",
... | [
169,
4
] | [
176,
68
] | python | en | ['en', 'en', 'en'] | True |
Configuration.set_value | (self, key, value) | Modify a value in the configuration.
| Modify a value in the configuration.
| def set_value(self, key, value):
# type: (str, Any) -> None
"""Modify a value in the configuration.
"""
self._ensure_have_load_only()
assert self.load_only
fname, parser = self._get_parser_to_modify()
if parser is not None:
section, name = _disassemb... | [
"def",
"set_value",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"# type: (str, Any) -> None",
"self",
".",
"_ensure_have_load_only",
"(",
")",
"assert",
"self",
".",
"load_only",
"fname",
",",
"parser",
"=",
"self",
".",
"_get_parser_to_modify",
"(",
")",... | [
178,
4
] | [
196,
45
] | python | en | ['en', 'it', 'en'] | True |
Configuration.unset_value | (self, key) | Unset a value in the configuration. | Unset a value in the configuration. | def unset_value(self, key):
# type: (str) -> None
"""Unset a value in the configuration."""
self._ensure_have_load_only()
assert self.load_only
if key not in self._config[self.load_only]:
raise ConfigurationError("No such key - {}".format(key))
fname, parser... | [
"def",
"unset_value",
"(",
"self",
",",
"key",
")",
":",
"# type: (str) -> None",
"self",
".",
"_ensure_have_load_only",
"(",
")",
"assert",
"self",
".",
"load_only",
"if",
"key",
"not",
"in",
"self",
".",
"_config",
"[",
"self",
".",
"load_only",
"]",
":"... | [
198,
4
] | [
223,
45
] | python | en | ['en', 'en', 'en'] | True |
Configuration.save | (self) | Save the current in-memory state.
| Save the current in-memory state.
| def save(self):
# type: () -> None
"""Save the current in-memory state.
"""
self._ensure_have_load_only()
for fname, parser in self._modified_parsers:
logger.info("Writing to %s", fname)
# Ensure directory exists.
ensure_dir(os.path.dirname(f... | [
"def",
"save",
"(",
"self",
")",
":",
"# type: () -> None",
"self",
".",
"_ensure_have_load_only",
"(",
")",
"for",
"fname",
",",
"parser",
"in",
"self",
".",
"_modified_parsers",
":",
"logger",
".",
"info",
"(",
"\"Writing to %s\"",
",",
"fname",
")",
"# En... | [
225,
4
] | [
238,
31
] | python | en | ['en', 'en', 'en'] | True |
Configuration._dictionary | (self) | A dictionary representing the loaded configuration.
| A dictionary representing the loaded configuration.
| def _dictionary(self):
# type: () -> Dict[str, Any]
"""A dictionary representing the loaded configuration.
"""
# NOTE: Dictionaries are not populated if not loaded. So, conditionals
# are not needed here.
retval = {}
for variant in self._override_order:
... | [
"def",
"_dictionary",
"(",
"self",
")",
":",
"# type: () -> Dict[str, Any]",
"# NOTE: Dictionaries are not populated if not loaded. So, conditionals",
"# are not needed here.",
"retval",
"=",
"{",
"}",
"for",
"variant",
"in",
"self",
".",
"_override_order",
":",
"retval... | [
251,
4
] | [
262,
21
] | python | en | ['en', 'en', 'en'] | True |
Configuration._load_config_files | (self) | Loads configuration from configuration files
| Loads configuration from configuration files
| def _load_config_files(self):
# type: () -> None
"""Loads configuration from configuration files
"""
config_files = dict(self.iter_config_files())
if config_files[kinds.ENV][0:1] == [os.devnull]:
logger.debug(
"Skipping loading configuration files due ... | [
"def",
"_load_config_files",
"(",
"self",
")",
":",
"# type: () -> None",
"config_files",
"=",
"dict",
"(",
"self",
".",
"iter_config_files",
"(",
")",
")",
"if",
"config_files",
"[",
"kinds",
".",
"ENV",
"]",
"[",
"0",
":",
"1",
"]",
"==",
"[",
"os",
... | [
264,
4
] | [
289,
62
] | python | en | ['en', 'en', 'en'] | True |
Configuration._load_environment_vars | (self) | Loads configuration from environment variables
| Loads configuration from environment variables
| def _load_environment_vars(self):
# type: () -> None
"""Loads configuration from environment variables
"""
self._config[kinds.ENV_VAR].update(
self._normalized_keys(":env:", self.get_environ_vars())
) | [
"def",
"_load_environment_vars",
"(",
"self",
")",
":",
"# type: () -> None",
"self",
".",
"_config",
"[",
"kinds",
".",
"ENV_VAR",
"]",
".",
"update",
"(",
"self",
".",
"_normalized_keys",
"(",
"\":env:\"",
",",
"self",
".",
"get_environ_vars",
"(",
")",
")... | [
325,
4
] | [
331,
9
] | python | en | ['en', 'en', 'en'] | True |
Configuration._normalized_keys | (self, section, items) | Normalizes items to construct a dictionary with normalized keys.
This routine is where the names become keys and are made the same
regardless of source - configuration files or environment.
| Normalizes items to construct a dictionary with normalized keys. | def _normalized_keys(self, section, items):
# type: (str, Iterable[Tuple[str, Any]]) -> Dict[str, Any]
"""Normalizes items to construct a dictionary with normalized keys.
This routine is where the names become keys and are made the same
regardless of source - configuration files or envi... | [
"def",
"_normalized_keys",
"(",
"self",
",",
"section",
",",
"items",
")",
":",
"# type: (str, Iterable[Tuple[str, Any]]) -> Dict[str, Any]",
"normalized",
"=",
"{",
"}",
"for",
"name",
",",
"val",
"in",
"items",
":",
"key",
"=",
"section",
"+",
"\".\"",
"+",
... | [
333,
4
] | [
344,
25
] | python | en | ['en', 'en', 'en'] | True |
Configuration.get_environ_vars | (self) | Returns a generator with all environmental vars with prefix PIP_ | Returns a generator with all environmental vars with prefix PIP_ | def get_environ_vars(self):
# type: () -> Iterable[Tuple[str, str]]
"""Returns a generator with all environmental vars with prefix PIP_"""
for key, val in os.environ.items():
should_be_yielded = (
key.startswith("PIP_") and
key[4:].lower() not in self.... | [
"def",
"get_environ_vars",
"(",
"self",
")",
":",
"# type: () -> Iterable[Tuple[str, str]]",
"for",
"key",
",",
"val",
"in",
"os",
".",
"environ",
".",
"items",
"(",
")",
":",
"should_be_yielded",
"=",
"(",
"key",
".",
"startswith",
"(",
"\"PIP_\"",
")",
"an... | [
346,
4
] | [
355,
42
] | python | en | ['en', 'en', 'en'] | True |
Configuration.iter_config_files | (self) | Yields variant and configuration files associated with it.
This should be treated like items of a dictionary.
| Yields variant and configuration files associated with it. | def iter_config_files(self):
# type: () -> Iterable[Tuple[Kind, List[str]]]
"""Yields variant and configuration files associated with it.
This should be treated like items of a dictionary.
"""
# SMELL: Move the conditions out of this function
# environment variables hav... | [
"def",
"iter_config_files",
"(",
"self",
")",
":",
"# type: () -> Iterable[Tuple[Kind, List[str]]]",
"# SMELL: Move the conditions out of this function",
"# environment variables have the lowest priority",
"config_file",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"'PIP_CONFIG_FILE... | [
358,
4
] | [
387,
50
] | python | en | ['en', 'en', 'en'] | True |
Configuration.get_values_in_config | (self, variant) | Get values present in a config file | Get values present in a config file | def get_values_in_config(self, variant):
# type: (Kind) -> Dict[str, Any]
"""Get values present in a config file"""
return self._config[variant] | [
"def",
"get_values_in_config",
"(",
"self",
",",
"variant",
")",
":",
"# type: (Kind) -> Dict[str, Any]",
"return",
"self",
".",
"_config",
"[",
"variant",
"]"
] | [
389,
4
] | [
392,
36
] | python | en | ['en', 'en', 'en'] | True |
test_entity_registry | (hass) | Tests that the devices are registered in the entity registry. | Tests that the devices are registered in the entity registry. | async def test_entity_registry(hass):
"""Tests that the devices are registered in the entity registry."""
await setup_platform(hass, BINARY_SENSOR_DOMAIN)
entity_registry = er.async_get(hass)
entry = entity_registry.async_get("binary_sensor.front_door")
assert entry.unique_id == "2834013428b6035fba... | [
"async",
"def",
"test_entity_registry",
"(",
"hass",
")",
":",
"await",
"setup_platform",
"(",
"hass",
",",
"BINARY_SENSOR_DOMAIN",
")",
"entity_registry",
"=",
"er",
".",
"async_get",
"(",
"hass",
")",
"entry",
"=",
"entity_registry",
".",
"async_get",
"(",
"... | [
18,
0
] | [
24,
64
] | python | en | ['en', 'en', 'en'] | True |
test_attributes | (hass) | Test the binary sensor attributes are correct. | Test the binary sensor attributes are correct. | async def test_attributes(hass):
"""Test the binary sensor attributes are correct."""
await setup_platform(hass, BINARY_SENSOR_DOMAIN)
state = hass.states.get("binary_sensor.front_door")
assert state.state == STATE_OFF
assert state.attributes.get(ATTR_ATTRIBUTION) == ATTRIBUTION
assert state.at... | [
"async",
"def",
"test_attributes",
"(",
"hass",
")",
":",
"await",
"setup_platform",
"(",
"hass",
",",
"BINARY_SENSOR_DOMAIN",
")",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"\"binary_sensor.front_door\"",
")",
"assert",
"state",
".",
"state",
"=="... | [
27,
0
] | [
39,
73
] | python | en | ['en', 'it', 'en'] | True |
setup_comp | (hass) | Initialize components. | Initialize components. | def setup_comp(hass):
"""Initialize components."""
mock_component(hass, "pilight") | [
"def",
"setup_comp",
"(",
"hass",
")",
":",
"mock_component",
"(",
"hass",
",",
"\"pilight\"",
")"
] | [
13,
0
] | [
15,
35
] | python | en | ['de', 'en', 'en'] | False |
fire_pilight_message | (hass, protocol, data) | Fire the fake Pilight message. | Fire the fake Pilight message. | def fire_pilight_message(hass, protocol, data):
"""Fire the fake Pilight message."""
message = {pilight.CONF_PROTOCOL: protocol}
message.update(data)
hass.bus.async_fire(pilight.EVENT, message) | [
"def",
"fire_pilight_message",
"(",
"hass",
",",
"protocol",
",",
"data",
")",
":",
"message",
"=",
"{",
"pilight",
".",
"CONF_PROTOCOL",
":",
"protocol",
"}",
"message",
".",
"update",
"(",
"data",
")",
"hass",
".",
"bus",
".",
"async_fire",
"(",
"pilig... | [
18,
0
] | [
23,
47
] | python | en | ['en', 'en', 'en'] | True |
test_sensor_value_from_code | (hass) | Test the setting of value via pilight. | Test the setting of value via pilight. | async def test_sensor_value_from_code(hass):
"""Test the setting of value via pilight."""
with assert_setup_component(1):
assert await async_setup_component(
hass,
sensor.DOMAIN,
{
sensor.DOMAIN: {
"platform": "pilight",
... | [
"async",
"def",
"test_sensor_value_from_code",
"(",
"hass",
")",
":",
"with",
"assert_setup_component",
"(",
"1",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"sensor",
".",
"DOMAIN",
",",
"{",
"sensor",
".",
"DOMAIN",
":",
"{",
"\... | [
26,
0
] | [
54,
34
] | python | en | ['en', 'en', 'en'] | True |
test_disregard_wrong_payload | (hass) | Test omitting setting of value with wrong payload. | Test omitting setting of value with wrong payload. | async def test_disregard_wrong_payload(hass):
"""Test omitting setting of value with wrong payload."""
with assert_setup_component(1):
assert await async_setup_component(
hass,
sensor.DOMAIN,
{
sensor.DOMAIN: {
"platform": "pilight"... | [
"async",
"def",
"test_disregard_wrong_payload",
"(",
"hass",
")",
":",
"with",
"assert_setup_component",
"(",
"1",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"sensor",
".",
"DOMAIN",
",",
"{",
"sensor",
".",
"DOMAIN",
":",
"{",
"... | [
57,
0
] | [
98,
36
] | python | en | ['en', 'en', 'en'] | True |
test_variable_missing | (hass, caplog) | Check if error message when variable missing. | Check if error message when variable missing. | async def test_variable_missing(hass, caplog):
"""Check if error message when variable missing."""
caplog.set_level(logging.ERROR)
with assert_setup_component(1):
assert await async_setup_component(
hass,
sensor.DOMAIN,
{
sensor.DOMAIN: {
... | [
"async",
"def",
"test_variable_missing",
"(",
"hass",
",",
"caplog",
")",
":",
"caplog",
".",
"set_level",
"(",
"logging",
".",
"ERROR",
")",
"with",
"assert_setup_component",
"(",
"1",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
... | [
101,
0
] | [
129,
58
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up the min/max/mean sensor. | Set up the min/max/mean sensor. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the min/max/mean sensor."""
entity_ids = config.get(CONF_ENTITY_IDS)
name = config.get(CONF_NAME)
sensor_type = config.get(CONF_TYPE)
round_digits = config.get(CONF_ROUND_DIGITS)
await async_setup_r... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"entity_ids",
"=",
"config",
".",
"get",
"(",
"CONF_ENTITY_IDS",
")",
"name",
"=",
"config",
".",
"get",
"(",
"CONF_N... | [
69,
0
] | [
78,
83
] | python | en | ['en', 'ca', 'en'] | True |
calc_min | (sensor_values) | Calculate min value, honoring unknown states. | Calculate min value, honoring unknown states. | def calc_min(sensor_values):
"""Calculate min value, honoring unknown states."""
val = None
entity_id = None
for sensor_id, sensor_value in sensor_values:
if sensor_value not in [STATE_UNKNOWN, STATE_UNAVAILABLE] and (
val is None or val > sensor_value
):
entity_i... | [
"def",
"calc_min",
"(",
"sensor_values",
")",
":",
"val",
"=",
"None",
"entity_id",
"=",
"None",
"for",
"sensor_id",
",",
"sensor_value",
"in",
"sensor_values",
":",
"if",
"sensor_value",
"not",
"in",
"[",
"STATE_UNKNOWN",
",",
"STATE_UNAVAILABLE",
"]",
"and",... | [
81,
0
] | [
90,
25
] | python | en | ['en', 'en', 'en'] | True |
calc_max | (sensor_values) | Calculate max value, honoring unknown states. | Calculate max value, honoring unknown states. | def calc_max(sensor_values):
"""Calculate max value, honoring unknown states."""
val = None
entity_id = None
for sensor_id, sensor_value in sensor_values:
if sensor_value not in [STATE_UNKNOWN, STATE_UNAVAILABLE] and (
val is None or val < sensor_value
):
entity_i... | [
"def",
"calc_max",
"(",
"sensor_values",
")",
":",
"val",
"=",
"None",
"entity_id",
"=",
"None",
"for",
"sensor_id",
",",
"sensor_value",
"in",
"sensor_values",
":",
"if",
"sensor_value",
"not",
"in",
"[",
"STATE_UNKNOWN",
",",
"STATE_UNAVAILABLE",
"]",
"and",... | [
93,
0
] | [
102,
25
] | python | en | ['en', 'en', 'en'] | True |
calc_mean | (sensor_values, round_digits) | Calculate mean value, honoring unknown states. | Calculate mean value, honoring unknown states. | def calc_mean(sensor_values, round_digits):
"""Calculate mean value, honoring unknown states."""
result = [
sensor_value
for _, sensor_value in sensor_values
if sensor_value not in [STATE_UNKNOWN, STATE_UNAVAILABLE]
]
if not result:
return None
return round(sum(resul... | [
"def",
"calc_mean",
"(",
"sensor_values",
",",
"round_digits",
")",
":",
"result",
"=",
"[",
"sensor_value",
"for",
"_",
",",
"sensor_value",
"in",
"sensor_values",
"if",
"sensor_value",
"not",
"in",
"[",
"STATE_UNKNOWN",
",",
"STATE_UNAVAILABLE",
"]",
"]",
"i... | [
105,
0
] | [
115,
57
] | python | en | ['en', 'en', 'en'] | True |
calc_median | (sensor_values, round_digits) | Calculate median value, honoring unknown states. | Calculate median value, honoring unknown states. | def calc_median(sensor_values, round_digits):
"""Calculate median value, honoring unknown states."""
result = [
sensor_value
for _, sensor_value in sensor_values
if sensor_value not in [STATE_UNKNOWN, STATE_UNAVAILABLE]
]
if not result:
return None
result.sort()
... | [
"def",
"calc_median",
"(",
"sensor_values",
",",
"round_digits",
")",
":",
"result",
"=",
"[",
"sensor_value",
"for",
"_",
",",
"sensor_value",
"in",
"sensor_values",
"if",
"sensor_value",
"not",
"in",
"[",
"STATE_UNKNOWN",
",",
"STATE_UNAVAILABLE",
"]",
"]",
... | [
118,
0
] | [
135,
38
] | python | en | ['en', 'en', 'en'] | True |
MinMaxSensor.__init__ | (self, entity_ids, name, sensor_type, round_digits) | Initialize the min/max sensor. | Initialize the min/max sensor. | def __init__(self, entity_ids, name, sensor_type, round_digits):
"""Initialize the min/max sensor."""
self._entity_ids = entity_ids
self._sensor_type = sensor_type
self._round_digits = round_digits
if name:
self._name = name
else:
self._name = f"{... | [
"def",
"__init__",
"(",
"self",
",",
"entity_ids",
",",
"name",
",",
"sensor_type",
",",
"round_digits",
")",
":",
"self",
".",
"_entity_ids",
"=",
"entity_ids",
"self",
".",
"_sensor_type",
"=",
"sensor_type",
"self",
".",
"_round_digits",
"=",
"round_digits"... | [
141,
4
] | [
156,
24
] | python | en | ['en', 'it', 'en'] | True |
MinMaxSensor.async_added_to_hass | (self) | Handle added to Hass. | Handle added to Hass. | async def async_added_to_hass(self):
"""Handle added to Hass."""
self.async_on_remove(
async_track_state_change_event(
self.hass, self._entity_ids, self._async_min_max_sensor_state_listener
)
)
self._calc_values() | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"async_on_remove",
"(",
"async_track_state_change_event",
"(",
"self",
".",
"hass",
",",
"self",
".",
"_entity_ids",
",",
"self",
".",
"_async_min_max_sensor_state_listener",
")",
")",
"sel... | [
158,
4
] | [
166,
27
] | python | en | ['en', 'en', 'en'] | True |
MinMaxSensor.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"
] | [
169,
4
] | [
171,
25
] | python | en | ['en', 'mi', 'en'] | True |
MinMaxSensor.native_value | (self) | Return the state of the sensor. | Return the state of the sensor. | def native_value(self):
"""Return the state of the sensor."""
if self._unit_of_measurement_mismatch:
return None
return getattr(
self, next(k for k, v in SENSOR_TYPES.items() if self._sensor_type == v)
) | [
"def",
"native_value",
"(",
"self",
")",
":",
"if",
"self",
".",
"_unit_of_measurement_mismatch",
":",
"return",
"None",
"return",
"getattr",
"(",
"self",
",",
"next",
"(",
"k",
"for",
"k",
",",
"v",
"in",
"SENSOR_TYPES",
".",
"items",
"(",
")",
"if",
... | [
174,
4
] | [
180,
9
] | python | en | ['en', 'en', 'en'] | True |
MinMaxSensor.native_unit_of_measurement | (self) | Return the unit the value is expressed in. | Return the unit the value is expressed in. | def native_unit_of_measurement(self):
"""Return the unit the value is expressed in."""
if self._unit_of_measurement_mismatch:
return "ERR"
return self._unit_of_measurement | [
"def",
"native_unit_of_measurement",
"(",
"self",
")",
":",
"if",
"self",
".",
"_unit_of_measurement_mismatch",
":",
"return",
"\"ERR\"",
"return",
"self",
".",
"_unit_of_measurement"
] | [
183,
4
] | [
187,
40
] | python | en | ['en', 'en', 'en'] | True |
MinMaxSensor.should_poll | (self) | No polling needed. | No polling needed. | def should_poll(self):
"""No polling needed."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
190,
4
] | [
192,
20
] | python | en | ['en', 'en', 'en'] | True |
MinMaxSensor.extra_state_attributes | (self) | Return the state attributes of the sensor. | Return the state attributes of the sensor. | def extra_state_attributes(self):
"""Return the state attributes of the sensor."""
return {
attr: getattr(self, attr)
for attr in ATTR_TO_PROPERTY
if getattr(self, attr) is not None
} | [
"def",
"extra_state_attributes",
"(",
"self",
")",
":",
"return",
"{",
"attr",
":",
"getattr",
"(",
"self",
",",
"attr",
")",
"for",
"attr",
"in",
"ATTR_TO_PROPERTY",
"if",
"getattr",
"(",
"self",
",",
"attr",
")",
"is",
"not",
"None",
"}"
] | [
195,
4
] | [
201,
9
] | python | en | ['en', 'en', 'en'] | True |
MinMaxSensor.icon | (self) | Return the icon to use in the frontend, if any. | Return the icon to use in the frontend, if any. | def icon(self):
"""Return the icon to use in the frontend, if any."""
return ICON | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"ICON"
] | [
204,
4
] | [
206,
19
] | python | en | ['en', 'en', 'en'] | True |
MinMaxSensor._async_min_max_sensor_state_listener | (self, event) | Handle the sensor state changes. | Handle the sensor state changes. | def _async_min_max_sensor_state_listener(self, event):
"""Handle the sensor state changes."""
new_state = event.data.get("new_state")
entity = event.data.get("entity_id")
if new_state.state is None or new_state.state in [
STATE_UNKNOWN,
STATE_UNAVAILABLE,
... | [
"def",
"_async_min_max_sensor_state_listener",
"(",
"self",
",",
"event",
")",
":",
"new_state",
"=",
"event",
".",
"data",
".",
"get",
"(",
"\"new_state\"",
")",
"entity",
"=",
"event",
".",
"data",
".",
"get",
"(",
"\"entity_id\"",
")",
"if",
"new_state",
... | [
209,
4
] | [
246,
35
] | python | en | ['en', 'en', 'en'] | True |
MinMaxSensor._calc_values | (self) | Calculate the values. | Calculate the values. | def _calc_values(self):
"""Calculate the values."""
sensor_values = [
(entity_id, self.states[entity_id])
for entity_id in self._entity_ids
if entity_id in self.states
]
self.min_entity_id, self.min_value = calc_min(sensor_values)
self.max_enti... | [
"def",
"_calc_values",
"(",
"self",
")",
":",
"sensor_values",
"=",
"[",
"(",
"entity_id",
",",
"self",
".",
"states",
"[",
"entity_id",
"]",
")",
"for",
"entity_id",
"in",
"self",
".",
"_entity_ids",
"if",
"entity_id",
"in",
"self",
".",
"states",
"]",
... | [
249,
4
] | [
259,
68
] | python | en | ['en', 'en', 'en'] | True |
setup_mock_onvif_camera | (
mock_onvif_camera,
with_h264=True,
two_profiles=False,
with_interfaces=True,
with_interfaces_not_implemented=False,
with_serial=True,
) | Prepare mock onvif.ONVIFCamera. | Prepare mock onvif.ONVIFCamera. | def setup_mock_onvif_camera(
mock_onvif_camera,
with_h264=True,
two_profiles=False,
with_interfaces=True,
with_interfaces_not_implemented=False,
with_serial=True,
):
"""Prepare mock onvif.ONVIFCamera."""
devicemgmt = MagicMock()
device_info = MagicMock()
device_info.SerialNumber... | [
"def",
"setup_mock_onvif_camera",
"(",
"mock_onvif_camera",
",",
"with_h264",
"=",
"True",
",",
"two_profiles",
"=",
"False",
",",
"with_interfaces",
"=",
"True",
",",
"with_interfaces_not_implemented",
"=",
"False",
",",
"with_serial",
"=",
"True",
",",
")",
":",... | [
38,
0
] | [
94,
52
] | python | en | ['en', 'sk', 'hi'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.