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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
ProliphixThermostat.set_temperature | (self, **kwargs) | Set new target temperature. | Set new target temperature. | def set_temperature(self, **kwargs):
"""Set new target temperature."""
temperature = kwargs.get(ATTR_TEMPERATURE)
if temperature is None:
return
self._pdp.setback = temperature | [
"def",
"set_temperature",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"temperature",
"=",
"kwargs",
".",
"get",
"(",
"ATTR_TEMPERATURE",
")",
"if",
"temperature",
"is",
"None",
":",
"return",
"self",
".",
"_pdp",
".",
"setback",
"=",
"temperature"
] | [
131,
4
] | [
136,
39
] | python | en | ['en', 'ca', 'en'] | True |
test_setup_missing_config | (hass) | Test setup with configuration missing required entries. | Test setup with configuration missing required entries. | async def test_setup_missing_config(hass):
"""Test setup with configuration missing required entries."""
assert not await rest.async_setup_platform(hass, {CONF_PLATFORM: rest.DOMAIN}, None) | [
"async",
"def",
"test_setup_missing_config",
"(",
"hass",
")",
":",
"assert",
"not",
"await",
"rest",
".",
"async_setup_platform",
"(",
"hass",
",",
"{",
"CONF_PLATFORM",
":",
"rest",
".",
"DOMAIN",
"}",
",",
"None",
")"
] | [
34,
0
] | [
36,
88
] | python | en | ['en', 'en', 'en'] | True |
test_setup_missing_schema | (hass) | Test setup with resource missing schema. | Test setup with resource missing schema. | async def test_setup_missing_schema(hass):
"""Test setup with resource missing schema."""
assert not await rest.async_setup_platform(
hass,
{CONF_PLATFORM: rest.DOMAIN, CONF_RESOURCE: "localhost"},
None,
) | [
"async",
"def",
"test_setup_missing_schema",
"(",
"hass",
")",
":",
"assert",
"not",
"await",
"rest",
".",
"async_setup_platform",
"(",
"hass",
",",
"{",
"CONF_PLATFORM",
":",
"rest",
".",
"DOMAIN",
",",
"CONF_RESOURCE",
":",
"\"localhost\"",
"}",
",",
"None",... | [
39,
0
] | [
45,
5
] | python | en | ['en', 'de', 'en'] | True |
test_setup_failed_connect | (hass, aioclient_mock) | Test setup when connection error occurs. | Test setup when connection error occurs. | async def test_setup_failed_connect(hass, aioclient_mock):
"""Test setup when connection error occurs."""
aioclient_mock.get("http://localhost", exc=aiohttp.ClientError)
assert not await rest.async_setup_platform(
hass,
{CONF_PLATFORM: rest.DOMAIN, CONF_RESOURCE: "http://localhost"},
... | [
"async",
"def",
"test_setup_failed_connect",
"(",
"hass",
",",
"aioclient_mock",
")",
":",
"aioclient_mock",
".",
"get",
"(",
"\"http://localhost\"",
",",
"exc",
"=",
"aiohttp",
".",
"ClientError",
")",
"assert",
"not",
"await",
"rest",
".",
"async_setup_platform"... | [
48,
0
] | [
55,
5
] | python | en | ['en', 'en', 'en'] | True |
test_setup_timeout | (hass, aioclient_mock) | Test setup when connection timeout occurs. | Test setup when connection timeout occurs. | async def test_setup_timeout(hass, aioclient_mock):
"""Test setup when connection timeout occurs."""
aioclient_mock.get("http://localhost", exc=asyncio.TimeoutError())
assert not await rest.async_setup_platform(
hass,
{CONF_PLATFORM: rest.DOMAIN, CONF_RESOURCE: "http://localhost"},
N... | [
"async",
"def",
"test_setup_timeout",
"(",
"hass",
",",
"aioclient_mock",
")",
":",
"aioclient_mock",
".",
"get",
"(",
"\"http://localhost\"",
",",
"exc",
"=",
"asyncio",
".",
"TimeoutError",
"(",
")",
")",
"assert",
"not",
"await",
"rest",
".",
"async_setup_p... | [
58,
0
] | [
65,
5
] | python | en | ['en', 'en', 'en'] | True |
test_setup_minimum | (hass, aioclient_mock) | Test setup with minimum configuration. | Test setup with minimum configuration. | async def test_setup_minimum(hass, aioclient_mock):
"""Test setup with minimum configuration."""
aioclient_mock.get("http://localhost", status=HTTP_OK)
with assert_setup_component(1, SWITCH_DOMAIN):
assert await async_setup_component(
hass,
SWITCH_DOMAIN,
{
... | [
"async",
"def",
"test_setup_minimum",
"(",
"hass",
",",
"aioclient_mock",
")",
":",
"aioclient_mock",
".",
"get",
"(",
"\"http://localhost\"",
",",
"status",
"=",
"HTTP_OK",
")",
"with",
"assert_setup_component",
"(",
"1",
",",
"SWITCH_DOMAIN",
")",
":",
"assert... | [
68,
0
] | [
82,
41
] | python | en | ['en', 'zu', 'en'] | True |
test_setup_query_params | (hass, aioclient_mock) | Test setup with query params. | Test setup with query params. | async def test_setup_query_params(hass, aioclient_mock):
"""Test setup with query params."""
aioclient_mock.get("http://localhost/?search=something", status=HTTP_OK)
with assert_setup_component(1, SWITCH_DOMAIN):
assert await async_setup_component(
hass,
SWITCH_DOMAIN,
... | [
"async",
"def",
"test_setup_query_params",
"(",
"hass",
",",
"aioclient_mock",
")",
":",
"aioclient_mock",
".",
"get",
"(",
"\"http://localhost/?search=something\"",
",",
"status",
"=",
"HTTP_OK",
")",
"with",
"assert_setup_component",
"(",
"1",
",",
"SWITCH_DOMAIN",
... | [
85,
0
] | [
101,
41
] | python | en | ['en', 'en', 'en'] | True |
test_setup | (hass, aioclient_mock) | Test setup with valid configuration. | Test setup with valid configuration. | async def test_setup(hass, aioclient_mock):
"""Test setup with valid configuration."""
aioclient_mock.get("http://localhost", status=HTTP_OK)
assert await async_setup_component(
hass,
SWITCH_DOMAIN,
{
SWITCH_DOMAIN: {
CONF_PLATFORM: rest.DOMAIN,
... | [
"async",
"def",
"test_setup",
"(",
"hass",
",",
"aioclient_mock",
")",
":",
"aioclient_mock",
".",
"get",
"(",
"\"http://localhost\"",
",",
"status",
"=",
"HTTP_OK",
")",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"SWITCH_DOMAIN",
",",
"{",
... | [
104,
0
] | [
122,
44
] | python | en | ['en', 'en', 'en'] | True |
test_setup_with_state_resource | (hass, aioclient_mock) | Test setup with valid configuration. | Test setup with valid configuration. | async def test_setup_with_state_resource(hass, aioclient_mock):
"""Test setup with valid configuration."""
aioclient_mock.get("http://localhost", status=HTTP_NOT_FOUND)
aioclient_mock.get("http://localhost/state", status=HTTP_OK)
assert await async_setup_component(
hass,
SWITCH_DOMAIN,
... | [
"async",
"def",
"test_setup_with_state_resource",
"(",
"hass",
",",
"aioclient_mock",
")",
":",
"aioclient_mock",
".",
"get",
"(",
"\"http://localhost\"",
",",
"status",
"=",
"HTTP_NOT_FOUND",
")",
"aioclient_mock",
".",
"get",
"(",
"\"http://localhost/state\"",
",",
... | [
125,
0
] | [
145,
44
] | python | en | ['en', 'en', 'en'] | True |
test_name | (hass) | Test the name. | Test the name. | def test_name(hass):
"""Test the name."""
switch, body_on, body_off = _setup_test_switch(hass)
assert NAME == switch.name | [
"def",
"test_name",
"(",
"hass",
")",
":",
"switch",
",",
"body_on",
",",
"body_off",
"=",
"_setup_test_switch",
"(",
"hass",
")",
"assert",
"NAME",
"==",
"switch",
".",
"name"
] | [
172,
0
] | [
175,
30
] | python | en | ['en', 'en', 'en'] | True |
test_is_on_before_update | (hass) | Test is_on in initial state. | Test is_on in initial state. | def test_is_on_before_update(hass):
"""Test is_on in initial state."""
switch, body_on, body_off = _setup_test_switch(hass)
assert switch.is_on is None | [
"def",
"test_is_on_before_update",
"(",
"hass",
")",
":",
"switch",
",",
"body_on",
",",
"body_off",
"=",
"_setup_test_switch",
"(",
"hass",
")",
"assert",
"switch",
".",
"is_on",
"is",
"None"
] | [
178,
0
] | [
181,
31
] | python | en | ['en', 'en', 'en'] | True |
test_turn_on_success | (hass, aioclient_mock) | Test turn_on. | Test turn_on. | async def test_turn_on_success(hass, aioclient_mock):
"""Test turn_on."""
aioclient_mock.post(RESOURCE, status=HTTP_OK)
switch, body_on, body_off = _setup_test_switch(hass)
await switch.async_turn_on()
assert body_on.template == aioclient_mock.mock_calls[-1][2].decode()
assert switch.is_on | [
"async",
"def",
"test_turn_on_success",
"(",
"hass",
",",
"aioclient_mock",
")",
":",
"aioclient_mock",
".",
"post",
"(",
"RESOURCE",
",",
"status",
"=",
"HTTP_OK",
")",
"switch",
",",
"body_on",
",",
"body_off",
"=",
"_setup_test_switch",
"(",
"hass",
")",
... | [
184,
0
] | [
191,
23
] | python | en | ['en', 'et', 'en'] | False |
test_turn_on_status_not_ok | (hass, aioclient_mock) | Test turn_on when error status returned. | Test turn_on when error status returned. | async def test_turn_on_status_not_ok(hass, aioclient_mock):
"""Test turn_on when error status returned."""
aioclient_mock.post(RESOURCE, status=HTTP_INTERNAL_SERVER_ERROR)
switch, body_on, body_off = _setup_test_switch(hass)
await switch.async_turn_on()
assert body_on.template == aioclient_mock.moc... | [
"async",
"def",
"test_turn_on_status_not_ok",
"(",
"hass",
",",
"aioclient_mock",
")",
":",
"aioclient_mock",
".",
"post",
"(",
"RESOURCE",
",",
"status",
"=",
"HTTP_INTERNAL_SERVER_ERROR",
")",
"switch",
",",
"body_on",
",",
"body_off",
"=",
"_setup_test_switch",
... | [
194,
0
] | [
201,
31
] | python | en | ['en', 'no', 'en'] | True |
test_turn_on_timeout | (hass, aioclient_mock) | Test turn_on when timeout occurs. | Test turn_on when timeout occurs. | async def test_turn_on_timeout(hass, aioclient_mock):
"""Test turn_on when timeout occurs."""
aioclient_mock.post(RESOURCE, status=HTTP_INTERNAL_SERVER_ERROR)
switch, body_on, body_off = _setup_test_switch(hass)
await switch.async_turn_on()
assert switch.is_on is None | [
"async",
"def",
"test_turn_on_timeout",
"(",
"hass",
",",
"aioclient_mock",
")",
":",
"aioclient_mock",
".",
"post",
"(",
"RESOURCE",
",",
"status",
"=",
"HTTP_INTERNAL_SERVER_ERROR",
")",
"switch",
",",
"body_on",
",",
"body_off",
"=",
"_setup_test_switch",
"(",
... | [
204,
0
] | [
210,
31
] | python | en | ['en', 'en', 'en'] | True |
test_turn_off_success | (hass, aioclient_mock) | Test turn_off. | Test turn_off. | async def test_turn_off_success(hass, aioclient_mock):
"""Test turn_off."""
aioclient_mock.post(RESOURCE, status=HTTP_OK)
switch, body_on, body_off = _setup_test_switch(hass)
await switch.async_turn_off()
assert body_off.template == aioclient_mock.mock_calls[-1][2].decode()
assert not switch.is... | [
"async",
"def",
"test_turn_off_success",
"(",
"hass",
",",
"aioclient_mock",
")",
":",
"aioclient_mock",
".",
"post",
"(",
"RESOURCE",
",",
"status",
"=",
"HTTP_OK",
")",
"switch",
",",
"body_on",
",",
"body_off",
"=",
"_setup_test_switch",
"(",
"hass",
")",
... | [
213,
0
] | [
220,
27
] | python | en | ['en', 'cy', 'en'] | False |
test_turn_off_status_not_ok | (hass, aioclient_mock) | Test turn_off when error status returned. | Test turn_off when error status returned. | async def test_turn_off_status_not_ok(hass, aioclient_mock):
"""Test turn_off when error status returned."""
aioclient_mock.post(RESOURCE, status=HTTP_INTERNAL_SERVER_ERROR)
switch, body_on, body_off = _setup_test_switch(hass)
await switch.async_turn_off()
assert body_off.template == aioclient_mock... | [
"async",
"def",
"test_turn_off_status_not_ok",
"(",
"hass",
",",
"aioclient_mock",
")",
":",
"aioclient_mock",
".",
"post",
"(",
"RESOURCE",
",",
"status",
"=",
"HTTP_INTERNAL_SERVER_ERROR",
")",
"switch",
",",
"body_on",
",",
"body_off",
"=",
"_setup_test_switch",
... | [
223,
0
] | [
230,
31
] | python | en | ['en', 'no', 'en'] | True |
test_turn_off_timeout | (hass, aioclient_mock) | Test turn_off when timeout occurs. | Test turn_off when timeout occurs. | async def test_turn_off_timeout(hass, aioclient_mock):
"""Test turn_off when timeout occurs."""
aioclient_mock.post(RESOURCE, exc=asyncio.TimeoutError())
switch, body_on, body_off = _setup_test_switch(hass)
await switch.async_turn_on()
assert switch.is_on is None | [
"async",
"def",
"test_turn_off_timeout",
"(",
"hass",
",",
"aioclient_mock",
")",
":",
"aioclient_mock",
".",
"post",
"(",
"RESOURCE",
",",
"exc",
"=",
"asyncio",
".",
"TimeoutError",
"(",
")",
")",
"switch",
",",
"body_on",
",",
"body_off",
"=",
"_setup_tes... | [
233,
0
] | [
239,
31
] | python | en | ['en', 'en', 'en'] | True |
test_update_when_on | (hass, aioclient_mock) | Test update when switch is on. | Test update when switch is on. | async def test_update_when_on(hass, aioclient_mock):
"""Test update when switch is on."""
switch, body_on, body_off = _setup_test_switch(hass)
aioclient_mock.get(RESOURCE, text=body_on.template)
await switch.async_update()
assert switch.is_on | [
"async",
"def",
"test_update_when_on",
"(",
"hass",
",",
"aioclient_mock",
")",
":",
"switch",
",",
"body_on",
",",
"body_off",
"=",
"_setup_test_switch",
"(",
"hass",
")",
"aioclient_mock",
".",
"get",
"(",
"RESOURCE",
",",
"text",
"=",
"body_on",
".",
"tem... | [
242,
0
] | [
248,
23
] | python | en | ['en', 'en', 'en'] | True |
test_update_when_off | (hass, aioclient_mock) | Test update when switch is off. | Test update when switch is off. | async def test_update_when_off(hass, aioclient_mock):
"""Test update when switch is off."""
switch, body_on, body_off = _setup_test_switch(hass)
aioclient_mock.get(RESOURCE, text=body_off.template)
await switch.async_update()
assert not switch.is_on | [
"async",
"def",
"test_update_when_off",
"(",
"hass",
",",
"aioclient_mock",
")",
":",
"switch",
",",
"body_on",
",",
"body_off",
"=",
"_setup_test_switch",
"(",
"hass",
")",
"aioclient_mock",
".",
"get",
"(",
"RESOURCE",
",",
"text",
"=",
"body_off",
".",
"t... | [
251,
0
] | [
257,
27
] | python | en | ['en', 'en', 'en'] | True |
test_update_when_unknown | (hass, aioclient_mock) | Test update when unknown status returned. | Test update when unknown status returned. | async def test_update_when_unknown(hass, aioclient_mock):
"""Test update when unknown status returned."""
aioclient_mock.get(RESOURCE, text="unknown status")
switch, body_on, body_off = _setup_test_switch(hass)
await switch.async_update()
assert switch.is_on is None | [
"async",
"def",
"test_update_when_unknown",
"(",
"hass",
",",
"aioclient_mock",
")",
":",
"aioclient_mock",
".",
"get",
"(",
"RESOURCE",
",",
"text",
"=",
"\"unknown status\"",
")",
"switch",
",",
"body_on",
",",
"body_off",
"=",
"_setup_test_switch",
"(",
"hass... | [
260,
0
] | [
266,
31
] | python | en | ['en', 'en', 'en'] | True |
test_update_timeout | (hass, aioclient_mock) | Test update when timeout occurs. | Test update when timeout occurs. | async def test_update_timeout(hass, aioclient_mock):
"""Test update when timeout occurs."""
aioclient_mock.get(RESOURCE, exc=asyncio.TimeoutError())
switch, body_on, body_off = _setup_test_switch(hass)
await switch.async_update()
assert switch.is_on is None | [
"async",
"def",
"test_update_timeout",
"(",
"hass",
",",
"aioclient_mock",
")",
":",
"aioclient_mock",
".",
"get",
"(",
"RESOURCE",
",",
"exc",
"=",
"asyncio",
".",
"TimeoutError",
"(",
")",
")",
"switch",
",",
"body_on",
",",
"body_off",
"=",
"_setup_test_s... | [
269,
0
] | [
275,
31
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (
hass: HomeAssistantType, entry: ConfigEntry, async_add_entities
) | Set up for AlarmDecoder alarm panels. | Set up for AlarmDecoder alarm panels. | async def async_setup_entry(
hass: HomeAssistantType, entry: ConfigEntry, async_add_entities
):
"""Set up for AlarmDecoder alarm panels."""
options = entry.options
arm_options = options.get(OPTIONS_ARM, DEFAULT_ARM_OPTIONS)
client = hass.data[DOMAIN][entry.entry_id][DATA_AD]
entity = AlarmDecod... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistantType",
",",
"entry",
":",
"ConfigEntry",
",",
"async_add_entities",
")",
":",
"options",
"=",
"entry",
".",
"options",
"arm_options",
"=",
"options",
".",
"get",
"(",
"OPTIONS_ARM",
",",
"DEF... | [
42,
0
] | [
74,
5
] | python | en | ['en', 'da', 'en'] | True |
AlarmDecoderAlarmPanel.__init__ | (self, client, auto_bypass, code_arm_required, alt_night_mode) | Initialize the alarm panel. | Initialize the alarm panel. | def __init__(self, client, auto_bypass, code_arm_required, alt_night_mode):
"""Initialize the alarm panel."""
self._client = client
self._display = ""
self._name = "Alarm Panel"
self._state = None
self._ac_power = None
self._alarm_event_occurred = None
sel... | [
"def",
"__init__",
"(",
"self",
",",
"client",
",",
"auto_bypass",
",",
"code_arm_required",
",",
"alt_night_mode",
")",
":",
"self",
".",
"_client",
"=",
"client",
"self",
".",
"_display",
"=",
"\"\"",
"self",
".",
"_name",
"=",
"\"Alarm Panel\"",
"self",
... | [
80,
4
] | [
98,
45
] | python | en | ['en', 'en', 'en'] | True |
AlarmDecoderAlarmPanel.async_added_to_hass | (self) | Register callbacks. | Register callbacks. | async def async_added_to_hass(self):
"""Register callbacks."""
self.async_on_remove(
self.hass.helpers.dispatcher.async_dispatcher_connect(
SIGNAL_PANEL_MESSAGE, self._message_callback
)
) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"async_on_remove",
"(",
"self",
".",
"hass",
".",
"helpers",
".",
"dispatcher",
".",
"async_dispatcher_connect",
"(",
"SIGNAL_PANEL_MESSAGE",
",",
"self",
".",
"_message_callback",
")",
"... | [
100,
4
] | [
106,
9
] | python | en | ['en', 'no', 'en'] | False |
AlarmDecoderAlarmPanel._message_callback | (self, message) | Handle received messages. | Handle received messages. | def _message_callback(self, message):
"""Handle received messages."""
if message.alarm_sounding or message.fire_alarm:
self._state = STATE_ALARM_TRIGGERED
elif message.armed_away:
self._state = STATE_ALARM_ARMED_AWAY
elif message.armed_home and (message.entry_dela... | [
"def",
"_message_callback",
"(",
"self",
",",
"message",
")",
":",
"if",
"message",
".",
"alarm_sounding",
"or",
"message",
".",
"fire_alarm",
":",
"self",
".",
"_state",
"=",
"STATE_ALARM_TRIGGERED",
"elif",
"message",
".",
"armed_away",
":",
"self",
".",
"... | [
108,
4
] | [
132,
39
] | python | en | ['en', 'en', 'en'] | True |
AlarmDecoderAlarmPanel.name | (self) | Return the name of the device. | Return the name of the device. | def name(self):
"""Return the name of the device."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
135,
4
] | [
137,
25
] | python | en | ['en', 'en', 'en'] | True |
AlarmDecoderAlarmPanel.should_poll | (self) | Return the polling state. | Return the polling state. | def should_poll(self):
"""Return the polling state."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
140,
4
] | [
142,
20
] | python | en | ['en', 'en', 'en'] | True |
AlarmDecoderAlarmPanel.code_format | (self) | Return one or more digits/characters. | Return one or more digits/characters. | def code_format(self):
"""Return one or more digits/characters."""
return FORMAT_NUMBER | [
"def",
"code_format",
"(",
"self",
")",
":",
"return",
"FORMAT_NUMBER"
] | [
145,
4
] | [
147,
28
] | python | en | ['en', 'en', 'en'] | True |
AlarmDecoderAlarmPanel.state | (self) | Return the state of the device. | Return the state of the device. | def state(self):
"""Return the state of the device."""
return self._state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
150,
4
] | [
152,
26
] | python | en | ['en', 'en', 'en'] | True |
AlarmDecoderAlarmPanel.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"
] | [
155,
4
] | [
157,
88
] | python | en | ['en', 'en', 'en'] | True |
AlarmDecoderAlarmPanel.code_arm_required | (self) | Whether the code is required for arm actions. | Whether the code is required for arm actions. | def code_arm_required(self):
"""Whether the code is required for arm actions."""
return self._code_arm_required | [
"def",
"code_arm_required",
"(",
"self",
")",
":",
"return",
"self",
".",
"_code_arm_required"
] | [
160,
4
] | [
162,
38
] | python | en | ['en', 'en', 'en'] | True |
AlarmDecoderAlarmPanel.device_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def device_state_attributes(self):
"""Return the state attributes."""
return {
"ac_power": self._ac_power,
"alarm_event_occurred": self._alarm_event_occurred,
"backlight_on": self._backlight_on,
"battery_low": self._battery_low,
"check_zone": s... | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"{",
"\"ac_power\"",
":",
"self",
".",
"_ac_power",
",",
"\"alarm_event_occurred\"",
":",
"self",
".",
"_alarm_event_occurred",
",",
"\"backlight_on\"",
":",
"self",
".",
"_backlight_on",
",",
"\"b... | [
165,
4
] | [
179,
9
] | python | en | ['en', 'en', 'en'] | True |
AlarmDecoderAlarmPanel.alarm_disarm | (self, code=None) | Send disarm command. | Send disarm command. | def alarm_disarm(self, code=None):
"""Send disarm command."""
if code:
self._client.send(f"{code!s}1") | [
"def",
"alarm_disarm",
"(",
"self",
",",
"code",
"=",
"None",
")",
":",
"if",
"code",
":",
"self",
".",
"_client",
".",
"send",
"(",
"f\"{code!s}1\"",
")"
] | [
181,
4
] | [
184,
43
] | python | en | ['en', 'pt', 'en'] | True |
AlarmDecoderAlarmPanel.alarm_arm_away | (self, code=None) | Send arm away command. | Send arm away command. | def alarm_arm_away(self, code=None):
"""Send arm away command."""
self._client.arm_away(
code=code,
code_arm_required=self._code_arm_required,
auto_bypass=self._auto_bypass,
) | [
"def",
"alarm_arm_away",
"(",
"self",
",",
"code",
"=",
"None",
")",
":",
"self",
".",
"_client",
".",
"arm_away",
"(",
"code",
"=",
"code",
",",
"code_arm_required",
"=",
"self",
".",
"_code_arm_required",
",",
"auto_bypass",
"=",
"self",
".",
"_auto_bypa... | [
186,
4
] | [
192,
9
] | python | en | ['en', 'en', 'en'] | True |
AlarmDecoderAlarmPanel.alarm_arm_home | (self, code=None) | Send arm home command. | Send arm home command. | def alarm_arm_home(self, code=None):
"""Send arm home command."""
self._client.arm_home(
code=code,
code_arm_required=self._code_arm_required,
auto_bypass=self._auto_bypass,
) | [
"def",
"alarm_arm_home",
"(",
"self",
",",
"code",
"=",
"None",
")",
":",
"self",
".",
"_client",
".",
"arm_home",
"(",
"code",
"=",
"code",
",",
"code_arm_required",
"=",
"self",
".",
"_code_arm_required",
",",
"auto_bypass",
"=",
"self",
".",
"_auto_bypa... | [
194,
4
] | [
200,
9
] | python | en | ['en', 'pt', 'en'] | True |
AlarmDecoderAlarmPanel.alarm_arm_night | (self, code=None) | Send arm night command. | Send arm night command. | def alarm_arm_night(self, code=None):
"""Send arm night command."""
self._client.arm_night(
code=code,
code_arm_required=self._code_arm_required,
alt_night_mode=self._alt_night_mode,
auto_bypass=self._auto_bypass,
) | [
"def",
"alarm_arm_night",
"(",
"self",
",",
"code",
"=",
"None",
")",
":",
"self",
".",
"_client",
".",
"arm_night",
"(",
"code",
"=",
"code",
",",
"code_arm_required",
"=",
"self",
".",
"_code_arm_required",
",",
"alt_night_mode",
"=",
"self",
".",
"_alt_... | [
202,
4
] | [
209,
9
] | python | en | ['en', 'zh', 'en'] | True |
AlarmDecoderAlarmPanel.alarm_toggle_chime | (self, code=None) | Send toggle chime command. | Send toggle chime command. | def alarm_toggle_chime(self, code=None):
"""Send toggle chime command."""
if code:
self._client.send(f"{code!s}9") | [
"def",
"alarm_toggle_chime",
"(",
"self",
",",
"code",
"=",
"None",
")",
":",
"if",
"code",
":",
"self",
".",
"_client",
".",
"send",
"(",
"f\"{code!s}9\"",
")"
] | [
211,
4
] | [
214,
43
] | python | en | ['en', 'en', 'en'] | True |
AlarmDecoderAlarmPanel.alarm_keypress | (self, keypress) | Send custom keypresses. | Send custom keypresses. | def alarm_keypress(self, keypress):
"""Send custom keypresses."""
if keypress:
self._client.send(keypress) | [
"def",
"alarm_keypress",
"(",
"self",
",",
"keypress",
")",
":",
"if",
"keypress",
":",
"self",
".",
"_client",
".",
"send",
"(",
"keypress",
")"
] | [
216,
4
] | [
219,
39
] | python | en | ['en', 'et', 'en'] | True |
websocket_network_status | (hass, connection, msg) | Get Z-Wave network status. | Get Z-Wave network status. | def websocket_network_status(hass, connection, msg):
"""Get Z-Wave network status."""
network = hass.data[DATA_NETWORK]
connection.send_result(msg[ID], {"state": network.state}) | [
"def",
"websocket_network_status",
"(",
"hass",
",",
"connection",
",",
"msg",
")",
":",
"network",
"=",
"hass",
".",
"data",
"[",
"DATA_NETWORK",
"]",
"connection",
".",
"send_result",
"(",
"msg",
"[",
"ID",
"]",
",",
"{",
"\"state\"",
":",
"network",
"... | [
22,
0
] | [
25,
61
] | python | en | ['en', 'de', 'en'] | True |
websocket_get_config | (hass, connection, msg) | Get Z-Wave configuration. | Get Z-Wave configuration. | def websocket_get_config(hass, connection, msg):
"""Get Z-Wave configuration."""
config = hass.data[DATA_ZWAVE_CONFIG]
connection.send_result(
msg[ID],
{
CONF_AUTOHEAL: config[CONF_AUTOHEAL],
CONF_DEBUG: config[CONF_DEBUG],
CONF_POLLING_INTERVAL: config[CO... | [
"def",
"websocket_get_config",
"(",
"hass",
",",
"connection",
",",
"msg",
")",
":",
"config",
"=",
"hass",
".",
"data",
"[",
"DATA_ZWAVE_CONFIG",
"]",
"connection",
".",
"send_result",
"(",
"msg",
"[",
"ID",
"]",
",",
"{",
"CONF_AUTOHEAL",
":",
"config",
... | [
30,
0
] | [
41,
5
] | python | en | ['en', 'fr', 'en'] | True |
websocket_get_migration_config | (hass, connection, msg) | Get Z-Wave configuration for migration. | Get Z-Wave configuration for migration. | def websocket_get_migration_config(hass, connection, msg):
"""Get Z-Wave configuration for migration."""
config = hass.data[DATA_ZWAVE_CONFIG]
connection.send_result(
msg[ID],
{
CONF_USB_STICK_PATH: config[CONF_USB_STICK_PATH],
CONF_NETWORK_KEY: config[CONF_NETWORK_KE... | [
"def",
"websocket_get_migration_config",
"(",
"hass",
",",
"connection",
",",
"msg",
")",
":",
"config",
"=",
"hass",
".",
"data",
"[",
"DATA_ZWAVE_CONFIG",
"]",
"connection",
".",
"send_result",
"(",
"msg",
"[",
"ID",
"]",
",",
"{",
"CONF_USB_STICK_PATH",
"... | [
46,
0
] | [
55,
5
] | python | en | ['en', 'da', 'en'] | True |
async_load_websocket_api | (hass) | Set up the web socket API. | Set up the web socket API. | def async_load_websocket_api(hass):
"""Set up the web socket API."""
websocket_api.async_register_command(hass, websocket_network_status)
websocket_api.async_register_command(hass, websocket_get_config)
websocket_api.async_register_command(hass, websocket_get_migration_config) | [
"def",
"async_load_websocket_api",
"(",
"hass",
")",
":",
"websocket_api",
".",
"async_register_command",
"(",
"hass",
",",
"websocket_network_status",
")",
"websocket_api",
".",
"async_register_command",
"(",
"hass",
",",
"websocket_get_config",
")",
"websocket_api",
"... | [
59,
0
] | [
63,
78
] | python | en | ['en', 'zu', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up the SABnzbd sensors. | Set up the SABnzbd sensors. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the SABnzbd sensors."""
if discovery_info is None:
return
sab_api_data = hass.data[DATA_SABNZBD]
sensors = sab_api_data.sensors
client_name = sab_api_data.name
async_add_entities(
[S... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"if",
"discovery_info",
"is",
"None",
":",
"return",
"sab_api_data",
"=",
"hass",
".",
"data",
"[",
"DATA_SABNZBD",
"]"... | [
7,
0
] | [
17,
5
] | python | en | ['en', 'da', 'en'] | True |
SabnzbdSensor.__init__ | (self, sensor_type, sabnzbd_api_data, client_name) | Initialize the sensor. | Initialize the sensor. | def __init__(self, sensor_type, sabnzbd_api_data, client_name):
"""Initialize the sensor."""
self._client_name = client_name
self._field_name = SENSOR_TYPES[sensor_type][2]
self._name = SENSOR_TYPES[sensor_type][0]
self._sabnzbd_api = sabnzbd_api_data
self._state = None
... | [
"def",
"__init__",
"(",
"self",
",",
"sensor_type",
",",
"sabnzbd_api_data",
",",
"client_name",
")",
":",
"self",
".",
"_client_name",
"=",
"client_name",
"self",
".",
"_field_name",
"=",
"SENSOR_TYPES",
"[",
"sensor_type",
"]",
"[",
"2",
"]",
"self",
".",
... | [
23,
4
] | [
31,
64
] | python | en | ['en', 'en', 'en'] | True |
SabnzbdSensor.async_added_to_hass | (self) | Call when entity about to be added to hass. | Call when entity about to be added to hass. | async def async_added_to_hass(self):
"""Call when entity about to be added to hass."""
self.async_on_remove(
async_dispatcher_connect(
self.hass, SIGNAL_SABNZBD_UPDATED, self.update_state
)
) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"async_on_remove",
"(",
"async_dispatcher_connect",
"(",
"self",
".",
"hass",
",",
"SIGNAL_SABNZBD_UPDATED",
",",
"self",
".",
"update_state",
")",
")"
] | [
33,
4
] | [
39,
9
] | python | en | ['en', 'en', 'en'] | True |
SabnzbdSensor.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
return f"{self._client_name} {self._name}" | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"f\"{self._client_name} {self._name}\""
] | [
42,
4
] | [
44,
50
] | python | en | ['en', 'mi', 'en'] | True |
SabnzbdSensor.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._state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
47,
4
] | [
49,
26
] | python | en | ['en', 'en', 'en'] | True |
SabnzbdSensor.should_poll | (self) | Don't poll. Will be updated by dispatcher signal. | Don't poll. Will be updated by dispatcher signal. | def should_poll(self):
"""Don't poll. Will be updated by dispatcher signal."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
52,
4
] | [
54,
20
] | python | en | ['en', 'en', 'en'] | True |
SabnzbdSensor.unit_of_measurement | (self) | Return the unit of measurement of this entity, if any. | Return the unit of measurement of this entity, if any. | def unit_of_measurement(self):
"""Return the unit of measurement of this entity, if any."""
return self._unit_of_measurement | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unit_of_measurement"
] | [
57,
4
] | [
59,
40
] | python | en | ['en', 'en', 'en'] | True |
SabnzbdSensor.update_state | (self, args) | Get the latest data and updates the states. | Get the latest data and updates the states. | def update_state(self, args):
"""Get the latest data and updates the states."""
self._state = self._sabnzbd_api.get_queue_field(self._field_name)
if self._type == "speed":
self._state = round(float(self._state) / 1024, 1)
elif "size" in self._type:
self._state = ... | [
"def",
"update_state",
"(",
"self",
",",
"args",
")",
":",
"self",
".",
"_state",
"=",
"self",
".",
"_sabnzbd_api",
".",
"get_queue_field",
"(",
"self",
".",
"_field_name",
")",
"if",
"self",
".",
"_type",
"==",
"\"speed\"",
":",
"self",
".",
"_state",
... | [
61,
4
] | [
70,
39
] | python | en | ['en', 'en', 'en'] | True |
get_service | (hass, config, discovery_info=None) | Get the Sinch notification service. | Get the Sinch notification service. | def get_service(hass, config, discovery_info=None):
"""Get the Sinch notification service."""
return SinchNotificationService(config) | [
"def",
"get_service",
"(",
"hass",
",",
"config",
",",
"discovery_info",
"=",
"None",
")",
":",
"return",
"SinchNotificationService",
"(",
"config",
")"
] | [
46,
0
] | [
48,
43
] | python | en | ['en', 'en', 'en'] | True |
SinchNotificationService.__init__ | (self, config) | Initialize the service. | Initialize the service. | def __init__(self, config):
"""Initialize the service."""
self.default_recipients = config[CONF_DEFAULT_RECIPIENTS]
self.sender = config[CONF_SENDER]
self.client = Client(config[CONF_SERVICE_PLAN_ID], config[CONF_API_KEY]) | [
"def",
"__init__",
"(",
"self",
",",
"config",
")",
":",
"self",
".",
"default_recipients",
"=",
"config",
"[",
"CONF_DEFAULT_RECIPIENTS",
"]",
"self",
".",
"sender",
"=",
"config",
"[",
"CONF_SENDER",
"]",
"self",
".",
"client",
"=",
"Client",
"(",
"confi... | [
54,
4
] | [
58,
80
] | python | en | ['en', 'en', 'en'] | True |
SinchNotificationService.send_message | (self, message="", **kwargs) | Send a message to a user. | Send a message to a user. | def send_message(self, message="", **kwargs):
"""Send a message to a user."""
targets = kwargs.get(ATTR_TARGET, self.default_recipients)
data = kwargs.get(ATTR_DATA) or {}
clx_args = {ATTR_MESSAGE: message, ATTR_SENDER: self.sender}
if ATTR_SENDER in data:
clx_args[... | [
"def",
"send_message",
"(",
"self",
",",
"message",
"=",
"\"\"",
",",
"*",
"*",
"kwargs",
")",
":",
"targets",
"=",
"kwargs",
".",
"get",
"(",
"ATTR_TARGET",
",",
"self",
".",
"default_recipients",
")",
"data",
"=",
"kwargs",
".",
"get",
"(",
"ATTR_DAT... | [
60,
4
] | [
96,
71
] | python | en | ['en', 'en', 'en'] | True |
HelpIntent.__init__ | (self, hass) | Set up the intent. | Set up the intent. | def __init__(self, hass):
"""Set up the intent."""
self.hass = hass | [
"def",
"__init__",
"(",
"self",
",",
"hass",
")",
":",
"self",
".",
"hass",
"=",
"hass"
] | [
13,
4
] | [
15,
24
] | python | en | ['en', 'en', 'en'] | True |
HelpIntent.async_handle | (self, intent_obj) | Handle the intent. | Handle the intent. | async def async_handle(self, intent_obj):
"""Handle the intent."""
slots = self.async_validate_slots(intent_obj.slots)
conv_id = slots["conv_id"]["value"]
intents = self.hass.data[DOMAIN][CONF_BOT].get_intents(conv_id)
response = intent_obj.create_response()
help_text = ... | [
"async",
"def",
"async_handle",
"(",
"self",
",",
"intent_obj",
")",
":",
"slots",
"=",
"self",
".",
"async_validate_slots",
"(",
"intent_obj",
".",
"slots",
")",
"conv_id",
"=",
"slots",
"[",
"\"conv_id\"",
"]",
"[",
"\"value\"",
"]",
"intents",
"=",
"sel... | [
17,
4
] | [
30,
23
] | python | en | ['en', 'en', 'en'] | True |
get_lengths_from_binary_sequence_mask | (mask: torch.Tensor) |
Compute sequence lengths for each batch element in a tensor using a
binary mask.
Parameters
----------
mask : torch.Tensor, required.
A 2D binary mask of shape (batch_size, sequence_length) to
calculate the per-batch sequence lengths from.
Returns
-------
A torch.LongT... |
Compute sequence lengths for each batch element in a tensor using a
binary mask. | def get_lengths_from_binary_sequence_mask(mask: torch.Tensor):
"""
Compute sequence lengths for each batch element in a tensor using a
binary mask.
Parameters
----------
mask : torch.Tensor, required.
A 2D binary mask of shape (batch_size, sequence_length) to
calculate the per-b... | [
"def",
"get_lengths_from_binary_sequence_mask",
"(",
"mask",
":",
"torch",
".",
"Tensor",
")",
":",
"return",
"mask",
".",
"long",
"(",
")",
".",
"sum",
"(",
"-",
"1",
")"
] | [
12,
0
] | [
28,
30
] | python | en | ['en', 'error', 'th'] | False |
sort_batch_by_length | (tensor: torch.Tensor, sequence_lengths: torch.Tensor) |
Sort a batch first tensor by some specified lengths.
Parameters
----------
tensor : torch.FloatTensor, required.
A batch first Pytorch tensor.
sequence_lengths : torch.LongTensor, required.
A tensor representing the lengths of some dimension of the tensor which
we want to s... |
Sort a batch first tensor by some specified lengths. | def sort_batch_by_length(tensor: torch.Tensor, sequence_lengths: torch.Tensor):
"""
Sort a batch first tensor by some specified lengths.
Parameters
----------
tensor : torch.FloatTensor, required.
A batch first Pytorch tensor.
sequence_lengths : torch.LongTensor, required.
A ten... | [
"def",
"sort_batch_by_length",
"(",
"tensor",
":",
"torch",
".",
"Tensor",
",",
"sequence_lengths",
":",
"torch",
".",
"Tensor",
")",
":",
"if",
"not",
"isinstance",
"(",
"tensor",
",",
"torch",
".",
"Tensor",
")",
"or",
"not",
"isinstance",
"(",
"sequence... | [
31,
0
] | [
68,
89
] | python | en | ['en', 'error', 'th'] | False |
_EncoderBase.sort_and_run_forward | (self,
module: Callable[[PackedSequence, Optional[RnnState]],
Tuple[Union[PackedSequence, torch.Tensor], RnnState]],
inputs: torch.Tensor,
mask: torch.Tensor,
... |
This function exists because Pytorch RNNs require that their inputs be sorted
before being passed as input. As all of our Seq2xxxEncoders use this functionality,
it is provided in a base class. This method can be called on any module which
takes as input a ``PackedSequence`` and some ``... |
This function exists because Pytorch RNNs require that their inputs be sorted
before being passed as input. As all of our Seq2xxxEncoders use this functionality,
it is provided in a base class. This method can be called on any module which
takes as input a ``PackedSequence`` and some ``... | def sort_and_run_forward(self,
module: Callable[[PackedSequence, Optional[RnnState]],
Tuple[Union[PackedSequence, torch.Tensor], RnnState]],
inputs: torch.Tensor,
mask: torch.Tensor,
... | [
"def",
"sort_and_run_forward",
"(",
"self",
",",
"module",
":",
"Callable",
"[",
"[",
"PackedSequence",
",",
"Optional",
"[",
"RnnState",
"]",
"]",
",",
"Tuple",
"[",
"Union",
"[",
"PackedSequence",
",",
"torch",
".",
"Tensor",
"]",
",",
"RnnState",
"]",
... | [
89,
4
] | [
175,
63
] | python | en | ['en', 'error', 'th'] | False |
_EncoderBase._get_initial_states | (self,
batch_size: int,
num_valid: int,
sorting_indices: torch.LongTensor) |
Returns an initial state for use in an RNN. Additionally, this method handles
the batch size changing across calls by mutating the state to append initial states
for new elements in the batch. Finally, it also handles sorting the states
with respect to the sequence lengths of elements i... |
Returns an initial state for use in an RNN. Additionally, this method handles
the batch size changing across calls by mutating the state to append initial states
for new elements in the batch. Finally, it also handles sorting the states
with respect to the sequence lengths of elements i... | def _get_initial_states(self,
batch_size: int,
num_valid: int,
sorting_indices: torch.LongTensor) -> Optional[RnnState]:
"""
Returns an initial state for use in an RNN. Additionally, this method handles
the batch... | [
"def",
"_get_initial_states",
"(",
"self",
",",
"batch_size",
":",
"int",
",",
"num_valid",
":",
"int",
",",
"sorting_indices",
":",
"torch",
".",
"LongTensor",
")",
"->",
"Optional",
"[",
"RnnState",
"]",
":",
"# We don't know the state sizes the first time calling... | [
177,
4
] | [
262,
76
] | python | en | ['en', 'error', 'th'] | False |
_EncoderBase._update_states | (self,
final_states: RnnStateStorage,
restoration_indices: torch.LongTensor) |
After the RNN has run forward, the states need to be updated.
This method just sets the state to the updated new state, performing
several pieces of book-keeping along the way - namely, unsorting the
states and ensuring that the states of completely padded sequences are
not upda... |
After the RNN has run forward, the states need to be updated.
This method just sets the state to the updated new state, performing
several pieces of book-keeping along the way - namely, unsorting the
states and ensuring that the states of completely padded sequences are
not upda... | def _update_states(self,
final_states: RnnStateStorage,
restoration_indices: torch.LongTensor) -> None:
"""
After the RNN has run forward, the states need to be updated.
This method just sets the state to the updated new state, performing
sev... | [
"def",
"_update_states",
"(",
"self",
",",
"final_states",
":",
"RnnStateStorage",
",",
"restoration_indices",
":",
"torch",
".",
"LongTensor",
")",
"->",
"None",
":",
"# TODO(Mark): seems weird to sort here, but append zeros in the subclasses.",
"# which way around is best?",
... | [
264,
4
] | [
339,
44
] | python | en | ['en', 'error', 'th'] | False |
CTCTrainer.training_step | (self, model: nn.Module, inputs: Dict[str, Union[torch.Tensor, Any]]) |
Perform a training step on a batch of inputs.
Subclass and override to inject custom behavior.
Args:
model (:obj:`nn.Module`):
The model to train.
inputs (:obj:`Dict[str, Union[torch.Tensor, Any]]`):
The inputs and targets of the model.
... |
Perform a training step on a batch of inputs. | def training_step(self, model: nn.Module, inputs: Dict[str, Union[torch.Tensor, Any]]) -> torch.Tensor:
"""
Perform a training step on a batch of inputs.
Subclass and override to inject custom behavior.
Args:
model (:obj:`nn.Module`):
The model to train.
... | [
"def",
"training_step",
"(",
"self",
",",
"model",
":",
"nn",
".",
"Module",
",",
"inputs",
":",
"Dict",
"[",
"str",
",",
"Union",
"[",
"torch",
".",
"Tensor",
",",
"Any",
"]",
"]",
")",
"->",
"torch",
".",
"Tensor",
":",
"model",
".",
"train",
"... | [
284,
4
] | [
333,
28
] | python | en | ['en', 'error', 'th'] | False |
_parse_gcs_url | (gsurl) |
Given a Google Cloud Storage URL (gs://<bucket>/<blob>), returns a
tuple containing the corresponding bucket and blob.
|
Given a Google Cloud Storage URL (gs://<bucket>/<blob>), returns a
tuple containing the corresponding bucket and blob.
| def _parse_gcs_url(gsurl):
"""
Given a Google Cloud Storage URL (gs://<bucket>/<blob>), returns a
tuple containing the corresponding bucket and blob.
"""
# Python 3
try:
from urllib.parse import urlparse
# Python 2
except ImportError:
from urlparse import urlparse
pa... | [
"def",
"_parse_gcs_url",
"(",
"gsurl",
")",
":",
"# Python 3",
"try",
":",
"from",
"urllib",
".",
"parse",
"import",
"urlparse",
"# Python 2",
"except",
"ImportError",
":",
"from",
"urlparse",
"import",
"urlparse",
"parsed_url",
"=",
"urlparse",
"(",
"gsurl",
... | [
519,
0
] | [
538,
27
] | python | en | ['en', 'error', 'th'] | False |
GoogleCloudStorageHook.get_conn | (self) |
Returns a Google Cloud Storage service object.
|
Returns a Google Cloud Storage service object.
| def get_conn(self):
"""
Returns a Google Cloud Storage service object.
"""
http_authorized = self._authorize()
return build(
'storage', 'v1', http=http_authorized, cache_discovery=False) | [
"def",
"get_conn",
"(",
"self",
")",
":",
"http_authorized",
"=",
"self",
".",
"_authorize",
"(",
")",
"return",
"build",
"(",
"'storage'",
",",
"'v1'",
",",
"http",
"=",
"http_authorized",
",",
"cache_discovery",
"=",
"False",
")"
] | [
41,
4
] | [
47,
73
] | python | en | ['en', 'error', 'th'] | False |
GoogleCloudStorageHook.copy | (self, source_bucket, source_object, destination_bucket=None,
destination_object=None) |
Copies an object from a bucket to another, with renaming if requested.
destination_bucket or destination_object can be omitted, in which case
source bucket/object is used, but not both.
:param source_bucket: The bucket of the object to copy from.
:type source_bucket: str
... |
Copies an object from a bucket to another, with renaming if requested. | def copy(self, source_bucket, source_object, destination_bucket=None,
destination_object=None):
"""
Copies an object from a bucket to another, with renaming if requested.
destination_bucket or destination_object can be omitted, in which case
source bucket/object is used, bu... | [
"def",
"copy",
"(",
"self",
",",
"source_bucket",
",",
"source_object",
",",
"destination_bucket",
"=",
"None",
",",
"destination_object",
"=",
"None",
")",
":",
"destination_bucket",
"=",
"destination_bucket",
"or",
"source_bucket",
"destination_object",
"=",
"dest... | [
50,
4
] | [
93,
17
] | python | en | ['en', 'error', 'th'] | False |
GoogleCloudStorageHook.rewrite | (self, source_bucket, source_object, destination_bucket,
destination_object=None) |
Has the same functionality as copy, except that will work on files
over 5 TB, as well as when copying between locations and/or storage
classes.
destination_object can be omitted, in which case source_object is used.
:param source_bucket: The bucket of the object to copy from.
... |
Has the same functionality as copy, except that will work on files
over 5 TB, as well as when copying between locations and/or storage
classes. | def rewrite(self, source_bucket, source_object, destination_bucket,
destination_object=None):
"""
Has the same functionality as copy, except that will work on files
over 5 TB, as well as when copying between locations and/or storage
classes.
destination_object ca... | [
"def",
"rewrite",
"(",
"self",
",",
"source_bucket",
",",
"source_object",
",",
"destination_bucket",
",",
"destination_object",
"=",
"None",
")",
":",
"destination_object",
"=",
"destination_object",
"or",
"source_object",
"if",
"(",
"source_bucket",
"==",
"destina... | [
95,
4
] | [
145,
17
] | python | en | ['en', 'error', 'th'] | False |
GoogleCloudStorageHook.download | (self, bucket, object, filename=None) |
Get a file from Google Cloud Storage.
:param bucket: The bucket to fetch from.
:type bucket: str
:param object: The object to fetch.
:type object: str
:param filename: If set, a local file path where the file should be written to.
:type filename: str
|
Get a file from Google Cloud Storage. | def download(self, bucket, object, filename=None):
"""
Get a file from Google Cloud Storage.
:param bucket: The bucket to fetch from.
:type bucket: str
:param object: The object to fetch.
:type object: str
:param filename: If set, a local file path where the file... | [
"def",
"download",
"(",
"self",
",",
"bucket",
",",
"object",
",",
"filename",
"=",
"None",
")",
":",
"service",
"=",
"self",
".",
"get_conn",
"(",
")",
"downloaded_file_bytes",
"=",
"service",
".",
"objects",
"(",
")",
".",
"get_media",
"(",
"bucket",
... | [
148,
4
] | [
171,
36
] | python | en | ['en', 'error', 'th'] | False |
GoogleCloudStorageHook.upload | (self, bucket, object, filename, mime_type='application/octet-stream') |
Uploads a local file to Google Cloud Storage.
:param bucket: The bucket to upload to.
:type bucket: str
:param object: The object name to set when uploading the local file.
:type object: str
:param filename: The local file path to the file to be uploaded.
:type ... |
Uploads a local file to Google Cloud Storage. | def upload(self, bucket, object, filename, mime_type='application/octet-stream'):
"""
Uploads a local file to Google Cloud Storage.
:param bucket: The bucket to upload to.
:type bucket: str
:param object: The object name to set when uploading the local file.
:type object... | [
"def",
"upload",
"(",
"self",
",",
"bucket",
",",
"object",
",",
"filename",
",",
"mime_type",
"=",
"'application/octet-stream'",
")",
":",
"service",
"=",
"self",
".",
"get_conn",
"(",
")",
"media",
"=",
"MediaFileUpload",
"(",
"filename",
",",
"mime_type",... | [
174,
4
] | [
198,
17
] | python | en | ['en', 'error', 'th'] | False |
GoogleCloudStorageHook.exists | (self, bucket, object) |
Checks for the existence of a file in Google Cloud Storage.
:param bucket: The Google cloud storage bucket where the object is.
:type bucket: str
:param object: The name of the object to check in the Google cloud
storage bucket.
:type object: str
|
Checks for the existence of a file in Google Cloud Storage. | def exists(self, bucket, object):
"""
Checks for the existence of a file in Google Cloud Storage.
:param bucket: The Google cloud storage bucket where the object is.
:type bucket: str
:param object: The name of the object to check in the Google cloud
storage bucket.
... | [
"def",
"exists",
"(",
"self",
",",
"bucket",
",",
"object",
")",
":",
"service",
"=",
"self",
".",
"get_conn",
"(",
")",
"try",
":",
"service",
".",
"objects",
"(",
")",
".",
"get",
"(",
"bucket",
"=",
"bucket",
",",
"object",
"=",
"object",
")",
... | [
201,
4
] | [
221,
17
] | python | en | ['en', 'error', 'th'] | False |
GoogleCloudStorageHook.is_updated_after | (self, bucket, object, ts) |
Checks if an object is updated in Google Cloud Storage.
:param bucket: The Google cloud storage bucket where the object is.
:type bucket: str
:param object: The name of the object to check in the Google cloud
storage bucket.
:type object: str
:param ts: The ... |
Checks if an object is updated in Google Cloud Storage. | def is_updated_after(self, bucket, object, ts):
"""
Checks if an object is updated in Google Cloud Storage.
:param bucket: The Google cloud storage bucket where the object is.
:type bucket: str
:param object: The name of the object to check in the Google cloud
storag... | [
"def",
"is_updated_after",
"(",
"self",
",",
"bucket",
",",
"object",
",",
"ts",
")",
":",
"service",
"=",
"self",
".",
"get_conn",
"(",
")",
"try",
":",
"response",
"=",
"(",
"service",
".",
"objects",
"(",
")",
".",
"get",
"(",
"bucket",
"=",
"bu... | [
224,
4
] | [
260,
20
] | python | en | ['en', 'error', 'th'] | False |
GoogleCloudStorageHook.delete | (self, bucket, object, generation=None) |
Delete an object if versioning is not enabled for the bucket, or if generation
parameter is used.
:param bucket: name of the bucket, where the object resides
:type bucket: str
:param object: name of the object to delete
:type object: str
:param generation: if pr... |
Delete an object if versioning is not enabled for the bucket, or if generation
parameter is used. | def delete(self, bucket, object, generation=None):
"""
Delete an object if versioning is not enabled for the bucket, or if generation
parameter is used.
:param bucket: name of the bucket, where the object resides
:type bucket: str
:param object: name of the object to del... | [
"def",
"delete",
"(",
"self",
",",
"bucket",
",",
"object",
",",
"generation",
"=",
"None",
")",
":",
"service",
"=",
"self",
".",
"get_conn",
"(",
")",
"try",
":",
"service",
".",
"objects",
"(",
")",
".",
"delete",
"(",
"bucket",
"=",
"bucket",
"... | [
262,
4
] | [
286,
17
] | python | en | ['en', 'error', 'th'] | False |
GoogleCloudStorageHook.list | (self, bucket, versions=None, maxResults=None, prefix=None, delimiter=None) |
List all objects from the bucket with the give string prefix in name
:param bucket: bucket name
:type bucket: str
:param versions: if true, list all versions of the objects
:type versions: bool
:param maxResults: max count of items to return in a single page of response... |
List all objects from the bucket with the give string prefix in name | def list(self, bucket, versions=None, maxResults=None, prefix=None, delimiter=None):
"""
List all objects from the bucket with the give string prefix in name
:param bucket: bucket name
:type bucket: str
:param versions: if true, list all versions of the objects
:type ver... | [
"def",
"list",
"(",
"self",
",",
"bucket",
",",
"versions",
"=",
"None",
",",
"maxResults",
"=",
"None",
",",
"prefix",
"=",
"None",
",",
"delimiter",
"=",
"None",
")",
":",
"service",
"=",
"self",
".",
"get_conn",
"(",
")",
"ids",
"=",
"list",
"("... | [
288,
4
] | [
339,
18
] | python | en | ['en', 'error', 'th'] | False |
GoogleCloudStorageHook.get_size | (self, bucket, object) |
Gets the size of a file in Google Cloud Storage.
:param bucket: The Google cloud storage bucket where the object is.
:type bucket: str
:param object: The name of the object to check in the Google cloud storage bucket.
:type object: str
|
Gets the size of a file in Google Cloud Storage. | def get_size(self, bucket, object):
"""
Gets the size of a file in Google Cloud Storage.
:param bucket: The Google cloud storage bucket where the object is.
:type bucket: str
:param object: The name of the object to check in the Google cloud storage bucket.
:type object:... | [
"def",
"get_size",
"(",
"self",
",",
"bucket",
",",
"object",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"'Checking the file size of object: %s in bucket: %s'",
",",
"object",
",",
"bucket",
")",
"service",
"=",
"self",
".",
"get_conn",
"(",
")",
"try",... | [
341,
4
] | [
370,
52
] | python | en | ['en', 'error', 'th'] | False |
GoogleCloudStorageHook.get_crc32c | (self, bucket, object) |
Gets the CRC32c checksum of an object in Google Cloud Storage.
:param bucket: The Google cloud storage bucket where the object is.
:type bucket: str
:param object: The name of the object to check in the Google cloud
storage bucket.
:type object: str
|
Gets the CRC32c checksum of an object in Google Cloud Storage. | def get_crc32c(self, bucket, object):
"""
Gets the CRC32c checksum of an object in Google Cloud Storage.
:param bucket: The Google cloud storage bucket where the object is.
:type bucket: str
:param object: The name of the object to check in the Google cloud
storage b... | [
"def",
"get_crc32c",
"(",
"self",
",",
"bucket",
",",
"object",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"'Retrieving the crc32c checksum of '",
"'object: %s in bucket: %s'",
",",
"object",
",",
"bucket",
")",
"service",
"=",
"self",
".",
"get_conn",
"(... | [
372,
4
] | [
397,
52
] | python | en | ['en', 'error', 'th'] | False |
GoogleCloudStorageHook.get_md5hash | (self, bucket, object) |
Gets the MD5 hash of an object in Google Cloud Storage.
:param bucket: The Google cloud storage bucket where the object is.
:type bucket: str
:param object: The name of the object to check in the Google cloud
storage bucket.
:type object: str
|
Gets the MD5 hash of an object in Google Cloud Storage. | def get_md5hash(self, bucket, object):
"""
Gets the MD5 hash of an object in Google Cloud Storage.
:param bucket: The Google cloud storage bucket where the object is.
:type bucket: str
:param object: The name of the object to check in the Google cloud
storage bucket.... | [
"def",
"get_md5hash",
"(",
"self",
",",
"bucket",
",",
"object",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"'Retrieving the MD5 hash of '",
"'object: %s in bucket: %s'",
",",
"object",
",",
"bucket",
")",
"service",
"=",
"self",
".",
"get_conn",
"(",
"... | [
399,
4
] | [
424,
52
] | python | en | ['en', 'error', 'th'] | False |
GoogleCloudStorageHook.create_bucket | (self,
bucket_name,
storage_class='MULTI_REGIONAL',
location='US',
project_id=None,
labels=None
) |
Creates a new bucket. Google Cloud Storage uses a flat namespace, so
you can't create a bucket with a name that is already in use.
.. seealso::
For more information, see Bucket Naming Guidelines:
https://cloud.google.com/storage/docs/bucketnaming.html#requirements
... |
Creates a new bucket. Google Cloud Storage uses a flat namespace, so
you can't create a bucket with a name that is already in use. | def create_bucket(self,
bucket_name,
storage_class='MULTI_REGIONAL',
location='US',
project_id=None,
labels=None
):
"""
Creates a new bucket. Google Cloud Storage uses a fl... | [
"def",
"create_bucket",
"(",
"self",
",",
"bucket_name",
",",
"storage_class",
"=",
"'MULTI_REGIONAL'",
",",
"location",
"=",
"'US'",
",",
"project_id",
"=",
"None",
",",
"labels",
"=",
"None",
")",
":",
"project_id",
"=",
"project_id",
"if",
"project_id",
"... | [
426,
4
] | [
516,
13
] | python | en | ['en', 'error', 'th'] | False |
async_setup_entry | (
hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities: Callable
) | Record the async_add_entities function to add them later when received from Dynalite. | Record the async_add_entities function to add them later when received from Dynalite. | async def async_setup_entry(
hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities: Callable
) -> None:
"""Record the async_add_entities function to add them later when received from Dynalite."""
async_setup_entry_base(
hass, config_entry, async_add_entities, "light", DynaliteLight
... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"config_entry",
":",
"ConfigEntry",
",",
"async_add_entities",
":",
"Callable",
")",
"->",
"None",
":",
"async_setup_entry_base",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities"... | [
10,
0
] | [
17,
5
] | python | en | ['en', 'en', 'en'] | True |
DynaliteLight.brightness | (self) | Return the brightness of this light between 0..255. | Return the brightness of this light between 0..255. | def brightness(self) -> int:
"""Return the brightness of this light between 0..255."""
return self._device.brightness | [
"def",
"brightness",
"(",
"self",
")",
"->",
"int",
":",
"return",
"self",
".",
"_device",
".",
"brightness"
] | [
24,
4
] | [
26,
38
] | python | en | ['en', 'en', 'en'] | True |
DynaliteLight.is_on | (self) | Return true if device is on. | Return true if device is on. | def is_on(self) -> bool:
"""Return true if device is on."""
return self._device.is_on | [
"def",
"is_on",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"_device",
".",
"is_on"
] | [
29,
4
] | [
31,
33
] | python | en | ['en', 'fy', 'en'] | True |
DynaliteLight.async_turn_on | (self, **kwargs) | Turn the light on. | Turn the light on. | async def async_turn_on(self, **kwargs) -> None:
"""Turn the light on."""
await self._device.async_turn_on(**kwargs) | [
"async",
"def",
"async_turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
"->",
"None",
":",
"await",
"self",
".",
"_device",
".",
"async_turn_on",
"(",
"*",
"*",
"kwargs",
")"
] | [
33,
4
] | [
35,
50
] | python | en | ['en', 'et', 'en'] | True |
DynaliteLight.async_turn_off | (self, **kwargs) | Turn the light off. | Turn the light off. | async def async_turn_off(self, **kwargs) -> None:
"""Turn the light off."""
await self._device.async_turn_off(**kwargs) | [
"async",
"def",
"async_turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
"->",
"None",
":",
"await",
"self",
".",
"_device",
".",
"async_turn_off",
"(",
"*",
"*",
"kwargs",
")"
] | [
37,
4
] | [
39,
51
] | python | en | ['en', 'zh', 'en'] | True |
DynaliteLight.supported_features | (self) | Flag supported features. | Flag supported features. | def supported_features(self) -> int:
"""Flag supported features."""
return SUPPORT_BRIGHTNESS | [
"def",
"supported_features",
"(",
"self",
")",
"->",
"int",
":",
"return",
"SUPPORT_BRIGHTNESS"
] | [
42,
4
] | [
44,
33
] | python | en | ['da', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Deluge sensors. | Set up the Deluge sensors. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Deluge sensors."""
name = config[CONF_NAME]
host = config[CONF_HOST]
username = config[CONF_USERNAME]
password = config[CONF_PASSWORD]
port = config[CONF_PORT]
deluge_api = DelugeRPCClient(host, port, userna... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"name",
"=",
"config",
"[",
"CONF_NAME",
"]",
"host",
"=",
"config",
"[",
"CONF_HOST",
"]",
"username",
"=",
"config",
"[",
"CONF_USERNA... | [
48,
0
] | [
67,
21
] | python | en | ['en', 'ca', 'en'] | True |
DelugeSensor.__init__ | (self, sensor_type, deluge_client, client_name) | Initialize the sensor. | Initialize the sensor. | def __init__(self, sensor_type, deluge_client, client_name):
"""Initialize the sensor."""
self._name = SENSOR_TYPES[sensor_type][0]
self.client = deluge_client
self.type = sensor_type
self.client_name = client_name
self._state = None
self._unit_of_measurement = SE... | [
"def",
"__init__",
"(",
"self",
",",
"sensor_type",
",",
"deluge_client",
",",
"client_name",
")",
":",
"self",
".",
"_name",
"=",
"SENSOR_TYPES",
"[",
"sensor_type",
"]",
"[",
"0",
"]",
"self",
".",
"client",
"=",
"deluge_client",
"self",
".",
"type",
"... | [
73,
4
] | [
82,
31
] | python | en | ['en', 'en', 'en'] | True |
DelugeSensor.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
return f"{self.client_name} {self._name}" | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"f\"{self.client_name} {self._name}\""
] | [
85,
4
] | [
87,
49
] | python | en | ['en', 'mi', 'en'] | True |
DelugeSensor.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._state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
90,
4
] | [
92,
26
] | python | en | ['en', 'en', 'en'] | True |
DelugeSensor.available | (self) | Return true if device is available. | Return true if device is available. | def available(self):
"""Return true if device is available."""
return self._available | [
"def",
"available",
"(",
"self",
")",
":",
"return",
"self",
".",
"_available"
] | [
95,
4
] | [
97,
30
] | python | en | ['en', 'en', 'en'] | True |
DelugeSensor.unit_of_measurement | (self) | Return the unit of measurement of this entity, if any. | Return the unit of measurement of this entity, if any. | def unit_of_measurement(self):
"""Return the unit of measurement of this entity, if any."""
return self._unit_of_measurement | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unit_of_measurement"
] | [
100,
4
] | [
102,
40
] | python | en | ['en', 'en', 'en'] | True |
DelugeSensor.update | (self) | Get the latest data from Deluge and updates the state. | Get the latest data from Deluge and updates the state. | def update(self):
"""Get the latest data from Deluge and updates the state."""
try:
self.data = self.client.call(
"core.get_session_status",
[
"upload_rate",
"download_rate",
"dht_upload_rate",
... | [
"def",
"update",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"data",
"=",
"self",
".",
"client",
".",
"call",
"(",
"\"core.get_session_status\"",
",",
"[",
"\"upload_rate\"",
",",
"\"download_rate\"",
",",
"\"dht_upload_rate\"",
",",
"\"dht_download_rate\"",... | [
104,
4
] | [
147,
69
] | python | en | ['en', 'en', 'en'] | True |
validate_input | (hass: core.HomeAssistant, data) | Validate the user input allows us to connect.
Data has the keys from DATA_SCHEMA with values provided by the user.
| Validate the user input allows us to connect. | async def validate_input(hass: core.HomeAssistant, data):
"""Validate the user input allows us to connect.
Data has the keys from DATA_SCHEMA with values provided by the user.
"""
session = async_get_clientsession(hass)
juicenet = Api(data[CONF_ACCESS_TOKEN], session)
try:
await juicen... | [
"async",
"def",
"validate_input",
"(",
"hass",
":",
"core",
".",
"HomeAssistant",
",",
"data",
")",
":",
"session",
"=",
"async_get_clientsession",
"(",
"hass",
")",
"juicenet",
"=",
"Api",
"(",
"data",
"[",
"CONF_ACCESS_TOKEN",
"]",
",",
"session",
")",
"... | [
18,
0
] | [
36,
32
] | python | en | ['en', 'en', 'en'] | True |
ConfigFlow.async_step_user | (self, user_input=None) | Handle the initial step. | Handle the initial step. | async def async_step_user(self, user_input=None):
"""Handle the initial step."""
errors = {}
if user_input is not None:
await self.async_set_unique_id(user_input[CONF_ACCESS_TOKEN])
self._abort_if_unique_id_configured()
try:
info = await vali... | [
"async",
"def",
"async_step_user",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"errors",
"=",
"{",
"}",
"if",
"user_input",
"is",
"not",
"None",
":",
"await",
"self",
".",
"async_set_unique_id",
"(",
"user_input",
"[",
"CONF_ACCESS_TOKEN",
"]",
... | [
45,
4
] | [
66,
9
] | python | en | ['en', 'en', 'en'] | True |
ConfigFlow.async_step_import | (self, user_input) | Handle import. | Handle import. | async def async_step_import(self, user_input):
"""Handle import."""
return await self.async_step_user(user_input) | [
"async",
"def",
"async_step_import",
"(",
"self",
",",
"user_input",
")",
":",
"return",
"await",
"self",
".",
"async_step_user",
"(",
"user_input",
")"
] | [
68,
4
] | [
70,
53
] | python | en | ['en', 'ja', 'en'] | False |
gen_email | (username: str) | username seems to be a 21 characters long number string, so mimic that in a reproducible way | username seems to be a 21 characters long number string, so mimic that in a reproducible way | def gen_email(username: str):
"""username seems to be a 21 characters long number string, so mimic that in a reproducible way"""
return str(int(hashlib.sha256(username.encode()).hexdigest(), 16))[0:21] | [
"def",
"gen_email",
"(",
"username",
":",
"str",
")",
":",
"return",
"str",
"(",
"int",
"(",
"hashlib",
".",
"sha256",
"(",
"username",
".",
"encode",
"(",
")",
")",
".",
"hexdigest",
"(",
")",
",",
"16",
")",
")",
"[",
"0",
":",
"21",
"]"
] | [
27,
0
] | [
29,
76
] | python | en | ['en', 'en', 'en'] | True |
entity_type_for_device_id | (device_id) | Return entity class for protocol of a given device_id.
Async friendly.
| Return entity class for protocol of a given device_id. | def entity_type_for_device_id(device_id):
"""Return entity class for protocol of a given device_id.
Async friendly.
"""
entity_type_mapping = {
# KlikAanKlikUit cover have the controls inverted
"newkaku": TYPE_INVERTED
}
protocol = device_id.split("_")[0]
return entity_type_... | [
"def",
"entity_type_for_device_id",
"(",
"device_id",
")",
":",
"entity_type_mapping",
"=",
"{",
"# KlikAanKlikUit cover have the controls inverted",
"\"newkaku\"",
":",
"TYPE_INVERTED",
"}",
"protocol",
"=",
"device_id",
".",
"split",
"(",
"\"_\"",
")",
"[",
"0",
"]"... | [
59,
0
] | [
69,
59
] | python | en | ['en', 'en', 'en'] | True |
entity_class_for_type | (entity_type) | Translate entity type to entity class.
Async friendly.
| Translate entity type to entity class. | def entity_class_for_type(entity_type):
"""Translate entity type to entity class.
Async friendly.
"""
entity_device_mapping = {
# default cover implementation
TYPE_STANDARD: RflinkCover,
# cover with open/close commands inverted
# like KAKU/COCO ASUN-650
TYPE_INV... | [
"def",
"entity_class_for_type",
"(",
"entity_type",
")",
":",
"entity_device_mapping",
"=",
"{",
"# default cover implementation",
"TYPE_STANDARD",
":",
"RflinkCover",
",",
"# cover with open/close commands inverted",
"# like KAKU/COCO ASUN-650",
"TYPE_INVERTED",
":",
"InvertedRf... | [
72,
0
] | [
85,
62
] | python | en | ['en', 'en', 'en'] | True |
devices_from_config | (domain_config) | Parse configuration and add Rflink cover devices. | Parse configuration and add Rflink cover devices. | def devices_from_config(domain_config):
"""Parse configuration and add Rflink cover devices."""
devices = []
for device_id, config in domain_config[CONF_DEVICES].items():
# Determine what kind of entity to create, RflinkCover
# or InvertedRflinkCover
if CONF_TYPE in config:
... | [
"def",
"devices_from_config",
"(",
"domain_config",
")",
":",
"devices",
"=",
"[",
"]",
"for",
"device_id",
",",
"config",
"in",
"domain_config",
"[",
"CONF_DEVICES",
"]",
".",
"items",
"(",
")",
":",
"# Determine what kind of entity to create, RflinkCover",
"# or I... | [
88,
0
] | [
106,
18
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up the Rflink cover platform. | Set up the Rflink cover platform. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the Rflink cover platform."""
async_add_entities(devices_from_config(config)) | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"async_add_entities",
"(",
"devices_from_config",
"(",
"config",
")",
")"
] | [
109,
0
] | [
111,
51
] | python | en | ['en', 'da', 'en'] | True |
RflinkCover.async_added_to_hass | (self) | Restore RFLink cover state (OPEN/CLOSE). | Restore RFLink cover state (OPEN/CLOSE). | async def async_added_to_hass(self):
"""Restore RFLink cover state (OPEN/CLOSE)."""
await super().async_added_to_hass()
old_state = await self.async_get_last_state()
if old_state is not None:
self._state = old_state.state == STATE_OPEN | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"await",
"super",
"(",
")",
".",
"async_added_to_hass",
"(",
")",
"old_state",
"=",
"await",
"self",
".",
"async_get_last_state",
"(",
")",
"if",
"old_state",
"is",
"not",
"None",
":",
"self",
"... | [
117,
4
] | [
123,
55
] | python | en | ['en', 'en', 'en'] | True |
RflinkCover._handle_event | (self, event) | Adjust state if Rflink picks up a remote command for this device. | Adjust state if Rflink picks up a remote command for this device. | def _handle_event(self, event):
"""Adjust state if Rflink picks up a remote command for this device."""
self.cancel_queued_send_commands()
command = event["command"]
if command in ["on", "allon", "up"]:
self._state = True
elif command in ["off", "alloff", "down"]:
... | [
"def",
"_handle_event",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"cancel_queued_send_commands",
"(",
")",
"command",
"=",
"event",
"[",
"\"command\"",
"]",
"if",
"command",
"in",
"[",
"\"on\"",
",",
"\"allon\"",
",",
"\"up\"",
"]",
":",
"self",
... | [
125,
4
] | [
133,
31
] | python | en | ['en', 'en', 'en'] | True |
RflinkCover.should_poll | (self) | No polling available in RFlink cover. | No polling available in RFlink cover. | def should_poll(self):
"""No polling available in RFlink cover."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
136,
4
] | [
138,
20
] | python | en | ['en', 'en', 'en'] | True |
RflinkCover.is_closed | (self) | Return if the cover is closed. | Return if the cover is closed. | def is_closed(self):
"""Return if the cover is closed."""
return not self._state | [
"def",
"is_closed",
"(",
"self",
")",
":",
"return",
"not",
"self",
".",
"_state"
] | [
141,
4
] | [
143,
30
] | 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.