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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
TestDashboard.test_get_sample_index_list | (self) | Test method get_sample_index_list(a,b) | Test method get_sample_index_list(a,b) | def test_get_sample_index_list(self):
"""Test method get_sample_index_list(a,b)"""
self.assertEqual(
[0, 10, 20, 30, 40],
get_sample_index_list(50, 0.1)
) | [
"def",
"test_get_sample_index_list",
"(",
"self",
")",
":",
"self",
".",
"assertEqual",
"(",
"[",
"0",
",",
"10",
",",
"20",
",",
"30",
",",
"40",
"]",
",",
"get_sample_index_list",
"(",
"50",
",",
"0.1",
")",
")"
] | [
17,
4
] | [
22,
9
] | python | de | ['de', 'is', 'en'] | False |
get_config_directory | () |
Get NNI config directory.
Create it if not exist.
|
Get NNI config directory.
Create it if not exist.
| def get_config_directory() -> Path:
"""
Get NNI config directory.
Create it if not exist.
"""
if sys.prefix != sys.base_prefix or Path(sys.prefix, 'conda-meta').is_dir():
config_dir = Path(sys.prefix, 'nni')
elif sys.platform == 'win32':
config_dir = Path(os.environ['APPDATA'], '... | [
"def",
"get_config_directory",
"(",
")",
"->",
"Path",
":",
"if",
"sys",
".",
"prefix",
"!=",
"sys",
".",
"base_prefix",
"or",
"Path",
"(",
"sys",
".",
"prefix",
",",
"'conda-meta'",
")",
".",
"is_dir",
"(",
")",
":",
"config_dir",
"=",
"Path",
"(",
... | [
10,
0
] | [
22,
21
] | python | en | ['en', 'error', 'th'] | False |
get_config_file | (name: str) |
Get an NNI config file.
Copy from `nni/runtime/default_config` if not exist.
|
Get an NNI config file.
Copy from `nni/runtime/default_config` if not exist.
| def get_config_file(name: str) -> Path:
"""
Get an NNI config file.
Copy from `nni/runtime/default_config` if not exist.
"""
config_file = get_config_directory() / name
if not config_file.exists():
default = Path(nni.__path__[0], 'runtime/default_config', name)
shutil.copyfile(de... | [
"def",
"get_config_file",
"(",
"name",
":",
"str",
")",
"->",
"Path",
":",
"config_file",
"=",
"get_config_directory",
"(",
")",
"/",
"name",
"if",
"not",
"config_file",
".",
"exists",
"(",
")",
":",
"default",
"=",
"Path",
"(",
"nni",
".",
"__path__",
... | [
24,
0
] | [
33,
22
] | python | en | ['en', 'error', 'th'] | False |
setup | (hass, base_config) | Set up waterfurnace platform. | Set up waterfurnace platform. | def setup(hass, base_config):
"""Set up waterfurnace platform."""
config = base_config.get(DOMAIN)
username = config.get(CONF_USERNAME)
password = config.get(CONF_PASSWORD)
wfconn = WaterFurnace(username, password)
# NOTE(sdague): login will throw an exception if this doesn't
# work, whic... | [
"def",
"setup",
"(",
"hass",
",",
"base_config",
")",
":",
"config",
"=",
"base_config",
".",
"get",
"(",
"DOMAIN",
")",
"username",
"=",
"config",
".",
"get",
"(",
"CONF_USERNAME",
")",
"password",
"=",
"config",
".",
"get",
"(",
"CONF_PASSWORD",
")",
... | [
37,
0
] | [
58,
15
] | python | en | ['en', 'jv', 'en'] | True |
WaterFurnaceData.__init__ | (self, hass, client) | Initialize the data object. | Initialize the data object. | def __init__(self, hass, client):
"""Initialize the data object."""
super().__init__()
self.hass = hass
self.client = client
self.unit = self.client.gwid
self.data = None
self._shutdown = False
self._fails = 0 | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"client",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
")",
"self",
".",
"hass",
"=",
"hass",
"self",
".",
"client",
"=",
"client",
"self",
".",
"unit",
"=",
"self",
".",
"client",
".",
"gwi... | [
72,
4
] | [
80,
23
] | python | en | ['en', 'en', 'en'] | True |
WaterFurnaceData._reconnect | (self) | Reconnect on a failure. | Reconnect on a failure. | def _reconnect(self):
"""Reconnect on a failure."""
self._fails += 1
if self._fails > MAX_FAILS:
_LOGGER.error("Failed to refresh login credentials. Thread stopped")
self.hass.components.persistent_notification.create(
"Error:<br/>Connection to waterfurna... | [
"def",
"_reconnect",
"(",
"self",
")",
":",
"self",
".",
"_fails",
"+=",
"1",
"if",
"self",
".",
"_fails",
">",
"MAX_FAILS",
":",
"_LOGGER",
".",
"error",
"(",
"\"Failed to refresh login credentials. Thread stopped\"",
")",
"self",
".",
"hass",
".",
"component... | [
82,
4
] | [
109,
27
] | python | en | ['en', 'en', 'en'] | True |
WaterFurnaceData.run | (self) | Thread run loop. | Thread run loop. | def run(self):
"""Thread run loop."""
@callback
def register():
"""Connect to hass for shutdown."""
def shutdown(event):
"""Shutdown the thread."""
_LOGGER.debug("Signaled to shutdown")
self._shutdown = True
... | [
"def",
"run",
"(",
"self",
")",
":",
"@",
"callback",
"def",
"register",
"(",
")",
":",
"\"\"\"Connect to hass for shutdown.\"\"\"",
"def",
"shutdown",
"(",
"event",
")",
":",
"\"\"\"Shutdown the thread.\"\"\"",
"_LOGGER",
".",
"debug",
"(",
"\"Signaled to shutdown\... | [
111,
4
] | [
151,
49
] | python | en | ['es', 'mn', 'en'] | False |
test_update_device | (hass) | Test that update works. | Test that update works. | async def test_update_device(hass):
"""Test that update works."""
host = "1.2.3.4"
entry = MockConfigEntry(domain=dynalite.DOMAIN, data={dynalite.CONF_HOST: host})
entry.add_to_hass(hass)
with patch(
"homeassistant.components.dynalite.bridge.DynaliteDevices"
) as mock_dyn_dev:
mo... | [
"async",
"def",
"test_update_device",
"(",
"hass",
")",
":",
"host",
"=",
"\"1.2.3.4\"",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"dynalite",
".",
"DOMAIN",
",",
"data",
"=",
"{",
"dynalite",
".",
"CONF_HOST",
":",
"host",
"}",
")",
"entry",
... | [
24,
0
] | [
51,
38
] | python | en | ['en', 'de', 'en'] | True |
test_add_devices_then_register | (hass) | Test that add_devices work. | Test that add_devices work. | async def test_add_devices_then_register(hass):
"""Test that add_devices work."""
host = "1.2.3.4"
entry = MockConfigEntry(domain=dynalite.DOMAIN, data={dynalite.CONF_HOST: host})
entry.add_to_hass(hass)
with patch(
"homeassistant.components.dynalite.bridge.DynaliteDevices"
) as mock_dyn... | [
"async",
"def",
"test_add_devices_then_register",
"(",
"hass",
")",
":",
"host",
"=",
"\"1.2.3.4\"",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"dynalite",
".",
"DOMAIN",
",",
"data",
"=",
"{",
"dynalite",
".",
"CONF_HOST",
":",
"host",
"}",
")",
... | [
54,
0
] | [
84,
42
] | python | en | ['en', 'en', 'en'] | True |
test_register_then_add_devices | (hass) | Test that add_devices work after register_add_entities. | Test that add_devices work after register_add_entities. | async def test_register_then_add_devices(hass):
"""Test that add_devices work after register_add_entities."""
host = "1.2.3.4"
entry = MockConfigEntry(domain=dynalite.DOMAIN, data={dynalite.CONF_HOST: host})
entry.add_to_hass(hass)
with patch(
"homeassistant.components.dynalite.bridge.Dynali... | [
"async",
"def",
"test_register_then_add_devices",
"(",
"hass",
")",
":",
"host",
"=",
"\"1.2.3.4\"",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"dynalite",
".",
"DOMAIN",
",",
"data",
"=",
"{",
"dynalite",
".",
"CONF_HOST",
":",
"host",
"}",
")",
... | [
87,
0
] | [
111,
42
] | python | en | ['en', 'en', 'en'] | True |
test_notifications | (hass) | Test that update works. | Test that update works. | async def test_notifications(hass):
"""Test that update works."""
host = "1.2.3.4"
entry = MockConfigEntry(domain=dynalite.DOMAIN, data={dynalite.CONF_HOST: host})
entry.add_to_hass(hass)
with patch(
"homeassistant.components.dynalite.bridge.DynaliteDevices"
) as mock_dyn_dev:
mo... | [
"async",
"def",
"test_notifications",
"(",
"hass",
")",
":",
"host",
"=",
"\"1.2.3.4\"",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"dynalite",
".",
"DOMAIN",
",",
"data",
"=",
"{",
"dynalite",
".",
"CONF_HOST",
":",
"host",
"}",
")",
"entry",
... | [
114,
0
] | [
149,
42
] | python | en | ['en', 'de', 'en'] | True |
nix_prefetch_git | (url, rev) | Prefetches the requested Git revision (incl. submodules) of the given repository URL. | Prefetches the requested Git revision (incl. submodules) of the given repository URL. | def nix_prefetch_git(url, rev):
"""Prefetches the requested Git revision (incl. submodules) of the given repository URL."""
print(f'nix-prefetch-git {url} {rev}')
out = subprocess.check_output(['nix-prefetch-git', '--quiet', '--url', url, '--rev', rev, '--fetch-submodules'])
return json.loads(out)['sha2... | [
"def",
"nix_prefetch_git",
"(",
"url",
",",
"rev",
")",
":",
"print",
"(",
"f'nix-prefetch-git {url} {rev}'",
")",
"out",
"=",
"subprocess",
".",
"check_output",
"(",
"[",
"'nix-prefetch-git'",
",",
"'--quiet'",
",",
"'--url'",
",",
"url",
",",
"'--rev'",
",",... | [
34,
0
] | [
38,
36
] | python | en | ['en', 'en', 'en'] | True |
nix_prefetch_url | (url, unpack=False) | Prefetches the content of the given URL. | Prefetches the content of the given URL. | def nix_prefetch_url(url, unpack=False):
"""Prefetches the content of the given URL."""
print(f'nix-prefetch-url {url}')
options = ['--type', 'sha256']
if unpack:
options += ['--unpack']
out = subprocess.check_output(['nix-prefetch-url'] + options + [url])
return out.decode('utf-8').rstr... | [
"def",
"nix_prefetch_url",
"(",
"url",
",",
"unpack",
"=",
"False",
")",
":",
"print",
"(",
"f'nix-prefetch-url {url}'",
")",
"options",
"=",
"[",
"'--type'",
",",
"'sha256'",
"]",
"if",
"unpack",
":",
"options",
"+=",
"[",
"'--unpack'",
"]",
"out",
"=",
... | [
41,
0
] | [
48,
39
] | python | en | ['en', 'en', 'en'] | True |
RequestDataValidator.__init__ | (self, schema: vol.Schema, allow_empty: bool = False) | Initialize the decorator. | Initialize the decorator. | def __init__(self, schema: vol.Schema, allow_empty: bool = False) -> None:
"""Initialize the decorator."""
if isinstance(schema, dict):
schema = vol.Schema(schema)
self._schema = schema
self._allow_empty = allow_empty | [
"def",
"__init__",
"(",
"self",
",",
"schema",
":",
"vol",
".",
"Schema",
",",
"allow_empty",
":",
"bool",
"=",
"False",
")",
"->",
"None",
":",
"if",
"isinstance",
"(",
"schema",
",",
"dict",
")",
":",
"schema",
"=",
"vol",
".",
"Schema",
"(",
"sc... | [
24,
4
] | [
30,
39
] | python | en | ['en', 'en', 'en'] | True |
RequestDataValidator.__call__ | (
self, method: Callable[..., Awaitable[web.StreamResponse]]
) | Decorate a function. | Decorate a function. | def __call__(
self, method: Callable[..., Awaitable[web.StreamResponse]]
) -> Callable:
"""Decorate a function."""
@wraps(method)
async def wrapper(
view: HomeAssistantView, request: web.Request, *args: Any, **kwargs: Any
) -> web.StreamResponse:
"""W... | [
"def",
"__call__",
"(",
"self",
",",
"method",
":",
"Callable",
"[",
"...",
",",
"Awaitable",
"[",
"web",
".",
"StreamResponse",
"]",
"]",
")",
"->",
"Callable",
":",
"@",
"wraps",
"(",
"method",
")",
"async",
"def",
"wrapper",
"(",
"view",
":",
"Hom... | [
32,
4
] | [
62,
22
] | python | en | ['en', 'en', 'en'] | True |
test_reload_config_service | (hass) | Test the reload config service. | Test the reload config service. | async def test_reload_config_service(hass):
"""Test the reload config service."""
assert await async_setup_component(hass, "scene", {})
test_reloaded_event = []
hass.bus.async_listen(
EVENT_SCENE_RELOADED, lambda event: test_reloaded_event.append(event)
)
with patch(
"homeassis... | [
"async",
"def",
"test_reload_config_service",
"(",
"hass",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"scene\"",
",",
"{",
"}",
")",
"test_reloaded_event",
"=",
"[",
"]",
"hass",
".",
"bus",
".",
"async_listen",
"(",
"EVENT_SCENE... | [
12,
0
] | [
42,
51
] | python | en | ['en', 'en', 'en'] | True |
test_apply_service | (hass) | Test the apply service. | Test the apply service. | async def test_apply_service(hass):
"""Test the apply service."""
assert await async_setup_component(hass, "scene", {})
assert await async_setup_component(hass, "light", {"light": {"platform": "demo"}})
await hass.async_block_till_done()
assert await hass.services.async_call(
"scene", "appl... | [
"async",
"def",
"test_apply_service",
"(",
"hass",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"scene\"",
",",
"{",
"}",
")",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"light\"",
",",
"{",
"\"light\"",
":",
... | [
45,
0
] | [
84,
56
] | python | en | ['en', 'en', 'en'] | True |
test_create_service | (hass, caplog) | Test the create service. | Test the create service. | async def test_create_service(hass, caplog):
"""Test the create service."""
assert await async_setup_component(
hass,
"scene",
{"scene": {"name": "hallo_2", "entities": {"light.kitchen": "on"}}},
)
await hass.async_block_till_done()
assert hass.states.get("scene.hallo") is No... | [
"async",
"def",
"test_create_service",
"(",
"hass",
",",
"caplog",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"scene\"",
",",
"{",
"\"scene\"",
":",
"{",
"\"name\"",
":",
"\"hallo_2\"",
",",
"\"entities\"",
":",
"{",
"\"light.kit... | [
87,
0
] | [
161,
65
] | python | en | ['en', 'en', 'en'] | True |
test_snapshot_service | (hass, caplog) | Test the snapshot option. | Test the snapshot option. | async def test_snapshot_service(hass, caplog):
"""Test the snapshot option."""
assert await async_setup_component(hass, "scene", {"scene": {}})
await hass.async_block_till_done()
hass.states.async_set("light.my_light", "on", {"hs_color": (345, 75)})
assert hass.states.get("scene.hallo") is None
... | [
"async",
"def",
"test_snapshot_service",
"(",
"hass",
",",
"caplog",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"scene\"",
",",
"{",
"\"scene\"",
":",
"{",
"}",
"}",
")",
"await",
"hass",
".",
"async_block_till_done",
"(",
")",... | [
164,
0
] | [
219,
65
] | python | en | ['en', 'fi', 'en'] | True |
test_ensure_no_intersection | (hass) | Test that entities and snapshot_entities do not overlap. | Test that entities and snapshot_entities do not overlap. | async def test_ensure_no_intersection(hass):
"""Test that entities and snapshot_entities do not overlap."""
assert await async_setup_component(hass, "scene", {"scene": {}})
await hass.async_block_till_done()
with pytest.raises(vol.MultipleInvalid) as ex:
assert await hass.services.async_call(
... | [
"async",
"def",
"test_ensure_no_intersection",
"(",
"hass",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"scene\"",
",",
"{",
"\"scene\"",
":",
"{",
"}",
"}",
")",
"await",
"hass",
".",
"async_block_till_done",
"(",
")",
"with",
... | [
222,
0
] | [
240,
49
] | python | en | ['en', 'en', 'en'] | True |
test_scenes_with_entity | (hass) | Test finding scenes with a specific entity. | Test finding scenes with a specific entity. | async def test_scenes_with_entity(hass):
"""Test finding scenes with a specific entity."""
assert await async_setup_component(
hass,
"scene",
{
"scene": [
{"name": "scene_1", "entities": {"light.kitchen": "on"}},
{"name": "scene_2", "entities":... | [
"async",
"def",
"test_scenes_with_entity",
"(",
"hass",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"scene\"",
",",
"{",
"\"scene\"",
":",
"[",
"{",
"\"name\"",
":",
"\"scene_1\"",
",",
"\"entities\"",
":",
"{",
"\"light.kitchen\"",... | [
243,
0
] | [
264,
5
] | python | en | ['en', 'en', 'en'] | True |
test_entities_in_scene | (hass) | Test finding entities in a scene. | Test finding entities in a scene. | async def test_entities_in_scene(hass):
"""Test finding entities in a scene."""
assert await async_setup_component(
hass,
"scene",
{
"scene": [
{"name": "scene_1", "entities": {"light.kitchen": "on"}},
{"name": "scene_2", "entities": {"light.li... | [
"async",
"def",
"test_entities_in_scene",
"(",
"hass",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"scene\"",
",",
"{",
"\"scene\"",
":",
"[",
"{",
"\"name\"",
":",
"\"scene_1\"",
",",
"\"entities\"",
":",
"{",
"\"light.kitchen\"",
... | [
267,
0
] | [
290,
69
] | python | en | ['en', 'fy', 'en'] | True |
test_config | (hass) | Test passing config in YAML. | Test passing config in YAML. | async def test_config(hass):
"""Test passing config in YAML."""
assert await async_setup_component(
hass,
"scene",
{
"scene": [
{
"id": "scene_id",
"name": "Scene Icon",
"icon": "mdi:party",
... | [
"async",
"def",
"test_config",
"(",
"hass",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"scene\"",
",",
"{",
"\"scene\"",
":",
"[",
"{",
"\"id\"",
":",
"\"scene_id\"",
",",
"\"name\"",
":",
"\"Scene Icon\"",
",",
"\"icon\"",
":"... | [
293,
0
] | [
321,
43
] | python | en | ['en', 'en', 'it'] | True |
test_validator | () | Test validators. | Test validators. | def test_validator():
"""Test validators."""
parsed = ha_scene.STATES_SCHEMA({"light.Test": {"state": "on"}})
assert len(parsed) == 1
assert "light.test" in parsed
assert parsed["light.test"].entity_id == "light.test"
assert parsed["light.test"].state == "on" | [
"def",
"test_validator",
"(",
")",
":",
"parsed",
"=",
"ha_scene",
".",
"STATES_SCHEMA",
"(",
"{",
"\"light.Test\"",
":",
"{",
"\"state\"",
":",
"\"on\"",
"}",
"}",
")",
"assert",
"len",
"(",
"parsed",
")",
"==",
"1",
"assert",
"\"light.test\"",
"in",
"p... | [
324,
0
] | [
330,
45
] | python | en | ['nl', 'et', 'en'] | False |
exactly_two_period_keys | (conf) | Ensure exactly 2 of CONF_PERIOD_KEYS are provided. | Ensure exactly 2 of CONF_PERIOD_KEYS are provided. | def exactly_two_period_keys(conf):
"""Ensure exactly 2 of CONF_PERIOD_KEYS are provided."""
if sum(param in conf for param in CONF_PERIOD_KEYS) != 2:
raise vol.Invalid(
"You must provide exactly 2 of the following: start, end, duration"
)
return conf | [
"def",
"exactly_two_period_keys",
"(",
"conf",
")",
":",
"if",
"sum",
"(",
"param",
"in",
"conf",
"for",
"param",
"in",
"CONF_PERIOD_KEYS",
")",
"!=",
"2",
":",
"raise",
"vol",
".",
"Invalid",
"(",
"\"You must provide exactly 2 of the following: start, end, duration... | [
51,
0
] | [
57,
15
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the History Stats sensor. | Set up the History Stats sensor. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the History Stats sensor."""
setup_reload_service(hass, DOMAIN, PLATFORMS)
entity_id = config.get(CONF_ENTITY_ID)
entity_state = config.get(CONF_STATE)
start = config.get(CONF_START)
end = config.get(CONF_END)
d... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"setup_reload_service",
"(",
"hass",
",",
"DOMAIN",
",",
"PLATFORMS",
")",
"entity_id",
"=",
"config",
".",
"get",
"(",
"CONF_ENTITY_ID",
... | [
77,
0
] | [
102,
15
] | python | en | ['en', 'ca', 'en'] | True |
HistoryStatsSensor.__init__ | (
self, hass, entity_id, entity_state, start, end, duration, sensor_type, name
) | Initialize the HistoryStats sensor. | Initialize the HistoryStats sensor. | def __init__(
self, hass, entity_id, entity_state, start, end, duration, sensor_type, name
):
"""Initialize the HistoryStats sensor."""
self._entity_id = entity_id
self._entity_state = entity_state
self._duration = duration
self._start = start
self._end = end
... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"entity_id",
",",
"entity_state",
",",
"start",
",",
"end",
",",
"duration",
",",
"sensor_type",
",",
"name",
")",
":",
"self",
".",
"_entity_id",
"=",
"entity_id",
"self",
".",
"_entity_state",
"=",
"ent... | [
108,
4
] | [
123,
25
] | python | en | ['en', 'en', 'en'] | True |
HistoryStatsSensor.async_added_to_hass | (self) | Create listeners when the entity is added. | Create listeners when the entity is added. | async def async_added_to_hass(self):
"""Create listeners when the entity is added."""
@callback
def start_refresh(*args):
"""Register state tracking."""
@callback
def force_refresh(*args):
"""Force the component to refresh."""
... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"@",
"callback",
"def",
"start_refresh",
"(",
"*",
"args",
")",
":",
"\"\"\"Register state tracking.\"\"\"",
"@",
"callback",
"def",
"force_refresh",
"(",
"*",
"args",
")",
":",
"\"\"\"Force the compone... | [
125,
4
] | [
149,
81
] | python | en | ['en', 'en', 'en'] | True |
HistoryStatsSensor.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"
] | [
152,
4
] | [
154,
25
] | python | en | ['en', 'mi', 'en'] | True |
HistoryStatsSensor.state | (self) | Return the state of the sensor. | Return the state of the sensor. | def state(self):
"""Return the state of the sensor."""
if self.value is None or self.count is None:
return None
if self._type == CONF_TYPE_TIME:
return round(self.value, 2)
if self._type == CONF_TYPE_RATIO:
return HistoryStatsHelper.pretty_ratio(self... | [
"def",
"state",
"(",
"self",
")",
":",
"if",
"self",
".",
"value",
"is",
"None",
"or",
"self",
".",
"count",
"is",
"None",
":",
"return",
"None",
"if",
"self",
".",
"_type",
"==",
"CONF_TYPE_TIME",
":",
"return",
"round",
"(",
"self",
".",
"value",
... | [
157,
4
] | [
169,
29
] | python | en | ['en', 'en', 'en'] | True |
HistoryStatsSensor.unit_of_measurement | (self) | Return the unit the value is expressed in. | Return the unit the value is expressed in. | def unit_of_measurement(self):
"""Return the unit the value is expressed in."""
return self._unit_of_measurement | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unit_of_measurement"
] | [
172,
4
] | [
174,
40
] | python | en | ['en', 'en', 'en'] | True |
HistoryStatsSensor.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."""
if self.value is None:
return {}
hsh = HistoryStatsHelper
return {ATTR_VALUE: hsh.pretty_duration(self.value)} | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"if",
"self",
".",
"value",
"is",
"None",
":",
"return",
"{",
"}",
"hsh",
"=",
"HistoryStatsHelper",
"return",
"{",
"ATTR_VALUE",
":",
"hsh",
".",
"pretty_duration",
"(",
"self",
".",
"value",
")",
... | [
177,
4
] | [
183,
60
] | python | en | ['en', 'en', 'en'] | True |
HistoryStatsSensor.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"
] | [
186,
4
] | [
188,
19
] | python | en | ['en', 'en', 'en'] | True |
HistoryStatsSensor.update | (self) | Get the latest data and updates the states. | Get the latest data and updates the states. | def update(self):
"""Get the latest data and updates the states."""
# Get previous values of start and end
p_start, p_end = self._period
# Parse templates
self.update_period()
start, end = self._period
# Convert times to UTC
start = dt_util.as_utc(start)... | [
"def",
"update",
"(",
"self",
")",
":",
"# Get previous values of start and end",
"p_start",
",",
"p_end",
"=",
"self",
".",
"_period",
"# Parse templates",
"self",
".",
"update_period",
"(",
")",
"start",
",",
"end",
"=",
"self",
".",
"_period",
"# Convert time... | [
190,
4
] | [
259,
26
] | python | en | ['en', 'en', 'en'] | True |
HistoryStatsSensor.update_period | (self) | Parse the templates and store a datetime tuple in _period. | Parse the templates and store a datetime tuple in _period. | def update_period(self):
"""Parse the templates and store a datetime tuple in _period."""
start = None
end = None
# Parse start
if self._start is not None:
try:
start_rendered = self._start.render()
except (TemplateError, TypeError) as ex:... | [
"def",
"update_period",
"(",
"self",
")",
":",
"start",
"=",
"None",
"end",
"=",
"None",
"# Parse start",
"if",
"self",
".",
"_start",
"is",
"not",
"None",
":",
"try",
":",
"start_rendered",
"=",
"self",
".",
"_start",
".",
"render",
"(",
")",
"except"... | [
261,
4
] | [
319,
33
] | python | en | ['en', 'en', 'en'] | True |
HistoryStatsHelper.pretty_duration | (hours) | Format a duration in days, hours, minutes, seconds. | Format a duration in days, hours, minutes, seconds. | def pretty_duration(hours):
"""Format a duration in days, hours, minutes, seconds."""
seconds = int(3600 * hours)
days, seconds = divmod(seconds, 86400)
hours, seconds = divmod(seconds, 3600)
minutes, seconds = divmod(seconds, 60)
if days > 0:
return "%dd %dh ... | [
"def",
"pretty_duration",
"(",
"hours",
")",
":",
"seconds",
"=",
"int",
"(",
"3600",
"*",
"hours",
")",
"days",
",",
"seconds",
"=",
"divmod",
"(",
"seconds",
",",
"86400",
")",
"hours",
",",
"seconds",
"=",
"divmod",
"(",
"seconds",
",",
"3600",
")... | [
326,
4
] | [
336,
30
] | python | en | ['en', 'en', 'en'] | True |
HistoryStatsHelper.pretty_ratio | (value, period) | Format the ratio of value / period duration. | Format the ratio of value / period duration. | def pretty_ratio(value, period):
"""Format the ratio of value / period duration."""
if len(period) != 2 or period[0] == period[1]:
return 0.0
ratio = 100 * 3600 * value / (period[1] - period[0]).total_seconds()
return round(ratio, 1) | [
"def",
"pretty_ratio",
"(",
"value",
",",
"period",
")",
":",
"if",
"len",
"(",
"period",
")",
"!=",
"2",
"or",
"period",
"[",
"0",
"]",
"==",
"period",
"[",
"1",
"]",
":",
"return",
"0.0",
"ratio",
"=",
"100",
"*",
"3600",
"*",
"value",
"/",
"... | [
339,
4
] | [
345,
30
] | python | en | ['en', 'en', 'en'] | True |
HistoryStatsHelper.handle_template_exception | (ex, field) | Log an error nicely if the template cannot be interpreted. | Log an error nicely if the template cannot be interpreted. | def handle_template_exception(ex, field):
"""Log an error nicely if the template cannot be interpreted."""
if ex.args and ex.args[0].startswith("UndefinedError: 'None' has no attribute"):
# Common during HA startup - so just a warning
_LOGGER.warning(ex)
return
... | [
"def",
"handle_template_exception",
"(",
"ex",
",",
"field",
")",
":",
"if",
"ex",
".",
"args",
"and",
"ex",
".",
"args",
"[",
"0",
"]",
".",
"startswith",
"(",
"\"UndefinedError: 'None' has no attribute\"",
")",
":",
"# Common during HA startup - so just a warning"... | [
348,
4
] | [
355,
25
] | python | en | ['en', 'en', 'en'] | True |
test_color_RGB_to_xy_brightness | () | Test color_RGB_to_xy_brightness. | Test color_RGB_to_xy_brightness. | def test_color_RGB_to_xy_brightness():
"""Test color_RGB_to_xy_brightness."""
assert color_util.color_RGB_to_xy_brightness(0, 0, 0) == (0, 0, 0)
assert color_util.color_RGB_to_xy_brightness(255, 255, 255) == (0.323, 0.329, 255)
assert color_util.color_RGB_to_xy_brightness(0, 0, 255) == (0.136, 0.04, 12... | [
"def",
"test_color_RGB_to_xy_brightness",
"(",
")",
":",
"assert",
"color_util",
".",
"color_RGB_to_xy_brightness",
"(",
"0",
",",
"0",
",",
"0",
")",
"==",
"(",
"0",
",",
"0",
",",
"0",
")",
"assert",
"color_util",
".",
"color_RGB_to_xy_brightness",
"(",
"2... | [
34,
0
] | [
55,
87
] | python | en | ['en', 'hmn', 'en'] | False |
test_color_RGB_to_xy | () | Test color_RGB_to_xy. | Test color_RGB_to_xy. | def test_color_RGB_to_xy():
"""Test color_RGB_to_xy."""
assert color_util.color_RGB_to_xy(0, 0, 0) == (0, 0)
assert color_util.color_RGB_to_xy(255, 255, 255) == (0.323, 0.329)
assert color_util.color_RGB_to_xy(0, 0, 255) == (0.136, 0.04)
assert color_util.color_RGB_to_xy(0, 255, 0) == (0.172, 0.74... | [
"def",
"test_color_RGB_to_xy",
"(",
")",
":",
"assert",
"color_util",
".",
"color_RGB_to_xy",
"(",
"0",
",",
"0",
",",
"0",
")",
"==",
"(",
"0",
",",
"0",
")",
"assert",
"color_util",
".",
"color_RGB_to_xy",
"(",
"255",
",",
"255",
",",
"255",
")",
"... | [
58,
0
] | [
75,
71
] | python | en | ['en', 'en', 'en'] | False |
test_color_xy_brightness_to_RGB | () | Test color_xy_brightness_to_RGB. | Test color_xy_brightness_to_RGB. | def test_color_xy_brightness_to_RGB():
"""Test color_xy_brightness_to_RGB."""
assert color_util.color_xy_brightness_to_RGB(1, 1, 0) == (0, 0, 0)
assert color_util.color_xy_brightness_to_RGB(0.35, 0.35, 128) == (194, 186, 169)
assert color_util.color_xy_brightness_to_RGB(0.35, 0.35, 255) == (255, 243, ... | [
"def",
"test_color_xy_brightness_to_RGB",
"(",
")",
":",
"assert",
"color_util",
".",
"color_xy_brightness_to_RGB",
"(",
"1",
",",
"1",
",",
"0",
")",
"==",
"(",
"0",
",",
"0",
",",
"0",
")",
"assert",
"color_util",
".",
"color_xy_brightness_to_RGB",
"(",
"0... | [
78,
0
] | [
96,
82
] | python | en | ['en', 'hmn', 'en'] | False |
test_color_xy_to_RGB | () | Test color_xy_to_RGB. | Test color_xy_to_RGB. | def test_color_xy_to_RGB():
"""Test color_xy_to_RGB."""
assert color_util.color_xy_to_RGB(0.35, 0.35) == (255, 243, 222)
assert color_util.color_xy_to_RGB(1, 0) == (255, 0, 60)
assert color_util.color_xy_to_RGB(0, 1) == (0, 255, 0)
assert color_util.color_xy_to_RGB(0, 0) == (0, 63, 255)
asse... | [
"def",
"test_color_xy_to_RGB",
"(",
")",
":",
"assert",
"color_util",
".",
"color_xy_to_RGB",
"(",
"0.35",
",",
"0.35",
")",
"==",
"(",
"255",
",",
"243",
",",
"222",
")",
"assert",
"color_util",
".",
"color_xy_to_RGB",
"(",
"1",
",",
"0",
")",
"==",
"... | [
99,
0
] | [
113,
66
] | python | en | ['en', 'en', 'en'] | False |
test_color_RGB_to_hsv | () | Test color_RGB_to_hsv. | Test color_RGB_to_hsv. | def test_color_RGB_to_hsv():
"""Test color_RGB_to_hsv."""
assert color_util.color_RGB_to_hsv(0, 0, 0) == (0, 0, 0)
assert color_util.color_RGB_to_hsv(255, 255, 255) == (0, 0, 100)
assert color_util.color_RGB_to_hsv(0, 0, 255) == (240, 100, 100)
assert color_util.color_RGB_to_hsv(0, 255, 0) == (12... | [
"def",
"test_color_RGB_to_hsv",
"(",
")",
":",
"assert",
"color_util",
".",
"color_RGB_to_hsv",
"(",
"0",
",",
"0",
",",
"0",
")",
"==",
"(",
"0",
",",
"0",
",",
"0",
")",
"assert",
"color_util",
".",
"color_RGB_to_hsv",
"(",
"255",
",",
"255",
",",
... | [
116,
0
] | [
126,
66
] | python | en | ['en', 'en', 'en'] | False |
test_color_hsv_to_RGB | () | Test color_hsv_to_RGB. | Test color_hsv_to_RGB. | def test_color_hsv_to_RGB():
"""Test color_hsv_to_RGB."""
assert color_util.color_hsv_to_RGB(0, 0, 0) == (0, 0, 0)
assert color_util.color_hsv_to_RGB(0, 0, 100) == (255, 255, 255)
assert color_util.color_hsv_to_RGB(240, 100, 100) == (0, 0, 255)
assert color_util.color_hsv_to_RGB(120, 100, 100) ==... | [
"def",
"test_color_hsv_to_RGB",
"(",
")",
":",
"assert",
"color_util",
".",
"color_hsv_to_RGB",
"(",
"0",
",",
"0",
",",
"0",
")",
"==",
"(",
"0",
",",
"0",
",",
"0",
")",
"assert",
"color_util",
".",
"color_hsv_to_RGB",
"(",
"0",
",",
"0",
",",
"100... | [
129,
0
] | [
139,
66
] | python | en | ['en', 'en', 'en'] | False |
test_color_hsb_to_RGB | () | Test color_hsb_to_RGB. | Test color_hsb_to_RGB. | def test_color_hsb_to_RGB():
"""Test color_hsb_to_RGB."""
assert color_util.color_hsb_to_RGB(0, 0, 0) == (0, 0, 0)
assert color_util.color_hsb_to_RGB(0, 0, 1.0) == (255, 255, 255)
assert color_util.color_hsb_to_RGB(240, 1.0, 1.0) == (0, 0, 255)
assert color_util.color_hsb_to_RGB(120, 1.0, 1.0) ==... | [
"def",
"test_color_hsb_to_RGB",
"(",
")",
":",
"assert",
"color_util",
".",
"color_hsb_to_RGB",
"(",
"0",
",",
"0",
",",
"0",
")",
"==",
"(",
"0",
",",
"0",
",",
"0",
")",
"assert",
"color_util",
".",
"color_hsb_to_RGB",
"(",
"0",
",",
"0",
",",
"1.0... | [
142,
0
] | [
152,
66
] | python | en | ['en', 'en', 'it'] | False |
test_color_xy_to_hs | () | Test color_xy_to_hs. | Test color_xy_to_hs. | def test_color_xy_to_hs():
"""Test color_xy_to_hs."""
assert color_util.color_xy_to_hs(1, 1) == (47.294, 100)
assert color_util.color_xy_to_hs(0.35, 0.35) == (38.182, 12.941)
assert color_util.color_xy_to_hs(1, 0) == (345.882, 100)
assert color_util.color_xy_to_hs(0, 1) == (120, 100)
assert ... | [
"def",
"test_color_xy_to_hs",
"(",
")",
":",
"assert",
"color_util",
".",
"color_xy_to_hs",
"(",
"1",
",",
"1",
")",
"==",
"(",
"47.294",
",",
"100",
")",
"assert",
"color_util",
".",
"color_xy_to_hs",
"(",
"0.35",
",",
"0.35",
")",
"==",
"(",
"38.182",
... | [
155,
0
] | [
171,
70
] | python | en | ['en', 'en', 'en'] | False |
test_color_hs_to_xy | () | Test color_hs_to_xy. | Test color_hs_to_xy. | def test_color_hs_to_xy():
"""Test color_hs_to_xy."""
assert color_util.color_hs_to_xy(180, 100) == (0.151, 0.343)
assert color_util.color_hs_to_xy(350, 12.5) == (0.356, 0.321)
assert color_util.color_hs_to_xy(140, 50) == (0.229, 0.474)
assert color_util.color_hs_to_xy(0, 40) == (0.474, 0.317)
... | [
"def",
"test_color_hs_to_xy",
"(",
")",
":",
"assert",
"color_util",
".",
"color_hs_to_xy",
"(",
"180",
",",
"100",
")",
"==",
"(",
"0.151",
",",
"0.343",
")",
"assert",
"color_util",
".",
"color_hs_to_xy",
"(",
"350",
",",
"12.5",
")",
"==",
"(",
"0.356... | [
174,
0
] | [
194,
69
] | python | en | ['en', 'en', 'en'] | False |
test_rgb_hex_to_rgb_list | () | Test rgb_hex_to_rgb_list. | Test rgb_hex_to_rgb_list. | def test_rgb_hex_to_rgb_list():
"""Test rgb_hex_to_rgb_list."""
assert [255, 255, 255] == color_util.rgb_hex_to_rgb_list("ffffff")
assert [0, 0, 0] == color_util.rgb_hex_to_rgb_list("000000")
assert [255, 255, 255, 255] == color_util.rgb_hex_to_rgb_list("ffffffff")
assert [0, 0, 0, 0] == color_ut... | [
"def",
"test_rgb_hex_to_rgb_list",
"(",
")",
":",
"assert",
"[",
"255",
",",
"255",
",",
"255",
"]",
"==",
"color_util",
".",
"rgb_hex_to_rgb_list",
"(",
"\"ffffff\"",
")",
"assert",
"[",
"0",
",",
"0",
",",
"0",
"]",
"==",
"color_util",
".",
"rgb_hex_to... | [
197,
0
] | [
209,
74
] | python | en | ['en', 'hmn', 'hi'] | False |
test_color_name_to_rgb_valid_name | () | Test color_name_to_rgb. | Test color_name_to_rgb. | def test_color_name_to_rgb_valid_name():
"""Test color_name_to_rgb."""
assert color_util.color_name_to_rgb("red") == (255, 0, 0)
assert color_util.color_name_to_rgb("blue") == (0, 0, 255)
assert color_util.color_name_to_rgb("green") == (0, 128, 0)
# spaces in the name
assert color_util.color_... | [
"def",
"test_color_name_to_rgb_valid_name",
"(",
")",
":",
"assert",
"color_util",
".",
"color_name_to_rgb",
"(",
"\"red\"",
")",
"==",
"(",
"255",
",",
"0",
",",
"0",
")",
"assert",
"color_util",
".",
"color_name_to_rgb",
"(",
"\"blue\"",
")",
"==",
"(",
"0... | [
212,
0
] | [
226,
74
] | python | en | ['en', 'en', 'en'] | False |
test_color_name_to_rgb_unknown_name_raises_value_error | () | Test color_name_to_rgb. | Test color_name_to_rgb. | def test_color_name_to_rgb_unknown_name_raises_value_error():
"""Test color_name_to_rgb."""
with pytest.raises(ValueError):
color_util.color_name_to_rgb("not a color") | [
"def",
"test_color_name_to_rgb_unknown_name_raises_value_error",
"(",
")",
":",
"with",
"pytest",
".",
"raises",
"(",
"ValueError",
")",
":",
"color_util",
".",
"color_name_to_rgb",
"(",
"\"not a color\"",
")"
] | [
229,
0
] | [
232,
51
] | python | en | ['en', 'en', 'en'] | False |
test_color_rgb_to_rgbw | () | Test color_rgb_to_rgbw. | Test color_rgb_to_rgbw. | def test_color_rgb_to_rgbw():
"""Test color_rgb_to_rgbw."""
assert color_util.color_rgb_to_rgbw(0, 0, 0) == (0, 0, 0, 0)
assert color_util.color_rgb_to_rgbw(255, 255, 255) == (0, 0, 0, 255)
assert color_util.color_rgb_to_rgbw(255, 0, 0) == (255, 0, 0, 0)
assert color_util.color_rgb_to_rgbw(0, 255... | [
"def",
"test_color_rgb_to_rgbw",
"(",
")",
":",
"assert",
"color_util",
".",
"color_rgb_to_rgbw",
"(",
"0",
",",
"0",
",",
"0",
")",
"==",
"(",
"0",
",",
"0",
",",
"0",
",",
"0",
")",
"assert",
"color_util",
".",
"color_rgb_to_rgbw",
"(",
"255",
",",
... | [
235,
0
] | [
251,
72
] | python | en | ['en', 'en', 'it'] | False |
test_color_rgbw_to_rgb | () | Test color_rgbw_to_rgb. | Test color_rgbw_to_rgb. | def test_color_rgbw_to_rgb():
"""Test color_rgbw_to_rgb."""
assert color_util.color_rgbw_to_rgb(0, 0, 0, 0) == (0, 0, 0)
assert color_util.color_rgbw_to_rgb(0, 0, 0, 255) == (255, 255, 255)
assert color_util.color_rgbw_to_rgb(255, 0, 0, 0) == (255, 0, 0)
assert color_util.color_rgbw_to_rgb(0, 255... | [
"def",
"test_color_rgbw_to_rgb",
"(",
")",
":",
"assert",
"color_util",
".",
"color_rgbw_to_rgb",
"(",
"0",
",",
"0",
",",
"0",
",",
"0",
")",
"==",
"(",
"0",
",",
"0",
",",
"0",
")",
"assert",
"color_util",
".",
"color_rgbw_to_rgb",
"(",
"0",
",",
"... | [
254,
0
] | [
270,
72
] | python | en | ['en', 'en', 'it'] | False |
test_color_rgb_to_hex | () | Test color_rgb_to_hex. | Test color_rgb_to_hex. | def test_color_rgb_to_hex():
"""Test color_rgb_to_hex."""
assert color_util.color_rgb_to_hex(255, 255, 255) == "ffffff"
assert color_util.color_rgb_to_hex(0, 0, 0) == "000000"
assert color_util.color_rgb_to_hex(51, 153, 255) == "3399ff"
assert color_util.color_rgb_to_hex(255, 67.9204190, 0) == "ff44... | [
"def",
"test_color_rgb_to_hex",
"(",
")",
":",
"assert",
"color_util",
".",
"color_rgb_to_hex",
"(",
"255",
",",
"255",
",",
"255",
")",
"==",
"\"ffffff\"",
"assert",
"color_util",
".",
"color_rgb_to_hex",
"(",
"0",
",",
"0",
",",
"0",
")",
"==",
"\"000000... | [
273,
0
] | [
278,
70
] | python | en | ['en', 'en', 'it'] | False |
test_gamut | () | Test gamut functions. | Test gamut functions. | def test_gamut():
"""Test gamut functions."""
assert color_util.check_valid_gamut(GAMUT)
assert not color_util.check_valid_gamut(GAMUT_INVALID_1)
assert not color_util.check_valid_gamut(GAMUT_INVALID_2)
assert not color_util.check_valid_gamut(GAMUT_INVALID_3)
assert not color_util.check_valid_ga... | [
"def",
"test_gamut",
"(",
")",
":",
"assert",
"color_util",
".",
"check_valid_gamut",
"(",
"GAMUT",
")",
"assert",
"not",
"color_util",
".",
"check_valid_gamut",
"(",
"GAMUT_INVALID_1",
")",
"assert",
"not",
"color_util",
".",
"check_valid_gamut",
"(",
"GAMUT_INVA... | [
281,
0
] | [
287,
60
] | python | en | ['en', 'en', 'en'] | True |
test_color_temperature_mired_to_kelvin | () | Test color_temperature_mired_to_kelvin. | Test color_temperature_mired_to_kelvin. | def test_color_temperature_mired_to_kelvin():
"""Test color_temperature_mired_to_kelvin."""
assert color_util.color_temperature_mired_to_kelvin(40) == 25000
assert color_util.color_temperature_mired_to_kelvin(200) == 5000
with pytest.raises(ZeroDivisionError):
assert color_util.color_temperature... | [
"def",
"test_color_temperature_mired_to_kelvin",
"(",
")",
":",
"assert",
"color_util",
".",
"color_temperature_mired_to_kelvin",
"(",
"40",
")",
"==",
"25000",
"assert",
"color_util",
".",
"color_temperature_mired_to_kelvin",
"(",
"200",
")",
"==",
"5000",
"with",
"p... | [
290,
0
] | [
295,
62
] | python | en | ['en', 'en', 'it'] | False |
test_color_temperature_kelvin_to_mired | () | Test color_temperature_kelvin_to_mired. | Test color_temperature_kelvin_to_mired. | def test_color_temperature_kelvin_to_mired():
"""Test color_temperature_kelvin_to_mired."""
assert color_util.color_temperature_kelvin_to_mired(25000) == 40
assert color_util.color_temperature_kelvin_to_mired(5000) == 200
with pytest.raises(ZeroDivisionError):
assert color_util.color_temperature... | [
"def",
"test_color_temperature_kelvin_to_mired",
"(",
")",
":",
"assert",
"color_util",
".",
"color_temperature_kelvin_to_mired",
"(",
"25000",
")",
"==",
"40",
"assert",
"color_util",
".",
"color_temperature_kelvin_to_mired",
"(",
"5000",
")",
"==",
"200",
"with",
"p... | [
298,
0
] | [
303,
62
] | python | en | ['en', 'en', 'it'] | False |
test_returns_same_value_for_any_two_temperatures_below_1000 | () | Function should return same value for 999 Kelvin and 0 Kelvin. | Function should return same value for 999 Kelvin and 0 Kelvin. | def test_returns_same_value_for_any_two_temperatures_below_1000():
"""Function should return same value for 999 Kelvin and 0 Kelvin."""
rgb_1 = color_util.color_temperature_to_rgb(999)
rgb_2 = color_util.color_temperature_to_rgb(0)
assert rgb_1 == rgb_2 | [
"def",
"test_returns_same_value_for_any_two_temperatures_below_1000",
"(",
")",
":",
"rgb_1",
"=",
"color_util",
".",
"color_temperature_to_rgb",
"(",
"999",
")",
"rgb_2",
"=",
"color_util",
".",
"color_temperature_to_rgb",
"(",
"0",
")",
"assert",
"rgb_1",
"==",
"rgb... | [
306,
0
] | [
310,
25
] | python | en | ['en', 'da', 'en'] | True |
test_returns_same_value_for_any_two_temperatures_above_40000 | () | Function should return same value for 40001K and 999999K. | Function should return same value for 40001K and 999999K. | def test_returns_same_value_for_any_two_temperatures_above_40000():
"""Function should return same value for 40001K and 999999K."""
rgb_1 = color_util.color_temperature_to_rgb(40001)
rgb_2 = color_util.color_temperature_to_rgb(999999)
assert rgb_1 == rgb_2 | [
"def",
"test_returns_same_value_for_any_two_temperatures_above_40000",
"(",
")",
":",
"rgb_1",
"=",
"color_util",
".",
"color_temperature_to_rgb",
"(",
"40001",
")",
"rgb_2",
"=",
"color_util",
".",
"color_temperature_to_rgb",
"(",
"999999",
")",
"assert",
"rgb_1",
"=="... | [
313,
0
] | [
317,
25
] | python | en | ['en', 'da', 'en'] | True |
test_should_return_pure_white_at_6600 | () |
Function should return red=255, blue=255, green=255 when given 6600K.
6600K is considered "pure white" light.
This is just a rough estimate because the formula itself is a "best
guess" approach.
|
Function should return red=255, blue=255, green=255 when given 6600K. | def test_should_return_pure_white_at_6600():
"""
Function should return red=255, blue=255, green=255 when given 6600K.
6600K is considered "pure white" light.
This is just a rough estimate because the formula itself is a "best
guess" approach.
"""
rgb = color_util.color_temperature_to_rgb(6... | [
"def",
"test_should_return_pure_white_at_6600",
"(",
")",
":",
"rgb",
"=",
"color_util",
".",
"color_temperature_to_rgb",
"(",
"6600",
")",
"assert",
"(",
"255",
",",
"255",
",",
"255",
")",
"==",
"rgb"
] | [
320,
0
] | [
329,
33
] | python | en | ['en', 'error', 'th'] | False |
test_color_above_6600_should_have_more_blue_than_red_or_green | () | Function should return a higher blue value for blue-ish light. | Function should return a higher blue value for blue-ish light. | def test_color_above_6600_should_have_more_blue_than_red_or_green():
"""Function should return a higher blue value for blue-ish light."""
rgb = color_util.color_temperature_to_rgb(6700)
assert rgb[2] > rgb[1]
assert rgb[2] > rgb[0] | [
"def",
"test_color_above_6600_should_have_more_blue_than_red_or_green",
"(",
")",
":",
"rgb",
"=",
"color_util",
".",
"color_temperature_to_rgb",
"(",
"6700",
")",
"assert",
"rgb",
"[",
"2",
"]",
">",
"rgb",
"[",
"1",
"]",
"assert",
"rgb",
"[",
"2",
"]",
">",
... | [
332,
0
] | [
336,
26
] | python | en | ['en', 'da', 'en'] | True |
test_color_below_6600_should_have_more_red_than_blue_or_green | () | Function should return a higher red value for red-ish light. | Function should return a higher red value for red-ish light. | def test_color_below_6600_should_have_more_red_than_blue_or_green():
"""Function should return a higher red value for red-ish light."""
rgb = color_util.color_temperature_to_rgb(6500)
assert rgb[0] > rgb[1]
assert rgb[0] > rgb[2] | [
"def",
"test_color_below_6600_should_have_more_red_than_blue_or_green",
"(",
")",
":",
"rgb",
"=",
"color_util",
".",
"color_temperature_to_rgb",
"(",
"6500",
")",
"assert",
"rgb",
"[",
"0",
"]",
">",
"rgb",
"[",
"1",
"]",
"assert",
"rgb",
"[",
"0",
"]",
">",
... | [
339,
0
] | [
343,
26
] | python | en | ['en', 'en', 'en'] | True |
test_get_color_in_voluptuous | () | Test using the get method in color validation. | Test using the get method in color validation. | def test_get_color_in_voluptuous():
"""Test using the get method in color validation."""
schema = vol.Schema(color_util.color_name_to_rgb)
with pytest.raises(vol.Invalid):
schema("not a color")
assert schema("red") == (255, 0, 0) | [
"def",
"test_get_color_in_voluptuous",
"(",
")",
":",
"schema",
"=",
"vol",
".",
"Schema",
"(",
"color_util",
".",
"color_name_to_rgb",
")",
"with",
"pytest",
".",
"raises",
"(",
"vol",
".",
"Invalid",
")",
":",
"schema",
"(",
"\"not a color\"",
")",
"assert... | [
346,
0
] | [
353,
39
] | python | en | ['en', 'en', 'en'] | True |
ImageFeatureExtractionMixin.to_pil_image | (self, image, rescale=None) |
Converts :obj:`image` to a PIL Image. Optionally rescales it and puts the channel dimension back as the last
axis if needed.
Args:
image (:obj:`PIL.Image.Image` or :obj:`numpy.ndarray` or :obj:`torch.Tensor`):
The image to convert to the PIL Image format.
... |
Converts :obj:`image` to a PIL Image. Optionally rescales it and puts the channel dimension back as the last
axis if needed. | def to_pil_image(self, image, rescale=None):
"""
Converts :obj:`image` to a PIL Image. Optionally rescales it and puts the channel dimension back as the last
axis if needed.
Args:
image (:obj:`PIL.Image.Image` or :obj:`numpy.ndarray` or :obj:`torch.Tensor`):
... | [
"def",
"to_pil_image",
"(",
"self",
",",
"image",
",",
"rescale",
"=",
"None",
")",
":",
"self",
".",
"_ensure_format_supported",
"(",
"image",
")",
"if",
"is_torch_tensor",
"(",
"image",
")",
":",
"image",
"=",
"image",
".",
"numpy",
"(",
")",
"if",
"... | [
38,
4
] | [
66,
20
] | python | en | ['en', 'error', 'th'] | False |
ImageFeatureExtractionMixin.to_numpy_array | (self, image, rescale=None, channel_first=True) |
Converts :obj:`image` to a numpy array. Optionally rescales it and puts the channel dimension as the first
dimension.
Args:
image (:obj:`PIL.Image.Image` or :obj:`np.ndarray` or :obj:`torch.Tensor`):
The image to convert to a NumPy array.
rescale (:obj:`... |
Converts :obj:`image` to a numpy array. Optionally rescales it and puts the channel dimension as the first
dimension. | def to_numpy_array(self, image, rescale=None, channel_first=True):
"""
Converts :obj:`image` to a numpy array. Optionally rescales it and puts the channel dimension as the first
dimension.
Args:
image (:obj:`PIL.Image.Image` or :obj:`np.ndarray` or :obj:`torch.Tensor`):
... | [
"def",
"to_numpy_array",
"(",
"self",
",",
"image",
",",
"rescale",
"=",
"None",
",",
"channel_first",
"=",
"True",
")",
":",
"self",
".",
"_ensure_format_supported",
"(",
"image",
")",
"if",
"isinstance",
"(",
"image",
",",
"PIL",
".",
"Image",
".",
"Im... | [
68,
4
] | [
100,
20
] | python | en | ['en', 'error', 'th'] | False |
ImageFeatureExtractionMixin.normalize | (self, image, mean, std) |
Normalizes :obj:`image` with :obj:`mean` and :obj:`std`. Note that this will trigger a conversion of
:obj:`image` to a NumPy array if it's a PIL Image.
Args:
image (:obj:`PIL.Image.Image` or :obj:`np.ndarray` or :obj:`torch.Tensor`):
The image to normalize.
... |
Normalizes :obj:`image` with :obj:`mean` and :obj:`std`. Note that this will trigger a conversion of
:obj:`image` to a NumPy array if it's a PIL Image. | def normalize(self, image, mean, std):
"""
Normalizes :obj:`image` with :obj:`mean` and :obj:`std`. Note that this will trigger a conversion of
:obj:`image` to a NumPy array if it's a PIL Image.
Args:
image (:obj:`PIL.Image.Image` or :obj:`np.ndarray` or :obj:`torch.Tensor`)... | [
"def",
"normalize",
"(",
"self",
",",
"image",
",",
"mean",
",",
"std",
")",
":",
"self",
".",
"_ensure_format_supported",
"(",
"image",
")",
"if",
"isinstance",
"(",
"image",
",",
"PIL",
".",
"Image",
".",
"Image",
")",
":",
"image",
"=",
"self",
".... | [
102,
4
] | [
136,
39
] | python | en | ['en', 'error', 'th'] | False |
ImageFeatureExtractionMixin.resize | (self, image, size, resample=PIL.Image.BILINEAR) |
Resizes :obj:`image`. Note that this will trigger a conversion of :obj:`image` to a PIL Image.
Args:
image (:obj:`PIL.Image.Image` or :obj:`np.ndarray` or :obj:`torch.Tensor`):
The image to resize.
size (:obj:`int` or :obj:`Tuple[int, int]`):
The... |
Resizes :obj:`image`. Note that this will trigger a conversion of :obj:`image` to a PIL Image. | def resize(self, image, size, resample=PIL.Image.BILINEAR):
"""
Resizes :obj:`image`. Note that this will trigger a conversion of :obj:`image` to a PIL Image.
Args:
image (:obj:`PIL.Image.Image` or :obj:`np.ndarray` or :obj:`torch.Tensor`):
The image to resize.
... | [
"def",
"resize",
"(",
"self",
",",
"image",
",",
"size",
",",
"resample",
"=",
"PIL",
".",
"Image",
".",
"BILINEAR",
")",
":",
"self",
".",
"_ensure_format_supported",
"(",
"image",
")",
"if",
"not",
"isinstance",
"(",
"size",
",",
"tuple",
")",
":",
... | [
138,
4
] | [
157,
52
] | python | en | ['en', 'error', 'th'] | False |
async_setup_scanner | (hass, config, async_see, discovery_info=None) | Set up the MQTT JSON tracker. | Set up the MQTT JSON tracker. | async def async_setup_scanner(hass, config, async_see, discovery_info=None):
"""Set up the MQTT JSON tracker."""
devices = config[CONF_DEVICES]
qos = config[CONF_QOS]
for dev_id, topic in devices.items():
@callback
def async_message_received(msg, dev_id=dev_id):
"""Handle r... | [
"async",
"def",
"async_setup_scanner",
"(",
"hass",
",",
"config",
",",
"async_see",
",",
"discovery_info",
"=",
"None",
")",
":",
"devices",
"=",
"config",
"[",
"CONF_DEVICES",
"]",
"qos",
"=",
"config",
"[",
"CONF_QOS",
"]",
"for",
"dev_id",
",",
"topic"... | [
36,
0
] | [
64,
15
] | python | en | ['en', 'lb', 'en'] | True |
_parse_see_args | (dev_id, data) | Parse the payload location parameters, into the format see expects. | Parse the payload location parameters, into the format see expects. | def _parse_see_args(dev_id, data):
"""Parse the payload location parameters, into the format see expects."""
kwargs = {"gps": (data[ATTR_LATITUDE], data[ATTR_LONGITUDE]), "dev_id": dev_id}
if ATTR_GPS_ACCURACY in data:
kwargs[ATTR_GPS_ACCURACY] = data[ATTR_GPS_ACCURACY]
if ATTR_BATTERY_LEVEL in... | [
"def",
"_parse_see_args",
"(",
"dev_id",
",",
"data",
")",
":",
"kwargs",
"=",
"{",
"\"gps\"",
":",
"(",
"data",
"[",
"ATTR_LATITUDE",
"]",
",",
"data",
"[",
"ATTR_LONGITUDE",
"]",
")",
",",
"\"dev_id\"",
":",
"dev_id",
"}",
"if",
"ATTR_GPS_ACCURACY",
"i... | [
67,
0
] | [
75,
17
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up the sochain sensors. | Set up the sochain sensors. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the sochain sensors."""
address = config.get(CONF_ADDRESS)
network = config.get(CONF_NETWORK)
name = config.get(CONF_NAME)
session = async_get_clientsession(hass)
chainso = ChainSo(network, address... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"address",
"=",
"config",
".",
"get",
"(",
"CONF_ADDRESS",
")",
"network",
"=",
"config",
".",
"get",
"(",
"CONF_NETW... | [
29,
0
] | [
39,
77
] | python | en | ['en', 'bg', 'en'] | True |
SochainSensor.__init__ | (self, name, unit_of_measurement, chainso) | Initialize the sensor. | Initialize the sensor. | def __init__(self, name, unit_of_measurement, chainso):
"""Initialize the sensor."""
self._name = name
self._unit_of_measurement = unit_of_measurement
self.chainso = chainso | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"unit_of_measurement",
",",
"chainso",
")",
":",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"_unit_of_measurement",
"=",
"unit_of_measurement",
"self",
".",
"chainso",
"=",
"chainso"
] | [
45,
4
] | [
49,
30
] | python | en | ['en', 'en', 'en'] | True |
SochainSensor.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"
] | [
52,
4
] | [
54,
25
] | python | en | ['en', 'mi', 'en'] | True |
SochainSensor.state | (self) | Return the state of the sensor. | Return the state of the sensor. | def state(self):
"""Return the state of the sensor."""
return (
self.chainso.data.get("confirmed_balance")
if self.chainso is not None
else None
) | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"(",
"self",
".",
"chainso",
".",
"data",
".",
"get",
"(",
"\"confirmed_balance\"",
")",
"if",
"self",
".",
"chainso",
"is",
"not",
"None",
"else",
"None",
")"
] | [
57,
4
] | [
63,
9
] | python | en | ['en', 'en', 'en'] | True |
SochainSensor.unit_of_measurement | (self) | Return the unit of measurement this sensor expresses itself in. | Return the unit of measurement this sensor expresses itself in. | def unit_of_measurement(self):
"""Return the unit of measurement this sensor expresses itself in."""
return self._unit_of_measurement | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unit_of_measurement"
] | [
66,
4
] | [
68,
40
] | python | en | ['en', 'en', 'en'] | True |
SochainSensor.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."""
return {ATTR_ATTRIBUTION: ATTRIBUTION} | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"{",
"ATTR_ATTRIBUTION",
":",
"ATTRIBUTION",
"}"
] | [
71,
4
] | [
73,
46
] | python | en | ['en', 'en', 'en'] | True |
SochainSensor.async_update | (self) | Get the latest state of the sensor. | Get the latest state of the sensor. | async def async_update(self):
"""Get the latest state of the sensor."""
await self.chainso.async_get_data() | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"await",
"self",
".",
"chainso",
".",
"async_get_data",
"(",
")"
] | [
75,
4
] | [
77,
43
] | python | en | ['en', 'en', 'en'] | True |
MetOfficeData.__init__ | (self, hass, api_key, latitude, longitude) | Initialize the data object. | Initialize the data object. | def __init__(self, hass, api_key, latitude, longitude):
"""Initialize the data object."""
self._hass = hass
self._datapoint = datapoint.connection(api_key=api_key)
self._site = None
# Public attributes
self.latitude = latitude
self.longitude = longitude
... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"api_key",
",",
"latitude",
",",
"longitude",
")",
":",
"self",
".",
"_hass",
"=",
"hass",
"self",
".",
"_datapoint",
"=",
"datapoint",
".",
"connection",
"(",
"api_key",
"=",
"api_key",
")",
"self",
".... | [
19,
4
] | [
32,
23
] | python | en | ['en', 'en', 'en'] | True |
MetOfficeData.async_update_site | (self) | Async wrapper for getting the DataPoint site. | Async wrapper for getting the DataPoint site. | async def async_update_site(self):
"""Async wrapper for getting the DataPoint site."""
return await self._hass.async_add_executor_job(self._update_site) | [
"async",
"def",
"async_update_site",
"(",
"self",
")",
":",
"return",
"await",
"self",
".",
"_hass",
".",
"async_add_executor_job",
"(",
"self",
".",
"_update_site",
")"
] | [
34,
4
] | [
36,
73
] | python | en | ['en', 'en', 'en'] | True |
MetOfficeData._update_site | (self) | Return the nearest DataPoint Site to the held latitude/longitude. | Return the nearest DataPoint Site to the held latitude/longitude. | def _update_site(self):
"""Return the nearest DataPoint Site to the held latitude/longitude."""
try:
new_site = self._datapoint.get_nearest_forecast_site(
latitude=self.latitude, longitude=self.longitude
)
if self._site is None or self._site.id != new_... | [
"def",
"_update_site",
"(",
"self",
")",
":",
"try",
":",
"new_site",
"=",
"self",
".",
"_datapoint",
".",
"get_nearest_forecast_site",
"(",
"latitude",
"=",
"self",
".",
"latitude",
",",
"longitude",
"=",
"self",
".",
"longitude",
")",
"if",
"self",
".",
... | [
38,
4
] | [
58,
25
] | python | en | ['en', 'en', 'en'] | True |
MetOfficeData.async_update | (self) | Async wrapper for update method. | Async wrapper for update method. | async def async_update(self):
"""Async wrapper for update method."""
return await self._hass.async_add_executor_job(self._update) | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"return",
"await",
"self",
".",
"_hass",
".",
"async_add_executor_job",
"(",
"self",
".",
"_update",
")"
] | [
60,
4
] | [
62,
68
] | python | en | ['nb', 'en', 'en'] | True |
MetOfficeData._update | (self) | Get the latest data from DataPoint. | Get the latest data from DataPoint. | def _update(self):
"""Get the latest data from DataPoint."""
if self._site is None:
_LOGGER.error("No Met Office forecast site held, check logs for problems")
return
try:
forecast = self._datapoint.get_forecast_for_site(
self._site.id, MODE_3H... | [
"def",
"_update",
"(",
"self",
")",
":",
"if",
"self",
".",
"_site",
"is",
"None",
":",
"_LOGGER",
".",
"error",
"(",
"\"No Met Office forecast site held, check logs for problems\"",
")",
"return",
"try",
":",
"forecast",
"=",
"self",
".",
"_datapoint",
".",
"... | [
64,
4
] | [
77,
27
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the IHC switch platform. | Set up the IHC switch platform. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the IHC switch platform."""
if discovery_info is None:
return
devices = []
for name, device in discovery_info.items():
ihc_id = device["ihc_id"]
product_cfg = device["product_cfg"]
product = de... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"if",
"discovery_info",
"is",
"None",
":",
"return",
"devices",
"=",
"[",
"]",
"for",
"name",
",",
"device",
"in",
"discovery_info",
"."... | [
9,
0
] | [
30,
25
] | python | en | ['en', 'zh', 'en'] | True |
IHCSwitch.__init__ | (
self,
ihc_controller,
name: str,
ihc_id: int,
ihc_off_id: int,
ihc_on_id: int,
info: bool,
product=None,
) | Initialize the IHC switch. | Initialize the IHC switch. | def __init__(
self,
ihc_controller,
name: str,
ihc_id: int,
ihc_off_id: int,
ihc_on_id: int,
info: bool,
product=None,
) -> None:
"""Initialize the IHC switch."""
super().__init__(ihc_controller, name, ihc_id, product)
self._ihc... | [
"def",
"__init__",
"(",
"self",
",",
"ihc_controller",
",",
"name",
":",
"str",
",",
"ihc_id",
":",
"int",
",",
"ihc_off_id",
":",
"int",
",",
"ihc_on_id",
":",
"int",
",",
"info",
":",
"bool",
",",
"product",
"=",
"None",
",",
")",
"->",
"None",
"... | [
36,
4
] | [
50,
27
] | python | en | ['en', 'pl', 'en'] | True |
IHCSwitch.is_on | (self) | Return true if switch is on. | Return true if switch is on. | def is_on(self):
"""Return true if switch is on."""
return self._state | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
53,
4
] | [
55,
26
] | python | en | ['en', 'fy', 'en'] | True |
IHCSwitch.async_turn_on | (self, **kwargs) | Turn the switch on. | Turn the switch on. | async def async_turn_on(self, **kwargs):
"""Turn the switch on."""
if self._ihc_on_id:
await async_pulse(self.hass, self.ihc_controller, self._ihc_on_id)
else:
await async_set_bool(self.hass, self.ihc_controller, self.ihc_id, True) | [
"async",
"def",
"async_turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"_ihc_on_id",
":",
"await",
"async_pulse",
"(",
"self",
".",
"hass",
",",
"self",
".",
"ihc_controller",
",",
"self",
".",
"_ihc_on_id",
")",
"else",
":... | [
57,
4
] | [
62,
83
] | python | en | ['en', 'en', 'en'] | True |
IHCSwitch.async_turn_off | (self, **kwargs) | Turn the device off. | Turn the device off. | async def async_turn_off(self, **kwargs):
"""Turn the device off."""
if self._ihc_off_id:
await async_pulse(self.hass, self.ihc_controller, self._ihc_off_id)
else:
await async_set_bool(self.hass, self.ihc_controller, self.ihc_id, False) | [
"async",
"def",
"async_turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"_ihc_off_id",
":",
"await",
"async_pulse",
"(",
"self",
".",
"hass",
",",
"self",
".",
"ihc_controller",
",",
"self",
".",
"_ihc_off_id",
")",
"else",
... | [
64,
4
] | [
69,
84
] | python | en | ['en', 'en', 'en'] | True |
IHCSwitch.on_ihc_change | (self, ihc_id, value) | Handle IHC resource change. | Handle IHC resource change. | def on_ihc_change(self, ihc_id, value):
"""Handle IHC resource change."""
self._state = value
self.schedule_update_ha_state() | [
"def",
"on_ihc_change",
"(",
"self",
",",
"ihc_id",
",",
"value",
")",
":",
"self",
".",
"_state",
"=",
"value",
"self",
".",
"schedule_update_ha_state",
"(",
")"
] | [
71,
4
] | [
74,
39
] | python | en | ['en', 'xh', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up the ElkM1 alarm platform. | Set up the ElkM1 alarm platform. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up the ElkM1 alarm platform."""
elk_data = hass.data[DOMAIN][config_entry.entry_id]
elk = elk_data["elk"]
entities = []
create_elk_entities(elk_data, elk.areas, "area", ElkArea, entities)
async_add_entities(entities, Tru... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"elk_data",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"config_entry",
".",
"entry_id",
"]",
"elk",
"=",
"elk_data",
"[",
"\"elk\"",
"]",
"e... | [
59,
0
] | [
98,
5
] | python | en | ['en', 'da', 'en'] | True |
ElkArea.__init__ | (self, element, elk, elk_data) | Initialize Area as Alarm Control Panel. | Initialize Area as Alarm Control Panel. | def __init__(self, element, elk, elk_data):
"""Initialize Area as Alarm Control Panel."""
super().__init__(element, elk, elk_data)
self._elk = elk
self._changed_by_keypad = None
self._changed_by_time = None
self._changed_by_id = None
self._changed_by = None
... | [
"def",
"__init__",
"(",
"self",
",",
"element",
",",
"elk",
",",
"elk_data",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"element",
",",
"elk",
",",
"elk_data",
")",
"self",
".",
"_elk",
"=",
"elk",
"self",
".",
"_changed_by_keypad",
"=",
"Non... | [
104,
4
] | [
112,
26
] | python | en | ['en', 'ro', 'en'] | True |
ElkArea.async_added_to_hass | (self) | Register callback for ElkM1 changes. | Register callback for ElkM1 changes. | async def async_added_to_hass(self):
"""Register callback for ElkM1 changes."""
await super().async_added_to_hass()
if len(self._elk.areas.elements) == 1:
for keypad in self._elk.keypads:
keypad.add_callback(self._watch_keypad)
self._element.add_callback(self.... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"await",
"super",
"(",
")",
".",
"async_added_to_hass",
"(",
")",
"if",
"len",
"(",
"self",
".",
"_elk",
".",
"areas",
".",
"elements",
")",
"==",
"1",
":",
"for",
"keypad",
"in",
"self",
... | [
114,
4
] | [
134,
69
] | python | en | ['en', 'da', 'en'] | True |
ElkArea.code_format | (self) | Return the alarm code format. | Return the alarm code format. | def code_format(self):
"""Return the alarm code format."""
return FORMAT_NUMBER | [
"def",
"code_format",
"(",
"self",
")",
":",
"return",
"FORMAT_NUMBER"
] | [
160,
4
] | [
162,
28
] | python | en | ['en', 'la', 'en'] | True |
ElkArea.state | (self) | Return the state of the element. | Return the state of the element. | def state(self):
"""Return the state of the element."""
return self._state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
165,
4
] | [
167,
26
] | python | en | ['en', 'en', 'en'] | True |
ElkArea.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"
] | [
170,
4
] | [
172,
88
] | python | en | ['en', 'en', 'en'] | True |
ElkArea.device_state_attributes | (self) | Attributes of the area. | Attributes of the area. | def device_state_attributes(self):
"""Attributes of the area."""
attrs = self.initial_attrs()
elmt = self._element
attrs["is_exit"] = elmt.is_exit
attrs["timer1"] = elmt.timer1
attrs["timer2"] = elmt.timer2
if elmt.armed_status is not None:
attrs["arme... | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"attrs",
"=",
"self",
".",
"initial_attrs",
"(",
")",
"elmt",
"=",
"self",
".",
"_element",
"attrs",
"[",
"\"is_exit\"",
"]",
"=",
"elmt",
".",
"is_exit",
"attrs",
"[",
"\"timer1\"",
"]",
"=",
"elm... | [
175,
4
] | [
191,
20
] | python | en | ['en', 'en', 'en'] | True |
ElkArea.changed_by | (self) | Last change triggered by. | Last change triggered by. | def changed_by(self):
"""Last change triggered by."""
return self._changed_by | [
"def",
"changed_by",
"(",
"self",
")",
":",
"return",
"self",
".",
"_changed_by"
] | [
194,
4
] | [
196,
31
] | python | en | ['en', 'en', 'en'] | True |
ElkArea.async_alarm_disarm | (self, code=None) | Send disarm command. | Send disarm command. | async def async_alarm_disarm(self, code=None):
"""Send disarm command."""
self._element.disarm(int(code)) | [
"async",
"def",
"async_alarm_disarm",
"(",
"self",
",",
"code",
"=",
"None",
")",
":",
"self",
".",
"_element",
".",
"disarm",
"(",
"int",
"(",
"code",
")",
")"
] | [
226,
4
] | [
228,
39
] | python | en | ['en', 'pt', 'en'] | True |
ElkArea.async_alarm_arm_home | (self, code=None) | Send arm home command. | Send arm home command. | async def async_alarm_arm_home(self, code=None):
"""Send arm home command."""
self._element.arm(ArmLevel.ARMED_STAY.value, int(code)) | [
"async",
"def",
"async_alarm_arm_home",
"(",
"self",
",",
"code",
"=",
"None",
")",
":",
"self",
".",
"_element",
".",
"arm",
"(",
"ArmLevel",
".",
"ARMED_STAY",
".",
"value",
",",
"int",
"(",
"code",
")",
")"
] | [
230,
4
] | [
232,
63
] | python | en | ['en', 'pt', 'en'] | True |
ElkArea.async_alarm_arm_away | (self, code=None) | Send arm away command. | Send arm away command. | async def async_alarm_arm_away(self, code=None):
"""Send arm away command."""
self._element.arm(ArmLevel.ARMED_AWAY.value, int(code)) | [
"async",
"def",
"async_alarm_arm_away",
"(",
"self",
",",
"code",
"=",
"None",
")",
":",
"self",
".",
"_element",
".",
"arm",
"(",
"ArmLevel",
".",
"ARMED_AWAY",
".",
"value",
",",
"int",
"(",
"code",
")",
")"
] | [
234,
4
] | [
236,
63
] | python | en | ['en', 'en', 'en'] | True |
ElkArea.async_alarm_arm_night | (self, code=None) | Send arm night command. | Send arm night command. | async def async_alarm_arm_night(self, code=None):
"""Send arm night command."""
self._element.arm(ArmLevel.ARMED_NIGHT.value, int(code)) | [
"async",
"def",
"async_alarm_arm_night",
"(",
"self",
",",
"code",
"=",
"None",
")",
":",
"self",
".",
"_element",
".",
"arm",
"(",
"ArmLevel",
".",
"ARMED_NIGHT",
".",
"value",
",",
"int",
"(",
"code",
")",
")"
] | [
238,
4
] | [
240,
64
] | python | en | ['en', 'zh', 'en'] | True |
ElkArea.async_alarm_arm_home_instant | (self, code=None) | Send arm stay instant command. | Send arm stay instant command. | async def async_alarm_arm_home_instant(self, code=None):
"""Send arm stay instant command."""
self._element.arm(ArmLevel.ARMED_STAY_INSTANT.value, int(code)) | [
"async",
"def",
"async_alarm_arm_home_instant",
"(",
"self",
",",
"code",
"=",
"None",
")",
":",
"self",
".",
"_element",
".",
"arm",
"(",
"ArmLevel",
".",
"ARMED_STAY_INSTANT",
".",
"value",
",",
"int",
"(",
"code",
")",
")"
] | [
242,
4
] | [
244,
71
] | python | en | ['en', 'en', 'en'] | True |
ElkArea.async_alarm_arm_night_instant | (self, code=None) | Send arm night instant command. | Send arm night instant command. | async def async_alarm_arm_night_instant(self, code=None):
"""Send arm night instant command."""
self._element.arm(ArmLevel.ARMED_NIGHT_INSTANT.value, int(code)) | [
"async",
"def",
"async_alarm_arm_night_instant",
"(",
"self",
",",
"code",
"=",
"None",
")",
":",
"self",
".",
"_element",
".",
"arm",
"(",
"ArmLevel",
".",
"ARMED_NIGHT_INSTANT",
".",
"value",
",",
"int",
"(",
"code",
")",
")"
] | [
246,
4
] | [
248,
72
] | 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.