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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
ZiggoMediaboxXLDevice.supported_features | (self) | Flag media player features that are supported. | Flag media player features that are supported. | def supported_features(self):
"""Flag media player features that are supported."""
return SUPPORT_ZIGGO | [
"def",
"supported_features",
"(",
"self",
")",
":",
"return",
"SUPPORT_ZIGGO"
] | [
152,
4
] | [
154,
28
] | python | en | ['en', 'en', 'en'] | True |
ZiggoMediaboxXLDevice.turn_on | (self) | Turn the media player on. | Turn the media player on. | def turn_on(self):
"""Turn the media player on."""
self.send_keys(["POWER"]) | [
"def",
"turn_on",
"(",
"self",
")",
":",
"self",
".",
"send_keys",
"(",
"[",
"\"POWER\"",
"]",
")"
] | [
156,
4
] | [
158,
33
] | python | en | ['en', 'en', 'en'] | True |
ZiggoMediaboxXLDevice.turn_off | (self) | Turn off media player. | Turn off media player. | def turn_off(self):
"""Turn off media player."""
self.send_keys(["POWER"]) | [
"def",
"turn_off",
"(",
"self",
")",
":",
"self",
".",
"send_keys",
"(",
"[",
"\"POWER\"",
"]",
")"
] | [
160,
4
] | [
162,
33
] | python | en | ['en', 'en', 'en'] | True |
ZiggoMediaboxXLDevice.media_play | (self) | Send play command. | Send play command. | def media_play(self):
"""Send play command."""
self.send_keys(["PLAY"])
self._state = STATE_PLAYING | [
"def",
"media_play",
"(",
"self",
")",
":",
"self",
".",
"send_keys",
"(",
"[",
"\"PLAY\"",
"]",
")",
"self",
".",
"_state",
"=",
"STATE_PLAYING"
] | [
164,
4
] | [
167,
35
] | python | en | ['en', 'en', 'en'] | True |
ZiggoMediaboxXLDevice.media_pause | (self) | Send pause command. | Send pause command. | def media_pause(self):
"""Send pause command."""
self.send_keys(["PAUSE"])
self._state = STATE_PAUSED | [
"def",
"media_pause",
"(",
"self",
")",
":",
"self",
".",
"send_keys",
"(",
"[",
"\"PAUSE\"",
"]",
")",
"self",
".",
"_state",
"=",
"STATE_PAUSED"
] | [
169,
4
] | [
172,
34
] | python | en | ['en', 'en', 'en'] | True |
ZiggoMediaboxXLDevice.media_play_pause | (self) | Simulate play pause media player. | Simulate play pause media player. | def media_play_pause(self):
"""Simulate play pause media player."""
self.send_keys(["PAUSE"])
if self._state == STATE_PAUSED:
self._state = STATE_PLAYING
else:
self._state = STATE_PAUSED | [
"def",
"media_play_pause",
"(",
"self",
")",
":",
"self",
".",
"send_keys",
"(",
"[",
"\"PAUSE\"",
"]",
")",
"if",
"self",
".",
"_state",
"==",
"STATE_PAUSED",
":",
"self",
".",
"_state",
"=",
"STATE_PLAYING",
"else",
":",
"self",
".",
"_state",
"=",
"... | [
174,
4
] | [
180,
38
] | python | en | ['en', 'en', 'it'] | True |
ZiggoMediaboxXLDevice.media_next_track | (self) | Channel up. | Channel up. | def media_next_track(self):
"""Channel up."""
self.send_keys(["CHAN_UP"])
self._state = STATE_PLAYING | [
"def",
"media_next_track",
"(",
"self",
")",
":",
"self",
".",
"send_keys",
"(",
"[",
"\"CHAN_UP\"",
"]",
")",
"self",
".",
"_state",
"=",
"STATE_PLAYING"
] | [
182,
4
] | [
185,
35
] | python | en | ['it', 'en', 'en'] | False |
ZiggoMediaboxXLDevice.media_previous_track | (self) | Channel down. | Channel down. | def media_previous_track(self):
"""Channel down."""
self.send_keys(["CHAN_DOWN"])
self._state = STATE_PLAYING | [
"def",
"media_previous_track",
"(",
"self",
")",
":",
"self",
".",
"send_keys",
"(",
"[",
"\"CHAN_DOWN\"",
"]",
")",
"self",
".",
"_state",
"=",
"STATE_PLAYING"
] | [
187,
4
] | [
190,
35
] | python | en | ['it', 'en', 'en'] | False |
ZiggoMediaboxXLDevice.select_source | (self, source) | Select the channel. | Select the channel. | def select_source(self, source):
"""Select the channel."""
if str(source).isdigit():
digits = str(source)
else:
digits = next(
(
key
for key, value in self._mediabox.channels().items()
if value ==... | [
"def",
"select_source",
"(",
"self",
",",
"source",
")",
":",
"if",
"str",
"(",
"source",
")",
".",
"isdigit",
"(",
")",
":",
"digits",
"=",
"str",
"(",
"source",
")",
"else",
":",
"digits",
"=",
"next",
"(",
"(",
"key",
"for",
"key",
",",
"value... | [
192,
4
] | [
209,
35
] | python | en | ['en', 'en', 'en'] | True |
rhn_schema_version | (context) |
Function to parse the output of command ``/usr/bin/rhn-schema-version``.
Sample input::
5.6.0.10-2.el6sat
Examples:
>>> db_ver = shared[rhn_schema_version]
>>> db_ver
'5.6.0.10-2.el6sat'
|
Function to parse the output of command ``/usr/bin/rhn-schema-version``. | def rhn_schema_version(context):
"""
Function to parse the output of command ``/usr/bin/rhn-schema-version``.
Sample input::
5.6.0.10-2.el6sat
Examples:
>>> db_ver = shared[rhn_schema_version]
>>> db_ver
'5.6.0.10-2.el6sat'
"""
if context.content:
cont... | [
"def",
"rhn_schema_version",
"(",
"context",
")",
":",
"if",
"context",
".",
"content",
":",
"content",
"=",
"context",
".",
"content",
"if",
"len",
"(",
"content",
")",
"==",
"1",
"and",
"'No such'",
"not",
"in",
"content",
"[",
"0",
"]",
":",
"ver",
... | [
11,
0
] | [
30,
26
] | python | en | ['en', 'error', 'th'] | False |
test_open_close_update | (gogogate2api_mock, hass: HomeAssistant) | Test open and close and data update. | Test open and close and data update. | async def test_open_close_update(gogogate2api_mock, hass: HomeAssistant) -> None:
"""Test open and close and data update."""
def info_response(door_status: DoorStatus) -> GogoGate2InfoResponse:
return GogoGate2InfoResponse(
user="user1",
gogogatename="gogogatename0",
... | [
"async",
"def",
"test_open_close_update",
"(",
"gogogate2api_mock",
",",
"hass",
":",
"HomeAssistant",
")",
"->",
"None",
":",
"def",
"info_response",
"(",
"door_status",
":",
"DoorStatus",
")",
"->",
"GogoGate2InfoResponse",
":",
"return",
"GogoGate2InfoResponse",
... | [
56,
0
] | [
247,
51
] | python | en | ['en', 'en', 'en'] | True |
test_availability | (ismartgateapi_mock, hass: HomeAssistant) | Test availability. | Test availability. | async def test_availability(ismartgateapi_mock, hass: HomeAssistant) -> None:
"""Test availability."""
closed_door_response = _mocked_ismartgate_closed_door_response()
expected_attributes = {
"device_class": "garage",
"door_id": 1,
"friendly_name": "Door1",
"supported_featur... | [
"async",
"def",
"test_availability",
"(",
"ismartgateapi_mock",
",",
"hass",
":",
"HomeAssistant",
")",
"->",
"None",
":",
"closed_door_response",
"=",
"_mocked_ismartgate_closed_door_response",
"(",
")",
"expected_attributes",
"=",
"{",
"\"device_class\"",
":",
"\"gara... | [
251,
0
] | [
306,
81
] | python | en | ['fr', 'ga', 'en'] | False |
test_device_info_ismartgate | (ismartgateapi_mock, hass: HomeAssistant) | Test device info. | Test device info. | async def test_device_info_ismartgate(ismartgateapi_mock, hass: HomeAssistant) -> None:
"""Test device info."""
device_registry = mock_device_registry(hass)
closed_door_response = _mocked_ismartgate_closed_door_response()
api = MagicMock(ISmartGateApi)
api.async_info.return_value = closed_door_res... | [
"async",
"def",
"test_device_info_ismartgate",
"(",
"ismartgateapi_mock",
",",
"hass",
":",
"HomeAssistant",
")",
"->",
"None",
":",
"device_registry",
"=",
"mock_device_registry",
"(",
"hass",
")",
"closed_door_response",
"=",
"_mocked_ismartgate_closed_door_response",
"... | [
310,
0
] | [
341,
37
] | python | en | ['fr', 'pl', 'en'] | False |
test_device_info_gogogate2 | (gogogate2api_mock, hass: HomeAssistant) | Test device info. | Test device info. | async def test_device_info_gogogate2(gogogate2api_mock, hass: HomeAssistant) -> None:
"""Test device info."""
device_registry = mock_device_registry(hass)
closed_door_response = _mocked_gogogate_open_door_response()
api = MagicMock(GogoGate2Api)
api.async_info.return_value = closed_door_response
... | [
"async",
"def",
"test_device_info_gogogate2",
"(",
"gogogate2api_mock",
",",
"hass",
":",
"HomeAssistant",
")",
"->",
"None",
":",
"device_registry",
"=",
"mock_device_registry",
"(",
"hass",
")",
"closed_door_response",
"=",
"_mocked_gogogate_open_door_response",
"(",
... | [
345,
0
] | [
376,
37
] | python | en | ['fr', 'pl', 'en'] | False |
cli | (ctx, tab_file, analysis_id, organism_id, prop_type, feature_type="", match_on_name=False) | Load feature properties from a tabular file (Column1: feature name or uniquename, Column2: property value)
Output:
Number of inserted featureprop
| Load feature properties from a tabular file (Column1: feature name or uniquename, Column2: property value) | def cli(ctx, tab_file, analysis_id, organism_id, prop_type, feature_type="", match_on_name=False):
"""Load feature properties from a tabular file (Column1: feature name or uniquename, Column2: property value)
Output:
Number of inserted featureprop
"""
return ctx.gi.feature.load_featureprops(tab_file, ... | [
"def",
"cli",
"(",
"ctx",
",",
"tab_file",
",",
"analysis_id",
",",
"organism_id",
",",
"prop_type",
",",
"feature_type",
"=",
"\"\"",
",",
"match_on_name",
"=",
"False",
")",
":",
"return",
"ctx",
".",
"gi",
".",
"feature",
".",
"load_featureprops",
"(",
... | [
23,
0
] | [
30,
146
] | python | en | ['en', 'en', 'en'] | True |
aldb_data_fixture | () | Load the controller state fixture data. | Load the controller state fixture data. | def aldb_data_fixture():
"""Load the controller state fixture data."""
return json.loads(load_fixture("insteon/aldb_data.json")) | [
"def",
"aldb_data_fixture",
"(",
")",
":",
"return",
"json",
".",
"loads",
"(",
"load_fixture",
"(",
"\"insteon/aldb_data.json\"",
")",
")"
] | [
26,
0
] | [
28,
61
] | python | en | ['en', 'en', 'en'] | True |
_setup | (hass, hass_ws_client, aldb_data) | Set up tests. | Set up tests. | async def _setup(hass, hass_ws_client, aldb_data):
"""Set up tests."""
ws_client = await hass_ws_client(hass)
devices = MockDevices()
await devices.async_load()
async_load_api(hass)
devices.fill_aldb("33.33.33", aldb_data)
return ws_client, devices | [
"async",
"def",
"_setup",
"(",
"hass",
",",
"hass_ws_client",
",",
"aldb_data",
")",
":",
"ws_client",
"=",
"await",
"hass_ws_client",
"(",
"hass",
")",
"devices",
"=",
"MockDevices",
"(",
")",
"await",
"devices",
".",
"async_load",
"(",
")",
"async_load_api... | [
31,
0
] | [
38,
29
] | python | en | ['en', 'da', 'en'] | True |
_compare_records | (aldb_rec, dict_rec) | Compare a record in the ALDB to the dictionary record. | Compare a record in the ALDB to the dictionary record. | def _compare_records(aldb_rec, dict_rec):
"""Compare a record in the ALDB to the dictionary record."""
assert aldb_rec.is_in_use == dict_rec["in_use"]
assert aldb_rec.is_controller == (dict_rec["is_controller"])
assert not aldb_rec.is_high_water_mark
assert aldb_rec.group == dict_rec["group"]
as... | [
"def",
"_compare_records",
"(",
"aldb_rec",
",",
"dict_rec",
")",
":",
"assert",
"aldb_rec",
".",
"is_in_use",
"==",
"dict_rec",
"[",
"\"in_use\"",
"]",
"assert",
"aldb_rec",
".",
"is_controller",
"==",
"(",
"dict_rec",
"[",
"\"is_controller\"",
"]",
")",
"ass... | [
41,
0
] | [
50,
46
] | python | en | ['en', 'en', 'en'] | True |
_aldb_dict | (mem_addr) | Generate an ALDB record as a dictionary. | Generate an ALDB record as a dictionary. | def _aldb_dict(mem_addr):
"""Generate an ALDB record as a dictionary."""
return {
"mem_addr": mem_addr,
"in_use": True,
"is_controller": True,
"highwater": False,
"group": 100,
"target": "111111",
"data1": 101,
"data2": 102,
"data3": 103,
... | [
"def",
"_aldb_dict",
"(",
"mem_addr",
")",
":",
"return",
"{",
"\"mem_addr\"",
":",
"mem_addr",
",",
"\"in_use\"",
":",
"True",
",",
"\"is_controller\"",
":",
"True",
",",
"\"highwater\"",
":",
"False",
",",
"\"group\"",
":",
"100",
",",
"\"target\"",
":",
... | [
53,
0
] | [
66,
5
] | python | en | ['en', 'en', 'en'] | True |
test_get_aldb | (hass, hass_ws_client, aldb_data) | Test getting an Insteon device's All-Link Database. | Test getting an Insteon device's All-Link Database. | async def test_get_aldb(hass, hass_ws_client, aldb_data):
"""Test getting an Insteon device's All-Link Database."""
ws_client, devices = await _setup(hass, hass_ws_client, aldb_data)
with patch.object(insteon.api.aldb, "devices", devices):
await ws_client.send_json(
{ID: 2, TYPE: "inste... | [
"async",
"def",
"test_get_aldb",
"(",
"hass",
",",
"hass_ws_client",
",",
"aldb_data",
")",
":",
"ws_client",
",",
"devices",
"=",
"await",
"_setup",
"(",
"hass",
",",
"hass_ws_client",
",",
"aldb_data",
")",
"with",
"patch",
".",
"object",
"(",
"insteon",
... | [
69,
0
] | [
80,
31
] | python | en | ['de', 'en', 'en'] | True |
test_change_aldb_record | (hass, hass_ws_client, aldb_data) | Test changing an Insteon device's All-Link Database record. | Test changing an Insteon device's All-Link Database record. | async def test_change_aldb_record(hass, hass_ws_client, aldb_data):
"""Test changing an Insteon device's All-Link Database record."""
ws_client, devices = await _setup(hass, hass_ws_client, aldb_data)
change_rec = _aldb_dict(4079)
with patch.object(insteon.api.aldb, "devices", devices):
await w... | [
"async",
"def",
"test_change_aldb_record",
"(",
"hass",
",",
"hass_ws_client",
",",
"aldb_data",
")",
":",
"ws_client",
",",
"devices",
"=",
"await",
"_setup",
"(",
"hass",
",",
"hass_ws_client",
",",
"aldb_data",
")",
"change_rec",
"=",
"_aldb_dict",
"(",
"40... | [
83,
0
] | [
101,
41
] | python | en | ['en', 'en', 'en'] | True |
test_create_aldb_record | (hass, hass_ws_client, aldb_data) | Test creating a new Insteon All-Link Database record. | Test creating a new Insteon All-Link Database record. | async def test_create_aldb_record(hass, hass_ws_client, aldb_data):
"""Test creating a new Insteon All-Link Database record."""
ws_client, devices = await _setup(hass, hass_ws_client, aldb_data)
new_rec = _aldb_dict(4079)
with patch.object(insteon.api.aldb, "devices", devices):
await ws_client.... | [
"async",
"def",
"test_create_aldb_record",
"(",
"hass",
",",
"hass_ws_client",
",",
"aldb_data",
")",
":",
"ws_client",
",",
"devices",
"=",
"await",
"_setup",
"(",
"hass",
",",
"hass_ws_client",
",",
"aldb_data",
")",
"new_rec",
"=",
"_aldb_dict",
"(",
"4079"... | [
104,
0
] | [
122,
38
] | python | en | ['en', 'en', 'en'] | True |
test_write_aldb | (hass, hass_ws_client, aldb_data) | Test writing an Insteon device's All-Link Database. | Test writing an Insteon device's All-Link Database. | async def test_write_aldb(hass, hass_ws_client, aldb_data):
"""Test writing an Insteon device's All-Link Database."""
ws_client, devices = await _setup(hass, hass_ws_client, aldb_data)
with patch.object(insteon.api.aldb, "devices", devices):
await ws_client.send_json(
{
... | [
"async",
"def",
"test_write_aldb",
"(",
"hass",
",",
"hass_ws_client",
",",
"aldb_data",
")",
":",
"ws_client",
",",
"devices",
"=",
"await",
"_setup",
"(",
"hass",
",",
"hass_ws_client",
",",
"aldb_data",
")",
"with",
"patch",
".",
"object",
"(",
"insteon",... | [
125,
0
] | [
141,
49
] | python | en | ['en', 'en', 'en'] | True |
test_load_aldb | (hass, hass_ws_client, aldb_data) | Test loading an Insteon device's All-Link Database. | Test loading an Insteon device's All-Link Database. | async def test_load_aldb(hass, hass_ws_client, aldb_data):
"""Test loading an Insteon device's All-Link Database."""
ws_client, devices = await _setup(hass, hass_ws_client, aldb_data)
with patch.object(insteon.api.aldb, "devices", devices):
await ws_client.send_json(
{
I... | [
"async",
"def",
"test_load_aldb",
"(",
"hass",
",",
"hass_ws_client",
",",
"aldb_data",
")",
":",
"ws_client",
",",
"devices",
"=",
"await",
"_setup",
"(",
"hass",
",",
"hass_ws_client",
",",
"aldb_data",
")",
"with",
"patch",
".",
"object",
"(",
"insteon",
... | [
144,
0
] | [
159,
49
] | python | en | ['en', 'en', 'en'] | True |
test_reset_aldb | (hass, hass_ws_client, aldb_data) | Test resetting an Insteon device's All-Link Database. | Test resetting an Insteon device's All-Link Database. | async def test_reset_aldb(hass, hass_ws_client, aldb_data):
"""Test resetting an Insteon device's All-Link Database."""
ws_client, devices = await _setup(hass, hass_ws_client, aldb_data)
record = _aldb_dict(4079)
devices["33.33.33"].aldb.modify(
mem_addr=record["mem_addr"],
in_use=record... | [
"async",
"def",
"test_reset_aldb",
"(",
"hass",
",",
"hass_ws_client",
",",
"aldb_data",
")",
":",
"ws_client",
",",
"devices",
"=",
"await",
"_setup",
"(",
"hass",
",",
"hass_ws_client",
",",
"aldb_data",
")",
"record",
"=",
"_aldb_dict",
"(",
"4079",
")",
... | [
162,
0
] | [
188,
59
] | python | en | ['en', 'en', 'en'] | True |
test_default_links | (hass, hass_ws_client, aldb_data) | Test getting an Insteon device's All-Link Database. | Test getting an Insteon device's All-Link Database. | async def test_default_links(hass, hass_ws_client, aldb_data):
"""Test getting an Insteon device's All-Link Database."""
ws_client, devices = await _setup(hass, hass_ws_client, aldb_data)
with patch.object(insteon.api.aldb, "devices", devices):
await ws_client.send_json(
{
... | [
"async",
"def",
"test_default_links",
"(",
"hass",
",",
"hass_ws_client",
",",
"aldb_data",
")",
":",
"ws_client",
",",
"devices",
"=",
"await",
"_setup",
"(",
"hass",
",",
"hass_ws_client",
",",
"aldb_data",
")",
"with",
"patch",
".",
"object",
"(",
"insteo... | [
191,
0
] | [
207,
49
] | python | en | ['de', 'en', 'en'] | True |
test_notify_on_aldb_status | (hass, hass_ws_client, aldb_data) | Test getting an Insteon device's All-Link Database. | Test getting an Insteon device's All-Link Database. | async def test_notify_on_aldb_status(hass, hass_ws_client, aldb_data):
"""Test getting an Insteon device's All-Link Database."""
ws_client, devices = await _setup(hass, hass_ws_client, aldb_data)
with patch.object(insteon.api.aldb, "devices", devices):
await ws_client.send_json(
{
... | [
"async",
"def",
"test_notify_on_aldb_status",
"(",
"hass",
",",
"hass_ws_client",
",",
"aldb_data",
")",
":",
"ws_client",
",",
"devices",
"=",
"await",
"_setup",
"(",
"hass",
",",
"hass_ws_client",
",",
"aldb_data",
")",
"with",
"patch",
".",
"object",
"(",
... | [
210,
0
] | [
228,
45
] | python | en | ['de', 'en', 'en'] | True |
test_notify_on_aldb_record_added | (hass, hass_ws_client, aldb_data) | Test getting an Insteon device's All-Link Database. | Test getting an Insteon device's All-Link Database. | async def test_notify_on_aldb_record_added(hass, hass_ws_client, aldb_data):
"""Test getting an Insteon device's All-Link Database."""
ws_client, devices = await _setup(hass, hass_ws_client, aldb_data)
with patch.object(insteon.api.aldb, "devices", devices):
await ws_client.send_json(
{... | [
"async",
"def",
"test_notify_on_aldb_record_added",
"(",
"hass",
",",
"hass_ws_client",
",",
"aldb_data",
")",
":",
"ws_client",
",",
"devices",
"=",
"await",
"_setup",
"(",
"hass",
",",
"hass_ws_client",
",",
"aldb_data",
")",
"with",
"patch",
".",
"object",
... | [
231,
0
] | [
253,
54
] | python | en | ['de', 'en', 'en'] | True |
test_bad_address | (hass, hass_ws_client, aldb_data) | Test for a bad Insteon address. | Test for a bad Insteon address. | async def test_bad_address(hass, hass_ws_client, aldb_data):
"""Test for a bad Insteon address."""
ws_client, _ = await _setup(hass, hass_ws_client, aldb_data)
record = _aldb_dict(0)
ws_id = 0
for call in ["get", "write", "load", "reset", "add_default_links", "notify"]:
ws_id += 1
a... | [
"async",
"def",
"test_bad_address",
"(",
"hass",
",",
"hass_ws_client",
",",
"aldb_data",
")",
":",
"ws_client",
",",
"_",
"=",
"await",
"_setup",
"(",
"hass",
",",
"hass_ws_client",
",",
"aldb_data",
")",
"record",
"=",
"_aldb_dict",
"(",
"0",
")",
"ws_id... | [
256,
0
] | [
287,
66
] | python | en | ['en', 'en', 'en'] | True |
_component_to_unique_id | (server_id: str, component: str, instance_num: int) | Convert a component to a unique_id. | Convert a component to a unique_id. | def _component_to_unique_id(server_id: str, component: str, instance_num: int) -> str:
"""Convert a component to a unique_id."""
return get_hyperion_unique_id(
server_id,
instance_num,
slugify(
f"{TYPE_HYPERION_COMPONENT_SWITCH_BASE} {KEY_COMPONENTID_TO_NAME[component]}"
... | [
"def",
"_component_to_unique_id",
"(",
"server_id",
":",
"str",
",",
"component",
":",
"str",
",",
"instance_num",
":",
"int",
")",
"->",
"str",
":",
"return",
"get_hyperion_unique_id",
"(",
"server_id",
",",
"instance_num",
",",
"slugify",
"(",
"f\"{TYPE_HYPERI... | [
64,
0
] | [
72,
5
] | python | en | ['en', 'ca', 'en'] | True |
_component_to_switch_name | (component: str, instance_name: str) | Convert a component to a switch name. | Convert a component to a switch name. | def _component_to_switch_name(component: str, instance_name: str) -> str:
"""Convert a component to a switch name."""
return (
f"{instance_name} "
f"{NAME_SUFFIX_HYPERION_COMPONENT_SWITCH} "
f"{KEY_COMPONENTID_TO_NAME.get(component, component.capitalize())}"
) | [
"def",
"_component_to_switch_name",
"(",
"component",
":",
"str",
",",
"instance_name",
":",
"str",
")",
"->",
"str",
":",
"return",
"(",
"f\"{instance_name} \"",
"f\"{NAME_SUFFIX_HYPERION_COMPONENT_SWITCH} \"",
"f\"{KEY_COMPONENTID_TO_NAME.get(component, component.capitalize())}... | [
75,
0
] | [
81,
5
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) | Set up a Hyperion platform from config entry. | Set up a Hyperion platform from config entry. | async def async_setup_entry(
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> bool:
"""Set up a Hyperion platform from config entry."""
entry_data = hass.data[DOMAIN][config_entry.entry_id]
server_id = config_entry.unique_id
@callback
def ins... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"config_entry",
":",
"ConfigEntry",
",",
"async_add_entities",
":",
"AddEntitiesCallback",
",",
")",
"->",
"bool",
":",
"entry_data",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"["... | [
84,
0
] | [
123,
15
] | python | en | ['en', 'en', 'en'] | True |
HyperionComponentSwitch.__init__ | (
self,
server_id: str,
instance_num: int,
instance_name: str,
component_name: str,
hyperion_client: client.HyperionClient,
) | Initialize the switch. | Initialize the switch. | def __init__(
self,
server_id: str,
instance_num: int,
instance_name: str,
component_name: str,
hyperion_client: client.HyperionClient,
) -> None:
"""Initialize the switch."""
self._unique_id = _component_to_unique_id(
server_id, component_... | [
"def",
"__init__",
"(",
"self",
",",
"server_id",
":",
"str",
",",
"instance_num",
":",
"int",
",",
"instance_name",
":",
"str",
",",
"component_name",
":",
"str",
",",
"hyperion_client",
":",
"client",
".",
"HyperionClient",
",",
")",
"->",
"None",
":",
... | [
129,
4
] | [
148,
9
] | python | en | ['en', 'en', 'en'] | True |
HyperionComponentSwitch.should_poll | (self) | Return whether or not this entity should be polled. | Return whether or not this entity should be polled. | def should_poll(self) -> bool:
"""Return whether or not this entity should be polled."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"False"
] | [
151,
4
] | [
153,
20
] | python | en | ['en', 'en', 'en'] | True |
HyperionComponentSwitch.entity_registry_enabled_default | (self) | Whether or not the entity is enabled by default. | Whether or not the entity is enabled by default. | def entity_registry_enabled_default(self) -> bool:
"""Whether or not the entity is enabled by default."""
# These component controls are for advanced users and are disabled by default.
return False | [
"def",
"entity_registry_enabled_default",
"(",
"self",
")",
"->",
"bool",
":",
"# These component controls are for advanced users and are disabled by default.",
"return",
"False"
] | [
156,
4
] | [
159,
20
] | python | en | ['en', 'en', 'en'] | True |
HyperionComponentSwitch.unique_id | (self) | Return a unique id for this instance. | Return a unique id for this instance. | def unique_id(self) -> str:
"""Return a unique id for this instance."""
return self._unique_id | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_unique_id"
] | [
162,
4
] | [
164,
30
] | python | en | ['en', 'en', 'en'] | True |
HyperionComponentSwitch.name | (self) | Return the name of the switch. | Return the name of the switch. | def name(self) -> str:
"""Return the name of the switch."""
return self._name | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_name"
] | [
167,
4
] | [
169,
25
] | python | en | ['en', 'en', 'en'] | True |
HyperionComponentSwitch.is_on | (self) | Return true if the switch is on. | Return true if the switch is on. | def is_on(self) -> bool:
"""Return true if the switch is on."""
for component in self._client.components or []:
if component[KEY_NAME] == self._component_name:
return bool(component.setdefault(KEY_ENABLED, False))
return False | [
"def",
"is_on",
"(",
"self",
")",
"->",
"bool",
":",
"for",
"component",
"in",
"self",
".",
"_client",
".",
"components",
"or",
"[",
"]",
":",
"if",
"component",
"[",
"KEY_NAME",
"]",
"==",
"self",
".",
"_component_name",
":",
"return",
"bool",
"(",
... | [
172,
4
] | [
177,
20
] | python | en | ['en', 'en', 'en'] | True |
HyperionComponentSwitch.available | (self) | Return server availability. | Return server availability. | def available(self) -> bool:
"""Return server availability."""
return bool(self._client.has_loaded_state) | [
"def",
"available",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"bool",
"(",
"self",
".",
"_client",
".",
"has_loaded_state",
")"
] | [
180,
4
] | [
182,
50
] | python | en | ['fr', 'ga', 'en'] | False |
HyperionComponentSwitch.device_info | (self) | Return device information. | Return device information. | def device_info(self) -> DeviceInfo:
"""Return device information."""
return {
"identifiers": {(DOMAIN, self._device_id)},
"name": self._instance_name,
"manufacturer": HYPERION_MANUFACTURER_NAME,
"model": HYPERION_MODEL_NAME,
} | [
"def",
"device_info",
"(",
"self",
")",
"->",
"DeviceInfo",
":",
"return",
"{",
"\"identifiers\"",
":",
"{",
"(",
"DOMAIN",
",",
"self",
".",
"_device_id",
")",
"}",
",",
"\"name\"",
":",
"self",
".",
"_instance_name",
",",
"\"manufacturer\"",
":",
"HYPERI... | [
185,
4
] | [
192,
9
] | python | da | ['es', 'da', 'en'] | False |
HyperionComponentSwitch._async_send_set_component | (self, value: bool) | Send a component control request. | Send a component control request. | async def _async_send_set_component(self, value: bool) -> None:
"""Send a component control request."""
await self._client.async_send_set_component(
**{
KEY_COMPONENTSTATE: {
KEY_COMPONENT: self._component_name,
KEY_STATE: value,
... | [
"async",
"def",
"_async_send_set_component",
"(",
"self",
",",
"value",
":",
"bool",
")",
"->",
"None",
":",
"await",
"self",
".",
"_client",
".",
"async_send_set_component",
"(",
"*",
"*",
"{",
"KEY_COMPONENTSTATE",
":",
"{",
"KEY_COMPONENT",
":",
"self",
"... | [
194,
4
] | [
203,
9
] | python | en | ['en', 'ca', 'en'] | True |
HyperionComponentSwitch.async_turn_on | (self, **kwargs: Any) | Turn on the switch. | Turn on the switch. | async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn on the switch."""
await self._async_send_set_component(True) | [
"async",
"def",
"async_turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"None",
":",
"await",
"self",
".",
"_async_send_set_component",
"(",
"True",
")"
] | [
205,
4
] | [
207,
50
] | python | en | ['en', 'en', 'en'] | True |
HyperionComponentSwitch.async_turn_off | (self, **kwargs: Any) | Turn off the switch. | Turn off the switch. | async def async_turn_off(self, **kwargs: Any) -> None:
"""Turn off the switch."""
await self._async_send_set_component(False) | [
"async",
"def",
"async_turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"None",
":",
"await",
"self",
".",
"_async_send_set_component",
"(",
"False",
")"
] | [
209,
4
] | [
211,
51
] | python | en | ['en', 'en', 'en'] | True |
HyperionComponentSwitch._update_components | (self, _: dict[str, Any] | None = None) | Update Hyperion components. | Update Hyperion components. | def _update_components(self, _: dict[str, Any] | None = None) -> None:
"""Update Hyperion components."""
self.async_write_ha_state() | [
"def",
"_update_components",
"(",
"self",
",",
"_",
":",
"dict",
"[",
"str",
",",
"Any",
"]",
"|",
"None",
"=",
"None",
")",
"->",
"None",
":",
"self",
".",
"async_write_ha_state",
"(",
")"
] | [
214,
4
] | [
216,
35
] | python | en | ['de', 'en', 'en'] | True |
HyperionComponentSwitch.async_added_to_hass | (self) | Register callbacks when entity added to hass. | Register callbacks when entity added to hass. | async def async_added_to_hass(self) -> None:
"""Register callbacks when entity added to hass."""
self.async_on_remove(
async_dispatcher_connect(
self.hass,
SIGNAL_ENTITY_REMOVE.format(self._unique_id),
functools.partial(self.async_remove, force... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"async_on_remove",
"(",
"async_dispatcher_connect",
"(",
"self",
".",
"hass",
",",
"SIGNAL_ENTITY_REMOVE",
".",
"format",
"(",
"self",
".",
"_unique_id",
")",
",",
"functo... | [
218,
4
] | [
228,
58
] | python | en | ['en', 'en', 'en'] | True |
HyperionComponentSwitch.async_will_remove_from_hass | (self) | Cleanup prior to hass removal. | Cleanup prior to hass removal. | async def async_will_remove_from_hass(self) -> None:
"""Cleanup prior to hass removal."""
self._client.remove_callbacks(self._client_callbacks) | [
"async",
"def",
"async_will_remove_from_hass",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"_client",
".",
"remove_callbacks",
"(",
"self",
".",
"_client_callbacks",
")"
] | [
230,
4
] | [
232,
61
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (
hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities
) | Set up the HomematicIP weather sensor from a config entry. | Set up the HomematicIP weather sensor from a config entry. | async def async_setup_entry(
hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities
) -> None:
"""Set up the HomematicIP weather sensor from a config entry."""
hap = hass.data[HMIPC_DOMAIN][config_entry.unique_id]
entities: list[HomematicipGenericEntity] = []
for device in hap.home.devic... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"config_entry",
":",
"ConfigEntry",
",",
"async_add_entities",
")",
"->",
"None",
":",
"hap",
"=",
"hass",
".",
"data",
"[",
"HMIPC_DOMAIN",
"]",
"[",
"config_entry",
".",
"unique_id"... | [
49,
0
] | [
64,
36
] | python | en | ['en', 'en', 'en'] | True |
HomematicipWeatherSensor.__init__ | (self, hap: HomematicipHAP, device) | Initialize the weather sensor. | Initialize the weather sensor. | def __init__(self, hap: HomematicipHAP, device) -> None:
"""Initialize the weather sensor."""
super().__init__(hap, device) | [
"def",
"__init__",
"(",
"self",
",",
"hap",
":",
"HomematicipHAP",
",",
"device",
")",
"->",
"None",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"hap",
",",
"device",
")"
] | [
70,
4
] | [
72,
37
] | python | en | ['en', 'en', 'en'] | True |
HomematicipWeatherSensor.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self) -> str:
"""Return the name of the sensor."""
return self._device.label | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_device",
".",
"label"
] | [
75,
4
] | [
77,
33
] | python | en | ['en', 'mi', 'en'] | True |
HomematicipWeatherSensor.temperature | (self) | Return the platform temperature. | Return the platform temperature. | def temperature(self) -> float:
"""Return the platform temperature."""
return self._device.actualTemperature | [
"def",
"temperature",
"(",
"self",
")",
"->",
"float",
":",
"return",
"self",
".",
"_device",
".",
"actualTemperature"
] | [
80,
4
] | [
82,
45
] | python | en | ['en', 'la', 'en'] | True |
HomematicipWeatherSensor.temperature_unit | (self) | Return the unit of measurement. | Return the unit of measurement. | def temperature_unit(self) -> str:
"""Return the unit of measurement."""
return TEMP_CELSIUS | [
"def",
"temperature_unit",
"(",
"self",
")",
"->",
"str",
":",
"return",
"TEMP_CELSIUS"
] | [
85,
4
] | [
87,
27
] | python | en | ['en', 'la', 'en'] | True |
HomematicipWeatherSensor.humidity | (self) | Return the humidity. | Return the humidity. | def humidity(self) -> int:
"""Return the humidity."""
return self._device.humidity | [
"def",
"humidity",
"(",
"self",
")",
"->",
"int",
":",
"return",
"self",
".",
"_device",
".",
"humidity"
] | [
90,
4
] | [
92,
36
] | python | en | ['en', 'sw', 'en'] | True |
HomematicipWeatherSensor.wind_speed | (self) | Return the wind speed. | Return the wind speed. | def wind_speed(self) -> float:
"""Return the wind speed."""
return self._device.windSpeed | [
"def",
"wind_speed",
"(",
"self",
")",
"->",
"float",
":",
"return",
"self",
".",
"_device",
".",
"windSpeed"
] | [
95,
4
] | [
97,
37
] | python | en | ['en', 'zh', 'en'] | True |
HomematicipWeatherSensor.attribution | (self) | Return the attribution. | Return the attribution. | def attribution(self) -> str:
"""Return the attribution."""
return "Powered by Homematic IP" | [
"def",
"attribution",
"(",
"self",
")",
"->",
"str",
":",
"return",
"\"Powered by Homematic IP\""
] | [
100,
4
] | [
102,
40
] | python | en | ['en', 'ja', 'en'] | True |
HomematicipWeatherSensor.condition | (self) | Return the current condition. | Return the current condition. | def condition(self) -> str:
"""Return the current condition."""
if getattr(self._device, "raining", None):
return ATTR_CONDITION_RAINY
if self._device.storm:
return ATTR_CONDITION_WINDY
if self._device.sunshine:
return ATTR_CONDITION_SUNNY
retu... | [
"def",
"condition",
"(",
"self",
")",
"->",
"str",
":",
"if",
"getattr",
"(",
"self",
".",
"_device",
",",
"\"raining\"",
",",
"None",
")",
":",
"return",
"ATTR_CONDITION_RAINY",
"if",
"self",
".",
"_device",
".",
"storm",
":",
"return",
"ATTR_CONDITION_WI... | [
105,
4
] | [
113,
17
] | python | en | ['en', 'en', 'en'] | True |
HomematicipWeatherSensorPro.wind_bearing | (self) | Return the wind bearing. | Return the wind bearing. | def wind_bearing(self) -> float:
"""Return the wind bearing."""
return self._device.windDirection | [
"def",
"wind_bearing",
"(",
"self",
")",
"->",
"float",
":",
"return",
"self",
".",
"_device",
".",
"windDirection"
] | [
120,
4
] | [
122,
41
] | python | en | ['en', 'ig', 'en'] | True |
HomematicipHomeWeather.__init__ | (self, hap: HomematicipHAP) | Initialize the home weather. | Initialize the home weather. | def __init__(self, hap: HomematicipHAP) -> None:
"""Initialize the home weather."""
hap.home.modelType = "HmIP-Home-Weather"
super().__init__(hap, hap.home) | [
"def",
"__init__",
"(",
"self",
",",
"hap",
":",
"HomematicipHAP",
")",
"->",
"None",
":",
"hap",
".",
"home",
".",
"modelType",
"=",
"\"HmIP-Home-Weather\"",
"super",
"(",
")",
".",
"__init__",
"(",
"hap",
",",
"hap",
".",
"home",
")"
] | [
128,
4
] | [
131,
39
] | python | en | ['en', 'en', 'en'] | True |
HomematicipHomeWeather.available | (self) | Return if weather entity is available. | Return if weather entity is available. | def available(self) -> bool:
"""Return if weather entity is available."""
return self._home.connected | [
"def",
"available",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"_home",
".",
"connected"
] | [
134,
4
] | [
136,
35
] | python | en | ['en', 'en', 'en'] | True |
HomematicipHomeWeather.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self) -> str:
"""Return the name of the sensor."""
return f"Weather {self._home.location.city}" | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"return",
"f\"Weather {self._home.location.city}\""
] | [
139,
4
] | [
141,
52
] | python | en | ['en', 'mi', 'en'] | True |
HomematicipHomeWeather.temperature | (self) | Return the temperature. | Return the temperature. | def temperature(self) -> float:
"""Return the temperature."""
return self._device.weather.temperature | [
"def",
"temperature",
"(",
"self",
")",
"->",
"float",
":",
"return",
"self",
".",
"_device",
".",
"weather",
".",
"temperature"
] | [
144,
4
] | [
146,
47
] | python | en | ['en', 'la', 'en'] | True |
HomematicipHomeWeather.temperature_unit | (self) | Return the unit of measurement. | Return the unit of measurement. | def temperature_unit(self) -> str:
"""Return the unit of measurement."""
return TEMP_CELSIUS | [
"def",
"temperature_unit",
"(",
"self",
")",
"->",
"str",
":",
"return",
"TEMP_CELSIUS"
] | [
149,
4
] | [
151,
27
] | python | en | ['en', 'la', 'en'] | True |
HomematicipHomeWeather.humidity | (self) | Return the humidity. | Return the humidity. | def humidity(self) -> int:
"""Return the humidity."""
return self._device.weather.humidity | [
"def",
"humidity",
"(",
"self",
")",
"->",
"int",
":",
"return",
"self",
".",
"_device",
".",
"weather",
".",
"humidity"
] | [
154,
4
] | [
156,
44
] | python | en | ['en', 'sw', 'en'] | True |
HomematicipHomeWeather.wind_speed | (self) | Return the wind speed. | Return the wind speed. | def wind_speed(self) -> float:
"""Return the wind speed."""
return round(self._device.weather.windSpeed, 1) | [
"def",
"wind_speed",
"(",
"self",
")",
"->",
"float",
":",
"return",
"round",
"(",
"self",
".",
"_device",
".",
"weather",
".",
"windSpeed",
",",
"1",
")"
] | [
159,
4
] | [
161,
55
] | python | en | ['en', 'zh', 'en'] | True |
HomematicipHomeWeather.wind_bearing | (self) | Return the wind bearing. | Return the wind bearing. | def wind_bearing(self) -> float:
"""Return the wind bearing."""
return self._device.weather.windDirection | [
"def",
"wind_bearing",
"(",
"self",
")",
"->",
"float",
":",
"return",
"self",
".",
"_device",
".",
"weather",
".",
"windDirection"
] | [
164,
4
] | [
166,
49
] | python | en | ['en', 'ig', 'en'] | True |
HomematicipHomeWeather.attribution | (self) | Return the attribution. | Return the attribution. | def attribution(self) -> str:
"""Return the attribution."""
return "Powered by Homematic IP" | [
"def",
"attribution",
"(",
"self",
")",
"->",
"str",
":",
"return",
"\"Powered by Homematic IP\""
] | [
169,
4
] | [
171,
40
] | python | en | ['en', 'ja', 'en'] | True |
HomematicipHomeWeather.condition | (self) | Return the current condition. | Return the current condition. | def condition(self) -> str | None:
"""Return the current condition."""
return HOME_WEATHER_CONDITION.get(self._device.weather.weatherCondition) | [
"def",
"condition",
"(",
"self",
")",
"->",
"str",
"|",
"None",
":",
"return",
"HOME_WEATHER_CONDITION",
".",
"get",
"(",
"self",
".",
"_device",
".",
"weather",
".",
"weatherCondition",
")"
] | [
174,
4
] | [
176,
80
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, entry, async_add_entities) | Set up the Tibber sensor. | Set up the Tibber sensor. | async def async_setup_entry(hass, entry, async_add_entities):
"""Set up the Tibber sensor."""
tibber_connection = hass.data.get(TIBBER_DOMAIN)
entity_registry = async_get_entity_reg(hass)
device_registry = async_get_dev_reg(hass)
entities = []
for home in tibber_connection.get_homes(only_acti... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"entry",
",",
"async_add_entities",
")",
":",
"tibber_connection",
"=",
"hass",
".",
"data",
".",
"get",
"(",
"TIBBER_DOMAIN",
")",
"entity_registry",
"=",
"async_get_entity_reg",
"(",
"hass",
")",
"device_r... | [
196,
0
] | [
245,
38
] | python | en | ['en', 'da', 'en'] | True |
TibberSensor.__init__ | (self, *args, tibber_home, **kwargs) | Initialize the sensor. | Initialize the sensor. | def __init__(self, *args, tibber_home, **kwargs):
"""Initialize the sensor."""
super().__init__(*args, **kwargs)
self._tibber_home = tibber_home
self._home_name = tibber_home.info["viewer"]["home"]["appNickname"]
if self._home_name is None:
self._home_name = tibber_ho... | [
"def",
"__init__",
"(",
"self",
",",
"*",
"args",
",",
"tibber_home",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"self",
".",
"_tibber_home",
"=",
"tibber_home",
"self",
".... | [
251,
4
] | [
261,
26
] | python | en | ['en', 'en', 'en'] | True |
TibberSensor.device_info | (self) | Return the device_info of the device. | Return the device_info of the device. | def device_info(self):
"""Return the device_info of the device."""
device_info = {
"identifiers": {(TIBBER_DOMAIN, self._tibber_home.home_id)},
"name": self._device_name,
"manufacturer": MANUFACTURER,
}
if self._model is not None:
device_in... | [
"def",
"device_info",
"(",
"self",
")",
":",
"device_info",
"=",
"{",
"\"identifiers\"",
":",
"{",
"(",
"TIBBER_DOMAIN",
",",
"self",
".",
"_tibber_home",
".",
"home_id",
")",
"}",
",",
"\"name\"",
":",
"self",
".",
"_device_name",
",",
"\"manufacturer\"",
... | [
264,
4
] | [
273,
26
] | python | en | ['en', 'en', 'en'] | True |
TibberSensorElPrice.__init__ | (self, tibber_home) | Initialize the sensor. | Initialize the sensor. | def __init__(self, tibber_home):
"""Initialize the sensor."""
super().__init__(tibber_home=tibber_home)
self._last_updated = None
self._spread_load_constant = randrange(5000)
self._attr_available = False
self._attr_extra_state_attributes = {
"app_nickname": N... | [
"def",
"__init__",
"(",
"self",
",",
"tibber_home",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"tibber_home",
"=",
"tibber_home",
")",
"self",
".",
"_last_updated",
"=",
"None",
"self",
".",
"_spread_load_constant",
"=",
"randrange",
"(",
"5000",
"... | [
279,
4
] | [
303,
43
] | python | en | ['en', 'en', 'en'] | True |
TibberSensorElPrice.async_update | (self) | Get the latest data and updates the states. | Get the latest data and updates the states. | async def async_update(self):
"""Get the latest data and updates the states."""
now = dt_util.now()
if (
not self._tibber_home.last_data_timestamp
or (self._tibber_home.last_data_timestamp - now).total_seconds()
< 5 * 3600 + self._spread_load_constant
... | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"now",
"=",
"dt_util",
".",
"now",
"(",
")",
"if",
"(",
"not",
"self",
".",
"_tibber_home",
".",
"last_data_timestamp",
"or",
"(",
"self",
".",
"_tibber_home",
".",
"last_data_timestamp",
"-",
"now",
... | [
305,
4
] | [
332,
76
] | python | en | ['en', 'en', 'en'] | True |
TibberSensorRT.__init__ | (
self,
tibber_home,
description: SensorEntityDescription,
initial_state,
coordinator: TibberRtDataCoordinator,
) | Initialize the sensor. | Initialize the sensor. | def __init__(
self,
tibber_home,
description: SensorEntityDescription,
initial_state,
coordinator: TibberRtDataCoordinator,
):
"""Initialize the sensor."""
super().__init__(coordinator=coordinator, tibber_home=tibber_home)
self.entity_description = des... | [
"def",
"__init__",
"(",
"self",
",",
"tibber_home",
",",
"description",
":",
"SensorEntityDescription",
",",
"initial_state",
",",
"coordinator",
":",
"TibberRtDataCoordinator",
",",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"coordinator",
"=",
"coordin... | [
354,
4
] | [
372,
72
] | python | en | ['en', 'en', 'en'] | True |
TibberSensorRT.available | (self) | Return True if entity is available. | Return True if entity is available. | def available(self):
"""Return True if entity is available."""
return self._tibber_home.rt_subscription_running | [
"def",
"available",
"(",
"self",
")",
":",
"return",
"self",
".",
"_tibber_home",
".",
"rt_subscription_running"
] | [
375,
4
] | [
377,
56
] | python | en | ['en', 'en', 'en'] | True |
TibberRtDataCoordinator.__init__ | (self, async_add_entities, tibber_home, hass) | Initialize the data handler. | Initialize the data handler. | def __init__(self, async_add_entities, tibber_home, hass):
"""Initialize the data handler."""
self._async_add_entities = async_add_entities
self._tibber_home = tibber_home
self.hass = hass
self._added_sensors = set()
super().__init__(
hass,
_LOGGER... | [
"def",
"__init__",
"(",
"self",
",",
"async_add_entities",
",",
"tibber_home",
",",
"hass",
")",
":",
"self",
".",
"_async_add_entities",
"=",
"async_add_entities",
"self",
".",
"_tibber_home",
"=",
"tibber_home",
"self",
".",
"hass",
"=",
"hass",
"self",
".",... | [
395,
4
] | [
412,
82
] | python | en | ['en', 'en', 'en'] | True |
TibberRtDataCoordinator._handle_ha_stop | (self, _event) | Handle Home Assistant stopping. | Handle Home Assistant stopping. | def _handle_ha_stop(self, _event) -> None:
"""Handle Home Assistant stopping."""
self._async_remove_device_updates_handler() | [
"def",
"_handle_ha_stop",
"(",
"self",
",",
"_event",
")",
"->",
"None",
":",
"self",
".",
"_async_remove_device_updates_handler",
"(",
")"
] | [
415,
4
] | [
417,
51
] | python | en | ['fr', 'en', 'en'] | True |
TibberRtDataCoordinator._add_sensors | (self) | Add sensor. | Add sensor. | def _add_sensors(self):
"""Add sensor."""
if not (live_measurement := self.get_live_measurement()):
return
new_entities = []
for sensor_description in RT_SENSORS:
if sensor_description.key in self._added_sensors:
continue
state = live_... | [
"def",
"_add_sensors",
"(",
"self",
")",
":",
"if",
"not",
"(",
"live_measurement",
":=",
"self",
".",
"get_live_measurement",
"(",
")",
")",
":",
"return",
"new_entities",
"=",
"[",
"]",
"for",
"sensor_description",
"in",
"RT_SENSORS",
":",
"if",
"sensor_de... | [
420,
4
] | [
441,
50
] | python | en | ['en', 'bg', 'en'] | False |
TibberRtDataCoordinator.get_live_measurement | (self) | Get live measurement data. | Get live measurement data. | def get_live_measurement(self):
"""Get live measurement data."""
errors = self.data.get("errors")
if errors:
_LOGGER.error(errors[0])
return None
return self.data.get("data", {}).get("liveMeasurement") | [
"def",
"get_live_measurement",
"(",
"self",
")",
":",
"errors",
"=",
"self",
".",
"data",
".",
"get",
"(",
"\"errors\"",
")",
"if",
"errors",
":",
"_LOGGER",
".",
"error",
"(",
"errors",
"[",
"0",
"]",
")",
"return",
"None",
"return",
"self",
".",
"d... | [
443,
4
] | [
449,
63
] | python | ca | ['fr', 'ca', 'en'] | False |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Wink platform. | Set up the Wink platform. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Wink platform."""
for switch in pywink.get_switches():
_id = switch.object_id() + switch.name()
if _id not in hass.data[DOMAIN]["unique_ids"]:
add_entities([WinkToggleDevice(switch, hass)])
for sw... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"for",
"switch",
"in",
"pywink",
".",
"get_switches",
"(",
")",
":",
"_id",
"=",
"switch",
".",
"object_id",
"(",
")",
"+",
"switch",
... | [
8,
0
] | [
26,
58
] | python | en | ['en', 'da', 'en'] | True |
WinkToggleDevice.async_added_to_hass | (self) | Call when entity is added to hass. | Call when entity is added to hass. | async def async_added_to_hass(self):
"""Call when entity is added to hass."""
self.hass.data[DOMAIN]["entities"]["switch"].append(self) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"\"entities\"",
"]",
"[",
"\"switch\"",
"]",
".",
"append",
"(",
"self",
")"
] | [
32,
4
] | [
34,
65
] | python | en | ['en', 'en', 'en'] | True |
WinkToggleDevice.is_on | (self) | Return true if device is on. | Return true if device is on. | def is_on(self):
"""Return true if device is on."""
return self.wink.state() | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"wink",
".",
"state",
"(",
")"
] | [
37,
4
] | [
39,
32
] | python | en | ['en', 'fy', 'en'] | True |
WinkToggleDevice.turn_on | (self, **kwargs) | Turn the device on. | Turn the device on. | def turn_on(self, **kwargs):
"""Turn the device on."""
self.wink.set_state(True) | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"wink",
".",
"set_state",
"(",
"True",
")"
] | [
41,
4
] | [
43,
33
] | python | en | ['en', 'en', 'en'] | True |
WinkToggleDevice.turn_off | (self, **kwargs) | Turn the device off. | Turn the device off. | def turn_off(self, **kwargs):
"""Turn the device off."""
self.wink.set_state(False) | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"wink",
".",
"set_state",
"(",
"False",
")"
] | [
45,
4
] | [
47,
34
] | python | en | ['en', 'en', 'en'] | True |
WinkToggleDevice.extra_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def extra_state_attributes(self):
"""Return the state attributes."""
attributes = super().extra_state_attributes
try:
event = self.wink.last_event()
if event is not None:
attributes["last_event"] = event
except AttributeError:
pass
... | [
"def",
"extra_state_attributes",
"(",
"self",
")",
":",
"attributes",
"=",
"super",
"(",
")",
".",
"extra_state_attributes",
"try",
":",
"event",
"=",
"self",
".",
"wink",
".",
"last_event",
"(",
")",
"if",
"event",
"is",
"not",
"None",
":",
"attributes",
... | [
50,
4
] | [
59,
25
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass, config) | Activate the Alexa component. | Activate the Alexa component. | async def async_setup(hass, config):
"""Activate the Alexa component."""
if DOMAIN not in config:
return True
config = config[DOMAIN]
flash_briefings_config = config.get(CONF_FLASH_BRIEFINGS)
intent.async_setup(hass)
if flash_briefings_config:
flash_briefings.async_setup(hass... | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"if",
"DOMAIN",
"not",
"in",
"config",
":",
"return",
"True",
"config",
"=",
"config",
"[",
"DOMAIN",
"]",
"flash_briefings_config",
"=",
"config",
".",
"get",
"(",
"CONF_FLASH_BRIEFINGS",
... | [
80,
0
] | [
102,
15
] | python | en | ['en', 'en', 'en'] | True |
setup | (hass, config) | Set up is called when Home Assistant is loading our component. | Set up is called when Home Assistant is loading our component. | def setup(hass, config):
"""Set up is called when Home Assistant is loading our component."""
dominos = Dominos(hass, config)
component = EntityComponent(_LOGGER, DOMAIN, hass)
hass.data[DOMAIN] = {}
entities = []
conf = config[DOMAIN]
hass.services.register(DOMAIN, "order", dominos.handle... | [
"def",
"setup",
"(",
"hass",
",",
"config",
")",
":",
"dominos",
"=",
"Dominos",
"(",
"hass",
",",
"config",
")",
"component",
"=",
"EntityComponent",
"(",
"_LOGGER",
",",
"DOMAIN",
",",
"hass",
")",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"=",
"{",... | [
64,
0
] | [
86,
15
] | python | en | ['en', 'en', 'en'] | True |
Dominos.__init__ | (self, hass, config) | Set up main service. | Set up main service. | def __init__(self, hass, config):
"""Set up main service."""
conf = config[DOMAIN]
self.hass = hass
self.customer = Customer(
conf.get(ATTR_FIRST_NAME),
conf.get(ATTR_LAST_NAME),
conf.get(ATTR_EMAIL),
conf.get(ATTR_PHONE),
conf... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"config",
")",
":",
"conf",
"=",
"config",
"[",
"DOMAIN",
"]",
"self",
".",
"hass",
"=",
"hass",
"self",
".",
"customer",
"=",
"Customer",
"(",
"conf",
".",
"get",
"(",
"ATTR_FIRST_NAME",
")",
",",
... | [
92,
4
] | [
111,
37
] | python | en | ['en', 'su', 'en'] | True |
Dominos.handle_order | (self, call) | Handle ordering pizza. | Handle ordering pizza. | def handle_order(self, call):
"""Handle ordering pizza."""
entity_ids = call.data.get(ATTR_ORDER_ENTITY)
target_orders = [
order
for order in self.hass.data[DOMAIN]["entities"]
if order.entity_id in entity_ids
]
for order in target_orders:
... | [
"def",
"handle_order",
"(",
"self",
",",
"call",
")",
":",
"entity_ids",
"=",
"call",
".",
"data",
".",
"get",
"(",
"ATTR_ORDER_ENTITY",
")",
"target_orders",
"=",
"[",
"order",
"for",
"order",
"in",
"self",
".",
"hass",
".",
"data",
"[",
"DOMAIN",
"]"... | [
113,
4
] | [
124,
25
] | python | en | ['mt', 'en', 'en'] | True |
Dominos.update_closest_store | (self) | Update the shared closest store (if open). | Update the shared closest store (if open). | def update_closest_store(self):
"""Update the shared closest store (if open)."""
try:
self.closest_store = self.address.closest_store()
return True
except StoreException:
self.closest_store = None
return False | [
"def",
"update_closest_store",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"closest_store",
"=",
"self",
".",
"address",
".",
"closest_store",
"(",
")",
"return",
"True",
"except",
"StoreException",
":",
"self",
".",
"closest_store",
"=",
"None",
"return... | [
127,
4
] | [
134,
24
] | python | en | ['en', 'en', 'en'] | True |
Dominos.get_menu | (self) | Return the products from the closest stores menu. | Return the products from the closest stores menu. | def get_menu(self):
"""Return the products from the closest stores menu."""
self.update_closest_store()
if self.closest_store is None:
_LOGGER.warning("Cannot get menu. Store may be closed")
return []
menu = self.closest_store.get_menu()
product_entries = ... | [
"def",
"get_menu",
"(",
"self",
")",
":",
"self",
".",
"update_closest_store",
"(",
")",
"if",
"self",
".",
"closest_store",
"is",
"None",
":",
"_LOGGER",
".",
"warning",
"(",
"\"Cannot get menu. Store may be closed\"",
")",
"return",
"[",
"]",
"menu",
"=",
... | [
136,
4
] | [
155,
30
] | python | en | ['en', 'en', 'en'] | True |
DominosProductListView.__init__ | (self, dominos) | Initialize suite view. | Initialize suite view. | def __init__(self, dominos):
"""Initialize suite view."""
self.dominos = dominos | [
"def",
"__init__",
"(",
"self",
",",
"dominos",
")",
":",
"self",
".",
"dominos",
"=",
"dominos"
] | [
164,
4
] | [
166,
30
] | python | en | ['en', 'en', 'en'] | True |
DominosProductListView.get | (self, request) | Retrieve if API is running. | Retrieve if API is running. | def get(self, request):
"""Retrieve if API is running."""
return self.json(self.dominos.get_menu()) | [
"def",
"get",
"(",
"self",
",",
"request",
")",
":",
"return",
"self",
".",
"json",
"(",
"self",
".",
"dominos",
".",
"get_menu",
"(",
")",
")"
] | [
169,
4
] | [
171,
49
] | python | en | ['en', 'sn', 'en'] | True |
DominosOrder.__init__ | (self, order_info, dominos) | Set up the entity. | Set up the entity. | def __init__(self, order_info, dominos):
"""Set up the entity."""
self._name = order_info["name"]
self._product_codes = order_info["codes"]
self._orderable = False
self.dominos = dominos | [
"def",
"__init__",
"(",
"self",
",",
"order_info",
",",
"dominos",
")",
":",
"self",
".",
"_name",
"=",
"order_info",
"[",
"\"name\"",
"]",
"self",
".",
"_product_codes",
"=",
"order_info",
"[",
"\"codes\"",
"]",
"self",
".",
"_orderable",
"=",
"False",
... | [
177,
4
] | [
182,
30
] | python | en | ['en', 'zu', 'en'] | True |
DominosOrder.name | (self) | Return the orders name. | Return the orders name. | def name(self):
"""Return the orders name."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
185,
4
] | [
187,
25
] | python | en | ['en', 'ig', 'en'] | True |
DominosOrder.product_codes | (self) | Return the orders product codes. | Return the orders product codes. | def product_codes(self):
"""Return the orders product codes."""
return self._product_codes | [
"def",
"product_codes",
"(",
"self",
")",
":",
"return",
"self",
".",
"_product_codes"
] | [
190,
4
] | [
192,
34
] | python | en | ['en', 'en', 'en'] | True |
DominosOrder.orderable | (self) | Return the true if orderable. | Return the true if orderable. | def orderable(self):
"""Return the true if orderable."""
return self._orderable | [
"def",
"orderable",
"(",
"self",
")",
":",
"return",
"self",
".",
"_orderable"
] | [
195,
4
] | [
197,
30
] | python | en | ['en', 'en', 'en'] | True |
DominosOrder.state | (self) | Return the state either closed, orderable or unorderable. | Return the state either closed, orderable or unorderable. | def state(self):
"""Return the state either closed, orderable or unorderable."""
if self.dominos.closest_store is None:
return "closed"
return "orderable" if self._orderable else "unorderable" | [
"def",
"state",
"(",
"self",
")",
":",
"if",
"self",
".",
"dominos",
".",
"closest_store",
"is",
"None",
":",
"return",
"\"closed\"",
"return",
"\"orderable\"",
"if",
"self",
".",
"_orderable",
"else",
"\"unorderable\""
] | [
200,
4
] | [
204,
64
] | python | en | ['en', 'en', 'en'] | True |
DominosOrder.update | (self) | Update the order state and refreshes the store. | Update the order state and refreshes the store. | def update(self):
"""Update the order state and refreshes the store."""
try:
self.dominos.update_closest_store()
except StoreException:
self._orderable = False
return
try:
order = self.order()
order.pay_with()
self.... | [
"def",
"update",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"dominos",
".",
"update_closest_store",
"(",
")",
"except",
"StoreException",
":",
"self",
".",
"_orderable",
"=",
"False",
"return",
"try",
":",
"order",
"=",
"self",
".",
"order",
"(",
... | [
207,
4
] | [
220,
35
] | python | en | ['en', 'en', 'en'] | True |
DominosOrder.order | (self) | Create the order object. | Create the order object. | def order(self):
"""Create the order object."""
if self.dominos.closest_store is None:
raise StoreException
order = Order(
self.dominos.closest_store,
self.dominos.customer,
self.dominos.address,
self.dominos.country,
)
... | [
"def",
"order",
"(",
"self",
")",
":",
"if",
"self",
".",
"dominos",
".",
"closest_store",
"is",
"None",
":",
"raise",
"StoreException",
"order",
"=",
"Order",
"(",
"self",
".",
"dominos",
".",
"closest_store",
",",
"self",
".",
"dominos",
".",
"customer... | [
222,
4
] | [
237,
20
] | python | en | ['en', 'en', 'en'] | True |
DominosOrder.place | (self) | Place the order. | Place the order. | def place(self):
"""Place the order."""
try:
order = self.order()
order.place()
except StoreException:
self._orderable = False
_LOGGER.warning(
"Attempted to order Dominos - Order invalid or store closed"
) | [
"def",
"place",
"(",
"self",
")",
":",
"try",
":",
"order",
"=",
"self",
".",
"order",
"(",
")",
"order",
".",
"place",
"(",
")",
"except",
"StoreException",
":",
"self",
".",
"_orderable",
"=",
"False",
"_LOGGER",
".",
"warning",
"(",
"\"Attempted to ... | [
239,
4
] | [
248,
13
] | python | en | ['en', 'en', 'en'] | True |
make_command | (*args) |
Create a CommandArgs object.
|
Create a CommandArgs object.
| def make_command(*args):
# type: (Union[str, HiddenText, CommandArgs]) -> CommandArgs
"""
Create a CommandArgs object.
"""
command_args = [] # type: CommandArgs
for arg in args:
# Check for list instead of CommandArgs since CommandArgs is
# only known during type-checking.
... | [
"def",
"make_command",
"(",
"*",
"args",
")",
":",
"# type: (Union[str, HiddenText, CommandArgs]) -> CommandArgs",
"command_args",
"=",
"[",
"]",
"# type: CommandArgs",
"for",
"arg",
"in",
"args",
":",
"# Check for list instead of CommandArgs since CommandArgs is",
"# only know... | [
26,
0
] | [
41,
23
] | python | en | ['en', 'error', 'th'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.