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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
KefMediaPlayer.async_turn_off | (self) | Turn the media player off. | Turn the media player off. | async def async_turn_off(self):
"""Turn the media player off."""
await self._speaker.turn_off() | [
"async",
"def",
"async_turn_off",
"(",
"self",
")",
":",
"await",
"self",
".",
"_speaker",
".",
"turn_off",
"(",
")"
] | [
316,
4
] | [
318,
38
] | python | en | ['en', 'en', 'en'] | True |
KefMediaPlayer.async_turn_on | (self) | Turn the media player on. | Turn the media player on. | async def async_turn_on(self):
"""Turn the media player on."""
if not self._supports_on:
raise NotImplementedError()
await self._speaker.turn_on() | [
"async",
"def",
"async_turn_on",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_supports_on",
":",
"raise",
"NotImplementedError",
"(",
")",
"await",
"self",
".",
"_speaker",
".",
"turn_on",
"(",
")"
] | [
320,
4
] | [
324,
37
] | python | en | ['en', 'en', 'en'] | True |
KefMediaPlayer.async_volume_up | (self) | Volume up the media player. | Volume up the media player. | async def async_volume_up(self):
"""Volume up the media player."""
await self._speaker.increase_volume() | [
"async",
"def",
"async_volume_up",
"(",
"self",
")",
":",
"await",
"self",
".",
"_speaker",
".",
"increase_volume",
"(",
")"
] | [
326,
4
] | [
328,
45
] | python | en | ['en', 'en', 'en'] | True |
KefMediaPlayer.async_volume_down | (self) | Volume down the media player. | Volume down the media player. | async def async_volume_down(self):
"""Volume down the media player."""
await self._speaker.decrease_volume() | [
"async",
"def",
"async_volume_down",
"(",
"self",
")",
":",
"await",
"self",
".",
"_speaker",
".",
"decrease_volume",
"(",
")"
] | [
330,
4
] | [
332,
45
] | python | en | ['en', 'en', 'en'] | True |
KefMediaPlayer.async_set_volume_level | (self, volume) | Set volume level, range 0..1. | Set volume level, range 0..1. | async def async_set_volume_level(self, volume):
"""Set volume level, range 0..1."""
await self._speaker.set_volume(volume) | [
"async",
"def",
"async_set_volume_level",
"(",
"self",
",",
"volume",
")",
":",
"await",
"self",
".",
"_speaker",
".",
"set_volume",
"(",
"volume",
")"
] | [
334,
4
] | [
336,
46
] | python | en | ['fr', 'zu', 'en'] | False |
KefMediaPlayer.async_mute_volume | (self, mute) | Mute (True) or unmute (False) media player. | Mute (True) or unmute (False) media player. | async def async_mute_volume(self, mute):
"""Mute (True) or unmute (False) media player."""
if mute:
await self._speaker.mute()
else:
await self._speaker.unmute() | [
"async",
"def",
"async_mute_volume",
"(",
"self",
",",
"mute",
")",
":",
"if",
"mute",
":",
"await",
"self",
".",
"_speaker",
".",
"mute",
"(",
")",
"else",
":",
"await",
"self",
".",
"_speaker",
".",
"unmute",
"(",
")"
] | [
338,
4
] | [
343,
40
] | python | en | ['en', 'la', 'it'] | False |
KefMediaPlayer.async_select_source | (self, source: str) | Select input source. | Select input source. | async def async_select_source(self, source: str):
"""Select input source."""
if source in self.source_list:
await self._speaker.set_source(source)
else:
raise ValueError(f"Unknown input source: {source}.") | [
"async",
"def",
"async_select_source",
"(",
"self",
",",
"source",
":",
"str",
")",
":",
"if",
"source",
"in",
"self",
".",
"source_list",
":",
"await",
"self",
".",
"_speaker",
".",
"set_source",
"(",
"source",
")",
"else",
":",
"raise",
"ValueError",
"... | [
345,
4
] | [
350,
64
] | python | en | ['fr', 'su', 'en'] | False |
KefMediaPlayer.async_media_play | (self) | Send play command. | Send play command. | async def async_media_play(self):
"""Send play command."""
await self._speaker.set_play_pause() | [
"async",
"def",
"async_media_play",
"(",
"self",
")",
":",
"await",
"self",
".",
"_speaker",
".",
"set_play_pause",
"(",
")"
] | [
352,
4
] | [
354,
44
] | python | en | ['en', 'en', 'en'] | True |
KefMediaPlayer.async_media_pause | (self) | Send pause command. | Send pause command. | async def async_media_pause(self):
"""Send pause command."""
await self._speaker.set_play_pause() | [
"async",
"def",
"async_media_pause",
"(",
"self",
")",
":",
"await",
"self",
".",
"_speaker",
".",
"set_play_pause",
"(",
")"
] | [
356,
4
] | [
358,
44
] | python | en | ['en', 'en', 'en'] | True |
KefMediaPlayer.async_media_previous_track | (self) | Send previous track command. | Send previous track command. | async def async_media_previous_track(self):
"""Send previous track command."""
await self._speaker.prev_track() | [
"async",
"def",
"async_media_previous_track",
"(",
"self",
")",
":",
"await",
"self",
".",
"_speaker",
".",
"prev_track",
"(",
")"
] | [
360,
4
] | [
362,
40
] | python | en | ['en', 'it', 'en'] | True |
KefMediaPlayer.async_media_next_track | (self) | Send next track command. | Send next track command. | async def async_media_next_track(self):
"""Send next track command."""
await self._speaker.next_track() | [
"async",
"def",
"async_media_next_track",
"(",
"self",
")",
":",
"await",
"self",
".",
"_speaker",
".",
"next_track",
"(",
")"
] | [
364,
4
] | [
366,
40
] | python | en | ['en', 'pt', 'en'] | True |
KefMediaPlayer.update_dsp | (self, _=None) | Update the DSP settings. | Update the DSP settings. | async def update_dsp(self, _=None) -> None:
"""Update the DSP settings."""
if self._speaker_type == "LS50" and self._state == STATE_OFF:
# The LSX is able to respond when off the LS50 has to be on.
return
mode = await self._speaker.get_mode()
self._dsp = dict(
... | [
"async",
"def",
"update_dsp",
"(",
"self",
",",
"_",
"=",
"None",
")",
"->",
"None",
":",
"if",
"self",
".",
"_speaker_type",
"==",
"\"LS50\"",
"and",
"self",
".",
"_state",
"==",
"STATE_OFF",
":",
"# The LSX is able to respond when off the LS50 has to be on.",
... | [
368,
4
] | [
383,
9
] | python | en | ['en', 'en', 'en'] | True |
KefMediaPlayer.async_added_to_hass | (self) | Subscribe to DSP updates. | Subscribe to DSP updates. | async def async_added_to_hass(self):
"""Subscribe to DSP updates."""
self._update_dsp_task_remover = async_track_time_interval(
self.hass, self.update_dsp, DSP_SCAN_INTERVAL
) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"_update_dsp_task_remover",
"=",
"async_track_time_interval",
"(",
"self",
".",
"hass",
",",
"self",
".",
"update_dsp",
",",
"DSP_SCAN_INTERVAL",
")"
] | [
385,
4
] | [
389,
9
] | python | en | ['en', 'en', 'en'] | True |
KefMediaPlayer.async_will_remove_from_hass | (self) | Unsubscribe to DSP updates. | Unsubscribe to DSP updates. | async def async_will_remove_from_hass(self):
"""Unsubscribe to DSP updates."""
self._update_dsp_task_remover()
self._update_dsp_task_remover = None | [
"async",
"def",
"async_will_remove_from_hass",
"(",
"self",
")",
":",
"self",
".",
"_update_dsp_task_remover",
"(",
")",
"self",
".",
"_update_dsp_task_remover",
"=",
"None"
] | [
391,
4
] | [
394,
44
] | python | en | ['en', 'en', 'en'] | True |
KefMediaPlayer.device_state_attributes | (self) | Return the DSP settings of the KEF device. | Return the DSP settings of the KEF device. | def device_state_attributes(self):
"""Return the DSP settings of the KEF device."""
return self._dsp or {} | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"self",
".",
"_dsp",
"or",
"{",
"}"
] | [
397,
4
] | [
399,
30
] | python | en | ['en', 'en', 'en'] | True |
KefMediaPlayer.set_mode | (
self,
desk_mode=None,
wall_mode=None,
phase_correction=None,
high_pass=None,
sub_polarity=None,
bass_extension=None,
) | Set the speaker mode. | Set the speaker mode. | async def set_mode(
self,
desk_mode=None,
wall_mode=None,
phase_correction=None,
high_pass=None,
sub_polarity=None,
bass_extension=None,
):
"""Set the speaker mode."""
await self._speaker.set_mode(
desk_mode=desk_mode,
w... | [
"async",
"def",
"set_mode",
"(",
"self",
",",
"desk_mode",
"=",
"None",
",",
"wall_mode",
"=",
"None",
",",
"phase_correction",
"=",
"None",
",",
"high_pass",
"=",
"None",
",",
"sub_polarity",
"=",
"None",
",",
"bass_extension",
"=",
"None",
",",
")",
":... | [
401,
4
] | [
419,
24
] | python | en | ['en', 'no', 'en'] | True |
KefMediaPlayer.set_desk_db | (self, db_value) | Set desk_db of the KEF speakers. | Set desk_db of the KEF speakers. | async def set_desk_db(self, db_value):
"""Set desk_db of the KEF speakers."""
await self._speaker.set_desk_db(db_value)
self._dsp = None | [
"async",
"def",
"set_desk_db",
"(",
"self",
",",
"db_value",
")",
":",
"await",
"self",
".",
"_speaker",
".",
"set_desk_db",
"(",
"db_value",
")",
"self",
".",
"_dsp",
"=",
"None"
] | [
421,
4
] | [
424,
24
] | python | en | ['en', 'af', 'en'] | True |
KefMediaPlayer.set_wall_db | (self, db_value) | Set wall_db of the KEF speakers. | Set wall_db of the KEF speakers. | async def set_wall_db(self, db_value):
"""Set wall_db of the KEF speakers."""
await self._speaker.set_wall_db(db_value)
self._dsp = None | [
"async",
"def",
"set_wall_db",
"(",
"self",
",",
"db_value",
")",
":",
"await",
"self",
".",
"_speaker",
".",
"set_wall_db",
"(",
"db_value",
")",
"self",
".",
"_dsp",
"=",
"None"
] | [
426,
4
] | [
429,
24
] | python | en | ['en', 'en', 'en'] | True |
KefMediaPlayer.set_treble_db | (self, db_value) | Set treble_db of the KEF speakers. | Set treble_db of the KEF speakers. | async def set_treble_db(self, db_value):
"""Set treble_db of the KEF speakers."""
await self._speaker.set_treble_db(db_value)
self._dsp = None | [
"async",
"def",
"set_treble_db",
"(",
"self",
",",
"db_value",
")",
":",
"await",
"self",
".",
"_speaker",
".",
"set_treble_db",
"(",
"db_value",
")",
"self",
".",
"_dsp",
"=",
"None"
] | [
431,
4
] | [
434,
24
] | python | en | ['en', 'af', 'en'] | True |
KefMediaPlayer.set_high_hz | (self, hz_value) | Set high_hz of the KEF speakers. | Set high_hz of the KEF speakers. | async def set_high_hz(self, hz_value):
"""Set high_hz of the KEF speakers."""
await self._speaker.set_high_hz(hz_value)
self._dsp = None | [
"async",
"def",
"set_high_hz",
"(",
"self",
",",
"hz_value",
")",
":",
"await",
"self",
".",
"_speaker",
".",
"set_high_hz",
"(",
"hz_value",
")",
"self",
".",
"_dsp",
"=",
"None"
] | [
436,
4
] | [
439,
24
] | python | en | ['en', 'en', 'en'] | True |
KefMediaPlayer.set_low_hz | (self, hz_value) | Set low_hz of the KEF speakers. | Set low_hz of the KEF speakers. | async def set_low_hz(self, hz_value):
"""Set low_hz of the KEF speakers."""
await self._speaker.set_low_hz(hz_value)
self._dsp = None | [
"async",
"def",
"set_low_hz",
"(",
"self",
",",
"hz_value",
")",
":",
"await",
"self",
".",
"_speaker",
".",
"set_low_hz",
"(",
"hz_value",
")",
"self",
".",
"_dsp",
"=",
"None"
] | [
441,
4
] | [
444,
24
] | python | en | ['en', 'af', 'en'] | True |
KefMediaPlayer.set_sub_db | (self, db_value) | Set sub_db of the KEF speakers. | Set sub_db of the KEF speakers. | async def set_sub_db(self, db_value):
"""Set sub_db of the KEF speakers."""
await self._speaker.set_sub_db(db_value)
self._dsp = None | [
"async",
"def",
"set_sub_db",
"(",
"self",
",",
"db_value",
")",
":",
"await",
"self",
".",
"_speaker",
".",
"set_sub_db",
"(",
"db_value",
")",
"self",
".",
"_dsp",
"=",
"None"
] | [
446,
4
] | [
449,
24
] | python | en | ['en', 'en', 'en'] | True |
test_search | (hass) | Test that search works. | Test that search works. | async def test_search(hass):
"""Test that search works."""
area_reg = await hass.helpers.area_registry.async_get_registry()
device_reg = await hass.helpers.device_registry.async_get_registry()
entity_reg = await hass.helpers.entity_registry.async_get_registry()
living_room_area = area_reg.async_cre... | [
"async",
"def",
"test_search",
"(",
"hass",
")",
":",
"area_reg",
"=",
"await",
"hass",
".",
"helpers",
".",
"area_registry",
".",
"async_get_registry",
"(",
")",
"device_reg",
"=",
"await",
"hass",
".",
"helpers",
".",
"device_registry",
".",
"async_get_regis... | [
7,
0
] | [
269,
66
] | python | en | ['en', 'en', 'en'] | True |
test_ws_api | (hass, hass_ws_client) | Test WS API. | Test WS API. | async def test_ws_api(hass, hass_ws_client):
"""Test WS API."""
assert await async_setup_component(hass, "search", {})
area_reg = await hass.helpers.area_registry.async_get_registry()
device_reg = await hass.helpers.device_registry.async_get_registry()
kitchen_area = area_reg.async_create("Kitchen... | [
"async",
"def",
"test_ws_api",
"(",
"hass",
",",
"hass_ws_client",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"search\"",
",",
"{",
"}",
")",
"area_reg",
"=",
"await",
"hass",
".",
"helpers",
".",
"area_registry",
".",
"async_g... | [
272,
0
] | [
307,
5
] | python | en | ['en', 'pl', 'en'] | True |
calls | (hass) | Track calls to a mock service. | Track calls to a mock service. | def calls(hass):
"""Track calls to a mock service."""
return async_mock_service(hass, "test", "automation") | [
"def",
"calls",
"(",
"hass",
")",
":",
"return",
"async_mock_service",
"(",
"hass",
",",
"\"test\"",
",",
"\"automation\"",
")"
] | [
22,
0
] | [
24,
57
] | python | en | ['en', 'en', 'en'] | True |
setup_comp | (hass) | Initialize components. | Initialize components. | def setup_comp(hass):
"""Initialize components."""
mock_component(hass, "group") | [
"def",
"setup_comp",
"(",
"hass",
")",
":",
"mock_component",
"(",
"hass",
",",
"\"group\"",
")"
] | [
28,
0
] | [
30,
33
] | python | en | ['de', 'en', 'en'] | False |
test_if_fires_using_at | (hass, calls) | Test for firing at. | Test for firing at. | async def test_if_fires_using_at(hass, calls):
"""Test for firing at."""
now = dt_util.now()
trigger_dt = now.replace(hour=5, minute=0, second=0, microsecond=0) + timedelta(2)
time_that_will_not_match_right_away = trigger_dt - timedelta(minutes=1)
with patch(
"homeassistant.util.dt.utcnow"... | [
"async",
"def",
"test_if_fires_using_at",
"(",
"hass",
",",
"calls",
")",
":",
"now",
"=",
"dt_util",
".",
"now",
"(",
")",
"trigger_dt",
"=",
"now",
".",
"replace",
"(",
"hour",
"=",
"5",
",",
"minute",
"=",
"0",
",",
"second",
"=",
"0",
",",
"mic... | [
33,
0
] | [
65,
46
] | python | en | ['en', 'en', 'en'] | True |
test_if_fires_using_at_input_datetime | (hass, calls, has_date, has_time) | Test for firing at input_datetime. | Test for firing at input_datetime. | async def test_if_fires_using_at_input_datetime(hass, calls, has_date, has_time):
"""Test for firing at input_datetime."""
await async_setup_component(
hass,
"input_datetime",
{"input_datetime": {"trigger": {"has_date": has_date, "has_time": has_time}}},
)
now = dt_util.now()
... | [
"async",
"def",
"test_if_fires_using_at_input_datetime",
"(",
"hass",
",",
"calls",
",",
"has_date",
",",
"has_time",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"input_datetime\"",
",",
"{",
"\"input_datetime\"",
":",
"{",
"\"trigger\"",
":",
... | [
71,
0
] | [
147,
5
] | python | en | ['en', 'en', 'en'] | True |
test_if_fires_using_multiple_at | (hass, calls) | Test for firing at. | Test for firing at. | async def test_if_fires_using_multiple_at(hass, calls):
"""Test for firing at."""
now = dt_util.now()
trigger_dt = now.replace(hour=5, minute=0, second=0, microsecond=0) + timedelta(2)
time_that_will_not_match_right_away = trigger_dt - timedelta(minutes=1)
with patch(
"homeassistant.util.... | [
"async",
"def",
"test_if_fires_using_multiple_at",
"(",
"hass",
",",
"calls",
")",
":",
"now",
"=",
"dt_util",
".",
"now",
"(",
")",
"trigger_dt",
"=",
"now",
".",
"replace",
"(",
"hour",
"=",
"5",
",",
"minute",
"=",
"0",
",",
"second",
"=",
"0",
",... | [
150,
0
] | [
189,
46
] | python | en | ['en', 'en', 'en'] | True |
test_if_not_fires_using_wrong_at | (hass, calls) | YAML translates time values to total seconds.
This should break the before rule.
| YAML translates time values to total seconds. | async def test_if_not_fires_using_wrong_at(hass, calls):
"""YAML translates time values to total seconds.
This should break the before rule.
"""
now = dt_util.utcnow()
time_that_will_not_match_right_away = now.replace(
year=now.year + 1, hour=1, minute=0, second=0
)
with patch(
... | [
"async",
"def",
"test_if_not_fires_using_wrong_at",
"(",
"hass",
",",
"calls",
")",
":",
"now",
"=",
"dt_util",
".",
"utcnow",
"(",
")",
"time_that_will_not_match_right_away",
"=",
"now",
".",
"replace",
"(",
"year",
"=",
"now",
".",
"year",
"+",
"1",
",",
... | [
192,
0
] | [
228,
26
] | python | en | ['en', 'en', 'en'] | True |
test_if_action_before | (hass, calls) | Test for if action before. | Test for if action before. | async def test_if_action_before(hass, calls):
"""Test for if action before."""
assert await async_setup_component(
hass,
automation.DOMAIN,
{
automation.DOMAIN: {
"trigger": {"platform": "event", "event_type": "test_event"},
"condition": {"cond... | [
"async",
"def",
"test_if_action_before",
"(",
"hass",
",",
"calls",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"automation",
".",
"DOMAIN",
",",
"{",
"automation",
".",
"DOMAIN",
":",
"{",
"\"trigger\"",
":",
"{",
"\"platform\"",
... | [
231,
0
] | [
259,
26
] | python | en | ['en', 'en', 'en'] | True |
test_if_action_after | (hass, calls) | Test for if action after. | Test for if action after. | async def test_if_action_after(hass, calls):
"""Test for if action after."""
assert await async_setup_component(
hass,
automation.DOMAIN,
{
automation.DOMAIN: {
"trigger": {"platform": "event", "event_type": "test_event"},
"condition": {"condit... | [
"async",
"def",
"test_if_action_after",
"(",
"hass",
",",
"calls",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"automation",
".",
"DOMAIN",
",",
"{",
"automation",
".",
"DOMAIN",
":",
"{",
"\"trigger\"",
":",
"{",
"\"platform\"",
... | [
262,
0
] | [
290,
26
] | python | en | ['da', 'en', 'en'] | True |
test_if_action_one_weekday | (hass, calls) | Test for if action with one weekday. | Test for if action with one weekday. | async def test_if_action_one_weekday(hass, calls):
"""Test for if action with one weekday."""
assert await async_setup_component(
hass,
automation.DOMAIN,
{
automation.DOMAIN: {
"trigger": {"platform": "event", "event_type": "test_event"},
"con... | [
"async",
"def",
"test_if_action_one_weekday",
"(",
"hass",
",",
"calls",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"automation",
".",
"DOMAIN",
",",
"{",
"automation",
".",
"DOMAIN",
":",
"{",
"\"trigger\"",
":",
"{",
"\"platform\... | [
293,
0
] | [
322,
26
] | python | en | ['en', 'en', 'en'] | True |
test_if_action_list_weekday | (hass, calls) | Test for action with a list of weekdays. | Test for action with a list of weekdays. | async def test_if_action_list_weekday(hass, calls):
"""Test for action with a list of weekdays."""
assert await async_setup_component(
hass,
automation.DOMAIN,
{
automation.DOMAIN: {
"trigger": {"platform": "event", "event_type": "test_event"},
... | [
"async",
"def",
"test_if_action_list_weekday",
"(",
"hass",
",",
"calls",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"automation",
".",
"DOMAIN",
",",
"{",
"automation",
".",
"DOMAIN",
":",
"{",
"\"trigger\"",
":",
"{",
"\"platform... | [
325,
0
] | [
361,
26
] | python | en | ['en', 'en', 'en'] | True |
test_untrack_time_change | (hass) | Test for removing tracked time changes. | Test for removing tracked time changes. | async def test_untrack_time_change(hass):
"""Test for removing tracked time changes."""
mock_track_time_change = Mock()
with patch(
"homeassistant.components.homeassistant.triggers.time.async_track_time_change",
return_value=mock_track_time_change,
):
assert await async_setup_com... | [
"async",
"def",
"test_untrack_time_change",
"(",
"hass",
")",
":",
"mock_track_time_change",
"=",
"Mock",
"(",
")",
"with",
"patch",
"(",
"\"homeassistant.components.homeassistant.triggers.time.async_track_time_change\"",
",",
"return_value",
"=",
"mock_track_time_change",
",... | [
364,
0
] | [
394,
54
] | python | en | ['en', 'en', 'en'] | True |
test_if_fires_using_at_sensor | (hass, calls) | Test for firing at sensor time. | Test for firing at sensor time. | async def test_if_fires_using_at_sensor(hass, calls):
"""Test for firing at sensor time."""
now = dt_util.now()
trigger_dt = now.replace(hour=5, minute=0, second=0, microsecond=0) + timedelta(2)
hass.states.async_set(
"sensor.next_alarm",
trigger_dt.isoformat(),
{ATTR_DEVICE_CL... | [
"async",
"def",
"test_if_fires_using_at_sensor",
"(",
"hass",
",",
"calls",
")",
":",
"now",
"=",
"dt_util",
".",
"now",
"(",
")",
"trigger_dt",
"=",
"now",
".",
"replace",
"(",
"hour",
"=",
"5",
",",
"minute",
"=",
"0",
",",
"second",
"=",
"0",
",",... | [
397,
0
] | [
495,
26
] | python | da | ['da', 'no', 'en'] | False |
test_schema_valid | (conf) | Make sure we don't accept number for 'at' value. | Make sure we don't accept number for 'at' value. | def test_schema_valid(conf):
"""Make sure we don't accept number for 'at' value."""
time.TRIGGER_SCHEMA(conf) | [
"def",
"test_schema_valid",
"(",
"conf",
")",
":",
"time",
".",
"TRIGGER_SCHEMA",
"(",
"conf",
")"
] | [
506,
0
] | [
508,
29
] | python | en | ['en', 'en', 'en'] | True |
test_schema_invalid | (conf) | Make sure we don't accept number for 'at' value. | Make sure we don't accept number for 'at' value. | def test_schema_invalid(conf):
"""Make sure we don't accept number for 'at' value."""
with pytest.raises(vol.Invalid):
time.TRIGGER_SCHEMA(conf) | [
"def",
"test_schema_invalid",
"(",
"conf",
")",
":",
"with",
"pytest",
".",
"raises",
"(",
"vol",
".",
"Invalid",
")",
":",
"time",
".",
"TRIGGER_SCHEMA",
"(",
"conf",
")"
] | [
519,
0
] | [
522,
33
] | python | en | ['en', 'en', 'en'] | True |
test_datetime_in_past_on_load | (hass, calls) | Test time trigger works if input_datetime is in past. | Test time trigger works if input_datetime is in past. | async def test_datetime_in_past_on_load(hass, calls):
"""Test time trigger works if input_datetime is in past."""
await async_setup_component(
hass,
"input_datetime",
{"input_datetime": {"my_trigger": {"has_date": True, "has_time": True}}},
)
now = dt_util.now()
past = now -... | [
"async",
"def",
"test_datetime_in_past_on_load",
"(",
"hass",
",",
"calls",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"input_datetime\"",
",",
"{",
"\"input_datetime\"",
":",
"{",
"\"my_trigger\"",
":",
"{",
"\"has_date\"",
":",
"True",
",",
... | [
525,
0
] | [
585,
5
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up a sensor for a Hydrawise device. | Set up a sensor for a Hydrawise device. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up a sensor for a Hydrawise device."""
hydrawise = hass.data[DATA_HYDRAWISE].data
default_watering_timer = config.get(CONF_WATERING_TIME)
sensors = []
for sensor_type in config.get(CONF_MONITORED_CONDITIONS):
# Cre... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"hydrawise",
"=",
"hass",
".",
"data",
"[",
"DATA_HYDRAWISE",
"]",
".",
"data",
"default_watering_timer",
"=",
"config",
".",
"get",
"(",
... | [
32,
0
] | [
44,
31
] | python | en | ['en', 'en', 'en'] | True |
HydrawiseSwitch.__init__ | (self, default_watering_timer, *args) | Initialize a switch for Hydrawise device. | Initialize a switch for Hydrawise device. | def __init__(self, default_watering_timer, *args):
"""Initialize a switch for Hydrawise device."""
super().__init__(*args)
self._default_watering_timer = default_watering_timer | [
"def",
"__init__",
"(",
"self",
",",
"default_watering_timer",
",",
"*",
"args",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"*",
"args",
")",
"self",
".",
"_default_watering_timer",
"=",
"default_watering_timer"
] | [
50,
4
] | [
53,
61
] | python | en | ['en', 'en', 'en'] | True |
HydrawiseSwitch.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._state | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
56,
4
] | [
58,
26
] | python | en | ['en', 'fy', 'en'] | True |
HydrawiseSwitch.turn_on | (self, **kwargs) | Turn the device on. | Turn the device on. | def turn_on(self, **kwargs):
"""Turn the device on."""
relay_data = self.data["relay"] - 1
if self._sensor_type == "manual_watering":
self.hass.data[DATA_HYDRAWISE].data.run_zone(
self._default_watering_timer, relay_data
)
elif self._sensor_type ==... | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"relay_data",
"=",
"self",
".",
"data",
"[",
"\"relay\"",
"]",
"-",
"1",
"if",
"self",
".",
"_sensor_type",
"==",
"\"manual_watering\"",
":",
"self",
".",
"hass",
".",
"data",
"[",
"DA... | [
60,
4
] | [
68,
75
] | python | en | ['en', 'en', 'en'] | True |
HydrawiseSwitch.turn_off | (self, **kwargs) | Turn the device off. | Turn the device off. | def turn_off(self, **kwargs):
"""Turn the device off."""
relay_data = self.data["relay"] - 1
if self._sensor_type == "manual_watering":
self.hass.data[DATA_HYDRAWISE].data.run_zone(0, relay_data)
elif self._sensor_type == "auto_watering":
self.hass.data[DATA_HYDRA... | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"relay_data",
"=",
"self",
".",
"data",
"[",
"\"relay\"",
"]",
"-",
"1",
"if",
"self",
".",
"_sensor_type",
"==",
"\"manual_watering\"",
":",
"self",
".",
"hass",
".",
"data",
"[",
"D... | [
70,
4
] | [
76,
77
] | python | en | ['en', 'en', 'en'] | True |
HydrawiseSwitch.update | (self) | Update device state. | Update device state. | def update(self):
"""Update device state."""
relay_data = self.data["relay"] - 1
mydata = self.hass.data[DATA_HYDRAWISE].data
_LOGGER.debug("Updating Hydrawise switch: %s", self._name)
if self._sensor_type == "manual_watering":
self._state = mydata.relays[relay_data][... | [
"def",
"update",
"(",
"self",
")",
":",
"relay_data",
"=",
"self",
".",
"data",
"[",
"\"relay\"",
"]",
"-",
"1",
"mydata",
"=",
"self",
".",
"hass",
".",
"data",
"[",
"DATA_HYDRAWISE",
"]",
".",
"data",
"_LOGGER",
".",
"debug",
"(",
"\"Updating Hydrawi... | [
78,
4
] | [
88,
13
] | python | en | ['fr', 'en', 'en'] | True |
HMDevice.__init__ | (self, config) | Initialize a generic HomeMatic device. | Initialize a generic HomeMatic device. | def __init__(self, config):
"""Initialize a generic HomeMatic device."""
self._name = config.get(ATTR_NAME)
self._address = config.get(ATTR_ADDRESS)
self._interface = config.get(ATTR_INTERFACE)
self._channel = config.get(ATTR_CHANNEL)
self._state = config.get(ATTR_PARAM)
... | [
"def",
"__init__",
"(",
"self",
",",
"config",
")",
":",
"self",
".",
"_name",
"=",
"config",
".",
"get",
"(",
"ATTR_NAME",
")",
"self",
".",
"_address",
"=",
"config",
".",
"get",
"(",
"ATTR_ADDRESS",
")",
"self",
".",
"_interface",
"=",
"config",
"... | [
29,
4
] | [
46,
45
] | python | en | ['en', 'en', 'en'] | True |
HMDevice.async_added_to_hass | (self) | Load data init callbacks. | Load data init callbacks. | async def async_added_to_hass(self):
"""Load data init callbacks."""
self._subscribe_homematic_events() | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"_subscribe_homematic_events",
"(",
")"
] | [
48,
4
] | [
50,
42
] | python | bg | ['es', 'bg', 'en'] | False |
HMDevice.unique_id | (self) | Return unique ID. HomeMatic entity IDs are unique by default. | Return unique ID. HomeMatic entity IDs are unique by default. | def unique_id(self):
"""Return unique ID. HomeMatic entity IDs are unique by default."""
return self._unique_id.replace(" ", "_") | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unique_id",
".",
"replace",
"(",
"\" \"",
",",
"\"_\"",
")"
] | [
53,
4
] | [
55,
48
] | python | en | ['en', 'fr', 'en'] | True |
HMDevice.should_poll | (self) | Return false. HomeMatic states are pushed by the XML-RPC Server. | Return false. HomeMatic states are pushed by the XML-RPC Server. | def should_poll(self):
"""Return false. HomeMatic states are pushed by the XML-RPC Server."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
58,
4
] | [
60,
20
] | python | en | ['en', 'en', 'en'] | True |
HMDevice.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"
] | [
63,
4
] | [
65,
25
] | python | en | ['en', 'en', 'en'] | True |
HMDevice.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"
] | [
68,
4
] | [
70,
30
] | python | en | ['en', 'en', 'en'] | True |
HMDevice.device_state_attributes | (self) | Return device specific state attributes. | Return device specific state attributes. | def device_state_attributes(self):
"""Return device specific state attributes."""
# Static attributes
attr = {
"id": self._hmdevice.ADDRESS,
"interface": self._interface,
}
# Generate a dictionary with attributes
for node, data in HM_ATTRIBUTE_SU... | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"# Static attributes",
"attr",
"=",
"{",
"\"id\"",
":",
"self",
".",
"_hmdevice",
".",
"ADDRESS",
",",
"\"interface\"",
":",
"self",
".",
"_interface",
",",
"}",
"# Generate a dictionary with attributes",
"f... | [
73,
4
] | [
89,
19
] | python | en | ['fr', 'en', 'en'] | True |
HMDevice.update | (self) | Connect to HomeMatic init values. | Connect to HomeMatic init values. | def update(self):
"""Connect to HomeMatic init values."""
if self._connected:
return True
# Initialize
self._homematic = self.hass.data[DATA_HOMEMATIC]
self._hmdevice = self._homematic.devices[self._interface][self._address]
self._connected = True
tr... | [
"def",
"update",
"(",
"self",
")",
":",
"if",
"self",
".",
"_connected",
":",
"return",
"True",
"# Initialize",
"self",
".",
"_homematic",
"=",
"self",
".",
"hass",
".",
"data",
"[",
"DATA_HOMEMATIC",
"]",
"self",
".",
"_hmdevice",
"=",
"self",
".",
"_... | [
91,
4
] | [
110,
84
] | python | en | ['en', 'en', 'en'] | True |
HMDevice._hm_event_callback | (self, device, caller, attribute, value) | Handle all pyhomematic device events. | Handle all pyhomematic device events. | def _hm_event_callback(self, device, caller, attribute, value):
"""Handle all pyhomematic device events."""
has_changed = False
# Is data needed for this instance?
if f"{attribute}:{device.partition(':')[2]}" in self._channel_map:
self._data[attribute] = value
ha... | [
"def",
"_hm_event_callback",
"(",
"self",
",",
"device",
",",
"caller",
",",
"attribute",
",",
"value",
")",
":",
"has_changed",
"=",
"False",
"# Is data needed for this instance?",
"if",
"f\"{attribute}:{device.partition(':')[2]}\"",
"in",
"self",
".",
"_channel_map",
... | [
112,
4
] | [
128,
43
] | python | en | ['en', 'en', 'en'] | True |
HMDevice._subscribe_homematic_events | (self) | Subscribe all required events to handle job. | Subscribe all required events to handle job. | def _subscribe_homematic_events(self):
"""Subscribe all required events to handle job."""
for metadata in (
self._hmdevice.SENSORNODE,
self._hmdevice.BINARYNODE,
self._hmdevice.ATTRIBUTENODE,
self._hmdevice.WRITENODE,
self._hmdevice.EVENTNODE,
... | [
"def",
"_subscribe_homematic_events",
"(",
"self",
")",
":",
"for",
"metadata",
"in",
"(",
"self",
".",
"_hmdevice",
".",
"SENSORNODE",
",",
"self",
".",
"_hmdevice",
".",
"BINARYNODE",
",",
"self",
".",
"_hmdevice",
".",
"ATTRIBUTENODE",
",",
"self",
".",
... | [
130,
4
] | [
152,
88
] | python | en | ['en', 'en', 'en'] | True |
HMDevice._load_data_from_hm | (self) | Load first value from pyhomematic. | Load first value from pyhomematic. | def _load_data_from_hm(self):
"""Load first value from pyhomematic."""
if not self._connected:
return False
# Read data from pyhomematic
for metadata, funct in (
(self._hmdevice.ATTRIBUTENODE, self._hmdevice.getAttributeData),
(self._hmdevice.WRITENOD... | [
"def",
"_load_data_from_hm",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_connected",
":",
"return",
"False",
"# Read data from pyhomematic",
"for",
"metadata",
",",
"funct",
"in",
"(",
"(",
"self",
".",
"_hmdevice",
".",
"ATTRIBUTENODE",
",",
"self",
... | [
154,
4
] | [
170,
19
] | python | en | ['en', 'en', 'en'] | True |
HMDevice._hm_set_state | (self, value) | Set data to main datapoint. | Set data to main datapoint. | def _hm_set_state(self, value):
"""Set data to main datapoint."""
if self._state in self._data:
self._data[self._state] = value | [
"def",
"_hm_set_state",
"(",
"self",
",",
"value",
")",
":",
"if",
"self",
".",
"_state",
"in",
"self",
".",
"_data",
":",
"self",
".",
"_data",
"[",
"self",
".",
"_state",
"]",
"=",
"value"
] | [
172,
4
] | [
175,
43
] | python | en | ['en', 'sn', 'ur'] | False |
HMDevice._hm_get_state | (self) | Get data from main datapoint. | Get data from main datapoint. | def _hm_get_state(self):
"""Get data from main datapoint."""
if self._state in self._data:
return self._data[self._state]
return None | [
"def",
"_hm_get_state",
"(",
"self",
")",
":",
"if",
"self",
".",
"_state",
"in",
"self",
".",
"_data",
":",
"return",
"self",
".",
"_data",
"[",
"self",
".",
"_state",
"]",
"return",
"None"
] | [
177,
4
] | [
181,
19
] | python | en | ['en', 'en', 'en'] | True |
HMDevice._init_data | (self) | Generate a data dict (self._data) from the HomeMatic metadata. | Generate a data dict (self._data) from the HomeMatic metadata. | def _init_data(self):
"""Generate a data dict (self._data) from the HomeMatic metadata."""
# Add all attributes to data dictionary
for data_note in self._hmdevice.ATTRIBUTENODE:
self._data.update({data_note: None})
# Initialize device specific data
self._init_data_st... | [
"def",
"_init_data",
"(",
"self",
")",
":",
"# Add all attributes to data dictionary",
"for",
"data_note",
"in",
"self",
".",
"_hmdevice",
".",
"ATTRIBUTENODE",
":",
"self",
".",
"_data",
".",
"update",
"(",
"{",
"data_note",
":",
"None",
"}",
")",
"# Initiali... | [
183,
4
] | [
190,
32
] | python | en | ['en', 'en', 'en'] | True |
HMDevice._init_data_struct | (self) | Generate a data dictionary from the HomeMatic device metadata. | Generate a data dictionary from the HomeMatic device metadata. | def _init_data_struct(self):
"""Generate a data dictionary from the HomeMatic device metadata.""" | [
"def",
"_init_data_struct",
"(",
"self",
")",
":"
] | [
193,
4
] | [
194,
76
] | python | en | ['en', 'en', 'en'] | True |
HMHub.__init__ | (self, hass, homematic, name) | Initialize HomeMatic hub. | Initialize HomeMatic hub. | def __init__(self, hass, homematic, name):
"""Initialize HomeMatic hub."""
self.hass = hass
self.entity_id = f"{DOMAIN}.{name.lower()}"
self._homematic = homematic
self._variables = {}
self._name = name
self._state = None
# Load data
self.hass.hel... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"homematic",
",",
"name",
")",
":",
"self",
".",
"hass",
"=",
"hass",
"self",
".",
"entity_id",
"=",
"f\"{DOMAIN}.{name.lower()}\"",
"self",
".",
"_homematic",
"=",
"homematic",
"self",
".",
"_variables",
"... | [
200,
4
] | [
216,
55
] | python | en | ['en', 'bg', 'en'] | True |
HMHub.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"
] | [
219,
4
] | [
221,
25
] | python | en | ['en', 'en', 'en'] | True |
HMHub.should_poll | (self) | Return false. HomeMatic Hub object updates variables. | Return false. HomeMatic Hub object updates variables. | def should_poll(self):
"""Return false. HomeMatic Hub object updates variables."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
224,
4
] | [
226,
20
] | python | en | ['en', 'no', 'en'] | True |
HMHub.state | (self) | Return the state of the entity. | Return the state of the entity. | def state(self):
"""Return the state of the entity."""
return self._state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
229,
4
] | [
231,
26
] | python | en | ['en', 'en', 'en'] | True |
HMHub.state_attributes | (self) | Return the state attributes. | Return the state attributes. | def state_attributes(self):
"""Return the state attributes."""
return self._variables.copy() | [
"def",
"state_attributes",
"(",
"self",
")",
":",
"return",
"self",
".",
"_variables",
".",
"copy",
"(",
")"
] | [
234,
4
] | [
236,
37
] | python | en | ['en', 'en', 'en'] | True |
HMHub.icon | (self) | Return the icon to use in the frontend, if any. | Return the icon to use in the frontend, if any. | def icon(self):
"""Return the icon to use in the frontend, if any."""
return "mdi:gradient" | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"\"mdi:gradient\""
] | [
239,
4
] | [
241,
29
] | python | en | ['en', 'en', 'en'] | True |
HMHub._update_hub | (self, now) | Retrieve latest state. | Retrieve latest state. | def _update_hub(self, now):
"""Retrieve latest state."""
service_message = self._homematic.getServiceMessages(self._name)
state = None if service_message is None else len(service_message)
# state have change?
if self._state != state:
self._state = state
s... | [
"def",
"_update_hub",
"(",
"self",
",",
"now",
")",
":",
"service_message",
"=",
"self",
".",
"_homematic",
".",
"getServiceMessages",
"(",
"self",
".",
"_name",
")",
"state",
"=",
"None",
"if",
"service_message",
"is",
"None",
"else",
"len",
"(",
"service... | [
243,
4
] | [
251,
43
] | python | en | ['es', 'sk', 'en'] | False |
HMHub._update_variables | (self, now) | Retrieve all variable data and update hmvariable states. | Retrieve all variable data and update hmvariable states. | def _update_variables(self, now):
"""Retrieve all variable data and update hmvariable states."""
variables = self._homematic.getAllSystemVariables(self._name)
if variables is None:
return
state_change = False
for key, value in variables.items():
if key in... | [
"def",
"_update_variables",
"(",
"self",
",",
"now",
")",
":",
"variables",
"=",
"self",
".",
"_homematic",
".",
"getAllSystemVariables",
"(",
"self",
".",
"_name",
")",
"if",
"variables",
"is",
"None",
":",
"return",
"state_change",
"=",
"False",
"for",
"... | [
253,
4
] | [
268,
43
] | python | en | ['en', 'en', 'en'] | True |
HMHub.hm_set_variable | (self, name, value) | Set variable value on CCU/Homegear. | Set variable value on CCU/Homegear. | def hm_set_variable(self, name, value):
"""Set variable value on CCU/Homegear."""
if name not in self._variables:
_LOGGER.error("Variable %s not found on %s", name, self.name)
return
old_value = self._variables.get(name)
if isinstance(old_value, bool):
... | [
"def",
"hm_set_variable",
"(",
"self",
",",
"name",
",",
"value",
")",
":",
"if",
"name",
"not",
"in",
"self",
".",
"_variables",
":",
"_LOGGER",
".",
"error",
"(",
"\"Variable %s not found on %s\"",
",",
"name",
",",
"self",
".",
"name",
")",
"return",
... | [
270,
4
] | [
283,
39
] | python | en | ['en', 'ga', 'en'] | True |
init_integration | (
hass: HomeAssistant,
aioclient_mock: AiohttpClientMocker,
rgbw: bool = False,
skip_setup: bool = False,
) | Set up the WLED integration in Home Assistant. | Set up the WLED integration in Home Assistant. | async def init_integration(
hass: HomeAssistant,
aioclient_mock: AiohttpClientMocker,
rgbw: bool = False,
skip_setup: bool = False,
) -> MockConfigEntry:
"""Set up the WLED integration in Home Assistant."""
fixture = "wled/rgb.json" if not rgbw else "wled/rgbw.json"
data = json.loads(load_f... | [
"async",
"def",
"init_integration",
"(",
"hass",
":",
"HomeAssistant",
",",
"aioclient_mock",
":",
"AiohttpClientMocker",
",",
"rgbw",
":",
"bool",
"=",
"False",
",",
"skip_setup",
":",
"bool",
"=",
"False",
",",
")",
"->",
"MockConfigEntry",
":",
"fixture",
... | [
12,
0
] | [
57,
16
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up Plex sensor from a config entry. | Set up Plex sensor from a config entry. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up Plex sensor from a config entry."""
server_id = config_entry.data[CONF_SERVER_IDENTIFIER]
plexserver = hass.data[PLEX_DOMAIN][SERVERS][server_id]
sensor = PlexSensor(plexserver)
async_add_entities([sensor]) | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"server_id",
"=",
"config_entry",
".",
"data",
"[",
"CONF_SERVER_IDENTIFIER",
"]",
"plexserver",
"=",
"hass",
".",
"data",
"[",
"PLEX_DOMAIN",
"]",
"[",
... | [
24,
0
] | [
29,
32
] | python | en | ['en', 'pt', 'en'] | True |
PlexSensor.__init__ | (self, plex_server) | Initialize the sensor. | Initialize the sensor. | def __init__(self, plex_server):
"""Initialize the sensor."""
self.sessions = []
self._state = None
self._now_playing = []
self._server = plex_server
self._name = NAME_FORMAT.format(plex_server.friendly_name)
self._unique_id = f"sensor-{plex_server.machine_identif... | [
"def",
"__init__",
"(",
"self",
",",
"plex_server",
")",
":",
"self",
".",
"sessions",
"=",
"[",
"]",
"self",
".",
"_state",
"=",
"None",
"self",
".",
"_now_playing",
"=",
"[",
"]",
"self",
".",
"_server",
"=",
"plex_server",
"self",
".",
"_name",
"=... | [
35,
4
] | [
42,
68
] | python | en | ['en', 'en', 'en'] | True |
PlexSensor.async_added_to_hass | (self) | Run when about to be added to hass. | Run when about to be added to hass. | async def async_added_to_hass(self):
"""Run when about to be added to hass."""
server_id = self._server.machine_identifier
unsub = async_dispatcher_connect(
self.hass,
PLEX_UPDATE_SENSOR_SIGNAL.format(server_id),
self.async_refresh_sensor,
)
se... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"server_id",
"=",
"self",
".",
"_server",
".",
"machine_identifier",
"unsub",
"=",
"async_dispatcher_connect",
"(",
"self",
".",
"hass",
",",
"PLEX_UPDATE_SENSOR_SIGNAL",
".",
"format",
"(",
"server_id"... | [
44,
4
] | [
52,
73
] | python | en | ['en', 'en', 'en'] | True |
PlexSensor.async_refresh_sensor | (self, sessions) | Set instance object and trigger an entity state update. | Set instance object and trigger an entity state update. | async def async_refresh_sensor(self, sessions):
"""Set instance object and trigger an entity state update."""
_LOGGER.debug("Refreshing sensor [%s]", self.unique_id)
self.sessions = sessions
update_failed = False
@callback
def update_plex(_):
async_dispatche... | [
"async",
"def",
"async_refresh_sensor",
"(",
"self",
",",
"sessions",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Refreshing sensor [%s]\"",
",",
"self",
".",
"unique_id",
")",
"self",
".",
"sessions",
"=",
"sessions",
"update_failed",
"=",
"False",
"@",
"callb... | [
54,
4
] | [
131,
55
] | python | en | ['en', 'en', 'en'] | True |
PlexSensor.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
134,
4
] | [
136,
25
] | python | en | ['en', 'mi', 'en'] | True |
PlexSensor.unique_id | (self) | Return the id of this plex client. | Return the id of this plex client. | def unique_id(self):
"""Return the id of this plex client."""
return self._unique_id | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unique_id"
] | [
139,
4
] | [
141,
30
] | python | en | ['en', 'la', 'en'] | True |
PlexSensor.should_poll | (self) | Return True if entity has to be polled for state. | Return True if entity has to be polled for state. | def should_poll(self):
"""Return True if entity has to be polled for state."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
144,
4
] | [
146,
20
] | python | en | ['en', 'en', 'en'] | True |
PlexSensor.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"
] | [
149,
4
] | [
151,
26
] | python | en | ['en', 'en', 'en'] | True |
PlexSensor.unit_of_measurement | (self) | Return the unit this state is expressed in. | Return the unit this state is expressed in. | def unit_of_measurement(self):
"""Return the unit this state is expressed in."""
return "Watching" | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"\"Watching\""
] | [
154,
4
] | [
156,
25
] | python | en | ['en', 'en', 'en'] | True |
PlexSensor.icon | (self) | Return the icon of the sensor. | Return the icon of the sensor. | def icon(self):
"""Return the icon of the sensor."""
return "mdi:plex" | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"\"mdi:plex\""
] | [
159,
4
] | [
161,
25
] | python | en | ['en', 'en', 'en'] | True |
PlexSensor.device_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def device_state_attributes(self):
"""Return the state attributes."""
return {content[0]: content[1] for content in self._now_playing} | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"{",
"content",
"[",
"0",
"]",
":",
"content",
"[",
"1",
"]",
"for",
"content",
"in",
"self",
".",
"_now_playing",
"}"
] | [
164,
4
] | [
166,
72
] | python | en | ['en', 'en', 'en'] | True |
PlexSensor.device_info | (self) | Return a device description for device registry. | Return a device description for device registry. | def device_info(self):
"""Return a device description for device registry."""
if self.unique_id is None:
return None
return {
"identifiers": {(PLEX_DOMAIN, self._server.machine_identifier)},
"manufacturer": "Plex",
"model": "Plex Media Server",
... | [
"def",
"device_info",
"(",
"self",
")",
":",
"if",
"self",
".",
"unique_id",
"is",
"None",
":",
"return",
"None",
"return",
"{",
"\"identifiers\"",
":",
"{",
"(",
"PLEX_DOMAIN",
",",
"self",
".",
"_server",
".",
"machine_identifier",
")",
"}",
",",
"\"ma... | [
169,
4
] | [
180,
9
] | python | en | ['ro', 'fr', 'en'] | False |
mock_auth_fixture | () | Mock check token. | Mock check token. | def mock_auth_fixture():
"""Mock check token."""
with patch("hass_nabucasa.auth.CognitoAuth.async_check_token"):
yield | [
"def",
"mock_auth_fixture",
"(",
")",
":",
"with",
"patch",
"(",
"\"hass_nabucasa.auth.CognitoAuth.async_check_token\"",
")",
":",
"yield"
] | [
28,
0
] | [
31,
13
] | python | en | ['en', 'gl', 'en'] | True |
mock_cloud_login_fixture | (hass, setup_api) | Mock cloud is logged in. | Mock cloud is logged in. | def mock_cloud_login_fixture(hass, setup_api):
"""Mock cloud is logged in."""
hass.data[DOMAIN].id_token = jwt.encode(
{
"email": "hello@home-assistant.io",
"custom:sub-exp": "2018-01-03",
"cognito:username": "abcdefghjkl",
},
"test",
) | [
"def",
"mock_cloud_login_fixture",
"(",
"hass",
",",
"setup_api",
")",
":",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
".",
"id_token",
"=",
"jwt",
".",
"encode",
"(",
"{",
"\"email\"",
":",
"\"hello@home-assistant.io\"",
",",
"\"custom:sub-exp\"",
":",
"\"2018-... | [
35,
0
] | [
44,
5
] | python | en | ['en', 'fy', 'en'] | True |
setup_api_fixture | (hass, aioclient_mock) | Initialize HTTP API. | Initialize HTTP API. | def setup_api_fixture(hass, aioclient_mock):
"""Initialize HTTP API."""
hass.loop.run_until_complete(
mock_cloud(
hass,
{
"mode": "development",
"cognito_client_id": "cognito_client_id",
"user_pool_id": "user_pool_id",
... | [
"def",
"setup_api_fixture",
"(",
"hass",
",",
"aioclient_mock",
")",
":",
"hass",
".",
"loop",
".",
"run_until_complete",
"(",
"mock_cloud",
"(",
"hass",
",",
"{",
"\"mode\"",
":",
"\"development\"",
",",
"\"cognito_client_id\"",
":",
"\"cognito_client_id\"",
",",... | [
48,
0
] | [
67,
33
] | python | en | ['en', 'en', 'it'] | True |
cloud_client_fixture | (hass, hass_client) | Fixture that can fetch from the cloud client. | Fixture that can fetch from the cloud client. | def cloud_client_fixture(hass, hass_client):
"""Fixture that can fetch from the cloud client."""
with patch("hass_nabucasa.Cloud.write_user_info"):
yield hass.loop.run_until_complete(hass_client()) | [
"def",
"cloud_client_fixture",
"(",
"hass",
",",
"hass_client",
")",
":",
"with",
"patch",
"(",
"\"hass_nabucasa.Cloud.write_user_info\"",
")",
":",
"yield",
"hass",
".",
"loop",
".",
"run_until_complete",
"(",
"hass_client",
"(",
")",
")"
] | [
71,
0
] | [
74,
57
] | python | en | ['en', 'en', 'en'] | True |
mock_cognito_fixture | () | Mock warrant. | Mock warrant. | def mock_cognito_fixture():
"""Mock warrant."""
with patch("hass_nabucasa.auth.CognitoAuth._cognito") as mock_cog:
yield mock_cog() | [
"def",
"mock_cognito_fixture",
"(",
")",
":",
"with",
"patch",
"(",
"\"hass_nabucasa.auth.CognitoAuth._cognito\"",
")",
"as",
"mock_cog",
":",
"yield",
"mock_cog",
"(",
")"
] | [
78,
0
] | [
81,
24
] | python | en | ['en', 'fy', 'en'] | False |
test_google_actions_sync | (mock_cognito, mock_cloud_login, cloud_client) | Test syncing Google Actions. | Test syncing Google Actions. | async def test_google_actions_sync(mock_cognito, mock_cloud_login, cloud_client):
"""Test syncing Google Actions."""
with patch(
"hass_nabucasa.cloud_api.async_google_actions_request_sync",
return_value=Mock(status=200),
) as mock_request_sync:
req = await cloud_client.post("/api/clo... | [
"async",
"def",
"test_google_actions_sync",
"(",
"mock_cognito",
",",
"mock_cloud_login",
",",
"cloud_client",
")",
":",
"with",
"patch",
"(",
"\"hass_nabucasa.cloud_api.async_google_actions_request_sync\"",
",",
"return_value",
"=",
"Mock",
"(",
"status",
"=",
"200",
"... | [
84,
0
] | [
92,
53
] | python | en | ['en', 'en', 'en'] | True |
test_google_actions_sync_fails | (mock_cognito, mock_cloud_login, cloud_client) | Test syncing Google Actions gone bad. | Test syncing Google Actions gone bad. | async def test_google_actions_sync_fails(mock_cognito, mock_cloud_login, cloud_client):
"""Test syncing Google Actions gone bad."""
with patch(
"hass_nabucasa.cloud_api.async_google_actions_request_sync",
return_value=Mock(status=HTTP_INTERNAL_SERVER_ERROR),
) as mock_request_sync:
r... | [
"async",
"def",
"test_google_actions_sync_fails",
"(",
"mock_cognito",
",",
"mock_cloud_login",
",",
"cloud_client",
")",
":",
"with",
"patch",
"(",
"\"hass_nabucasa.cloud_api.async_google_actions_request_sync\"",
",",
"return_value",
"=",
"Mock",
"(",
"status",
"=",
"HTT... | [
95,
0
] | [
103,
53
] | python | en | ['en', 'en', 'en'] | True |
test_login_view | (hass, cloud_client) | Test logging in. | Test logging in. | async def test_login_view(hass, cloud_client):
"""Test logging in."""
hass.data["cloud"] = MagicMock(login=AsyncMock())
req = await cloud_client.post(
"/api/cloud/login", json={"email": "my_username", "password": "my_password"}
)
assert req.status == 200
result = await req.json()
a... | [
"async",
"def",
"test_login_view",
"(",
"hass",
",",
"cloud_client",
")",
":",
"hass",
".",
"data",
"[",
"\"cloud\"",
"]",
"=",
"MagicMock",
"(",
"login",
"=",
"AsyncMock",
"(",
")",
")",
"req",
"=",
"await",
"cloud_client",
".",
"post",
"(",
"\"/api/clo... | [
106,
0
] | [
116,
38
] | python | it | ['it', 'da', 'it'] | True |
test_login_view_random_exception | (cloud_client) | Try logging in with invalid JSON. | Try logging in with invalid JSON. | async def test_login_view_random_exception(cloud_client):
"""Try logging in with invalid JSON."""
with patch("async_timeout.timeout", side_effect=ValueError("Boom")):
req = await cloud_client.post(
"/api/cloud/login", json={"email": "my_username", "password": "my_password"}
)
ass... | [
"async",
"def",
"test_login_view_random_exception",
"(",
"cloud_client",
")",
":",
"with",
"patch",
"(",
"\"async_timeout.timeout\"",
",",
"side_effect",
"=",
"ValueError",
"(",
"\"Boom\"",
")",
")",
":",
"req",
"=",
"await",
"cloud_client",
".",
"post",
"(",
"\... | [
119,
0
] | [
127,
78
] | python | en | ['en', 'en', 'en'] | True |
test_login_view_invalid_json | (cloud_client) | Try logging in with invalid JSON. | Try logging in with invalid JSON. | async def test_login_view_invalid_json(cloud_client):
"""Try logging in with invalid JSON."""
with patch("hass_nabucasa.auth.CognitoAuth.async_login") as mock_login:
req = await cloud_client.post("/api/cloud/login", data="Not JSON")
assert req.status == 400
assert len(mock_login.mock_calls) == 0 | [
"async",
"def",
"test_login_view_invalid_json",
"(",
"cloud_client",
")",
":",
"with",
"patch",
"(",
"\"hass_nabucasa.auth.CognitoAuth.async_login\"",
")",
"as",
"mock_login",
":",
"req",
"=",
"await",
"cloud_client",
".",
"post",
"(",
"\"/api/cloud/login\"",
",",
"da... | [
130,
0
] | [
135,
42
] | python | en | ['en', 'en', 'en'] | True |
test_login_view_invalid_schema | (cloud_client) | Try logging in with invalid schema. | Try logging in with invalid schema. | async def test_login_view_invalid_schema(cloud_client):
"""Try logging in with invalid schema."""
with patch("hass_nabucasa.auth.CognitoAuth.async_login") as mock_login:
req = await cloud_client.post("/api/cloud/login", json={"invalid": "schema"})
assert req.status == 400
assert len(mock_login.m... | [
"async",
"def",
"test_login_view_invalid_schema",
"(",
"cloud_client",
")",
":",
"with",
"patch",
"(",
"\"hass_nabucasa.auth.CognitoAuth.async_login\"",
")",
"as",
"mock_login",
":",
"req",
"=",
"await",
"cloud_client",
".",
"post",
"(",
"\"/api/cloud/login\"",
",",
"... | [
138,
0
] | [
143,
42
] | python | en | ['en', 'en', 'en'] | True |
test_login_view_request_timeout | (cloud_client) | Test request timeout while trying to log in. | Test request timeout while trying to log in. | async def test_login_view_request_timeout(cloud_client):
"""Test request timeout while trying to log in."""
with patch(
"hass_nabucasa.auth.CognitoAuth.async_login", side_effect=asyncio.TimeoutError
):
req = await cloud_client.post(
"/api/cloud/login", json={"email": "my_username... | [
"async",
"def",
"test_login_view_request_timeout",
"(",
"cloud_client",
")",
":",
"with",
"patch",
"(",
"\"hass_nabucasa.auth.CognitoAuth.async_login\"",
",",
"side_effect",
"=",
"asyncio",
".",
"TimeoutError",
")",
":",
"req",
"=",
"await",
"cloud_client",
".",
"post... | [
146,
0
] | [
155,
28
] | python | en | ['en', 'en', 'en'] | True |
test_login_view_invalid_credentials | (cloud_client) | Test logging in with invalid credentials. | Test logging in with invalid credentials. | async def test_login_view_invalid_credentials(cloud_client):
"""Test logging in with invalid credentials."""
with patch(
"hass_nabucasa.auth.CognitoAuth.async_login", side_effect=Unauthenticated
):
req = await cloud_client.post(
"/api/cloud/login", json={"email": "my_username", "... | [
"async",
"def",
"test_login_view_invalid_credentials",
"(",
"cloud_client",
")",
":",
"with",
"patch",
"(",
"\"hass_nabucasa.auth.CognitoAuth.async_login\"",
",",
"side_effect",
"=",
"Unauthenticated",
")",
":",
"req",
"=",
"await",
"cloud_client",
".",
"post",
"(",
"... | [
158,
0
] | [
167,
28
] | python | en | ['en', 'en', 'en'] | True |
test_login_view_unknown_error | (cloud_client) | Test unknown error while logging in. | Test unknown error while logging in. | async def test_login_view_unknown_error(cloud_client):
"""Test unknown error while logging in."""
with patch("hass_nabucasa.auth.CognitoAuth.async_login", side_effect=UnknownError):
req = await cloud_client.post(
"/api/cloud/login", json={"email": "my_username", "password": "my_password"}
... | [
"async",
"def",
"test_login_view_unknown_error",
"(",
"cloud_client",
")",
":",
"with",
"patch",
"(",
"\"hass_nabucasa.auth.CognitoAuth.async_login\"",
",",
"side_effect",
"=",
"UnknownError",
")",
":",
"req",
"=",
"await",
"cloud_client",
".",
"post",
"(",
"\"/api/cl... | [
170,
0
] | [
177,
28
] | python | en | ['en', 'de', 'en'] | True |
test_logout_view | (hass, cloud_client) | Test logging out. | Test logging out. | async def test_logout_view(hass, cloud_client):
"""Test logging out."""
cloud = hass.data["cloud"] = MagicMock()
cloud.logout = AsyncMock(return_value=None)
req = await cloud_client.post("/api/cloud/logout")
assert req.status == 200
data = await req.json()
assert data == {"message": "ok"}
... | [
"async",
"def",
"test_logout_view",
"(",
"hass",
",",
"cloud_client",
")",
":",
"cloud",
"=",
"hass",
".",
"data",
"[",
"\"cloud\"",
"]",
"=",
"MagicMock",
"(",
")",
"cloud",
".",
"logout",
"=",
"AsyncMock",
"(",
"return_value",
"=",
"None",
")",
"req",
... | [
180,
0
] | [
188,
44
] | python | en | ['it', 'en', 'en'] | True |
test_logout_view_request_timeout | (hass, cloud_client) | Test timeout while logging out. | Test timeout while logging out. | async def test_logout_view_request_timeout(hass, cloud_client):
"""Test timeout while logging out."""
cloud = hass.data["cloud"] = MagicMock()
cloud.logout.side_effect = asyncio.TimeoutError
req = await cloud_client.post("/api/cloud/logout")
assert req.status == 502 | [
"async",
"def",
"test_logout_view_request_timeout",
"(",
"hass",
",",
"cloud_client",
")",
":",
"cloud",
"=",
"hass",
".",
"data",
"[",
"\"cloud\"",
"]",
"=",
"MagicMock",
"(",
")",
"cloud",
".",
"logout",
".",
"side_effect",
"=",
"asyncio",
".",
"TimeoutErr... | [
191,
0
] | [
196,
28
] | python | en | ['en', 'en', 'en'] | True |
test_logout_view_unknown_error | (hass, cloud_client) | Test unknown error while logging out. | Test unknown error while logging out. | async def test_logout_view_unknown_error(hass, cloud_client):
"""Test unknown error while logging out."""
cloud = hass.data["cloud"] = MagicMock()
cloud.logout.side_effect = UnknownError
req = await cloud_client.post("/api/cloud/logout")
assert req.status == 502 | [
"async",
"def",
"test_logout_view_unknown_error",
"(",
"hass",
",",
"cloud_client",
")",
":",
"cloud",
"=",
"hass",
".",
"data",
"[",
"\"cloud\"",
"]",
"=",
"MagicMock",
"(",
")",
"cloud",
".",
"logout",
".",
"side_effect",
"=",
"UnknownError",
"req",
"=",
... | [
199,
0
] | [
204,
28
] | python | en | ['en', 'en', 'en'] | True |
test_register_view | (mock_cognito, cloud_client) | Test logging out. | Test logging out. | async def test_register_view(mock_cognito, cloud_client):
"""Test logging out."""
req = await cloud_client.post(
"/api/cloud/register", json={"email": "hello@bla.com", "password": "falcon42"}
)
assert req.status == 200
assert len(mock_cognito.register.mock_calls) == 1
result_email, resul... | [
"async",
"def",
"test_register_view",
"(",
"mock_cognito",
",",
"cloud_client",
")",
":",
"req",
"=",
"await",
"cloud_client",
".",
"post",
"(",
"\"/api/cloud/register\"",
",",
"json",
"=",
"{",
"\"email\"",
":",
"\"hello@bla.com\"",
",",
"\"password\"",
":",
"\... | [
207,
0
] | [
216,
36
] | python | en | ['it', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.