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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
test_load_key_map | (hass) | Test loading an existing key map from the file. | Test loading an existing key map from the file. | def test_load_key_map(hass):
"""Test loading an existing key map from the file."""
with patch("builtins.open", mock_open(read_data=JSON_STRING)), patch(
"os.path.isfile", Mock(return_value=True)
):
config = rtm.RememberTheMilkConfiguration(hass)
assert ("0", "1", "2") == config.get_rtm_i... | [
"def",
"test_load_key_map",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"builtins.open\"",
",",
"mock_open",
"(",
"read_data",
"=",
"JSON_STRING",
")",
")",
",",
"patch",
"(",
"\"os.path.isfile\"",
",",
"Mock",
"(",
"return_value",
"=",
"True",
")",
")",
... | [
54,
0
] | [
60,
64
] | python | en | ['en', 'en', 'en'] | True |
async_get_engine | (hass, config, discovery_info=None) | Set up Demo speech component. | Set up Demo speech component. | async def async_get_engine(hass, config, discovery_info=None):
"""Set up Demo speech component."""
return DemoProvider() | [
"async",
"def",
"async_get_engine",
"(",
"hass",
",",
"config",
",",
"discovery_info",
"=",
"None",
")",
":",
"return",
"DemoProvider",
"(",
")"
] | [
18,
0
] | [
20,
25
] | python | en | ['en', 'lb', 'en'] | True |
DemoProvider.supported_languages | (self) | Return a list of supported languages. | Return a list of supported languages. | def supported_languages(self) -> List[str]:
"""Return a list of supported languages."""
return SUPPORT_LANGUAGES | [
"def",
"supported_languages",
"(",
"self",
")",
"->",
"List",
"[",
"str",
"]",
":",
"return",
"SUPPORT_LANGUAGES"
] | [
27,
4
] | [
29,
32
] | python | en | ['en', 'en', 'en'] | True |
DemoProvider.supported_formats | (self) | Return a list of supported formats. | Return a list of supported formats. | def supported_formats(self) -> List[AudioFormats]:
"""Return a list of supported formats."""
return [AudioFormats.WAV] | [
"def",
"supported_formats",
"(",
"self",
")",
"->",
"List",
"[",
"AudioFormats",
"]",
":",
"return",
"[",
"AudioFormats",
".",
"WAV",
"]"
] | [
32,
4
] | [
34,
33
] | python | en | ['en', 'en', 'en'] | True |
DemoProvider.supported_codecs | (self) | Return a list of supported codecs. | Return a list of supported codecs. | def supported_codecs(self) -> List[AudioCodecs]:
"""Return a list of supported codecs."""
return [AudioCodecs.PCM] | [
"def",
"supported_codecs",
"(",
"self",
")",
"->",
"List",
"[",
"AudioCodecs",
"]",
":",
"return",
"[",
"AudioCodecs",
".",
"PCM",
"]"
] | [
37,
4
] | [
39,
32
] | python | en | ['en', 'en', 'en'] | True |
DemoProvider.supported_bit_rates | (self) | Return a list of supported bit rates. | Return a list of supported bit rates. | def supported_bit_rates(self) -> List[AudioBitRates]:
"""Return a list of supported bit rates."""
return [AudioBitRates.BITRATE_16] | [
"def",
"supported_bit_rates",
"(",
"self",
")",
"->",
"List",
"[",
"AudioBitRates",
"]",
":",
"return",
"[",
"AudioBitRates",
".",
"BITRATE_16",
"]"
] | [
42,
4
] | [
44,
41
] | python | en | ['en', 'en', 'en'] | True |
DemoProvider.supported_sample_rates | (self) | Return a list of supported sample rates. | Return a list of supported sample rates. | def supported_sample_rates(self) -> List[AudioSampleRates]:
"""Return a list of supported sample rates."""
return [AudioSampleRates.SAMPLERATE_16000, AudioSampleRates.SAMPLERATE_44100] | [
"def",
"supported_sample_rates",
"(",
"self",
")",
"->",
"List",
"[",
"AudioSampleRates",
"]",
":",
"return",
"[",
"AudioSampleRates",
".",
"SAMPLERATE_16000",
",",
"AudioSampleRates",
".",
"SAMPLERATE_44100",
"]"
] | [
47,
4
] | [
49,
85
] | python | en | ['en', 'en', 'en'] | True |
DemoProvider.supported_channels | (self) | Return a list of supported channels. | Return a list of supported channels. | def supported_channels(self) -> List[AudioChannels]:
"""Return a list of supported channels."""
return [AudioChannels.CHANNEL_STEREO] | [
"def",
"supported_channels",
"(",
"self",
")",
"->",
"List",
"[",
"AudioChannels",
"]",
":",
"return",
"[",
"AudioChannels",
".",
"CHANNEL_STEREO",
"]"
] | [
52,
4
] | [
54,
45
] | python | en | ['en', 'en', 'en'] | True |
DemoProvider.async_process_audio_stream | (
self, metadata: SpeechMetadata, stream: StreamReader
) | Process an audio stream to STT service. | Process an audio stream to STT service. | async def async_process_audio_stream(
self, metadata: SpeechMetadata, stream: StreamReader
) -> SpeechResult:
"""Process an audio stream to STT service."""
# Read available data
async for _ in stream.iter_chunked(4096):
pass
return SpeechResult("Turn the Kitchen... | [
"async",
"def",
"async_process_audio_stream",
"(",
"self",
",",
"metadata",
":",
"SpeechMetadata",
",",
"stream",
":",
"StreamReader",
")",
"->",
"SpeechResult",
":",
"# Read available data",
"async",
"for",
"_",
"in",
"stream",
".",
"iter_chunked",
"(",
"4096",
... | [
56,
4
] | [
65,
84
] | python | en | ['en', 'lb', 'en'] | True |
problem4_2 | (ran_list) | Compute the mean and standard deviation of a list of floats | Compute the mean and standard deviation of a list of floats | def problem4_2(ran_list):
""" Compute the mean and standard deviation of a list of floats """
import statistics
print(statistics.mean(ran_list))
print(statistics.stdev(ran_list)) | [
"def",
"problem4_2",
"(",
"ran_list",
")",
":",
"import",
"statistics",
"print",
"(",
"statistics",
".",
"mean",
"(",
"ran_list",
")",
")",
"print",
"(",
"statistics",
".",
"stdev",
"(",
"ran_list",
")",
")"
] | [
20,
0
] | [
24,
37
] | python | en | ['en', 'en', 'en'] | True |
mock_http_client | (loop, hass, hass_client) | Set up test fixture. | Set up test fixture. | def mock_http_client(loop, hass, hass_client):
"""Set up test fixture."""
config = {
"rss_feed_template": {
"testfeed": {
"title": "feed title is {{states.test.test1.state}}",
"items": [
{
"title": "item title is {{s... | [
"def",
"mock_http_client",
"(",
"loop",
",",
"hass",
",",
"hass_client",
")",
":",
"config",
"=",
"{",
"\"rss_feed_template\"",
":",
"{",
"\"testfeed\"",
":",
"{",
"\"title\"",
":",
"\"feed title is {{states.test.test1.state}}\"",
",",
"\"items\"",
":",
"[",
"{",
... | [
9,
0
] | [
26,
49
] | python | en | ['en', 'lb', 'en'] | True |
test_get_nonexistant_feed | (mock_http_client) | Test if we can retrieve the correct rss feed. | Test if we can retrieve the correct rss feed. | async def test_get_nonexistant_feed(mock_http_client):
"""Test if we can retrieve the correct rss feed."""
resp = await mock_http_client.get("/api/rss_template/otherfeed")
assert resp.status == HTTP_NOT_FOUND | [
"async",
"def",
"test_get_nonexistant_feed",
"(",
"mock_http_client",
")",
":",
"resp",
"=",
"await",
"mock_http_client",
".",
"get",
"(",
"\"/api/rss_template/otherfeed\"",
")",
"assert",
"resp",
".",
"status",
"==",
"HTTP_NOT_FOUND"
] | [
29,
0
] | [
32,
40
] | python | en | ['en', 'en', 'en'] | True |
test_get_rss_feed | (mock_http_client, hass) | Test if we can retrieve the correct rss feed. | Test if we can retrieve the correct rss feed. | async def test_get_rss_feed(mock_http_client, hass):
"""Test if we can retrieve the correct rss feed."""
hass.states.async_set("test.test1", "a_state_1")
hass.states.async_set("test.test2", "a_state_2")
hass.states.async_set("test.test3", "a_state_3")
resp = await mock_http_client.get("/api/rss_tem... | [
"async",
"def",
"test_get_rss_feed",
"(",
"mock_http_client",
",",
"hass",
")",
":",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"test.test1\"",
",",
"\"a_state_1\"",
")",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"test.test2\"",
",",
"\"a_state_2\"",
... | [
35,
0
] | [
49,
45
] | python | en | ['en', 'en', 'en'] | True |
test_state | (hass) | Test Air Quality state. | Test Air Quality state. | async def test_state(hass):
"""Test Air Quality state."""
config = {"air_quality": {"platform": "demo"}}
assert await async_setup_component(hass, "air_quality", config)
await hass.async_block_till_done()
state = hass.states.get("air_quality.demo_air_quality_home")
assert state is not None
... | [
"async",
"def",
"test_state",
"(",
"hass",
")",
":",
"config",
"=",
"{",
"\"air_quality\"",
":",
"{",
"\"platform\"",
":",
"\"demo\"",
"}",
"}",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"air_quality\"",
",",
"config",
")",
"await",
"ha... | [
14,
0
] | [
24,
30
] | python | en | ['en', 'en', 'en'] | True |
test_attributes | (hass) | Test Air Quality attributes. | Test Air Quality attributes. | async def test_attributes(hass):
"""Test Air Quality attributes."""
config = {"air_quality": {"platform": "demo"}}
assert await async_setup_component(hass, "air_quality", config)
await hass.async_block_till_done()
state = hass.states.get("air_quality.demo_air_quality_office")
assert state is n... | [
"async",
"def",
"test_attributes",
"(",
"hass",
")",
":",
"config",
"=",
"{",
"\"air_quality\"",
":",
"{",
"\"platform\"",
":",
"\"demo\"",
"}",
"}",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"air_quality\"",
",",
"config",
")",
"await",
... | [
27,
0
] | [
44,
5
] | python | en | ['en', 'hmn', 'en'] | True |
TestLiteJetLight.setup_method | (self, method, mock_pylitejet) | Set up things to be run when tests are started. | Set up things to be run when tests are started. | def setup_method(self, method, mock_pylitejet):
"""Set up things to be run when tests are started."""
self.hass = get_test_home_assistant()
self.hass.start()
self.load_activated_callbacks = {}
self.load_deactivated_callbacks = {}
def get_load_name(number):
r... | [
"def",
"setup_method",
"(",
"self",
",",
"method",
",",
"mock_pylitejet",
")",
":",
"self",
".",
"hass",
"=",
"get_test_home_assistant",
"(",
")",
"self",
".",
"hass",
".",
"start",
"(",
")",
"self",
".",
"load_activated_callbacks",
"=",
"{",
"}",
"self",
... | [
24,
4
] | [
58,
48
] | python | en | ['en', 'en', 'en'] | True |
TestLiteJetLight.light | (self) | Test for main light entity. | Test for main light entity. | def light(self):
"""Test for main light entity."""
return self.hass.states.get(ENTITY_LIGHT) | [
"def",
"light",
"(",
"self",
")",
":",
"return",
"self",
".",
"hass",
".",
"states",
".",
"get",
"(",
"ENTITY_LIGHT",
")"
] | [
60,
4
] | [
62,
49
] | python | en | ['da', 'en', 'en'] | True |
TestLiteJetLight.other_light | (self) | Test the other light. | Test the other light. | def other_light(self):
"""Test the other light."""
return self.hass.states.get(ENTITY_OTHER_LIGHT) | [
"def",
"other_light",
"(",
"self",
")",
":",
"return",
"self",
".",
"hass",
".",
"states",
".",
"get",
"(",
"ENTITY_OTHER_LIGHT",
")"
] | [
64,
4
] | [
66,
55
] | python | en | ['en', 'en', 'en'] | True |
TestLiteJetLight.teardown_method | (self, method) | Stop everything that was started. | Stop everything that was started. | def teardown_method(self, method):
"""Stop everything that was started."""
self.hass.stop() | [
"def",
"teardown_method",
"(",
"self",
",",
"method",
")",
":",
"self",
".",
"hass",
".",
"stop",
"(",
")"
] | [
68,
4
] | [
70,
24
] | python | en | ['en', 'en', 'en'] | True |
TestLiteJetLight.test_on_brightness | (self) | Test turning the light on with brightness. | Test turning the light on with brightness. | def test_on_brightness(self):
"""Test turning the light on with brightness."""
assert self.light().state == "off"
assert self.other_light().state == "off"
assert not light.is_on(self.hass, ENTITY_LIGHT)
common.turn_on(self.hass, ENTITY_LIGHT, brightness=102)
self.hass.b... | [
"def",
"test_on_brightness",
"(",
"self",
")",
":",
"assert",
"self",
".",
"light",
"(",
")",
".",
"state",
"==",
"\"off\"",
"assert",
"self",
".",
"other_light",
"(",
")",
".",
"state",
"==",
"\"off\"",
"assert",
"not",
"light",
".",
"is_on",
"(",
"se... | [
72,
4
] | [
81,
84
] | python | en | ['en', 'en', 'en'] | True |
TestLiteJetLight.test_on_off | (self) | Test turning the light on and off. | Test turning the light on and off. | def test_on_off(self):
"""Test turning the light on and off."""
assert self.light().state == "off"
assert self.other_light().state == "off"
assert not light.is_on(self.hass, ENTITY_LIGHT)
common.turn_on(self.hass, ENTITY_LIGHT)
self.hass.block_till_done()
self.m... | [
"def",
"test_on_off",
"(",
"self",
")",
":",
"assert",
"self",
".",
"light",
"(",
")",
".",
"state",
"==",
"\"off\"",
"assert",
"self",
".",
"other_light",
"(",
")",
".",
"state",
"==",
"\"off\"",
"assert",
"not",
"light",
".",
"is_on",
"(",
"self",
... | [
83,
4
] | [
96,
76
] | python | en | ['en', 'en', 'en'] | True |
TestLiteJetLight.test_activated_event | (self) | Test handling an event from LiteJet. | Test handling an event from LiteJet. | def test_activated_event(self):
"""Test handling an event from LiteJet."""
self.mock_lj.get_load_level.return_value = 99
# Light 1
_LOGGER.info(self.load_activated_callbacks[ENTITY_LIGHT_NUMBER])
self.load_activated_callbacks[ENTITY_LIGHT_NUMBER]()
self.hass.block_till_... | [
"def",
"test_activated_event",
"(",
"self",
")",
":",
"self",
".",
"mock_lj",
".",
"get_load_level",
".",
"return_value",
"=",
"99",
"# Light 1",
"_LOGGER",
".",
"info",
"(",
"self",
".",
"load_activated_callbacks",
"[",
"ENTITY_LIGHT_NUMBER",
"]",
")",
"self",
... | [
98,
4
] | [
131,
79
] | python | en | ['en', 'en', 'en'] | True |
TestLiteJetLight.test_deactivated_event | (self) | Test handling an event from LiteJet. | Test handling an event from LiteJet. | def test_deactivated_event(self):
"""Test handling an event from LiteJet."""
# Initial state is on.
self.mock_lj.get_load_level.return_value = 99
self.load_activated_callbacks[ENTITY_OTHER_LIGHT_NUMBER]()
self.hass.block_till_done()
assert light.is_on(self.hass, ENTITY... | [
"def",
"test_deactivated_event",
"(",
"self",
")",
":",
"# Initial state is on.",
"self",
".",
"mock_lj",
".",
"get_load_level",
".",
"return_value",
"=",
"99",
"self",
".",
"load_activated_callbacks",
"[",
"ENTITY_OTHER_LIGHT_NUMBER",
"]",
"(",
")",
"self",
".",
... | [
133,
4
] | [
160,
48
] | python | en | ['en', 'en', 'en'] | True |
_address | (value: str) | r"""Coerce address by replacing '\n' with ' '. | r"""Coerce address by replacing '\n' with ' '. | def _address(value: str) -> str:
r"""Coerce address by replacing '\n' with ' '."""
return value.replace("\n", " ") | [
"def",
"_address",
"(",
"value",
":",
"str",
")",
"->",
"str",
":",
"return",
"value",
".",
"replace",
"(",
"\"\\n\"",
",",
"\" \"",
")"
] | [
51,
0
] | [
53,
35
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass, hass_config) | Set up the Geofency component. | Set up the Geofency component. | async def async_setup(hass, hass_config):
"""Set up the Geofency component."""
config = hass_config.get(DOMAIN, {})
mobile_beacons = config.get(CONF_MOBILE_BEACONS, [])
hass.data[DOMAIN] = {
"beacons": [slugify(beacon) for beacon in mobile_beacons],
"devices": set(),
"unsub_devic... | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"hass_config",
")",
":",
"config",
"=",
"hass_config",
".",
"get",
"(",
"DOMAIN",
",",
"{",
"}",
")",
"mobile_beacons",
"=",
"config",
".",
"get",
"(",
"CONF_MOBILE_BEACONS",
",",
"[",
"]",
")",
"hass",
... | [
72,
0
] | [
81,
15
] | python | en | ['en', 'en', 'en'] | True |
handle_webhook | (hass, webhook_id, request) | Handle incoming webhook from Geofency. | Handle incoming webhook from Geofency. | async def handle_webhook(hass, webhook_id, request):
"""Handle incoming webhook from Geofency."""
try:
data = WEBHOOK_SCHEMA(dict(await request.post()))
except vol.MultipleInvalid as error:
return web.Response(text=error.error_message, status=HTTP_UNPROCESSABLE_ENTITY)
if _is_mobile_bea... | [
"async",
"def",
"handle_webhook",
"(",
"hass",
",",
"webhook_id",
",",
"request",
")",
":",
"try",
":",
"data",
"=",
"WEBHOOK_SCHEMA",
"(",
"dict",
"(",
"await",
"request",
".",
"post",
"(",
")",
")",
")",
"except",
"vol",
".",
"MultipleInvalid",
"as",
... | [
84,
0
] | [
101,
51
] | python | en | ['en', 'en', 'en'] | True |
_is_mobile_beacon | (data, mobile_beacons) | Check if we have a mobile beacon. | Check if we have a mobile beacon. | def _is_mobile_beacon(data, mobile_beacons):
"""Check if we have a mobile beacon."""
return ATTR_BEACON_ID in data and data["name"] in mobile_beacons | [
"def",
"_is_mobile_beacon",
"(",
"data",
",",
"mobile_beacons",
")",
":",
"return",
"ATTR_BEACON_ID",
"in",
"data",
"and",
"data",
"[",
"\"name\"",
"]",
"in",
"mobile_beacons"
] | [
104,
0
] | [
106,
68
] | python | en | ['en', 'en', 'en'] | True |
_device_name | (data) | Return name of device tracker. | Return name of device tracker. | def _device_name(data):
"""Return name of device tracker."""
if ATTR_BEACON_ID in data:
return f"{BEACON_DEV_PREFIX}_{data['name']}"
return data["device"] | [
"def",
"_device_name",
"(",
"data",
")",
":",
"if",
"ATTR_BEACON_ID",
"in",
"data",
":",
"return",
"f\"{BEACON_DEV_PREFIX}_{data['name']}\"",
"return",
"data",
"[",
"\"device\"",
"]"
] | [
109,
0
] | [
113,
25
] | python | en | ['en', 'ig', 'en'] | True |
_set_location | (hass, data, location_name) | Fire HA event to set location. | Fire HA event to set location. | def _set_location(hass, data, location_name):
"""Fire HA event to set location."""
device = _device_name(data)
async_dispatcher_send(
hass,
TRACKER_UPDATE,
device,
(data[ATTR_LATITUDE], data[ATTR_LONGITUDE]),
location_name,
data,
)
return web.Respons... | [
"def",
"_set_location",
"(",
"hass",
",",
"data",
",",
"location_name",
")",
":",
"device",
"=",
"_device_name",
"(",
"data",
")",
"async_dispatcher_send",
"(",
"hass",
",",
"TRACKER_UPDATE",
",",
"device",
",",
"(",
"data",
"[",
"ATTR_LATITUDE",
"]",
",",
... | [
116,
0
] | [
129,
78
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, entry) | Configure based on config entry. | Configure based on config entry. | async def async_setup_entry(hass, entry):
"""Configure based on config entry."""
hass.components.webhook.async_register(
DOMAIN, "Geofency", entry.data[CONF_WEBHOOK_ID], handle_webhook
)
hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, DEVICE_TRACKER)
)
... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"entry",
")",
":",
"hass",
".",
"components",
".",
"webhook",
".",
"async_register",
"(",
"DOMAIN",
",",
"\"Geofency\"",
",",
"entry",
".",
"data",
"[",
"CONF_WEBHOOK_ID",
"]",
",",
"handle_webhook",
")"... | [
132,
0
] | [
141,
15
] | python | en | ['en', 'en', 'en'] | True |
async_unload_entry | (hass, entry) | Unload a config entry. | Unload a config entry. | async def async_unload_entry(hass, entry):
"""Unload a config entry."""
hass.components.webhook.async_unregister(entry.data[CONF_WEBHOOK_ID])
hass.data[DOMAIN]["unsub_device_tracker"].pop(entry.entry_id)()
await hass.config_entries.async_forward_entry_unload(entry, DEVICE_TRACKER)
return True | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
",",
"entry",
")",
":",
"hass",
".",
"components",
".",
"webhook",
".",
"async_unregister",
"(",
"entry",
".",
"data",
"[",
"CONF_WEBHOOK_ID",
"]",
")",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"\"u... | [
144,
0
] | [
149,
15
] | python | en | ['en', 'es', 'en'] | True |
async_setup | (hass, config) | Set up the Fast.com component. | Set up the Fast.com component. | async def async_setup(hass, config):
"""Set up the Fast.com component."""
conf = config[DOMAIN]
data = hass.data[DOMAIN] = SpeedtestData(hass)
if not conf[CONF_MANUAL]:
async_track_time_interval(hass, data.update, conf[CONF_SCAN_INTERVAL])
def update(call=None):
"""Service call to ... | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"conf",
"=",
"config",
"[",
"DOMAIN",
"]",
"data",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"=",
"SpeedtestData",
"(",
"hass",
")",
"if",
"not",
"conf",
"[",
"CONF_MANUAL",
"]"... | [
37,
0
] | [
53,
15
] | python | en | ['en', 'pt', 'en'] | True |
SpeedtestData.__init__ | (self, hass) | Initialize the data object. | Initialize the data object. | def __init__(self, hass):
"""Initialize the data object."""
self.data = None
self._hass = hass | [
"def",
"__init__",
"(",
"self",
",",
"hass",
")",
":",
"self",
".",
"data",
"=",
"None",
"self",
".",
"_hass",
"=",
"hass"
] | [
59,
4
] | [
62,
25
] | python | en | ['en', 'en', 'en'] | True |
SpeedtestData.update | (self, now=None) | Get the latest data from fast.com. | Get the latest data from fast.com. | def update(self, now=None):
"""Get the latest data from fast.com."""
_LOGGER.debug("Executing fast.com speedtest")
self.data = {"download": fast_com()}
dispatcher_send(self._hass, DATA_UPDATED) | [
"def",
"update",
"(",
"self",
",",
"now",
"=",
"None",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Executing fast.com speedtest\"",
")",
"self",
".",
"data",
"=",
"{",
"\"download\"",
":",
"fast_com",
"(",
")",
"}",
"dispatcher_send",
"(",
"self",
".",
"_... | [
64,
4
] | [
69,
49
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass: HomeAssistantType, config_entry, async_add_entities) | Set up Xbox Live friends. | Set up Xbox Live friends. | async def async_setup_entry(hass: HomeAssistantType, config_entry, async_add_entities):
"""Set up Xbox Live friends."""
coordinator: XboxUpdateCoordinator = hass.data[DOMAIN][config_entry.entry_id][
"coordinator"
]
update_friends = partial(async_update_friends, coordinator, {}, async_add_entiti... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistantType",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"coordinator",
":",
"XboxUpdateCoordinator",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"config_entry",
".",
"entry_id",
... | [
17,
0
] | [
27,
20
] | python | en | ['en', 'fr', 'en'] | True |
async_update_friends | (
coordinator: XboxUpdateCoordinator,
current: Dict[str, List[XboxSensorEntity]],
async_add_entities,
) | Update friends. | Update friends. | def async_update_friends(
coordinator: XboxUpdateCoordinator,
current: Dict[str, List[XboxSensorEntity]],
async_add_entities,
) -> None:
"""Update friends."""
new_ids = set(coordinator.data.presence)
current_ids = set(current)
# Process new favorites, add them to Home Assistant
new_enti... | [
"def",
"async_update_friends",
"(",
"coordinator",
":",
"XboxUpdateCoordinator",
",",
"current",
":",
"Dict",
"[",
"str",
",",
"List",
"[",
"XboxSensorEntity",
"]",
"]",
",",
"async_add_entities",
",",
")",
"->",
"None",
":",
"new_ids",
"=",
"set",
"(",
"coo... | [
43,
0
] | [
68,
9
] | python | en | ['en', 'co', 'en'] | False |
async_remove_entities | (
xuid: str,
coordinator: XboxUpdateCoordinator,
current: Dict[str, XboxSensorEntity],
) | Remove friend sensors from Home Assistant. | Remove friend sensors from Home Assistant. | async def async_remove_entities(
xuid: str,
coordinator: XboxUpdateCoordinator,
current: Dict[str, XboxSensorEntity],
) -> None:
"""Remove friend sensors from Home Assistant."""
registry = await async_get_entity_registry(coordinator.hass)
entities = current[xuid]
for entity in entities:
... | [
"async",
"def",
"async_remove_entities",
"(",
"xuid",
":",
"str",
",",
"coordinator",
":",
"XboxUpdateCoordinator",
",",
"current",
":",
"Dict",
"[",
"str",
",",
"XboxSensorEntity",
"]",
",",
")",
"->",
"None",
":",
"registry",
"=",
"await",
"async_get_entity_... | [
71,
0
] | [
82,
21
] | python | en | ['en', 'en', 'en'] | True |
XboxSensorEntity.state | (self) | Return the state of the requested attribute. | Return the state of the requested attribute. | def state(self):
"""Return the state of the requested attribute."""
if not self.coordinator.last_update_success:
return None
return getattr(self.data, self.attribute, None) | [
"def",
"state",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"coordinator",
".",
"last_update_success",
":",
"return",
"None",
"return",
"getattr",
"(",
"self",
".",
"data",
",",
"self",
".",
"attribute",
",",
"None",
")"
] | [
34,
4
] | [
39,
55
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up Roon MediaPlayer from Config Entry. | Set up Roon MediaPlayer from Config Entry. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up Roon MediaPlayer from Config Entry."""
roon_server = hass.data[DOMAIN][config_entry.entry_id]
media_players = set()
# Register entity services
platform = entity_platform.current_platform.get()
platform.async_register... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"roon_server",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"config_entry",
".",
"entry_id",
"]",
"media_players",
"=",
"set",
"(",
")",
"# Regi... | [
69,
0
] | [
108,
82
] | python | en | ['en', 'en', 'en'] | True |
RoonDevice.__init__ | (self, server, player_data) | Initialize Roon device object. | Initialize Roon device object. | def __init__(self, server, player_data):
"""Initialize Roon device object."""
self._remove_signal_status = None
self._server = server
self._available = True
self._last_position_update = None
self._supports_standby = False
self._state = STATE_IDLE
self._las... | [
"def",
"__init__",
"(",
"self",
",",
"server",
",",
"player_data",
")",
":",
"self",
".",
"_remove_signal_status",
"=",
"None",
"self",
".",
"_server",
"=",
"server",
"self",
".",
"_available",
"=",
"True",
"self",
".",
"_last_position_update",
"=",
"None",
... | [
114,
4
] | [
138,
37
] | python | en | ['nl', 'en', 'en'] | True |
RoonDevice.async_added_to_hass | (self) | Register callback. | Register callback. | async def async_added_to_hass(self):
"""Register callback."""
self.async_on_remove(
async_dispatcher_connect(
self.hass,
f"room_media_player_update_{self.unique_id}",
self.async_update_callback,
)
)
self._server.add_... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"async_on_remove",
"(",
"async_dispatcher_connect",
"(",
"self",
".",
"hass",
",",
"f\"room_media_player_update_{self.unique_id}\"",
",",
"self",
".",
"async_update_callback",
",",
")",
")",
... | [
140,
4
] | [
149,
61
] | python | en | ['en', 'no', 'en'] | False |
RoonDevice.async_update_callback | (self, player_data) | Handle device updates. | Handle device updates. | def async_update_callback(self, player_data):
"""Handle device updates."""
self.update_data(player_data)
self.async_write_ha_state() | [
"def",
"async_update_callback",
"(",
"self",
",",
"player_data",
")",
":",
"self",
".",
"update_data",
"(",
"player_data",
")",
"self",
".",
"async_write_ha_state",
"(",
")"
] | [
152,
4
] | [
155,
35
] | python | en | ['fr', 'sr', 'en'] | False |
RoonDevice.available | (self) | Return True if entity is available. | Return True if entity is available. | def available(self):
"""Return True if entity is available."""
return self._available | [
"def",
"available",
"(",
"self",
")",
":",
"return",
"self",
".",
"_available"
] | [
158,
4
] | [
160,
30
] | python | en | ['en', 'en', 'en'] | True |
RoonDevice.supported_features | (self) | Flag media player features that are supported. | Flag media player features that are supported. | def supported_features(self):
"""Flag media player features that are supported."""
return SUPPORT_ROON | [
"def",
"supported_features",
"(",
"self",
")",
":",
"return",
"SUPPORT_ROON"
] | [
163,
4
] | [
165,
27
] | python | en | ['en', 'en', 'en'] | True |
RoonDevice.device_info | (self) | Return the device info. | Return the device info. | def device_info(self):
"""Return the device info."""
dev_model = "player"
if self.player_data.get("source_controls"):
dev_model = self.player_data["source_controls"][0].get("display_name")
return {
"identifiers": {(DOMAIN, self.unique_id)},
"name": sel... | [
"def",
"device_info",
"(",
"self",
")",
":",
"dev_model",
"=",
"\"player\"",
"if",
"self",
".",
"player_data",
".",
"get",
"(",
"\"source_controls\"",
")",
":",
"dev_model",
"=",
"self",
".",
"player_data",
"[",
"\"source_controls\"",
"]",
"[",
"0",
"]",
"... | [
168,
4
] | [
179,
9
] | python | en | ['en', 'en', 'en'] | True |
RoonDevice.update_data | (self, player_data=None) | Update session object. | Update session object. | def update_data(self, player_data=None):
"""Update session object."""
if player_data:
self.player_data = player_data
if not self.player_data["is_available"]:
# this player was removed
self._available = False
self._state = STATE_OFF
else:
... | [
"def",
"update_data",
"(",
"self",
",",
"player_data",
"=",
"None",
")",
":",
"if",
"player_data",
":",
"self",
".",
"player_data",
"=",
"player_data",
"if",
"not",
"self",
".",
"player_data",
"[",
"\"is_available\"",
"]",
":",
"# this player was removed",
"se... | [
181,
4
] | [
194,
53
] | python | en | ['en', 'en', 'en'] | True |
RoonDevice._parse_volume | (cls, player_data) | Parse volume data to determine volume levels and mute state. | Parse volume data to determine volume levels and mute state. | def _parse_volume(cls, player_data):
"""Parse volume data to determine volume levels and mute state."""
volume = {
"level": 0,
"step": 0,
"muted": False,
}
try:
volume_data = player_data["volume"]
volume_muted = volume_data["is... | [
"def",
"_parse_volume",
"(",
"cls",
",",
"player_data",
")",
":",
"volume",
"=",
"{",
"\"level\"",
":",
"0",
",",
"\"step\"",
":",
"0",
",",
"\"muted\"",
":",
"False",
",",
"}",
"try",
":",
"volume_data",
"=",
"player_data",
"[",
"\"volume\"",
"]",
"vo... | [
197,
4
] | [
224,
21
] | python | en | ['en', 'en', 'en'] | True |
RoonDevice._parse_now_playing | (self, player_data) | Parse now playing data to determine title, artist, position, duration and artwork. | Parse now playing data to determine title, artist, position, duration and artwork. | def _parse_now_playing(self, player_data):
"""Parse now playing data to determine title, artist, position, duration and artwork."""
now_playing = {
"title": None,
"artist": None,
"album": None,
"position": 0,
"duration": 0,
"image":... | [
"def",
"_parse_now_playing",
"(",
"self",
",",
"player_data",
")",
":",
"now_playing",
"=",
"{",
"\"title\"",
":",
"None",
",",
"\"artist\"",
":",
"None",
",",
"\"album\"",
":",
"None",
",",
"\"position\"",
":",
"0",
",",
"\"duration\"",
":",
"0",
",",
"... | [
226,
4
] | [
258,
26
] | python | en | ['en', 'en', 'en'] | True |
RoonDevice.update_state | (self) | Update the power state and player state. | Update the power state and player state. | def update_state(self):
"""Update the power state and player state."""
new_state = ""
# power state from source control (if supported)
if "source_controls" in self.player_data:
for source in self.player_data["source_controls"]:
if source["supports_standby"] a... | [
"def",
"update_state",
"(",
"self",
")",
":",
"new_state",
"=",
"\"\"",
"# power state from source control (if supported)",
"if",
"\"source_controls\"",
"in",
"self",
".",
"player_data",
":",
"for",
"source",
"in",
"self",
".",
"player_data",
"[",
"\"source_controls\"... | [
260,
4
] | [
303,
52
] | python | en | ['en', 'en', 'en'] | True |
RoonDevice.media_position_updated_at | (self) | When was the position of the current playing media valid. | When was the position of the current playing media valid. | def media_position_updated_at(self):
"""When was the position of the current playing media valid."""
# Returns value from homeassistant.util.dt.utcnow().
return self._last_position_update | [
"def",
"media_position_updated_at",
"(",
"self",
")",
":",
"# Returns value from homeassistant.util.dt.utcnow().",
"return",
"self",
".",
"_last_position_update"
] | [
306,
4
] | [
309,
41
] | python | en | ['en', 'en', 'en'] | True |
RoonDevice.unique_id | (self) | Return the id of this roon client. | Return the id of this roon client. | def unique_id(self):
"""Return the id of this roon client."""
return self._unique_id | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unique_id"
] | [
312,
4
] | [
314,
30
] | python | en | ['en', 'en', 'en'] | True |
RoonDevice.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"
] | [
317,
4
] | [
319,
20
] | python | en | ['en', 'en', 'en'] | True |
RoonDevice.zone_id | (self) | Return current session Id. | Return current session Id. | def zone_id(self):
"""Return current session Id."""
return self._zone_id | [
"def",
"zone_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_zone_id"
] | [
322,
4
] | [
324,
28
] | python | en | ['en', 'bg', 'en'] | True |
RoonDevice.output_id | (self) | Return current session Id. | Return current session Id. | def output_id(self):
"""Return current session Id."""
return self._output_id | [
"def",
"output_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_output_id"
] | [
327,
4
] | [
329,
30
] | python | en | ['en', 'bg', 'en'] | True |
RoonDevice.name | (self) | Return device name. | Return device name. | def name(self):
"""Return device name."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
332,
4
] | [
334,
25
] | python | en | ['es', 'sl', 'en'] | False |
RoonDevice.media_title | (self) | Return title currently playing. | Return title currently playing. | def media_title(self):
"""Return title currently playing."""
return self._media_title | [
"def",
"media_title",
"(",
"self",
")",
":",
"return",
"self",
".",
"_media_title"
] | [
337,
4
] | [
339,
32
] | python | en | ['en', 'en', 'en'] | True |
RoonDevice.media_album_name | (self) | Album name of current playing media (Music track only). | Album name of current playing media (Music track only). | def media_album_name(self):
"""Album name of current playing media (Music track only)."""
return self._media_album_name | [
"def",
"media_album_name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_media_album_name"
] | [
342,
4
] | [
344,
37
] | python | en | ['en', 'en', 'en'] | True |
RoonDevice.media_artist | (self) | Artist of current playing media (Music track only). | Artist of current playing media (Music track only). | def media_artist(self):
"""Artist of current playing media (Music track only)."""
return self._media_artist | [
"def",
"media_artist",
"(",
"self",
")",
":",
"return",
"self",
".",
"_media_artist"
] | [
347,
4
] | [
349,
33
] | python | en | ['en', 'en', 'en'] | True |
RoonDevice.media_album_artist | (self) | Album artist of current playing media (Music track only). | Album artist of current playing media (Music track only). | def media_album_artist(self):
"""Album artist of current playing media (Music track only)."""
return self._media_artist | [
"def",
"media_album_artist",
"(",
"self",
")",
":",
"return",
"self",
".",
"_media_artist"
] | [
352,
4
] | [
354,
33
] | python | en | ['en', 'en', 'en'] | True |
RoonDevice.media_playlist | (self) | Title of Playlist currently playing. | Title of Playlist currently playing. | def media_playlist(self):
"""Title of Playlist currently playing."""
return self._last_playlist | [
"def",
"media_playlist",
"(",
"self",
")",
":",
"return",
"self",
".",
"_last_playlist"
] | [
357,
4
] | [
359,
34
] | python | en | ['en', 'en', 'en'] | True |
RoonDevice.media_image_url | (self) | Image url of current playing media. | Image url of current playing media. | def media_image_url(self):
"""Image url of current playing media."""
return self._media_image_url | [
"def",
"media_image_url",
"(",
"self",
")",
":",
"return",
"self",
".",
"_media_image_url"
] | [
362,
4
] | [
364,
36
] | python | en | ['en', 'en', 'en'] | True |
RoonDevice.media_position | (self) | Return position currently playing. | Return position currently playing. | def media_position(self):
"""Return position currently playing."""
return self._media_position | [
"def",
"media_position",
"(",
"self",
")",
":",
"return",
"self",
".",
"_media_position"
] | [
367,
4
] | [
369,
35
] | python | en | ['en', 'en', 'en'] | True |
RoonDevice.media_duration | (self) | Return total runtime length. | Return total runtime length. | def media_duration(self):
"""Return total runtime length."""
return self._media_duration | [
"def",
"media_duration",
"(",
"self",
")",
":",
"return",
"self",
".",
"_media_duration"
] | [
372,
4
] | [
374,
35
] | python | en | ['fr', 'no', 'en'] | False |
RoonDevice.volume_level | (self) | Return current volume level. | Return current volume level. | def volume_level(self):
"""Return current volume level."""
return self._volume_level | [
"def",
"volume_level",
"(",
"self",
")",
":",
"return",
"self",
".",
"_volume_level"
] | [
377,
4
] | [
379,
33
] | python | en | ['fr', 'la', 'en'] | False |
RoonDevice.is_volume_muted | (self) | Return mute state. | Return mute state. | def is_volume_muted(self):
"""Return mute state."""
return self._is_volume_muted | [
"def",
"is_volume_muted",
"(",
"self",
")",
":",
"return",
"self",
".",
"_is_volume_muted"
] | [
382,
4
] | [
384,
36
] | python | co | ['ro', 'co', 'en'] | False |
RoonDevice.volume_step | (self) | .Return volume step size. | .Return volume step size. | def volume_step(self):
""".Return volume step size."""
return self._volume_step | [
"def",
"volume_step",
"(",
"self",
")",
":",
"return",
"self",
".",
"_volume_step"
] | [
387,
4
] | [
389,
32
] | python | en | ['nl', 'ko', 'en'] | False |
RoonDevice.supports_standby | (self) | Return power state of source controls. | Return power state of source controls. | def supports_standby(self):
"""Return power state of source controls."""
return self._supports_standby | [
"def",
"supports_standby",
"(",
"self",
")",
":",
"return",
"self",
".",
"_supports_standby"
] | [
392,
4
] | [
394,
37
] | python | en | ['en', 'en', 'en'] | True |
RoonDevice.state | (self) | Return current playstate of the device. | Return current playstate of the device. | def state(self):
"""Return current playstate of the device."""
return self._state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
397,
4
] | [
399,
26
] | python | en | ['en', 'en', 'en'] | True |
RoonDevice.shuffle | (self) | Boolean if shuffle is enabled. | Boolean if shuffle is enabled. | def shuffle(self):
"""Boolean if shuffle is enabled."""
return self._shuffle | [
"def",
"shuffle",
"(",
"self",
")",
":",
"return",
"self",
".",
"_shuffle"
] | [
402,
4
] | [
404,
28
] | python | en | ['en', 'en', 'en'] | True |
RoonDevice.media_play | (self) | Send play command to device. | Send play command to device. | def media_play(self):
"""Send play command to device."""
self._server.roonapi.playback_control(self.output_id, "play") | [
"def",
"media_play",
"(",
"self",
")",
":",
"self",
".",
"_server",
".",
"roonapi",
".",
"playback_control",
"(",
"self",
".",
"output_id",
",",
"\"play\"",
")"
] | [
406,
4
] | [
408,
69
] | python | en | ['en', 'en', 'en'] | True |
RoonDevice.media_pause | (self) | Send pause command to device. | Send pause command to device. | def media_pause(self):
"""Send pause command to device."""
self._server.roonapi.playback_control(self.output_id, "pause") | [
"def",
"media_pause",
"(",
"self",
")",
":",
"self",
".",
"_server",
".",
"roonapi",
".",
"playback_control",
"(",
"self",
".",
"output_id",
",",
"\"pause\"",
")"
] | [
410,
4
] | [
412,
70
] | python | en | ['en', 'en', 'en'] | True |
RoonDevice.media_play_pause | (self) | Toggle play command to device. | Toggle play command to device. | def media_play_pause(self):
"""Toggle play command to device."""
self._server.roonapi.playback_control(self.output_id, "playpause") | [
"def",
"media_play_pause",
"(",
"self",
")",
":",
"self",
".",
"_server",
".",
"roonapi",
".",
"playback_control",
"(",
"self",
".",
"output_id",
",",
"\"playpause\"",
")"
] | [
414,
4
] | [
416,
74
] | python | en | ['en', 'en', 'en'] | True |
RoonDevice.media_stop | (self) | Send stop command to device. | Send stop command to device. | def media_stop(self):
"""Send stop command to device."""
self._server.roonapi.playback_control(self.output_id, "stop") | [
"def",
"media_stop",
"(",
"self",
")",
":",
"self",
".",
"_server",
".",
"roonapi",
".",
"playback_control",
"(",
"self",
".",
"output_id",
",",
"\"stop\"",
")"
] | [
418,
4
] | [
420,
69
] | python | en | ['en', 'en', 'en'] | True |
RoonDevice.media_next_track | (self) | Send next track command to device. | Send next track command to device. | def media_next_track(self):
"""Send next track command to device."""
self._server.roonapi.playback_control(self.output_id, "next") | [
"def",
"media_next_track",
"(",
"self",
")",
":",
"self",
".",
"_server",
".",
"roonapi",
".",
"playback_control",
"(",
"self",
".",
"output_id",
",",
"\"next\"",
")"
] | [
422,
4
] | [
424,
69
] | python | en | ['en', 'en', 'en'] | True |
RoonDevice.media_previous_track | (self) | Send previous track command to device. | Send previous track command to device. | def media_previous_track(self):
"""Send previous track command to device."""
self._server.roonapi.playback_control(self.output_id, "previous") | [
"def",
"media_previous_track",
"(",
"self",
")",
":",
"self",
".",
"_server",
".",
"roonapi",
".",
"playback_control",
"(",
"self",
".",
"output_id",
",",
"\"previous\"",
")"
] | [
426,
4
] | [
428,
73
] | python | en | ['en', 'en', 'en'] | True |
RoonDevice.media_seek | (self, position) | Send seek command to device. | Send seek command to device. | def media_seek(self, position):
"""Send seek command to device."""
self._server.roonapi.seek(self.output_id, position)
# Seek doesn't cause an async update - so force one
self._media_position = position
self.schedule_update_ha_state() | [
"def",
"media_seek",
"(",
"self",
",",
"position",
")",
":",
"self",
".",
"_server",
".",
"roonapi",
".",
"seek",
"(",
"self",
".",
"output_id",
",",
"position",
")",
"# Seek doesn't cause an async update - so force one",
"self",
".",
"_media_position",
"=",
"po... | [
430,
4
] | [
435,
39
] | python | en | ['en', 'en', 'en'] | True |
RoonDevice.set_volume_level | (self, volume) | Send new volume_level to device. | Send new volume_level to device. | def set_volume_level(self, volume):
"""Send new volume_level to device."""
volume = int(volume * 100)
self._server.roonapi.change_volume(self.output_id, volume) | [
"def",
"set_volume_level",
"(",
"self",
",",
"volume",
")",
":",
"volume",
"=",
"int",
"(",
"volume",
"*",
"100",
")",
"self",
".",
"_server",
".",
"roonapi",
".",
"change_volume",
"(",
"self",
".",
"output_id",
",",
"volume",
")"
] | [
437,
4
] | [
440,
66
] | python | en | ['it', 'en', 'en'] | True |
RoonDevice.mute_volume | (self, mute=True) | Send mute/unmute to device. | Send mute/unmute to device. | def mute_volume(self, mute=True):
"""Send mute/unmute to device."""
self._server.roonapi.mute(self.output_id, mute) | [
"def",
"mute_volume",
"(",
"self",
",",
"mute",
"=",
"True",
")",
":",
"self",
".",
"_server",
".",
"roonapi",
".",
"mute",
"(",
"self",
".",
"output_id",
",",
"mute",
")"
] | [
442,
4
] | [
444,
55
] | python | it | ['it', 'it', 'en'] | True |
RoonDevice.volume_up | (self) | Send new volume_level to device. | Send new volume_level to device. | def volume_up(self):
"""Send new volume_level to device."""
self._server.roonapi.change_volume(self.output_id, 3, "relative") | [
"def",
"volume_up",
"(",
"self",
")",
":",
"self",
".",
"_server",
".",
"roonapi",
".",
"change_volume",
"(",
"self",
".",
"output_id",
",",
"3",
",",
"\"relative\"",
")"
] | [
446,
4
] | [
448,
73
] | python | en | ['it', 'en', 'en'] | True |
RoonDevice.volume_down | (self) | Send new volume_level to device. | Send new volume_level to device. | def volume_down(self):
"""Send new volume_level to device."""
self._server.roonapi.change_volume(self.output_id, -3, "relative") | [
"def",
"volume_down",
"(",
"self",
")",
":",
"self",
".",
"_server",
".",
"roonapi",
".",
"change_volume",
"(",
"self",
".",
"output_id",
",",
"-",
"3",
",",
"\"relative\"",
")"
] | [
450,
4
] | [
452,
74
] | python | en | ['it', 'en', 'en'] | True |
RoonDevice.turn_on | (self) | Turn on device (if supported). | Turn on device (if supported). | def turn_on(self):
"""Turn on device (if supported)."""
if not (self.supports_standby and "source_controls" in self.player_data):
self.media_play()
return
for source in self.player_data["source_controls"]:
if source["supports_standby"] and source["status"] != ... | [
"def",
"turn_on",
"(",
"self",
")",
":",
"if",
"not",
"(",
"self",
".",
"supports_standby",
"and",
"\"source_controls\"",
"in",
"self",
".",
"player_data",
")",
":",
"self",
".",
"media_play",
"(",
")",
"return",
"for",
"source",
"in",
"self",
".",
"play... | [
454,
4
] | [
464,
22
] | python | en | ['fr', 'en', 'en'] | True |
RoonDevice.turn_off | (self) | Turn off device (if supported). | Turn off device (if supported). | def turn_off(self):
"""Turn off device (if supported)."""
if not (self.supports_standby and "source_controls" in self.player_data):
self.media_stop()
return
for source in self.player_data["source_controls"]:
if source["supports_standby"] and not source["statu... | [
"def",
"turn_off",
"(",
"self",
")",
":",
"if",
"not",
"(",
"self",
".",
"supports_standby",
"and",
"\"source_controls\"",
"in",
"self",
".",
"player_data",
")",
":",
"self",
".",
"media_stop",
"(",
")",
"return",
"for",
"source",
"in",
"self",
".",
"pla... | [
466,
4
] | [
475,
22
] | python | en | ['en', 'en', 'en'] | True |
RoonDevice.set_shuffle | (self, shuffle) | Set shuffle state. | Set shuffle state. | def set_shuffle(self, shuffle):
"""Set shuffle state."""
self._server.roonapi.shuffle(self.output_id, shuffle) | [
"def",
"set_shuffle",
"(",
"self",
",",
"shuffle",
")",
":",
"self",
".",
"_server",
".",
"roonapi",
".",
"shuffle",
"(",
"self",
".",
"output_id",
",",
"shuffle",
")"
] | [
477,
4
] | [
479,
61
] | python | de | ['de', 'ny', 'en'] | False |
RoonDevice.play_media | (self, media_type, media_id, **kwargs) | Send the play_media command to the media player. | Send the play_media command to the media player. | def play_media(self, media_type, media_id, **kwargs):
"""Send the play_media command to the media player."""
# Roon itself doesn't support playback of media by filename/url so this a bit of a workaround.
media_type = media_type.lower()
if media_type == "radio":
if self._serve... | [
"def",
"play_media",
"(",
"self",
",",
"media_type",
",",
"media_id",
",",
"*",
"*",
"kwargs",
")",
":",
"# Roon itself doesn't support playback of media by filename/url so this a bit of a workaround.",
"media_type",
"=",
"media_type",
".",
"lower",
"(",
")",
"if",
"med... | [
481,
4
] | [
508,
13
] | python | en | ['en', 'en', 'en'] | True |
RoonDevice.join | (self, join_ids) | Add another Roon player to this player's join group. | Add another Roon player to this player's join group. | def join(self, join_ids):
"""Add another Roon player to this player's join group."""
zone_data = self._server.roonapi.zone_by_output_id(self._output_id)
if zone_data is None:
_LOGGER.error("No zone data for %s", self.name)
return
sync_available = {}
for ... | [
"def",
"join",
"(",
"self",
",",
"join_ids",
")",
":",
"zone_data",
"=",
"self",
".",
"_server",
".",
"roonapi",
".",
"zone_by_output_id",
"(",
"self",
".",
"_output_id",
")",
"if",
"zone_data",
"is",
"None",
":",
"_LOGGER",
".",
"error",
"(",
"\"No zone... | [
510,
4
] | [
548,
9
] | python | en | ['en', 'en', 'en'] | True |
RoonDevice.unjoin | (self, unjoin_ids=None) | Remove a Roon player to this player's join group. | Remove a Roon player to this player's join group. | def unjoin(self, unjoin_ids=None):
"""Remove a Roon player to this player's join group."""
zone_data = self._server.roonapi.zone_by_output_id(self._output_id)
if zone_data is None:
_LOGGER.error("No zone data for %s", self.name)
return
join_group = {
... | [
"def",
"unjoin",
"(",
"self",
",",
"unjoin_ids",
"=",
"None",
")",
":",
"zone_data",
"=",
"self",
".",
"_server",
".",
"roonapi",
".",
"zone_by_output_id",
"(",
"self",
".",
"_output_id",
")",
"if",
"zone_data",
"is",
"None",
":",
"_LOGGER",
".",
"error"... | [
550,
4
] | [
586,
82
] | python | en | ['en', 'en', 'en'] | True |
RoonDevice.async_transfer | (self, transfer_id) | Transfer playback from this roon player to another. | Transfer playback from this roon player to another. | async def async_transfer(self, transfer_id):
"""Transfer playback from this roon player to another."""
name = self._server.roon_name(transfer_id)
if name is None:
_LOGGER.error("No roon player found for %s", transfer_id)
return
zone_ids = {
output["d... | [
"async",
"def",
"async_transfer",
"(",
"self",
",",
"transfer_id",
")",
":",
"name",
"=",
"self",
".",
"_server",
".",
"roon_name",
"(",
"transfer_id",
")",
"if",
"name",
"is",
"None",
":",
"_LOGGER",
".",
"error",
"(",
"\"No roon player found for %s\"",
","... | [
588,
4
] | [
614,
9
] | python | en | ['en', 'en', 'en'] | True |
RoonDevice.async_browse_media | (self, media_content_type=None, media_content_id=None) | Implement the websocket media browsing helper. | Implement the websocket media browsing helper. | async def async_browse_media(self, media_content_type=None, media_content_id=None):
"""Implement the websocket media browsing helper."""
return await self.hass.async_add_executor_job(
browse_media,
self.zone_id,
self._server,
media_content_type,
... | [
"async",
"def",
"async_browse_media",
"(",
"self",
",",
"media_content_type",
"=",
"None",
",",
"media_content_id",
"=",
"None",
")",
":",
"return",
"await",
"self",
".",
"hass",
".",
"async_add_executor_job",
"(",
"browse_media",
",",
"self",
".",
"zone_id",
... | [
616,
4
] | [
624,
9
] | python | en | ['en', 'af', 'en'] | True |
GarminConnectConfigFlowHandler._show_setup_form | (self, errors=None) | Show the setup form to the user. | Show the setup form to the user. | async def _show_setup_form(self, errors=None):
"""Show the setup form to the user."""
return self.async_show_form(
step_id="user",
data_schema=vol.Schema(
{vol.Required(CONF_USERNAME): str, vol.Required(CONF_PASSWORD): str}
),
errors=errors... | [
"async",
"def",
"_show_setup_form",
"(",
"self",
",",
"errors",
"=",
"None",
")",
":",
"return",
"self",
".",
"async_show_form",
"(",
"step_id",
"=",
"\"user\"",
",",
"data_schema",
"=",
"vol",
".",
"Schema",
"(",
"{",
"vol",
".",
"Required",
"(",
"CONF_... | [
25,
4
] | [
33,
9
] | python | en | ['en', 'en', 'en'] | True |
GarminConnectConfigFlowHandler.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."""
if user_input is None:
return await self._show_setup_form()
garmin_client = Garmin(user_input[CONF_USERNAME], user_input[CONF_PASSWORD])
errors = {}
try:
await self.hass.asy... | [
"async",
"def",
"async_step_user",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"if",
"user_input",
"is",
"None",
":",
"return",
"await",
"self",
".",
"_show_setup_form",
"(",
")",
"garmin_client",
"=",
"Garmin",
"(",
"user_input",
"[",
"CONF_USERN... | [
35,
4
] | [
71,
9
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Nextcloud sensors. | Set up the Nextcloud sensors. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Nextcloud sensors."""
if discovery_info is None:
return
sensors = []
for name in hass.data[DOMAIN]:
if name in SENSORS:
sensors.append(NextcloudSensor(name))
add_entities(sensors, True) | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"if",
"discovery_info",
"is",
"None",
":",
"return",
"sensors",
"=",
"[",
"]",
"for",
"name",
"in",
"hass",
".",
"data",
"[",
"DOMAIN"... | [
6,
0
] | [
14,
31
] | python | en | ['en', 'su', 'en'] | True |
NextcloudSensor.__init__ | (self, item) | Initialize the Nextcloud sensor. | Initialize the Nextcloud sensor. | def __init__(self, item):
"""Initialize the Nextcloud sensor."""
self._name = item
self._state = None | [
"def",
"__init__",
"(",
"self",
",",
"item",
")",
":",
"self",
".",
"_name",
"=",
"item",
"self",
".",
"_state",
"=",
"None"
] | [
20,
4
] | [
23,
26
] | python | en | ['en', 'su', 'en'] | True |
NextcloudSensor.icon | (self) | Return the icon for this sensor. | Return the icon for this sensor. | def icon(self):
"""Return the icon for this sensor."""
return "mdi:cloud" | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"\"mdi:cloud\""
] | [
26,
4
] | [
28,
26
] | python | en | ['en', 'en', 'en'] | True |
NextcloudSensor.name | (self) | Return the name for this sensor. | Return the name for this sensor. | def name(self):
"""Return the name for this sensor."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
31,
4
] | [
33,
25
] | python | en | ['en', 'ceb', 'en'] | True |
NextcloudSensor.state | (self) | Return the state for this sensor. | Return the state for this sensor. | def state(self):
"""Return the state for this sensor."""
return self._state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
36,
4
] | [
38,
26
] | python | en | ['en', 'en', 'en'] | True |
NextcloudSensor.unique_id | (self) | Return the unique ID for this sensor. | Return the unique ID for this sensor. | def unique_id(self):
"""Return the unique ID for this sensor."""
return f"{self.hass.data[DOMAIN]['instance']}#{self._name}" | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"f\"{self.hass.data[DOMAIN]['instance']}#{self._name}\""
] | [
41,
4
] | [
43,
67
] | python | en | ['en', 'la', 'en'] | True |
NextcloudSensor.update | (self) | Update the sensor. | Update the sensor. | def update(self):
"""Update the sensor."""
self._state = self.hass.data[DOMAIN][self._name] | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"_state",
"=",
"self",
".",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"self",
".",
"_name",
"]"
] | [
45,
4
] | [
47,
56
] | python | en | ['en', 'nl', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up the Serial sensor platform. | Set up the Serial sensor platform. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the Serial sensor platform."""
name = config.get(CONF_NAME)
port = config.get(CONF_SERIAL_PORT)
baudrate = config.get(CONF_BAUDRATE)
bytesize = config.get(CONF_BYTESIZE)
parity = config.get(CONF_PARI... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"name",
"=",
"config",
".",
"get",
"(",
"CONF_NAME",
")",
"port",
"=",
"config",
".",
"get",
"(",
"CONF_SERIAL_PORT",... | [
72,
0
] | [
102,
38
] | python | en | ['en', 'pt', 'en'] | True |
SerialSensor.__init__ | (
self,
name,
port,
baudrate,
bytesize,
parity,
stopbits,
xonxoff,
rtscts,
dsrdtr,
value_template,
) | Initialize the Serial sensor. | Initialize the Serial sensor. | def __init__(
self,
name,
port,
baudrate,
bytesize,
parity,
stopbits,
xonxoff,
rtscts,
dsrdtr,
value_template,
):
"""Initialize the Serial sensor."""
self._name = name
self._state = None
self._por... | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"port",
",",
"baudrate",
",",
"bytesize",
",",
"parity",
",",
"stopbits",
",",
"xonxoff",
",",
"rtscts",
",",
"dsrdtr",
",",
"value_template",
",",
")",
":",
"self",
".",
"_name",
"=",
"name",
"self",
... | [
108,
4
] | [
134,
31
] | python | en | ['en', 'pt', 'en'] | True |
SerialSensor.async_added_to_hass | (self) | Handle when an entity is about to be added to Home Assistant. | Handle when an entity is about to be added to Home Assistant. | async def async_added_to_hass(self):
"""Handle when an entity is about to be added to Home Assistant."""
self._serial_loop_task = self.hass.loop.create_task(
self.serial_read(
self._port,
self._baudrate,
self._bytesize,
self._pa... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"_serial_loop_task",
"=",
"self",
".",
"hass",
".",
"loop",
".",
"create_task",
"(",
"self",
".",
"serial_read",
"(",
"self",
".",
"_port",
",",
"self",
".",
"_baudrate",
",",
"se... | [
136,
4
] | [
149,
9
] | 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.