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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
logbook_filtering_state | (hass) | Filter state changes. | Filter state changes. | async def logbook_filtering_state(hass):
"""Filter state changes."""
return await _logbook_filtering(hass, 1, 1) | [
"async",
"def",
"logbook_filtering_state",
"(",
"hass",
")",
":",
"return",
"await",
"_logbook_filtering",
"(",
"hass",
",",
"1",
",",
"1",
")"
] | [
188,
0
] | [
190,
47
] | python | en | ['en', 'en', 'en'] | True |
logbook_filtering_attributes | (hass) | Filter attribute changes. | Filter attribute changes. | async def logbook_filtering_attributes(hass):
"""Filter attribute changes."""
return await _logbook_filtering(hass, 1, 2) | [
"async",
"def",
"logbook_filtering_attributes",
"(",
"hass",
")",
":",
"return",
"await",
"_logbook_filtering",
"(",
"hass",
",",
"1",
",",
"2",
")"
] | [
194,
0
] | [
196,
47
] | python | en | ['en', 'en', 'en'] | True |
filtering_entity_id | (hass) | Run a 100k state changes through entity filter. | Run a 100k state changes through entity filter. | async def filtering_entity_id(hass):
"""Run a 100k state changes through entity filter."""
config = {
"include": {
"domains": [
"automation",
"script",
"group",
"media_player",
"custom_component",
],
... | [
"async",
"def",
"filtering_entity_id",
"(",
"hass",
")",
":",
"config",
"=",
"{",
"\"include\"",
":",
"{",
"\"domains\"",
":",
"[",
"\"automation\"",
",",
"\"script\"",
",",
"\"group\"",
",",
"\"media_player\"",
",",
"\"custom_component\"",
",",
"]",
",",
"\"e... | [
239,
0
] | [
300,
26
] | python | en | ['en', 'en', 'en'] | True |
valid_entity_id | (hass) | Run valid entity ID a million times. | Run valid entity ID a million times. | async def valid_entity_id(hass):
"""Run valid entity ID a million times."""
start = timer()
for _ in range(10 ** 6):
core.valid_entity_id("light.kitchen")
return timer() - start | [
"async",
"def",
"valid_entity_id",
"(",
"hass",
")",
":",
"start",
"=",
"timer",
"(",
")",
"for",
"_",
"in",
"range",
"(",
"10",
"**",
"6",
")",
":",
"core",
".",
"valid_entity_id",
"(",
"\"light.kitchen\"",
")",
"return",
"timer",
"(",
")",
"-",
"st... | [
304,
0
] | [
309,
26
] | python | en | ['en', 'cy', 'en'] | True |
json_serialize_states | (hass) | Serialize million states with websocket default encoder. | Serialize million states with websocket default encoder. | async def json_serialize_states(hass):
"""Serialize million states with websocket default encoder."""
states = [
core.State("light.kitchen", "on", {"friendly_name": "Kitchen Lights"})
for _ in range(10 ** 6)
]
start = timer()
JSON_DUMP(states)
return timer() - start | [
"async",
"def",
"json_serialize_states",
"(",
"hass",
")",
":",
"states",
"=",
"[",
"core",
".",
"State",
"(",
"\"light.kitchen\"",
",",
"\"on\"",
",",
"{",
"\"friendly_name\"",
":",
"\"Kitchen Lights\"",
"}",
")",
"for",
"_",
"in",
"range",
"(",
"10",
"**... | [
313,
0
] | [
322,
26
] | python | en | ['en', 'da', 'en'] | True |
_create_state_changed_event_from_old_new | (
entity_id, event_time_fired, old_state, new_state
) | Create a state changed event from a old and new state. | Create a state changed event from a old and new state. | def _create_state_changed_event_from_old_new(
entity_id, event_time_fired, old_state, new_state
):
"""Create a state changed event from a old and new state."""
attributes = {}
if new_state is not None:
attributes = new_state.get("attributes")
attributes_json = json.dumps(attributes, cls=JSON... | [
"def",
"_create_state_changed_event_from_old_new",
"(",
"entity_id",
",",
"event_time_fired",
",",
"old_state",
",",
"new_state",
")",
":",
"attributes",
"=",
"{",
"}",
"if",
"new_state",
"is",
"not",
"None",
":",
"attributes",
"=",
"new_state",
".",
"get",
"(",... | [
325,
0
] | [
367,
45
] | python | en | ['en', 'en', 'en'] | True |
blueprint_1 | () | Blueprint fixture. | Blueprint fixture. | def blueprint_1():
"""Blueprint fixture."""
return models.Blueprint(
{
"blueprint": {
"name": "Hello",
"domain": "automation",
"source_url": "https://github.com/balloob/home-assistant-config/blob/main/blueprints/automation/motion_light.yaml",
... | [
"def",
"blueprint_1",
"(",
")",
":",
"return",
"models",
".",
"Blueprint",
"(",
"{",
"\"blueprint\"",
":",
"{",
"\"name\"",
":",
"\"Hello\"",
",",
"\"domain\"",
":",
"\"automation\"",
",",
"\"source_url\"",
":",
"\"https://github.com/balloob/home-assistant-config/blob... | [
12,
0
] | [
26,
5
] | python | en | ['fr', 'lb', 'en'] | False |
domain_bps | (hass) | Domain blueprints fixture. | Domain blueprints fixture. | def domain_bps(hass):
"""Domain blueprints fixture."""
return models.DomainBlueprints(hass, "automation", logging.getLogger(__name__)) | [
"def",
"domain_bps",
"(",
"hass",
")",
":",
"return",
"models",
".",
"DomainBlueprints",
"(",
"hass",
",",
"\"automation\"",
",",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
")"
] | [
30,
0
] | [
32,
83
] | python | fr | ['fr', 'fr', 'en'] | True |
test_blueprint_model_init | () | Test constructor validation. | Test constructor validation. | def test_blueprint_model_init():
"""Test constructor validation."""
with pytest.raises(errors.InvalidBlueprint):
models.Blueprint({})
with pytest.raises(errors.InvalidBlueprint):
models.Blueprint(
{"blueprint": {"name": "Hello", "domain": "automation"}},
expected_dom... | [
"def",
"test_blueprint_model_init",
"(",
")",
":",
"with",
"pytest",
".",
"raises",
"(",
"errors",
".",
"InvalidBlueprint",
")",
":",
"models",
".",
"Blueprint",
"(",
"{",
"}",
")",
"with",
"pytest",
".",
"raises",
"(",
"errors",
".",
"InvalidBlueprint",
"... | [
35,
0
] | [
56,
9
] | python | en | ['en', 'sv', 'en'] | True |
test_blueprint_properties | (blueprint_1) | Test properties. | Test properties. | def test_blueprint_properties(blueprint_1):
"""Test properties."""
assert blueprint_1.metadata == {
"name": "Hello",
"domain": "automation",
"source_url": "https://github.com/balloob/home-assistant-config/blob/main/blueprints/automation/motion_light.yaml",
"input": {"test-placeho... | [
"def",
"test_blueprint_properties",
"(",
"blueprint_1",
")",
":",
"assert",
"blueprint_1",
".",
"metadata",
"==",
"{",
"\"name\"",
":",
"\"Hello\"",
",",
"\"domain\"",
":",
"\"automation\"",
",",
"\"source_url\"",
":",
"\"https://github.com/balloob/home-assistant-config/b... | [
59,
0
] | [
69,
59
] | python | en | ['en', 'nl', 'en'] | False |
test_blueprint_update_metadata | () | Test update metadata. | Test update metadata. | def test_blueprint_update_metadata():
"""Test update metadata."""
bp = models.Blueprint(
{
"blueprint": {
"name": "Hello",
"domain": "automation",
},
}
)
bp.update_metadata(source_url="http://bla.com")
assert bp.metadata["sourc... | [
"def",
"test_blueprint_update_metadata",
"(",
")",
":",
"bp",
"=",
"models",
".",
"Blueprint",
"(",
"{",
"\"blueprint\"",
":",
"{",
"\"name\"",
":",
"\"Hello\"",
",",
"\"domain\"",
":",
"\"automation\"",
",",
"}",
",",
"}",
")",
"bp",
".",
"update_metadata",... | [
72,
0
] | [
84,
56
] | python | de | ['en', 'de', 'it'] | False |
test_blueprint_validate | () | Test validate blueprint. | Test validate blueprint. | def test_blueprint_validate():
"""Test validate blueprint."""
assert (
models.Blueprint(
{
"blueprint": {
"name": "Hello",
"domain": "automation",
},
}
).validate()
is None
)
assert (... | [
"def",
"test_blueprint_validate",
"(",
")",
":",
"assert",
"(",
"models",
".",
"Blueprint",
"(",
"{",
"\"blueprint\"",
":",
"{",
"\"name\"",
":",
"\"Hello\"",
",",
"\"domain\"",
":",
"\"automation\"",
",",
"}",
",",
"}",
")",
".",
"validate",
"(",
")",
"... | [
87,
0
] | [
112,
5
] | python | en | ['en', 'et', 'it'] | False |
test_blueprint_inputs | (blueprint_1) | Test blueprint inputs. | Test blueprint inputs. | def test_blueprint_inputs(blueprint_1):
"""Test blueprint inputs."""
inputs = models.BlueprintInputs(
blueprint_1,
{"use_blueprint": {"path": "bla", "input": {"test-placeholder": 1}}},
)
inputs.validate()
assert inputs.inputs == {"test-placeholder": 1}
assert inputs.async_substit... | [
"def",
"test_blueprint_inputs",
"(",
"blueprint_1",
")",
":",
"inputs",
"=",
"models",
".",
"BlueprintInputs",
"(",
"blueprint_1",
",",
"{",
"\"use_blueprint\"",
":",
"{",
"\"path\"",
":",
"\"bla\"",
",",
"\"input\"",
":",
"{",
"\"test-placeholder\"",
":",
"1",
... | [
115,
0
] | [
123,
54
] | python | en | ['en', 'lb', 'en'] | True |
test_blueprint_inputs_validation | (blueprint_1) | Test blueprint input validation. | Test blueprint input validation. | def test_blueprint_inputs_validation(blueprint_1):
"""Test blueprint input validation."""
inputs = models.BlueprintInputs(
blueprint_1,
{"use_blueprint": {"path": "bla", "input": {"non-existing-placeholder": 1}}},
)
with pytest.raises(errors.MissingPlaceholder):
inputs.validate() | [
"def",
"test_blueprint_inputs_validation",
"(",
"blueprint_1",
")",
":",
"inputs",
"=",
"models",
".",
"BlueprintInputs",
"(",
"blueprint_1",
",",
"{",
"\"use_blueprint\"",
":",
"{",
"\"path\"",
":",
"\"bla\"",
",",
"\"input\"",
":",
"{",
"\"non-existing-placeholder... | [
126,
0
] | [
133,
25
] | python | en | ['en', 'et', 'en'] | True |
test_domain_blueprints_get_blueprint_errors | (hass, domain_bps) | Test domain blueprints. | Test domain blueprints. | async def test_domain_blueprints_get_blueprint_errors(hass, domain_bps):
"""Test domain blueprints."""
assert hass.data["blueprint"]["automation"] is domain_bps
with pytest.raises(errors.FailedToLoad), patch(
"homeassistant.util.yaml.load_yaml", side_effect=FileNotFoundError
):
await do... | [
"async",
"def",
"test_domain_blueprints_get_blueprint_errors",
"(",
"hass",
",",
"domain_bps",
")",
":",
"assert",
"hass",
".",
"data",
"[",
"\"blueprint\"",
"]",
"[",
"\"automation\"",
"]",
"is",
"domain_bps",
"with",
"pytest",
".",
"raises",
"(",
"errors",
"."... | [
136,
0
] | [
148,
80
] | python | fr | ['fr', 'fr', 'en'] | True |
test_domain_blueprints_caching | (domain_bps) | Test domain blueprints cache blueprints. | Test domain blueprints cache blueprints. | async def test_domain_blueprints_caching(domain_bps):
"""Test domain blueprints cache blueprints."""
obj = object()
with patch.object(domain_bps, "_load_blueprint", return_value=obj):
assert await domain_bps.async_get_blueprint("something") is obj
# Now we hit cache
assert await domain_bps.... | [
"async",
"def",
"test_domain_blueprints_caching",
"(",
"domain_bps",
")",
":",
"obj",
"=",
"object",
"(",
")",
"with",
"patch",
".",
"object",
"(",
"domain_bps",
",",
"\"_load_blueprint\"",
",",
"return_value",
"=",
"obj",
")",
":",
"assert",
"await",
"domain_... | [
151,
0
] | [
165,
73
] | python | en | ['en', 'fr', 'en'] | True |
test_domain_blueprints_inputs_from_config | (domain_bps, blueprint_1) | Test DomainBlueprints.async_inputs_from_config. | Test DomainBlueprints.async_inputs_from_config. | async def test_domain_blueprints_inputs_from_config(domain_bps, blueprint_1):
"""Test DomainBlueprints.async_inputs_from_config."""
with pytest.raises(errors.InvalidBlueprintInputs):
await domain_bps.async_inputs_from_config({"not-referencing": "use_blueprint"})
with pytest.raises(errors.MissingPla... | [
"async",
"def",
"test_domain_blueprints_inputs_from_config",
"(",
"domain_bps",
",",
"blueprint_1",
")",
":",
"with",
"pytest",
".",
"raises",
"(",
"errors",
".",
"InvalidBlueprintInputs",
")",
":",
"await",
"domain_bps",
".",
"async_inputs_from_config",
"(",
"{",
"... | [
168,
0
] | [
185,
54
] | python | en | ['en', 'en', 'en'] | False |
test_domain_blueprints_add_blueprint | (domain_bps, blueprint_1) | Test DomainBlueprints.async_add_blueprint. | Test DomainBlueprints.async_add_blueprint. | async def test_domain_blueprints_add_blueprint(domain_bps, blueprint_1):
"""Test DomainBlueprints.async_add_blueprint."""
with patch.object(domain_bps, "_create_file") as create_file_mock:
# Should add extension when not present.
await domain_bps.async_add_blueprint(blueprint_1, "something")
... | [
"async",
"def",
"test_domain_blueprints_add_blueprint",
"(",
"domain_bps",
",",
"blueprint_1",
")",
":",
"with",
"patch",
".",
"object",
"(",
"domain_bps",
",",
"\"_create_file\"",
")",
"as",
"create_file_mock",
":",
"# Should add extension when not present.",
"await",
... | [
188,
0
] | [
201,
39
] | python | en | ['fr', 'hu', 'en'] | False |
create_matcher | (utterance) | Create a regex that matches the utterance. | Create a regex that matches the utterance. | def create_matcher(utterance):
"""Create a regex that matches the utterance."""
# Split utterance into parts that are type: NORMAL, GROUP or OPTIONAL
# Pattern matches (GROUP|OPTIONAL): Change light to [the color] {name}
parts = re.split(r"({\w+}|\[[\w\s]+\] *)", utterance)
# Pattern to extract name... | [
"def",
"create_matcher",
"(",
"utterance",
")",
":",
"# Split utterance into parts that are type: NORMAL, GROUP or OPTIONAL",
"# Pattern matches (GROUP|OPTIONAL): Change light to [the color] {name}",
"parts",
"=",
"re",
".",
"split",
"(",
"r\"({\\w+}|\\[[\\w\\s]+\\] *)\"",
",",
"utte... | [
4,
0
] | [
33,
45
] | python | en | ['en', 'en', 'en'] | True |
test_form | (hass) | Test we get the form. | Test we get the form. | async def test_form(hass):
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == "form"
assert result["errors... | [
"async",
"def",
"test_form",
"(",
"hass",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(... | [
20,
0
] | [
44,
48
] | python | en | ['en', 'en', 'en'] | True |
test_form_invalid_auth | (hass) | Test we handle invalid auth. | Test we handle invalid auth. | async def test_form_invalid_auth(hass):
"""Test we handle invalid auth."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
with patch(
"smart_meter_texas.Client.authenticate",
side_effect=SmartMeterTexasAuthError,
... | [
"async",
"def",
"test_form_invalid_auth",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"config_entries",
".",
"SOURCE_USER",
"}",
")"... | [
47,
0
] | [
63,
56
] | python | en | ['en', 'en', 'en'] | True |
test_form_cannot_connect | (hass, side_effect) | Test we handle cannot connect error. | Test we handle cannot connect error. | async def test_form_cannot_connect(hass, side_effect):
"""Test we handle cannot connect error."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
with patch(
"smart_meter_texas.Client.authenticate",
side_effect=side_ef... | [
"async",
"def",
"test_form_cannot_connect",
"(",
"hass",
",",
"side_effect",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"config_entries",
".",
"... | [
69,
0
] | [
84,
58
] | python | en | ['en', 'en', 'en'] | True |
test_form_unknown_exception | (hass) | Test base exception is handled. | Test base exception is handled. | async def test_form_unknown_exception(hass):
"""Test base exception is handled."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
with patch(
"smart_meter_texas.Client.authenticate",
side_effect=Exception,
):
... | [
"async",
"def",
"test_form_unknown_exception",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"config_entries",
".",
"SOURCE_USER",
"}",
... | [
87,
0
] | [
103,
51
] | python | en | ['en', 'en', 'en'] | True |
test_form_duplicate_account | (hass) | Test that a duplicate account cannot be configured. | Test that a duplicate account cannot be configured. | async def test_form_duplicate_account(hass):
"""Test that a duplicate account cannot be configured."""
MockConfigEntry(
domain=DOMAIN,
unique_id="user123",
data={"username": "user123", "password": "password123"},
).add_to_hass(hass)
with patch(
"smart_meter_texas.Client.... | [
"async",
"def",
"test_form_duplicate_account",
"(",
"hass",
")",
":",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"unique_id",
"=",
"\"user123\"",
",",
"data",
"=",
"{",
"\"username\"",
":",
"\"user123\"",
",",
"\"password\"",
":",
"\"password123\"",
"... | [
106,
0
] | [
125,
51
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up the IMAP platform. | Set up the IMAP platform. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the IMAP platform."""
sensor = ImapSensor(
config.get(CONF_NAME),
config.get(CONF_USERNAME),
config.get(CONF_PASSWORD),
config.get(CONF_SERVER),
config.get(CONF_PORT),
... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"sensor",
"=",
"ImapSensor",
"(",
"config",
".",
"get",
"(",
"CONF_NAME",
")",
",",
"config",
".",
"get",
"(",
"CON... | [
45,
0
] | [
61,
38
] | python | en | ['en', 'ru', 'en'] | True |
ImapSensor.__init__ | (self, name, user, password, server, port, charset, folder, search) | Initialize the sensor. | Initialize the sensor. | def __init__(self, name, user, password, server, port, charset, folder, search):
"""Initialize the sensor."""
self._name = name or user
self._user = user
self._password = password
self._server = server
self._port = port
self._charset = charset
self._folder... | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"user",
",",
"password",
",",
"server",
",",
"port",
",",
"charset",
",",
"folder",
",",
"search",
")",
":",
"self",
".",
"_name",
"=",
"name",
"or",
"user",
"self",
".",
"_user",
"=",
"user",
"self... | [
67,
4
] | [
80,
35
] | python | en | ['en', 'en', 'en'] | True |
ImapSensor.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."""
if not self.should_poll:
self._idle_loop_task = self.hass.loop.create_task(self.idle_loop()) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"should_poll",
":",
"self",
".",
"_idle_loop_task",
"=",
"self",
".",
"hass",
".",
"loop",
".",
"create_task",
"(",
"self",
".",
"idle_loop",
"(",
")",
")"
] | [
82,
4
] | [
85,
79
] | python | en | ['en', 'en', 'en'] | True |
ImapSensor.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"
] | [
88,
4
] | [
90,
25
] | python | en | ['en', 'mi', 'en'] | True |
ImapSensor.icon | (self) | Return the icon to use in the frontend. | Return the icon to use in the frontend. | def icon(self):
"""Return the icon to use in the frontend."""
return ICON | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"ICON"
] | [
93,
4
] | [
95,
19
] | python | en | ['en', 'en', 'en'] | True |
ImapSensor.state | (self) | Return the number of emails found. | Return the number of emails found. | def state(self):
"""Return the number of emails found."""
return self._email_count | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_email_count"
] | [
98,
4
] | [
100,
32
] | python | en | ['en', 'en', 'en'] | True |
ImapSensor.available | (self) | Return the availability of the device. | Return the availability of the device. | def available(self):
"""Return the availability of the device."""
return self._connection is not None | [
"def",
"available",
"(",
"self",
")",
":",
"return",
"self",
".",
"_connection",
"is",
"not",
"None"
] | [
103,
4
] | [
105,
43
] | python | en | ['en', 'en', 'en'] | True |
ImapSensor.should_poll | (self) | Return if polling is needed. | Return if polling is needed. | def should_poll(self):
"""Return if polling is needed."""
return not self._does_push | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"not",
"self",
".",
"_does_push"
] | [
108,
4
] | [
110,
34
] | python | en | ['en', 'en', 'en'] | True |
ImapSensor.connection | (self) | Return a connection to the server, establishing it if necessary. | Return a connection to the server, establishing it if necessary. | async def connection(self):
"""Return a connection to the server, establishing it if necessary."""
if self._connection is None:
try:
self._connection = IMAP4_SSL(self._server, self._port)
await self._connection.wait_hello_from_server()
await se... | [
"async",
"def",
"connection",
"(",
"self",
")",
":",
"if",
"self",
".",
"_connection",
"is",
"None",
":",
"try",
":",
"self",
".",
"_connection",
"=",
"IMAP4_SSL",
"(",
"self",
".",
"_server",
",",
"self",
".",
"_port",
")",
"await",
"self",
".",
"_c... | [
112,
4
] | [
124,
31
] | python | en | ['en', 'en', 'en'] | True |
ImapSensor.idle_loop | (self) | Wait for data pushed from server. | Wait for data pushed from server. | async def idle_loop(self):
"""Wait for data pushed from server."""
while True:
try:
if await self.connection():
await self.refresh_email_count()
self.async_write_ha_state()
idle = await self._connection.idle_start()... | [
"async",
"def",
"idle_loop",
"(",
"self",
")",
":",
"while",
"True",
":",
"try",
":",
"if",
"await",
"self",
".",
"connection",
"(",
")",
":",
"await",
"self",
".",
"refresh_email_count",
"(",
")",
"self",
".",
"async_write_ha_state",
"(",
")",
"idle",
... | [
126,
4
] | [
142,
35
] | python | en | ['en', 'en', 'en'] | True |
ImapSensor.async_update | (self) | Periodic polling of state. | Periodic polling of state. | async def async_update(self):
"""Periodic polling of state."""
try:
if await self.connection():
await self.refresh_email_count()
except (AioImapException, asyncio.TimeoutError):
self.disconnected() | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"try",
":",
"if",
"await",
"self",
".",
"connection",
"(",
")",
":",
"await",
"self",
".",
"refresh_email_count",
"(",
")",
"except",
"(",
"AioImapException",
",",
"asyncio",
".",
"TimeoutError",
")",
... | [
144,
4
] | [
150,
31
] | python | en | ['en', 'en', 'en'] | True |
ImapSensor.refresh_email_count | (self) | Check the number of found emails. | Check the number of found emails. | async def refresh_email_count(self):
"""Check the number of found emails."""
if self._connection:
await self._connection.noop()
result, lines = await self._connection.search(
self._search, charset=self._charset
)
if result == "OK":
... | [
"async",
"def",
"refresh_email_count",
"(",
"self",
")",
":",
"if",
"self",
".",
"_connection",
":",
"await",
"self",
".",
"_connection",
".",
"noop",
"(",
")",
"result",
",",
"lines",
"=",
"await",
"self",
".",
"_connection",
".",
"search",
"(",
"self",... | [
152,
4
] | [
168,
17
] | python | en | ['en', 'en', 'en'] | True |
ImapSensor.disconnected | (self) | Forget the connection after it was lost. | Forget the connection after it was lost. | def disconnected(self):
"""Forget the connection after it was lost."""
_LOGGER.warning("Lost %s (will attempt to reconnect)", self._server)
self._connection = None | [
"def",
"disconnected",
"(",
"self",
")",
":",
"_LOGGER",
".",
"warning",
"(",
"\"Lost %s (will attempt to reconnect)\"",
",",
"self",
".",
"_server",
")",
"self",
".",
"_connection",
"=",
"None"
] | [
170,
4
] | [
173,
31
] | python | en | ['en', 'en', 'en'] | True |
ImapSensor.shutdown | (self, *_) | Close resources. | Close resources. | async def shutdown(self, *_):
"""Close resources."""
if self._connection:
if self._connection.has_pending_idle():
self._connection.idle_done()
await self._connection.logout()
if self._idle_loop_task:
self._idle_loop_task.cancel() | [
"async",
"def",
"shutdown",
"(",
"self",
",",
"*",
"_",
")",
":",
"if",
"self",
".",
"_connection",
":",
"if",
"self",
".",
"_connection",
".",
"has_pending_idle",
"(",
")",
":",
"self",
".",
"_connection",
".",
"idle_done",
"(",
")",
"await",
"self",
... | [
175,
4
] | [
182,
41
] | python | en | ['en', 'la', 'en'] | False |
registered_flow | (hass) | Mock a registered flow. | Mock a registered flow. | def registered_flow(hass):
"""Mock a registered flow."""
local_auth.initialize(hass, "TEST-CLIENT-ID", "TEST-CLIENT-SECRET")
return hass.data[config_flow.DATA_FLOW_IMPL][const.DOMAIN] | [
"def",
"registered_flow",
"(",
"hass",
")",
":",
"local_auth",
".",
"initialize",
"(",
"hass",
",",
"\"TEST-CLIENT-ID\"",
",",
"\"TEST-CLIENT-SECRET\"",
")",
"return",
"hass",
".",
"data",
"[",
"config_flow",
".",
"DATA_FLOW_IMPL",
"]",
"[",
"const",
".",
"DOM... | [
10,
0
] | [
13,
62
] | python | en | ['en', 'da', 'en'] | True |
test_generate_auth_url | (registered_flow) | Test generating an auth url.
Mainly testing that it doesn't blow up.
| Test generating an auth url. | async def test_generate_auth_url(registered_flow):
"""Test generating an auth url.
Mainly testing that it doesn't blow up.
"""
url = await registered_flow["gen_authorize_url"]("TEST-FLOW-ID")
assert url is not None | [
"async",
"def",
"test_generate_auth_url",
"(",
"registered_flow",
")",
":",
"url",
"=",
"await",
"registered_flow",
"[",
"\"gen_authorize_url\"",
"]",
"(",
"\"TEST-FLOW-ID\"",
")",
"assert",
"url",
"is",
"not",
"None"
] | [
16,
0
] | [
22,
26
] | python | de | ['de', 'en', 'it'] | False |
test_convert_code | (requests_mock, registered_flow) | Test converting a code. | Test converting a code. | async def test_convert_code(requests_mock, registered_flow):
"""Test converting a code."""
from nest.nest import ACCESS_TOKEN_URL
def token_matcher(request):
"""Match a fetch token request."""
if request.url != ACCESS_TOKEN_URL:
return None
assert dict(parse_qsl(request... | [
"async",
"def",
"test_convert_code",
"(",
"requests_mock",
",",
"registered_flow",
")",
":",
"from",
"nest",
".",
"nest",
"import",
"ACCESS_TOKEN_URL",
"def",
"token_matcher",
"(",
"request",
")",
":",
"\"\"\"Match a fetch token request.\"\"\"",
"if",
"request",
".",
... | [
25,
0
] | [
48,
58
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up a wake on lan switch. | Set up a wake on lan switch. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up a wake on lan switch."""
broadcast_address = config.get(CONF_BROADCAST_ADDRESS)
broadcast_port = config.get(CONF_BROADCAST_PORT)
host = config.get(CONF_HOST)
mac_address = config[CONF_MAC]
name = config[CONF_NAME]
... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"broadcast_address",
"=",
"config",
".",
"get",
"(",
"CONF_BROADCAST_ADDRESS",
")",
"broadcast_port",
"=",
"config",
".",
"get",
"(",
"CONF_... | [
38,
0
] | [
60,
5
] | python | en | ['en', 'jv', 'en'] | True |
WolSwitch.__init__ | (
self,
hass,
name,
host,
mac_address,
off_action,
broadcast_address,
broadcast_port,
) | Initialize the WOL switch. | Initialize the WOL switch. | def __init__(
self,
hass,
name,
host,
mac_address,
off_action,
broadcast_address,
broadcast_port,
):
"""Initialize the WOL switch."""
self._hass = hass
self._name = name
self._host = host
self._mac_address = mac_... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"name",
",",
"host",
",",
"mac_address",
",",
"off_action",
",",
"broadcast_address",
",",
"broadcast_port",
",",
")",
":",
"self",
".",
"_hass",
"=",
"hass",
"self",
".",
"_name",
"=",
"name",
"self",
... | [
66,
4
] | [
87,
27
] | python | en | ['en', 'en', 'en'] | True |
WolSwitch.is_on | (self) | Return true if switch is on. | Return true if switch is on. | def is_on(self):
"""Return true if switch is on."""
return self._state | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
90,
4
] | [
92,
26
] | python | en | ['en', 'fy', 'en'] | True |
WolSwitch.name | (self) | Return the name of the switch. | Return the name of the switch. | def name(self):
"""Return the name of the switch."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
95,
4
] | [
97,
25
] | python | en | ['en', 'en', 'en'] | True |
WolSwitch.turn_on | (self, **kwargs) | Turn the device on. | Turn the device on. | def turn_on(self, **kwargs):
"""Turn the device on."""
service_kwargs = {}
if self._broadcast_address is not None:
service_kwargs["ip_address"] = self._broadcast_address
if self._broadcast_port is not None:
service_kwargs["port"] = self._broadcast_port
_L... | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"service_kwargs",
"=",
"{",
"}",
"if",
"self",
".",
"_broadcast_address",
"is",
"not",
"None",
":",
"service_kwargs",
"[",
"\"ip_address\"",
"]",
"=",
"self",
".",
"_broadcast_address",
"if"... | [
99,
4
] | [
114,
72
] | python | en | ['en', 'en', 'en'] | True |
WolSwitch.turn_off | (self, **kwargs) | Turn the device off if an off action is present. | Turn the device off if an off action is present. | def turn_off(self, **kwargs):
"""Turn the device off if an off action is present."""
if self._off_script is not None:
self._off_script.run(context=self._context) | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"_off_script",
"is",
"not",
"None",
":",
"self",
".",
"_off_script",
".",
"run",
"(",
"context",
"=",
"self",
".",
"_context",
")"
] | [
116,
4
] | [
119,
55
] | python | en | ['en', 'en', 'en'] | True |
WolSwitch.update | (self) | Check if device is on and update the state. | Check if device is on and update the state. | def update(self):
"""Check if device is on and update the state."""
if platform.system().lower() == "windows":
ping_cmd = [
"ping",
"-n",
"1",
"-w",
str(DEFAULT_PING_TIMEOUT * 1000),
str(self._hos... | [
"def",
"update",
"(",
"self",
")",
":",
"if",
"platform",
".",
"system",
"(",
")",
".",
"lower",
"(",
")",
"==",
"\"windows\"",
":",
"ping_cmd",
"=",
"[",
"\"ping\"",
",",
"\"-n\"",
",",
"\"1\"",
",",
"\"-w\"",
",",
"str",
"(",
"DEFAULT_PING_TIMEOUT",
... | [
121,
4
] | [
143,
38
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Perform the setup for Xiaomi devices. | Perform the setup for Xiaomi devices. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Perform the setup for Xiaomi devices."""
entities = []
gateway = hass.data[DOMAIN][GATEWAYS_KEY][config_entry.entry_id]
for device in gateway.devices["light"]:
model = device["model"]
if model in ["gateway", "gateway... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"entities",
"=",
"[",
"]",
"gateway",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"GATEWAYS_KEY",
"]",
"[",
"config_entry",
".",
"entry_id",
... | [
20,
0
] | [
30,
32
] | python | en | ['en', 'en', 'en'] | True |
XiaomiGatewayLight.__init__ | (self, device, name, xiaomi_hub, config_entry) | Initialize the XiaomiGatewayLight. | Initialize the XiaomiGatewayLight. | def __init__(self, device, name, xiaomi_hub, config_entry):
"""Initialize the XiaomiGatewayLight."""
self._data_key = "rgb"
self._hs = (0, 0)
self._brightness = 100
super().__init__(device, name, xiaomi_hub, config_entry) | [
"def",
"__init__",
"(",
"self",
",",
"device",
",",
"name",
",",
"xiaomi_hub",
",",
"config_entry",
")",
":",
"self",
".",
"_data_key",
"=",
"\"rgb\"",
"self",
".",
"_hs",
"=",
"(",
"0",
",",
"0",
")",
"self",
".",
"_brightness",
"=",
"100",
"super",... | [
36,
4
] | [
42,
64
] | python | en | ['en', 'pl', 'en'] | True |
XiaomiGatewayLight.is_on | (self) | Return true if it is on. | Return true if it is on. | def is_on(self):
"""Return true if it is on."""
return self._state | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
45,
4
] | [
47,
26
] | python | en | ['en', 'fy', 'en'] | True |
XiaomiGatewayLight.parse_data | (self, data, raw_data) | Parse data sent by gateway. | Parse data sent by gateway. | def parse_data(self, data, raw_data):
"""Parse data sent by gateway."""
value = data.get(self._data_key)
if value is None:
return False
if value == 0:
if self._state:
self._state = False
return True
rgbhexstr = "%x" % value
... | [
"def",
"parse_data",
"(",
"self",
",",
"data",
",",
"raw_data",
")",
":",
"value",
"=",
"data",
".",
"get",
"(",
"self",
".",
"_data_key",
")",
"if",
"value",
"is",
"None",
":",
"return",
"False",
"if",
"value",
"==",
"0",
":",
"if",
"self",
".",
... | [
49,
4
] | [
78,
19
] | python | en | ['en', 'de', 'en'] | True |
XiaomiGatewayLight.brightness | (self) | Return the brightness of this light between 0..255. | Return the brightness of this light between 0..255. | def brightness(self):
"""Return the brightness of this light between 0..255."""
return int(255 * self._brightness / 100) | [
"def",
"brightness",
"(",
"self",
")",
":",
"return",
"int",
"(",
"255",
"*",
"self",
".",
"_brightness",
"/",
"100",
")"
] | [
81,
4
] | [
83,
48
] | python | en | ['en', 'en', 'en'] | True |
XiaomiGatewayLight.hs_color | (self) | Return the hs color value. | Return the hs color value. | def hs_color(self):
"""Return the hs color value."""
return self._hs | [
"def",
"hs_color",
"(",
"self",
")",
":",
"return",
"self",
".",
"_hs"
] | [
86,
4
] | [
88,
23
] | python | en | ['en', 'en', 'en'] | True |
XiaomiGatewayLight.supported_features | (self) | Return the supported features. | Return the supported features. | def supported_features(self):
"""Return the supported features."""
return SUPPORT_BRIGHTNESS | SUPPORT_COLOR | [
"def",
"supported_features",
"(",
"self",
")",
":",
"return",
"SUPPORT_BRIGHTNESS",
"|",
"SUPPORT_COLOR"
] | [
91,
4
] | [
93,
49
] | python | en | ['en', 'en', 'en'] | True |
XiaomiGatewayLight.turn_on | (self, **kwargs) | Turn the light on. | Turn the light on. | def turn_on(self, **kwargs):
"""Turn the light on."""
if ATTR_HS_COLOR in kwargs:
self._hs = kwargs[ATTR_HS_COLOR]
if ATTR_BRIGHTNESS in kwargs:
self._brightness = int(100 * kwargs[ATTR_BRIGHTNESS] / 255)
rgb = color_util.color_hs_to_RGB(*self._hs)
rgba ... | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"ATTR_HS_COLOR",
"in",
"kwargs",
":",
"self",
".",
"_hs",
"=",
"kwargs",
"[",
"ATTR_HS_COLOR",
"]",
"if",
"ATTR_BRIGHTNESS",
"in",
"kwargs",
":",
"self",
".",
"_brightness",
"=",
"... | [
95,
4
] | [
110,
43
] | python | en | ['en', 'et', 'en'] | True |
XiaomiGatewayLight.turn_off | (self, **kwargs) | Turn the light off. | Turn the light off. | def turn_off(self, **kwargs):
"""Turn the light off."""
if self._write_to_hub(self._sid, **{self._data_key: 0}):
self._state = False
self.schedule_update_ha_state() | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"_write_to_hub",
"(",
"self",
".",
"_sid",
",",
"*",
"*",
"{",
"self",
".",
"_data_key",
":",
"0",
"}",
")",
":",
"self",
".",
"_state",
"=",
"False",
"self",
... | [
112,
4
] | [
116,
43
] | python | en | ['en', 'zh', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up the Rachio binary sensors. | Set up the Rachio binary sensors. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up the Rachio binary sensors."""
entities = await hass.async_add_executor_job(_create_entities, hass, config_entry)
async_add_entities(entities)
_LOGGER.info("%d Rachio binary sensor(s) added", len(entities)) | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"entities",
"=",
"await",
"hass",
".",
"async_add_executor_job",
"(",
"_create_entities",
",",
"hass",
",",
"config_entry",
")",
"async_add_entities",
"(",
... | [
34,
0
] | [
38,
67
] | python | en | ['en', 'mi', 'en'] | True |
RachioControllerBinarySensor.__init__ | (self, controller) | Set up a new Rachio controller binary sensor. | Set up a new Rachio controller binary sensor. | def __init__(self, controller):
"""Set up a new Rachio controller binary sensor."""
super().__init__(controller)
self._state = None | [
"def",
"__init__",
"(",
"self",
",",
"controller",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"controller",
")",
"self",
".",
"_state",
"=",
"None"
] | [
52,
4
] | [
55,
26
] | python | en | ['en', 'gl', 'en'] | True |
RachioControllerBinarySensor.is_on | (self) | Return whether the sensor has a 'true' value. | Return whether the sensor has a 'true' value. | def is_on(self) -> bool:
"""Return whether the sensor has a 'true' value."""
return self._state | [
"def",
"is_on",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"_state"
] | [
58,
4
] | [
60,
26
] | python | en | ['en', 'pt', 'en'] | True |
RachioControllerBinarySensor._async_handle_any_update | (self, *args, **kwargs) | Determine whether an update event applies to this device. | Determine whether an update event applies to this device. | def _async_handle_any_update(self, *args, **kwargs) -> None:
"""Determine whether an update event applies to this device."""
if args[0][KEY_DEVICE_ID] != self._controller.controller_id:
# For another device
return
# For this device
self._async_handle_update(args,... | [
"def",
"_async_handle_any_update",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"->",
"None",
":",
"if",
"args",
"[",
"0",
"]",
"[",
"KEY_DEVICE_ID",
"]",
"!=",
"self",
".",
"_controller",
".",
"controller_id",
":",
"# For another device",
... | [
63,
4
] | [
70,
47
] | python | en | ['en', 'en', 'en'] | True |
RachioControllerBinarySensor._async_handle_update | (self, *args, **kwargs) | Handle an update to the state of this sensor. | Handle an update to the state of this sensor. | def _async_handle_update(self, *args, **kwargs) -> None:
"""Handle an update to the state of this sensor.""" | [
"def",
"_async_handle_update",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"->",
"None",
":"
] | [
73,
4
] | [
74,
59
] | python | en | ['en', 'en', 'en'] | True |
RachioControllerOnlineBinarySensor.name | (self) | Return the name of this sensor including the controller name. | Return the name of this sensor including the controller name. | def name(self) -> str:
"""Return the name of this sensor including the controller name."""
return self._controller.name | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_controller",
".",
"name"
] | [
81,
4
] | [
83,
36
] | python | en | ['en', 'en', 'en'] | True |
RachioControllerOnlineBinarySensor.unique_id | (self) | Return a unique id for this entity. | Return a unique id for this entity. | def unique_id(self) -> str:
"""Return a unique id for this entity."""
return f"{self._controller.controller_id}-online" | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"str",
":",
"return",
"f\"{self._controller.controller_id}-online\""
] | [
86,
4
] | [
88,
57
] | python | en | ['en', 'en', 'en'] | True |
RachioControllerOnlineBinarySensor.device_class | (self) | Return the class of this device, from component DEVICE_CLASSES. | Return the class of this device, from component DEVICE_CLASSES. | def device_class(self) -> str:
"""Return the class of this device, from component DEVICE_CLASSES."""
return DEVICE_CLASS_CONNECTIVITY | [
"def",
"device_class",
"(",
"self",
")",
"->",
"str",
":",
"return",
"DEVICE_CLASS_CONNECTIVITY"
] | [
91,
4
] | [
93,
40
] | python | en | ['en', 'en', 'en'] | True |
RachioControllerOnlineBinarySensor.icon | (self) | Return the name of an icon for this sensor. | Return the name of an icon for this sensor. | def icon(self) -> str:
"""Return the name of an icon for this sensor."""
return "mdi:wifi-strength-4" if self.is_on else "mdi:wifi-strength-off-outline" | [
"def",
"icon",
"(",
"self",
")",
"->",
"str",
":",
"return",
"\"mdi:wifi-strength-4\"",
"if",
"self",
".",
"is_on",
"else",
"\"mdi:wifi-strength-off-outline\""
] | [
96,
4
] | [
98,
87
] | python | en | ['en', 'en', 'en'] | True |
RachioControllerOnlineBinarySensor._async_handle_update | (self, *args, **kwargs) | Handle an update to the state of this sensor. | Handle an update to the state of this sensor. | def _async_handle_update(self, *args, **kwargs) -> None:
"""Handle an update to the state of this sensor."""
if (
args[0][0][KEY_SUBTYPE] == SUBTYPE_ONLINE
or args[0][0][KEY_SUBTYPE] == SUBTYPE_COLD_REBOOT
):
self._state = True
elif args[0][0][KEY_SUBT... | [
"def",
"_async_handle_update",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"->",
"None",
":",
"if",
"(",
"args",
"[",
"0",
"]",
"[",
"0",
"]",
"[",
"KEY_SUBTYPE",
"]",
"==",
"SUBTYPE_ONLINE",
"or",
"args",
"[",
"0",
"]",
"[",
"0"... | [
101,
4
] | [
111,
35
] | python | en | ['en', 'en', 'en'] | True |
RachioControllerOnlineBinarySensor.async_added_to_hass | (self) | Subscribe to updates. | Subscribe to updates. | async def async_added_to_hass(self):
"""Subscribe to updates."""
self._state = self._controller.init_data[KEY_STATUS] == STATUS_ONLINE
self.async_on_remove(
async_dispatcher_connect(
self.hass,
SIGNAL_RACHIO_CONTROLLER_UPDATE,
self._as... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"_state",
"=",
"self",
".",
"_controller",
".",
"init_data",
"[",
"KEY_STATUS",
"]",
"==",
"STATUS_ONLINE",
"self",
".",
"async_on_remove",
"(",
"async_dispatcher_connect",
"(",
"self",
... | [
113,
4
] | [
123,
9
] | python | en | ['en', 'en', 'en'] | True |
RachioRainSensor.name | (self) | Return the name of this sensor including the controller name. | Return the name of this sensor including the controller name. | def name(self) -> str:
"""Return the name of this sensor including the controller name."""
return f"{self._controller.name} rain sensor" | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"return",
"f\"{self._controller.name} rain sensor\""
] | [
130,
4
] | [
132,
53
] | python | en | ['en', 'en', 'en'] | True |
RachioRainSensor.unique_id | (self) | Return a unique id for this entity. | Return a unique id for this entity. | def unique_id(self) -> str:
"""Return a unique id for this entity."""
return f"{self._controller.controller_id}-rain_sensor" | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"str",
":",
"return",
"f\"{self._controller.controller_id}-rain_sensor\""
] | [
135,
4
] | [
137,
62
] | python | en | ['en', 'en', 'en'] | True |
RachioRainSensor.device_class | (self) | Return the class of this device. | Return the class of this device. | def device_class(self) -> str:
"""Return the class of this device."""
return DEVICE_CLASS_MOISTURE | [
"def",
"device_class",
"(",
"self",
")",
"->",
"str",
":",
"return",
"DEVICE_CLASS_MOISTURE"
] | [
140,
4
] | [
142,
36
] | python | en | ['en', 'en', 'en'] | True |
RachioRainSensor.icon | (self) | Return the icon for this sensor. | Return the icon for this sensor. | def icon(self) -> str:
"""Return the icon for this sensor."""
return "mdi:water" if self.is_on else "mdi:water-off" | [
"def",
"icon",
"(",
"self",
")",
"->",
"str",
":",
"return",
"\"mdi:water\"",
"if",
"self",
".",
"is_on",
"else",
"\"mdi:water-off\""
] | [
145,
4
] | [
147,
61
] | python | en | ['en', 'en', 'en'] | True |
RachioRainSensor._async_handle_update | (self, *args, **kwargs) | Handle an update to the state of this sensor. | Handle an update to the state of this sensor. | def _async_handle_update(self, *args, **kwargs) -> None:
"""Handle an update to the state of this sensor."""
if args[0][0][KEY_SUBTYPE] == SUBTYPE_RAIN_SENSOR_DETECTION_ON:
self._state = True
elif args[0][0][KEY_SUBTYPE] == SUBTYPE_RAIN_SENSOR_DETECTION_OFF:
self._state =... | [
"def",
"_async_handle_update",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"->",
"None",
":",
"if",
"args",
"[",
"0",
"]",
"[",
"0",
"]",
"[",
"KEY_SUBTYPE",
"]",
"==",
"SUBTYPE_RAIN_SENSOR_DETECTION_ON",
":",
"self",
".",
"_state",
"=... | [
150,
4
] | [
157,
35
] | python | en | ['en', 'en', 'en'] | True |
RachioRainSensor.async_added_to_hass | (self) | Subscribe to updates. | Subscribe to updates. | async def async_added_to_hass(self):
"""Subscribe to updates."""
self._state = self._controller.init_data[KEY_RAIN_SENSOR_TRIPPED]
self.async_on_remove(
async_dispatcher_connect(
self.hass,
SIGNAL_RACHIO_RAIN_SENSOR_UPDATE,
self._async... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"_state",
"=",
"self",
".",
"_controller",
".",
"init_data",
"[",
"KEY_RAIN_SENSOR_TRIPPED",
"]",
"self",
".",
"async_on_remove",
"(",
"async_dispatcher_connect",
"(",
"self",
".",
"hass"... | [
159,
4
] | [
169,
9
] | python | en | ['en', 'en', 'en'] | True |
test_pr3000rt2u | (hass) | Test creation of PR3000RT2U sensors. | Test creation of PR3000RT2U sensors. | async def test_pr3000rt2u(hass):
"""Test creation of PR3000RT2U sensors."""
await async_init_integration(hass, "PR3000RT2U", ["battery.charge"])
registry = await hass.helpers.entity_registry.async_get_registry()
entry = registry.async_get("sensor.ups1_battery_charge")
assert entry
assert entry.... | [
"async",
"def",
"test_pr3000rt2u",
"(",
"hass",
")",
":",
"await",
"async_init_integration",
"(",
"hass",
",",
"\"PR3000RT2U\"",
",",
"[",
"\"battery.charge\"",
"]",
")",
"registry",
"=",
"await",
"hass",
".",
"helpers",
".",
"entity_registry",
".",
"async_get_r... | [
7,
0
] | [
29,
5
] | python | en | ['en', 'et', 'en'] | True |
test_cp1350c | (hass) | Test creation of CP1350C sensors. | Test creation of CP1350C sensors. | async def test_cp1350c(hass):
"""Test creation of CP1350C sensors."""
config_entry = await async_init_integration(hass, "CP1350C", ["battery.charge"])
registry = await hass.helpers.entity_registry.async_get_registry()
entry = registry.async_get("sensor.ups1_battery_charge")
assert entry
assert... | [
"async",
"def",
"test_cp1350c",
"(",
"hass",
")",
":",
"config_entry",
"=",
"await",
"async_init_integration",
"(",
"hass",
",",
"\"CP1350C\"",
",",
"[",
"\"battery.charge\"",
"]",
")",
"registry",
"=",
"await",
"hass",
".",
"helpers",
".",
"entity_registry",
... | [
32,
0
] | [
55,
5
] | python | en | ['en', 'en', 'en'] | True |
test_5e850i | (hass) | Test creation of 5E850I sensors. | Test creation of 5E850I sensors. | async def test_5e850i(hass):
"""Test creation of 5E850I sensors."""
config_entry = await async_init_integration(hass, "5E850I", ["battery.charge"])
registry = await hass.helpers.entity_registry.async_get_registry()
entry = registry.async_get("sensor.ups1_battery_charge")
assert entry
assert ent... | [
"async",
"def",
"test_5e850i",
"(",
"hass",
")",
":",
"config_entry",
"=",
"await",
"async_init_integration",
"(",
"hass",
",",
"\"5E850I\"",
",",
"[",
"\"battery.charge\"",
"]",
")",
"registry",
"=",
"await",
"hass",
".",
"helpers",
".",
"entity_registry",
".... | [
58,
0
] | [
80,
5
] | python | en | ['en', 'sm', 'en'] | True |
test_5e650i | (hass) | Test creation of 5E650I sensors. | Test creation of 5E650I sensors. | async def test_5e650i(hass):
"""Test creation of 5E650I sensors."""
config_entry = await async_init_integration(hass, "5E650I", ["battery.charge"])
registry = await hass.helpers.entity_registry.async_get_registry()
entry = registry.async_get("sensor.ups1_battery_charge")
assert entry
assert ent... | [
"async",
"def",
"test_5e650i",
"(",
"hass",
")",
":",
"config_entry",
"=",
"await",
"async_init_integration",
"(",
"hass",
",",
"\"5E650I\"",
",",
"[",
"\"battery.charge\"",
"]",
")",
"registry",
"=",
"await",
"hass",
".",
"helpers",
".",
"entity_registry",
".... | [
83,
0
] | [
105,
5
] | python | en | ['en', 'sm', 'en'] | True |
test_backupsses600m1 | (hass) | Test creation of BACKUPSES600M1 sensors. | Test creation of BACKUPSES600M1 sensors. | async def test_backupsses600m1(hass):
"""Test creation of BACKUPSES600M1 sensors."""
await async_init_integration(hass, "BACKUPSES600M1", ["battery.charge"])
registry = await hass.helpers.entity_registry.async_get_registry()
entry = registry.async_get("sensor.ups1_battery_charge")
assert entry
... | [
"async",
"def",
"test_backupsses600m1",
"(",
"hass",
")",
":",
"await",
"async_init_integration",
"(",
"hass",
",",
"\"BACKUPSES600M1\"",
",",
"[",
"\"battery.charge\"",
"]",
")",
"registry",
"=",
"await",
"hass",
".",
"helpers",
".",
"entity_registry",
".",
"as... | [
108,
0
] | [
133,
5
] | python | en | ['en', 'da', 'en'] | True |
test_cp1500pfclcd | (hass) | Test creation of CP1500PFCLCD sensors. | Test creation of CP1500PFCLCD sensors. | async def test_cp1500pfclcd(hass):
"""Test creation of CP1500PFCLCD sensors."""
config_entry = await async_init_integration(
hass, "CP1500PFCLCD", ["battery.charge"]
)
registry = await hass.helpers.entity_registry.async_get_registry()
entry = registry.async_get("sensor.ups1_battery_charge")... | [
"async",
"def",
"test_cp1500pfclcd",
"(",
"hass",
")",
":",
"config_entry",
"=",
"await",
"async_init_integration",
"(",
"hass",
",",
"\"CP1500PFCLCD\"",
",",
"[",
"\"battery.charge\"",
"]",
")",
"registry",
"=",
"await",
"hass",
".",
"helpers",
".",
"entity_reg... | [
136,
0
] | [
160,
5
] | python | en | ['en', 'en', 'en'] | True |
test_dl650elcd | (hass) | Test creation of DL650ELCD sensors. | Test creation of DL650ELCD sensors. | async def test_dl650elcd(hass):
"""Test creation of DL650ELCD sensors."""
config_entry = await async_init_integration(hass, "DL650ELCD", ["battery.charge"])
registry = await hass.helpers.entity_registry.async_get_registry()
entry = registry.async_get("sensor.ups1_battery_charge")
assert entry
a... | [
"async",
"def",
"test_dl650elcd",
"(",
"hass",
")",
":",
"config_entry",
"=",
"await",
"async_init_integration",
"(",
"hass",
",",
"\"DL650ELCD\"",
",",
"[",
"\"battery.charge\"",
"]",
")",
"registry",
"=",
"await",
"hass",
".",
"helpers",
".",
"entity_registry"... | [
163,
0
] | [
185,
5
] | python | en | ['en', 'da', 'en'] | True |
test_blazer_usb | (hass) | Test creation of blazer_usb sensors. | Test creation of blazer_usb sensors. | async def test_blazer_usb(hass):
"""Test creation of blazer_usb sensors."""
config_entry = await async_init_integration(hass, "blazer_usb", ["battery.charge"])
registry = await hass.helpers.entity_registry.async_get_registry()
entry = registry.async_get("sensor.ups1_battery_charge")
assert entry
... | [
"async",
"def",
"test_blazer_usb",
"(",
"hass",
")",
":",
"config_entry",
"=",
"await",
"async_init_integration",
"(",
"hass",
",",
"\"blazer_usb\"",
",",
"[",
"\"battery.charge\"",
"]",
")",
"registry",
"=",
"await",
"hass",
".",
"helpers",
".",
"entity_registr... | [
188,
0
] | [
210,
5
] | python | en | ['en', 'ko', 'en'] | True |
async_setup | (hass, config) | Set up the Roon platform. | Set up the Roon platform. | async def async_setup(hass, config):
"""Set up the Roon platform."""
hass.data[DOMAIN] = {}
return True | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"=",
"{",
"}",
"return",
"True"
] | [
8,
0
] | [
11,
15
] | python | en | ['en', 'da', 'en'] | True |
async_setup_entry | (hass, entry) | Set up a roonserver from a config entry. | Set up a roonserver from a config entry. | async def async_setup_entry(hass, entry):
"""Set up a roonserver from a config entry."""
host = entry.data[CONF_HOST]
roonserver = RoonServer(hass, entry)
if not await roonserver.async_setup():
return False
hass.data[DOMAIN][entry.entry_id] = roonserver
device_registry = await dr.async... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"entry",
")",
":",
"host",
"=",
"entry",
".",
"data",
"[",
"CONF_HOST",
"]",
"roonserver",
"=",
"RoonServer",
"(",
"hass",
",",
"entry",
")",
"if",
"not",
"await",
"roonserver",
".",
"async_setup",
"... | [
14,
0
] | [
30,
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."""
roonserver = hass.data[DOMAIN].pop(entry.entry_id)
return await roonserver.async_reset() | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
",",
"entry",
")",
":",
"roonserver",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
".",
"pop",
"(",
"entry",
".",
"entry_id",
")",
"return",
"await",
"roonserver",
".",
"async_reset",
"(",
")"
] | [
33,
0
] | [
36,
41
] | python | en | ['en', 'es', 'en'] | True |
test_get_url_internal | (hass: HomeAssistant) | Test getting an instance URL when the user has set an internal URL. | Test getting an instance URL when the user has set an internal URL. | async def test_get_url_internal(hass: HomeAssistant):
"""Test getting an instance URL when the user has set an internal URL."""
assert hass.config.internal_url is None
with pytest.raises(NoURLAvailableError):
_get_internal_url(hass, require_current_request=True)
# Test with internal URL: http:... | [
"async",
"def",
"test_get_url_internal",
"(",
"hass",
":",
"HomeAssistant",
")",
":",
"assert",
"hass",
".",
"config",
".",
"internal_url",
"is",
"None",
"with",
"pytest",
".",
"raises",
"(",
"NoURLAvailableError",
")",
":",
"_get_internal_url",
"(",
"hass",
"... | [
20,
0
] | [
159,
83
] | python | en | ['en', 'lb', 'en'] | True |
test_get_url_internal_fallback | (hass: HomeAssistant) | Test getting an instance URL when the user has not set an internal URL. | Test getting an instance URL when the user has not set an internal URL. | async def test_get_url_internal_fallback(hass: HomeAssistant):
"""Test getting an instance URL when the user has not set an internal URL."""
assert hass.config.internal_url is None
hass.config.api = Mock(
use_ssl=False, port=8123, deprecated_base_url=None, local_ip="192.168.123.123"
)
asser... | [
"async",
"def",
"test_get_url_internal_fallback",
"(",
"hass",
":",
"HomeAssistant",
")",
":",
"assert",
"hass",
".",
"config",
".",
"internal_url",
"is",
"None",
"hass",
".",
"config",
".",
"api",
"=",
"Mock",
"(",
"use_ssl",
"=",
"False",
",",
"port",
"=... | [
162,
0
] | [
221,
49
] | python | en | ['en', 'lb', 'en'] | True |
test_get_url_external | (hass: HomeAssistant) | Test getting an instance URL when the user has set an external URL. | Test getting an instance URL when the user has set an external URL. | async def test_get_url_external(hass: HomeAssistant):
"""Test getting an instance URL when the user has set an external URL."""
assert hass.config.external_url is None
with pytest.raises(NoURLAvailableError):
_get_external_url(hass, require_current_request=True)
# Test with external URL: http:... | [
"async",
"def",
"test_get_url_external",
"(",
"hass",
":",
"HomeAssistant",
")",
":",
"assert",
"hass",
".",
"config",
".",
"external_url",
"is",
"None",
"with",
"pytest",
".",
"raises",
"(",
"NoURLAvailableError",
")",
":",
"_get_external_url",
"(",
"hass",
"... | [
224,
0
] | [
347,
83
] | python | en | ['en', 'lb', 'en'] | True |
test_get_cloud_url | (hass: HomeAssistant) | Test getting an instance URL when the user has set an external URL. | Test getting an instance URL when the user has set an external URL. | async def test_get_cloud_url(hass: HomeAssistant):
"""Test getting an instance URL when the user has set an external URL."""
assert hass.config.external_url is None
hass.config.components.add("cloud")
with patch.object(
hass.components.cloud,
"async_remote_ui_url",
return_value=... | [
"async",
"def",
"test_get_cloud_url",
"(",
"hass",
":",
"HomeAssistant",
")",
":",
"assert",
"hass",
".",
"config",
".",
"external_url",
"is",
"None",
"hass",
".",
"config",
".",
"components",
".",
"add",
"(",
"\"cloud\"",
")",
"with",
"patch",
".",
"objec... | [
350,
0
] | [
386,
32
] | python | en | ['en', 'lb', 'en'] | True |
test_get_external_url_cloud_fallback | (hass: HomeAssistant) | Test getting an external instance URL with cloud fallback. | Test getting an external instance URL with cloud fallback. | async def test_get_external_url_cloud_fallback(hass: HomeAssistant):
"""Test getting an external instance URL with cloud fallback."""
assert hass.config.external_url is None
# Test with external URL: http://1.1.1.1:8123
await async_process_ha_core_config(
hass,
{"external_url": "http://... | [
"async",
"def",
"test_get_external_url_cloud_fallback",
"(",
"hass",
":",
"HomeAssistant",
")",
":",
"assert",
"hass",
".",
"config",
".",
"external_url",
"is",
"None",
"# Test with external URL: http://1.1.1.1:8123",
"await",
"async_process_ha_core_config",
"(",
"hass",
... | [
389,
0
] | [
446,
9
] | python | en | ['en', 'en', 'en'] | True |
test_get_url | (hass: HomeAssistant) | Test getting an instance URL. | Test getting an instance URL. | async def test_get_url(hass: HomeAssistant):
"""Test getting an instance URL."""
assert hass.config.external_url is None
assert hass.config.internal_url is None
with pytest.raises(NoURLAvailableError):
get_url(hass)
hass.config.api = Mock(
use_ssl=False, port=8123, deprecated_base_... | [
"async",
"def",
"test_get_url",
"(",
"hass",
":",
"HomeAssistant",
")",
":",
"assert",
"hass",
".",
"config",
".",
"external_url",
"is",
"None",
"assert",
"hass",
".",
"config",
".",
"internal_url",
"is",
"None",
"with",
"pytest",
".",
"raises",
"(",
"NoUR... | [
449,
0
] | [
527,
61
] | python | en | ['en', 'lb', 'en'] | True |
test_get_request_host | (hass: HomeAssistant) | Test getting the host of the current web request from the request context. | Test getting the host of the current web request from the request context. | async def test_get_request_host(hass: HomeAssistant):
"""Test getting the host of the current web request from the request context."""
with pytest.raises(NoURLAvailableError):
_get_request_host()
with patch("homeassistant.helpers.network.current_request") as mock_request_context:
mock_reque... | [
"async",
"def",
"test_get_request_host",
"(",
"hass",
":",
"HomeAssistant",
")",
":",
"with",
"pytest",
".",
"raises",
"(",
"NoURLAvailableError",
")",
":",
"_get_request_host",
"(",
")",
"with",
"patch",
"(",
"\"homeassistant.helpers.network.current_request\"",
")",
... | [
530,
0
] | [
540,
51
] | python | en | ['en', 'en', 'en'] | True |
test_get_deprecated_base_url_internal | (hass: HomeAssistant) | Test getting an internal instance URL from the deprecated base_url. | Test getting an internal instance URL from the deprecated base_url. | async def test_get_deprecated_base_url_internal(hass: HomeAssistant):
"""Test getting an internal instance URL from the deprecated base_url."""
# Test with SSL local URL
hass.config.api = Mock(deprecated_base_url="https://example.local")
assert _get_deprecated_base_url(hass, internal=True) == "https://e... | [
"async",
"def",
"test_get_deprecated_base_url_internal",
"(",
"hass",
":",
"HomeAssistant",
")",
":",
"# Test with SSL local URL",
"hass",
".",
"config",
".",
"api",
"=",
"Mock",
"(",
"deprecated_base_url",
"=",
"\"https://example.local\"",
")",
"assert",
"_get_deprecat... | [
543,
0
] | [
612,
81
] | python | en | ['en', 'en', 'en'] | True |
test_get_deprecated_base_url_external | (hass: HomeAssistant) | Test getting an external instance URL from the deprecated base_url. | Test getting an external instance URL from the deprecated base_url. | async def test_get_deprecated_base_url_external(hass: HomeAssistant):
"""Test getting an external instance URL from the deprecated base_url."""
# Test with SSL and external domain on standard port
hass.config.api = Mock(deprecated_base_url="https://example.com:443/")
assert _get_deprecated_base_url(hass... | [
"async",
"def",
"test_get_deprecated_base_url_external",
"(",
"hass",
":",
"HomeAssistant",
")",
":",
"# Test with SSL and external domain on standard port",
"hass",
".",
"config",
".",
"api",
"=",
"Mock",
"(",
"deprecated_base_url",
"=",
"\"https://example.com:443/\"",
")"... | [
615,
0
] | [
687,
66
] | python | en | ['en', 'en', 'en'] | True |
test_get_internal_url_with_base_url_fallback | (hass: HomeAssistant) | Test getting an internal instance URL with the deprecated base_url fallback. | Test getting an internal instance URL with the deprecated base_url fallback. | async def test_get_internal_url_with_base_url_fallback(hass: HomeAssistant):
"""Test getting an internal instance URL with the deprecated base_url fallback."""
hass.config.api = Mock(
use_ssl=False, port=8123, deprecated_base_url=None, local_ip="192.168.123.123"
)
assert hass.config.internal_url... | [
"async",
"def",
"test_get_internal_url_with_base_url_fallback",
"(",
"hass",
":",
"HomeAssistant",
")",
":",
"hass",
".",
"config",
".",
"api",
"=",
"Mock",
"(",
"use_ssl",
"=",
"False",
",",
"port",
"=",
"8123",
",",
"deprecated_base_url",
"=",
"None",
",",
... | [
690,
0
] | [
752,
79
] | python | en | ['en', 'en', 'en'] | True |
test_get_external_url_with_base_url_fallback | (hass: HomeAssistant) | Test getting an external instance URL with the deprecated base_url fallback. | Test getting an external instance URL with the deprecated base_url fallback. | async def test_get_external_url_with_base_url_fallback(hass: HomeAssistant):
"""Test getting an external instance URL with the deprecated base_url fallback."""
hass.config.api = Mock(use_ssl=False, port=8123, deprecated_base_url=None)
assert hass.config.internal_url is None
with pytest.raises(NoURLAvai... | [
"async",
"def",
"test_get_external_url_with_base_url_fallback",
"(",
"hass",
":",
"HomeAssistant",
")",
":",
"hass",
".",
"config",
".",
"api",
"=",
"Mock",
"(",
"use_ssl",
"=",
"False",
",",
"port",
"=",
"8123",
",",
"deprecated_base_url",
"=",
"None",
")",
... | [
755,
0
] | [
801,
77
] | python | en | ['en', 'en', 'en'] | True |
test_get_current_request_url_with_known_host | (
hass: HomeAssistant, current_request
) | Test getting current request URL with known hosts addresses. | Test getting current request URL with known hosts addresses. | async def test_get_current_request_url_with_known_host(
hass: HomeAssistant, current_request
):
"""Test getting current request URL with known hosts addresses."""
hass.config.api = Mock(
use_ssl=False, port=8123, local_ip="127.0.0.1", deprecated_base_url=None
)
assert hass.config.internal_ur... | [
"async",
"def",
"test_get_current_request_url_with_known_host",
"(",
"hass",
":",
"HomeAssistant",
",",
"current_request",
")",
":",
"hass",
".",
"config",
".",
"api",
"=",
"Mock",
"(",
"use_ssl",
"=",
"False",
",",
"port",
"=",
"8123",
",",
"local_ip",
"=",
... | [
804,
0
] | [
861,
51
] | python | en | ['en', 'en', 'en'] | True |
calculate_next_active_alarms | (alarms) |
Calculate garmin next active alarms from settings.
Alarms are sorted by time
|
Calculate garmin next active alarms from settings. | def calculate_next_active_alarms(alarms):
"""
Calculate garmin next active alarms from settings.
Alarms are sorted by time
"""
active_alarms = []
_LOGGER.debug(alarms)
for alarm_setting in alarms:
if alarm_setting["alarmMode"] != "ON":
continue
for day in alarm_... | [
"def",
"calculate_next_active_alarms",
"(",
"alarms",
")",
":",
"active_alarms",
"=",
"[",
"]",
"_LOGGER",
".",
"debug",
"(",
"alarms",
")",
"for",
"alarm_setting",
"in",
"alarms",
":",
"if",
"alarm_setting",
"[",
"\"alarmMode\"",
"]",
"!=",
"\"ON\"",
":",
"... | [
20,
0
] | [
49,
59
] | python | en | ['en', 'error', 'th'] | False |
_include_yaml | (
constructor: ExtSafeConstructor, node: ruamel.yaml.nodes.Node
) | Load another YAML file and embeds it using the !include tag.
Example:
device_tracker: !include device_tracker.yaml
| Load another YAML file and embeds it using the !include tag. | def _include_yaml(
constructor: ExtSafeConstructor, node: ruamel.yaml.nodes.Node
) -> JSON_TYPE:
"""Load another YAML file and embeds it using the !include tag.
Example:
device_tracker: !include device_tracker.yaml
"""
if constructor.name is None:
raise HomeAssistantError(
... | [
"def",
"_include_yaml",
"(",
"constructor",
":",
"ExtSafeConstructor",
",",
"node",
":",
"ruamel",
".",
"yaml",
".",
"nodes",
".",
"Node",
")",
"->",
"JSON_TYPE",
":",
"if",
"constructor",
".",
"name",
"is",
"None",
":",
"raise",
"HomeAssistantError",
"(",
... | [
35,
0
] | [
49,
34
] | python | en | ['en', 'en', 'en'] | True |
object_to_yaml | (data: JSON_TYPE) | Create yaml string from object. | Create yaml string from object. | def object_to_yaml(data: JSON_TYPE) -> str:
"""Create yaml string from object."""
yaml = YAML(typ="rt")
yaml.indent(sequence=4, offset=2)
stream = StringIO()
try:
yaml.dump(data, stream)
result: str = stream.getvalue()
return result
except YAMLError as exc:
_LOGGE... | [
"def",
"object_to_yaml",
"(",
"data",
":",
"JSON_TYPE",
")",
"->",
"str",
":",
"yaml",
"=",
"YAML",
"(",
"typ",
"=",
"\"rt\"",
")",
"yaml",
".",
"indent",
"(",
"sequence",
"=",
"4",
",",
"offset",
"=",
"2",
")",
"stream",
"=",
"StringIO",
"(",
")",... | [
61,
0
] | [
72,
46
] | 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.