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_user_policy | () | Test user policy works. | Test user policy works. | def test_user_policy():
"""Test user policy works."""
# Make sure it's valid
POLICY_SCHEMA(system_policies.USER_POLICY)
perms = PolicyPermissions(system_policies.USER_POLICY, None)
assert perms.check_entity("light.kitchen", "read")
assert perms.check_entity("light.kitchen", "control")
asser... | [
"def",
"test_user_policy",
"(",
")",
":",
"# Make sure it's valid",
"POLICY_SCHEMA",
"(",
"system_policies",
".",
"USER_POLICY",
")",
"perms",
"=",
"PolicyPermissions",
"(",
"system_policies",
".",
"USER_POLICY",
",",
"None",
")",
"assert",
"perms",
".",
"check_enti... | [
19,
0
] | [
27,
54
] | python | en | ['en', 'en', 'en'] | True |
test_read_only_policy | () | Test read only policy works. | Test read only policy works. | def test_read_only_policy():
"""Test read only policy works."""
# Make sure it's valid
POLICY_SCHEMA(system_policies.READ_ONLY_POLICY)
perms = PolicyPermissions(system_policies.READ_ONLY_POLICY, None)
assert perms.check_entity("light.kitchen", "read")
assert not perms.check_entity("light.kitche... | [
"def",
"test_read_only_policy",
"(",
")",
":",
"# Make sure it's valid",
"POLICY_SCHEMA",
"(",
"system_policies",
".",
"READ_ONLY_POLICY",
")",
"perms",
"=",
"PolicyPermissions",
"(",
"system_policies",
".",
"READ_ONLY_POLICY",
",",
"None",
")",
"assert",
"perms",
"."... | [
30,
0
] | [
38,
58
] | python | en | ['en', 'en', 'en'] | True |
nzbget_api | (hass) | Mock NZBGetApi for easier testing. | Mock NZBGetApi for easier testing. | def nzbget_api(hass):
"""Mock NZBGetApi for easier testing."""
with patch("homeassistant.components.nzbget.coordinator.NZBGetAPI") as mock_api:
instance = mock_api.return_value
instance.history = MagicMock(return_value=list(MOCK_HISTORY))
instance.pausedownload = MagicMock(return_value=... | [
"def",
"nzbget_api",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.nzbget.coordinator.NZBGetAPI\"",
")",
"as",
"mock_api",
":",
"instance",
"=",
"mock_api",
".",
"return_value",
"instance",
".",
"history",
"=",
"MagicMock",
"(",
"return_va... | [
9,
0
] | [
20,
22
] | python | en | ['en', 'no', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up switches for a Wireless Sensor Tags. | Set up switches for a Wireless Sensor Tags. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up switches for a Wireless Sensor Tags."""
platform = hass.data.get(WIRELESSTAG_DOMAIN)
switches = []
tags = platform.load_tags()
for switch_type in config.get(CONF_MONITORED_CONDITIONS):
for tag in tags.values():
... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"platform",
"=",
"hass",
".",
"data",
".",
"get",
"(",
"WIRELESSTAG_DOMAIN",
")",
"switches",
"=",
"[",
"]",
"tags",
"=",
"platform",
... | [
33,
0
] | [
44,
32
] | python | en | ['en', 'en', 'en'] | True |
WirelessTagSwitch.__init__ | (self, api, tag, switch_type) | Initialize a switch for Wireless Sensor Tag. | Initialize a switch for Wireless Sensor Tag. | def __init__(self, api, tag, switch_type):
"""Initialize a switch for Wireless Sensor Tag."""
super().__init__(api, tag)
self._switch_type = switch_type
self.sensor_type = SWITCH_TYPES[self._switch_type][1]
self._name = f"{self._tag.name} {SWITCH_TYPES[self._switch_type][0]}" | [
"def",
"__init__",
"(",
"self",
",",
"api",
",",
"tag",
",",
"switch_type",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"api",
",",
"tag",
")",
"self",
".",
"_switch_type",
"=",
"switch_type",
"self",
".",
"sensor_type",
"=",
"SWITCH_TYPES",
"["... | [
50,
4
] | [
55,
77
] | python | en | ['en', 'en', 'en'] | True |
WirelessTagSwitch.turn_on | (self, **kwargs) | Turn on the switch. | Turn on the switch. | def turn_on(self, **kwargs):
"""Turn on the switch."""
self._api.arm(self) | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_api",
".",
"arm",
"(",
"self",
")"
] | [
57,
4
] | [
59,
27
] | python | en | ['en', 'en', 'en'] | True |
WirelessTagSwitch.turn_off | (self, **kwargs) | Turn on the switch. | Turn on the switch. | def turn_off(self, **kwargs):
"""Turn on the switch."""
self._api.disarm(self) | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_api",
".",
"disarm",
"(",
"self",
")"
] | [
61,
4
] | [
63,
30
] | python | en | ['en', 'en', 'en'] | True |
WirelessTagSwitch.is_on | (self) | Return True if entity is on. | Return True if entity is on. | def is_on(self) -> bool:
"""Return True if entity is on."""
return self._state | [
"def",
"is_on",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"_state"
] | [
66,
4
] | [
68,
26
] | python | en | ['en', 'cy', 'en'] | True |
WirelessTagSwitch.updated_state_value | (self) | Provide formatted value. | Provide formatted value. | def updated_state_value(self):
"""Provide formatted value."""
return self.principal_value | [
"def",
"updated_state_value",
"(",
"self",
")",
":",
"return",
"self",
".",
"principal_value"
] | [
70,
4
] | [
72,
35
] | python | en | ['fr', 'en', 'en'] | True |
WirelessTagSwitch.principal_value | (self) | Provide actual value of switch. | Provide actual value of switch. | def principal_value(self):
"""Provide actual value of switch."""
attr_name = f"is_{self.sensor_type}_sensor_armed"
return getattr(self._tag, attr_name, False) | [
"def",
"principal_value",
"(",
"self",
")",
":",
"attr_name",
"=",
"f\"is_{self.sensor_type}_sensor_armed\"",
"return",
"getattr",
"(",
"self",
".",
"_tag",
",",
"attr_name",
",",
"False",
")"
] | [
75,
4
] | [
78,
51
] | python | en | ['en', 'en', 'en'] | True |
test_platform_manually_configured | (hass) | Test that we do not discover anything or try to set up a gateway. | Test that we do not discover anything or try to set up a gateway. | async def test_platform_manually_configured(hass):
"""Test that we do not discover anything or try to set up a gateway."""
assert (
await async_setup_component(
hass, BINARY_SENSOR_DOMAIN, {"binary_sensor": {"platform": DECONZ_DOMAIN}}
)
is True
)
assert DECONZ_DOMAIN... | [
"async",
"def",
"test_platform_manually_configured",
"(",
"hass",
")",
":",
"assert",
"(",
"await",
"async_setup_component",
"(",
"hass",
",",
"BINARY_SENSOR_DOMAIN",
",",
"{",
"\"binary_sensor\"",
":",
"{",
"\"platform\"",
":",
"DECONZ_DOMAIN",
"}",
"}",
")",
"is... | [
62,
0
] | [
70,
41
] | python | en | ['en', 'en', 'en'] | True |
test_no_binary_sensors | (hass) | Test that no sensors in deconz results in no sensor entities. | Test that no sensors in deconz results in no sensor entities. | async def test_no_binary_sensors(hass):
"""Test that no sensors in deconz results in no sensor entities."""
await setup_deconz_integration(hass)
assert len(hass.states.async_all()) == 0 | [
"async",
"def",
"test_no_binary_sensors",
"(",
"hass",
")",
":",
"await",
"setup_deconz_integration",
"(",
"hass",
")",
"assert",
"len",
"(",
"hass",
".",
"states",
".",
"async_all",
"(",
")",
")",
"==",
"0"
] | [
73,
0
] | [
76,
44
] | python | en | ['en', 'en', 'en'] | True |
test_binary_sensors | (hass) | Test successful creation of binary sensor entities. | Test successful creation of binary sensor entities. | async def test_binary_sensors(hass):
"""Test successful creation of binary sensor entities."""
data = deepcopy(DECONZ_WEB_REQUEST)
data["sensors"] = deepcopy(SENSORS)
config_entry = await setup_deconz_integration(hass, get_state_response=data)
gateway = get_gateway_from_config_entry(hass, config_ent... | [
"async",
"def",
"test_binary_sensors",
"(",
"hass",
")",
":",
"data",
"=",
"deepcopy",
"(",
"DECONZ_WEB_REQUEST",
")",
"data",
"[",
"\"sensors\"",
"]",
"=",
"deepcopy",
"(",
"SENSORS",
")",
"config_entry",
"=",
"await",
"setup_deconz_integration",
"(",
"hass",
... | [
79,
0
] | [
110,
44
] | python | en | ['en', 'en', 'en'] | True |
test_allow_clip_sensor | (hass) | Test that CLIP sensors can be allowed. | Test that CLIP sensors can be allowed. | async def test_allow_clip_sensor(hass):
"""Test that CLIP sensors can be allowed."""
data = deepcopy(DECONZ_WEB_REQUEST)
data["sensors"] = deepcopy(SENSORS)
config_entry = await setup_deconz_integration(
hass,
options={CONF_ALLOW_CLIP_SENSOR: True},
get_state_response=data,
)... | [
"async",
"def",
"test_allow_clip_sensor",
"(",
"hass",
")",
":",
"data",
"=",
"deepcopy",
"(",
"DECONZ_WEB_REQUEST",
")",
"data",
"[",
"\"sensors\"",
"]",
"=",
"deepcopy",
"(",
"SENSORS",
")",
"config_entry",
"=",
"await",
"setup_deconz_integration",
"(",
"hass"... | [
113,
0
] | [
147,
83
] | python | en | ['en', 'en', 'en'] | True |
test_add_new_binary_sensor | (hass) | Test that adding a new binary sensor works. | Test that adding a new binary sensor works. | async def test_add_new_binary_sensor(hass):
"""Test that adding a new binary sensor works."""
config_entry = await setup_deconz_integration(hass)
gateway = get_gateway_from_config_entry(hass, config_entry)
assert len(hass.states.async_all()) == 0
state_added_event = {
"t": "event",
... | [
"async",
"def",
"test_add_new_binary_sensor",
"(",
"hass",
")",
":",
"config_entry",
"=",
"await",
"setup_deconz_integration",
"(",
"hass",
")",
"gateway",
"=",
"get_gateway_from_config_entry",
"(",
"hass",
",",
"config_entry",
")",
"assert",
"len",
"(",
"hass",
"... | [
150,
0
] | [
167,
78
] | python | en | ['en', 'en', 'en'] | True |
test_add_new_binary_sensor_ignored | (hass) | Test that adding a new binary sensor is not allowed. | Test that adding a new binary sensor is not allowed. | async def test_add_new_binary_sensor_ignored(hass):
"""Test that adding a new binary sensor is not allowed."""
config_entry = await setup_deconz_integration(
hass,
options={CONF_ALLOW_NEW_DEVICES: False},
)
gateway = get_gateway_from_config_entry(hass, config_entry)
assert len(hass.s... | [
"async",
"def",
"test_add_new_binary_sensor_ignored",
"(",
"hass",
")",
":",
"config_entry",
"=",
"await",
"setup_deconz_integration",
"(",
"hass",
",",
"options",
"=",
"{",
"CONF_ALLOW_NEW_DEVICES",
":",
"False",
"}",
",",
")",
"gateway",
"=",
"get_gateway_from_con... | [
170,
0
] | [
194,
5
] | python | en | ['en', 'en', 'en'] | True |
validate_device_has_at_least_one_identifier | (value: ConfigType) | Validate that a device info entry has at least one identifying value. | Validate that a device info entry has at least one identifying value. | def validate_device_has_at_least_one_identifier(value: ConfigType) -> ConfigType:
"""Validate that a device info entry has at least one identifying value."""
if not value.get(CONF_IDENTIFIERS) and not value.get(CONF_CONNECTIONS):
raise vol.Invalid(
"Device must have at least one identifying ... | [
"def",
"validate_device_has_at_least_one_identifier",
"(",
"value",
":",
"ConfigType",
")",
"->",
"ConfigType",
":",
"if",
"not",
"value",
".",
"get",
"(",
"CONF_IDENTIFIERS",
")",
"and",
"not",
"value",
".",
"get",
"(",
"CONF_CONNECTIONS",
")",
":",
"raise",
... | [
153,
0
] | [
160,
16
] | python | en | ['en', 'en', 'en'] | True |
embedded_broker_deprecated | (value) | Warn user that embedded MQTT broker is deprecated. | Warn user that embedded MQTT broker is deprecated. | def embedded_broker_deprecated(value):
"""Warn user that embedded MQTT broker is deprecated."""
_LOGGER.warning(
"The embedded MQTT broker has been deprecated and will stop working"
"after June 5th, 2019. Use an external broker instead. For"
"instructions, see https://www.home-assistant.... | [
"def",
"embedded_broker_deprecated",
"(",
"value",
")",
":",
"_LOGGER",
".",
"warning",
"(",
"\"The embedded MQTT broker has been deprecated and will stop working\"",
"\"after June 5th, 2019. Use an external broker instead. For\"",
"\"instructions, see https://www.home-assistant.io/docs/mqtt... | [
179,
0
] | [
186,
16
] | python | en | ['en', 'fy', 'en'] | True |
_build_publish_data | (topic: Any, qos: int, retain: bool) | Build the arguments for the publish service without the payload. | Build the arguments for the publish service without the payload. | def _build_publish_data(topic: Any, qos: int, retain: bool) -> ServiceDataType:
"""Build the arguments for the publish service without the payload."""
data = {ATTR_TOPIC: topic}
if qos is not None:
data[ATTR_QOS] = qos
if retain is not None:
data[ATTR_RETAIN] = retain
return data | [
"def",
"_build_publish_data",
"(",
"topic",
":",
"Any",
",",
"qos",
":",
"int",
",",
"retain",
":",
"bool",
")",
"->",
"ServiceDataType",
":",
"data",
"=",
"{",
"ATTR_TOPIC",
":",
"topic",
"}",
"if",
"qos",
"is",
"not",
"None",
":",
"data",
"[",
"ATT... | [
337,
0
] | [
344,
15
] | python | en | ['en', 'en', 'en'] | True |
publish | (hass: HomeAssistantType, topic, payload, qos=None, retain=None) | Publish message to an MQTT topic. | Publish message to an MQTT topic. | def publish(hass: HomeAssistantType, topic, payload, qos=None, retain=None) -> None:
"""Publish message to an MQTT topic."""
hass.add_job(async_publish, hass, topic, payload, qos, retain) | [
"def",
"publish",
"(",
"hass",
":",
"HomeAssistantType",
",",
"topic",
",",
"payload",
",",
"qos",
"=",
"None",
",",
"retain",
"=",
"None",
")",
"->",
"None",
":",
"hass",
".",
"add_job",
"(",
"async_publish",
",",
"hass",
",",
"topic",
",",
"payload",... | [
348,
0
] | [
350,
66
] | python | en | ['en', 'en', 'en'] | True |
async_publish | (
hass: HomeAssistantType, topic: Any, payload, qos=None, retain=None
) | Publish message to an MQTT topic. | Publish message to an MQTT topic. | def async_publish(
hass: HomeAssistantType, topic: Any, payload, qos=None, retain=None
) -> None:
"""Publish message to an MQTT topic."""
data = _build_publish_data(topic, qos, retain)
data[ATTR_PAYLOAD] = payload
hass.async_create_task(hass.services.async_call(DOMAIN, SERVICE_PUBLISH, data)) | [
"def",
"async_publish",
"(",
"hass",
":",
"HomeAssistantType",
",",
"topic",
":",
"Any",
",",
"payload",
",",
"qos",
"=",
"None",
",",
"retain",
"=",
"None",
")",
"->",
"None",
":",
"data",
"=",
"_build_publish_data",
"(",
"topic",
",",
"qos",
",",
"re... | [
355,
0
] | [
361,
83
] | python | en | ['en', 'en', 'en'] | True |
publish_template | (
hass: HomeAssistantType, topic, payload_template, qos=None, retain=None
) | Publish message to an MQTT topic. | Publish message to an MQTT topic. | def publish_template(
hass: HomeAssistantType, topic, payload_template, qos=None, retain=None
) -> None:
"""Publish message to an MQTT topic."""
hass.add_job(async_publish_template, hass, topic, payload_template, qos, retain) | [
"def",
"publish_template",
"(",
"hass",
":",
"HomeAssistantType",
",",
"topic",
",",
"payload_template",
",",
"qos",
"=",
"None",
",",
"retain",
"=",
"None",
")",
"->",
"None",
":",
"hass",
".",
"add_job",
"(",
"async_publish_template",
",",
"hass",
",",
"... | [
365,
0
] | [
369,
84
] | python | en | ['en', 'en', 'en'] | True |
async_publish_template | (
hass: HomeAssistantType, topic, payload_template, qos=None, retain=None
) | Publish message to an MQTT topic using a template payload. | Publish message to an MQTT topic using a template payload. | def async_publish_template(
hass: HomeAssistantType, topic, payload_template, qos=None, retain=None
) -> None:
"""Publish message to an MQTT topic using a template payload."""
data = _build_publish_data(topic, qos, retain)
data[ATTR_PAYLOAD_TEMPLATE] = payload_template
hass.async_create_task(hass.se... | [
"def",
"async_publish_template",
"(",
"hass",
":",
"HomeAssistantType",
",",
"topic",
",",
"payload_template",
",",
"qos",
"=",
"None",
",",
"retain",
"=",
"None",
")",
"->",
"None",
":",
"data",
"=",
"_build_publish_data",
"(",
"topic",
",",
"qos",
",",
"... | [
373,
0
] | [
379,
83
] | python | en | ['en', 'en', 'en'] | True |
wrap_msg_callback | (msg_callback: MessageCallbackType) | Wrap an MQTT message callback to support deprecated signature. | Wrap an MQTT message callback to support deprecated signature. | def wrap_msg_callback(msg_callback: MessageCallbackType) -> MessageCallbackType:
"""Wrap an MQTT message callback to support deprecated signature."""
# Check for partials to properly determine if coroutine function
check_func = msg_callback
while isinstance(check_func, partial):
check_func = che... | [
"def",
"wrap_msg_callback",
"(",
"msg_callback",
":",
"MessageCallbackType",
")",
"->",
"MessageCallbackType",
":",
"# Check for partials to properly determine if coroutine function",
"check_func",
"=",
"msg_callback",
"while",
"isinstance",
"(",
"check_func",
",",
"partial",
... | [
382,
0
] | [
406,
23
] | python | en | ['en', 'en', 'en'] | True |
async_subscribe | (
hass: HomeAssistantType,
topic: str,
msg_callback: MessageCallbackType,
qos: int = DEFAULT_QOS,
encoding: Optional[str] = "utf-8",
) | Subscribe to an MQTT topic.
Call the return value to unsubscribe.
| Subscribe to an MQTT topic. | async def async_subscribe(
hass: HomeAssistantType,
topic: str,
msg_callback: MessageCallbackType,
qos: int = DEFAULT_QOS,
encoding: Optional[str] = "utf-8",
):
"""Subscribe to an MQTT topic.
Call the return value to unsubscribe.
"""
# Count callback parameters which don't have a de... | [
"async",
"def",
"async_subscribe",
"(",
"hass",
":",
"HomeAssistantType",
",",
"topic",
":",
"str",
",",
"msg_callback",
":",
"MessageCallbackType",
",",
"qos",
":",
"int",
"=",
"DEFAULT_QOS",
",",
"encoding",
":",
"Optional",
"[",
"str",
"]",
"=",
"\"utf-8\... | [
410,
0
] | [
451,
23
] | python | en | ['en', 'en', 'en'] | True |
subscribe | (
hass: HomeAssistantType,
topic: str,
msg_callback: MessageCallbackType,
qos: int = DEFAULT_QOS,
encoding: str = "utf-8",
) | Subscribe to an MQTT topic. | Subscribe to an MQTT topic. | def subscribe(
hass: HomeAssistantType,
topic: str,
msg_callback: MessageCallbackType,
qos: int = DEFAULT_QOS,
encoding: str = "utf-8",
) -> Callable[[], None]:
"""Subscribe to an MQTT topic."""
async_remove = asyncio.run_coroutine_threadsafe(
async_subscribe(hass, topic, msg_callbac... | [
"def",
"subscribe",
"(",
"hass",
":",
"HomeAssistantType",
",",
"topic",
":",
"str",
",",
"msg_callback",
":",
"MessageCallbackType",
",",
"qos",
":",
"int",
"=",
"DEFAULT_QOS",
",",
"encoding",
":",
"str",
"=",
"\"utf-8\"",
",",
")",
"->",
"Callable",
"["... | [
455,
0
] | [
471,
17
] | python | en | ['en', 'en', 'en'] | True |
_async_setup_discovery | (
hass: HomeAssistantType, conf: ConfigType, config_entry
) | Try to start the discovery of MQTT devices.
This method is a coroutine.
| Try to start the discovery of MQTT devices. | async def _async_setup_discovery(
hass: HomeAssistantType, conf: ConfigType, config_entry
) -> bool:
"""Try to start the discovery of MQTT devices.
This method is a coroutine.
"""
success: bool = await discovery.async_start(
hass, conf[CONF_DISCOVERY_PREFIX], config_entry
)
return ... | [
"async",
"def",
"_async_setup_discovery",
"(",
"hass",
":",
"HomeAssistantType",
",",
"conf",
":",
"ConfigType",
",",
"config_entry",
")",
"->",
"bool",
":",
"success",
":",
"bool",
"=",
"await",
"discovery",
".",
"async_start",
"(",
"hass",
",",
"conf",
"["... | [
474,
0
] | [
485,
18
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass: HomeAssistantType, config: ConfigType) | Start the MQTT protocol service. | Start the MQTT protocol service. | async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool:
"""Start the MQTT protocol service."""
conf: Optional[ConfigType] = config.get(DOMAIN)
websocket_api.async_register_command(hass, websocket_subscribe)
websocket_api.async_register_command(hass, websocket_remove_device)
webs... | [
"async",
"def",
"async_setup",
"(",
"hass",
":",
"HomeAssistantType",
",",
"config",
":",
"ConfigType",
")",
"->",
"bool",
":",
"conf",
":",
"Optional",
"[",
"ConfigType",
"]",
"=",
"config",
".",
"get",
"(",
"DOMAIN",
")",
"websocket_api",
".",
"async_reg... | [
488,
0
] | [
513,
15
] | python | en | ['en', 'it', 'en'] | True |
_merge_config | (entry, conf) | Merge configuration.yaml config with config entry. | Merge configuration.yaml config with config entry. | def _merge_config(entry, conf):
"""Merge configuration.yaml config with config entry."""
return {**conf, **entry.data} | [
"def",
"_merge_config",
"(",
"entry",
",",
"conf",
")",
":",
"return",
"{",
"*",
"*",
"conf",
",",
"*",
"*",
"entry",
".",
"data",
"}"
] | [
516,
0
] | [
518,
33
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, entry) | Load a config entry. | Load a config entry. | async def async_setup_entry(hass, entry):
"""Load a config entry."""
conf = hass.data.get(DATA_MQTT_CONFIG)
# Config entry was created because user had configuration.yaml entry
# They removed that, so remove entry.
if conf is None and entry.source == config_entries.SOURCE_IMPORT:
hass.async... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"entry",
")",
":",
"conf",
"=",
"hass",
".",
"data",
".",
"get",
"(",
"DATA_MQTT_CONFIG",
")",
"# Config entry was created because user had configuration.yaml entry",
"# They removed that, so remove entry.",
"if",
"co... | [
521,
0
] | [
626,
15
] | python | en | ['en', 'en', 'en'] | True |
_raise_on_error | (result_code: int) | Raise error if error result. | Raise error if error result. | def _raise_on_error(result_code: int) -> None:
"""Raise error if error result."""
# pylint: disable=import-outside-toplevel
import paho.mqtt.client as mqtt
if result_code != 0:
raise HomeAssistantError(
f"Error talking to MQTT: {mqtt.error_string(result_code)}"
) | [
"def",
"_raise_on_error",
"(",
"result_code",
":",
"int",
")",
"->",
"None",
":",
"# pylint: disable=import-outside-toplevel",
"import",
"paho",
".",
"mqtt",
".",
"client",
"as",
"mqtt",
"if",
"result_code",
"!=",
"0",
":",
"raise",
"HomeAssistantError",
"(",
"f... | [
1057,
0
] | [
1065,
9
] | python | da | ['da', 'la', 'en'] | False |
cleanup_device_registry | (hass, device_id) | Remove device registry entry if there are no remaining entities or triggers. | Remove device registry entry if there are no remaining entities or triggers. | async def cleanup_device_registry(hass, device_id):
"""Remove device registry entry if there are no remaining entities or triggers."""
# Local import to avoid circular dependencies
# pylint: disable=import-outside-toplevel
from . import device_trigger, tag
device_registry = await hass.helpers.devic... | [
"async",
"def",
"cleanup_device_registry",
"(",
"hass",
",",
"device_id",
")",
":",
"# Local import to avoid circular dependencies",
"# pylint: disable=import-outside-toplevel",
"from",
".",
"import",
"device_trigger",
",",
"tag",
"device_registry",
"=",
"await",
"hass",
".... | [
1239,
0
] | [
1255,
54
] | python | en | ['en', 'en', 'en'] | True |
device_info_from_config | (config) | Return a device description for device registry. | Return a device description for device registry. | def device_info_from_config(config):
"""Return a device description for device registry."""
if not config:
return None
info = {
"identifiers": {(DOMAIN, id_) for id_ in config[CONF_IDENTIFIERS]},
"connections": {tuple(x) for x in config[CONF_CONNECTIONS]},
}
if CONF_MANUFAC... | [
"def",
"device_info_from_config",
"(",
"config",
")",
":",
"if",
"not",
"config",
":",
"return",
"None",
"info",
"=",
"{",
"\"identifiers\"",
":",
"{",
"(",
"DOMAIN",
",",
"id_",
")",
"for",
"id_",
"in",
"config",
"[",
"CONF_IDENTIFIERS",
"]",
"}",
",",
... | [
1354,
0
] | [
1379,
15
] | python | en | ['ro', 'fr', 'en'] | False |
websocket_mqtt_info | (hass, connection, msg) | Get MQTT debug info for device. | Get MQTT debug info for device. | async def websocket_mqtt_info(hass, connection, msg):
"""Get MQTT debug info for device."""
device_id = msg["device_id"]
mqtt_info = await debug_info.info_for_device(hass, device_id)
connection.send_result(msg["id"], mqtt_info) | [
"async",
"def",
"websocket_mqtt_info",
"(",
"hass",
",",
"connection",
",",
"msg",
")",
":",
"device_id",
"=",
"msg",
"[",
"\"device_id\"",
"]",
"mqtt_info",
"=",
"await",
"debug_info",
".",
"info_for_device",
"(",
"hass",
",",
"device_id",
")",
"connection",
... | [
1411,
0
] | [
1416,
48
] | python | en | ['da', 'en', 'en'] | True |
websocket_remove_device | (hass, connection, msg) | Delete device. | Delete device. | async def websocket_remove_device(hass, connection, msg):
"""Delete device."""
device_id = msg["device_id"]
dev_registry = await hass.helpers.device_registry.async_get_registry()
device = dev_registry.async_get(device_id)
if not device:
connection.send_error(
msg["id"], websocke... | [
"async",
"def",
"websocket_remove_device",
"(",
"hass",
",",
"connection",
",",
"msg",
")",
":",
"device_id",
"=",
"msg",
"[",
"\"device_id\"",
"]",
"dev_registry",
"=",
"await",
"hass",
".",
"helpers",
".",
"device_registry",
".",
"async_get_registry",
"(",
"... | [
1423,
0
] | [
1445,
5
] | python | it | ['it', 'it', 'en'] | False |
websocket_subscribe | (hass, connection, msg) | Subscribe to a MQTT topic. | Subscribe to a MQTT topic. | async def websocket_subscribe(hass, connection, msg):
"""Subscribe to a MQTT topic."""
if not connection.user.is_admin:
raise Unauthorized
async def forward_messages(mqttmsg: Message):
"""Forward events to websocket."""
connection.send_message(
websocket_api.event_messag... | [
"async",
"def",
"websocket_subscribe",
"(",
"hass",
",",
"connection",
",",
"msg",
")",
":",
"if",
"not",
"connection",
".",
"user",
".",
"is_admin",
":",
"raise",
"Unauthorized",
"async",
"def",
"forward_messages",
"(",
"mqttmsg",
":",
"Message",
")",
":",
... | [
1455,
0
] | [
1478,
68
] | python | en | ['en', 'en', 'en'] | True |
async_subscribe_connection_status | (hass, connection_status_callback) | Subscribe to MQTT connection changes. | Subscribe to MQTT connection changes. | def async_subscribe_connection_status(hass, connection_status_callback):
"""Subscribe to MQTT connection changes."""
connection_status_callback_job = HassJob(connection_status_callback)
@callback
def connected():
hass.async_add_hass_job(connection_status_callback_job, True)
@callback
... | [
"def",
"async_subscribe_connection_status",
"(",
"hass",
",",
"connection_status_callback",
")",
":",
"connection_status_callback_job",
"=",
"HassJob",
"(",
"connection_status_callback",
")",
"@",
"callback",
"def",
"connected",
"(",
")",
":",
"hass",
".",
"async_add_ha... | [
1482,
0
] | [
1505,
22
] | python | en | ['en', 'en', 'en'] | True |
is_connected | (hass) | Return if MQTT client is connected. | Return if MQTT client is connected. | def is_connected(hass):
"""Return if MQTT client is connected."""
return hass.data[DATA_MQTT].connected | [
"def",
"is_connected",
"(",
"hass",
")",
":",
"return",
"hass",
".",
"data",
"[",
"DATA_MQTT",
"]",
".",
"connected"
] | [
1508,
0
] | [
1510,
41
] | python | en | ['en', 'en', 'en'] | True |
MQTT.__init__ | (
self,
hass: HomeAssistantType,
config_entry,
conf,
) | Initialize Home Assistant MQTT client. | Initialize Home Assistant MQTT client. | def __init__(
self,
hass: HomeAssistantType,
config_entry,
conf,
) -> None:
"""Initialize Home Assistant MQTT client."""
# We don't import on the top because some integrations
# should be able to optionally rely on MQTT.
import paho.mqtt.client as mqtt... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
":",
"HomeAssistantType",
",",
"config_entry",
",",
"conf",
",",
")",
"->",
"None",
":",
"# We don't import on the top because some integrations",
"# should be able to optionally rely on MQTT.",
"import",
"paho",
".",
"mqtt",
... | [
643,
4
] | [
677,
78
] | python | fr | ['fr', 'fr', 'en'] | True |
MQTT.async_config_entry_updated | (hass, entry) | Handle signals of config entry being updated.
This is a static method because a class method (bound method), can not be used with weak references.
Causes for this is config entry options changing.
| Handle signals of config entry being updated. | async def async_config_entry_updated(hass, entry) -> None:
"""Handle signals of config entry being updated.
This is a static method because a class method (bound method), can not be used with weak references.
Causes for this is config entry options changing.
"""
self = hass.data... | [
"async",
"def",
"async_config_entry_updated",
"(",
"hass",
",",
"entry",
")",
"->",
"None",
":",
"self",
"=",
"hass",
".",
"data",
"[",
"DATA_MQTT",
"]",
"conf",
"=",
"hass",
".",
"data",
".",
"get",
"(",
"DATA_MQTT_CONFIG",
")",
"if",
"conf",
"is",
"N... | [
680,
4
] | [
699,
64
] | python | en | ['en', 'en', 'en'] | True |
MQTT.init_client | (self) | Initialize paho client. | Initialize paho client. | def init_client(self):
"""Initialize paho client."""
# We don't import on the top because some integrations
# should be able to optionally rely on MQTT.
import paho.mqtt.client as mqtt # pylint: disable=import-outside-toplevel
if self.conf[CONF_PROTOCOL] == PROTOCOL_31:
... | [
"def",
"init_client",
"(",
"self",
")",
":",
"# We don't import on the top because some integrations",
"# should be able to optionally rely on MQTT.",
"import",
"paho",
".",
"mqtt",
".",
"client",
"as",
"mqtt",
"# pylint: disable=import-outside-toplevel",
"if",
"self",
".",
"... | [
701,
4
] | [
778,
13
] | python | en | ['en', 'fr', 'it'] | False |
MQTT.async_publish | (
self, topic: str, payload: PublishPayloadType, qos: int, retain: bool
) | Publish a MQTT message. | Publish a MQTT message. | async def async_publish(
self, topic: str, payload: PublishPayloadType, qos: int, retain: bool
) -> None:
"""Publish a MQTT message."""
async with self._paho_lock:
msg_info = await self.hass.async_add_executor_job(
self._mqttc.publish, topic, payload, qos, retain
... | [
"async",
"def",
"async_publish",
"(",
"self",
",",
"topic",
":",
"str",
",",
"payload",
":",
"PublishPayloadType",
",",
"qos",
":",
"int",
",",
"retain",
":",
"bool",
")",
"->",
"None",
":",
"async",
"with",
"self",
".",
"_paho_lock",
":",
"msg_info",
... | [
780,
4
] | [
795,
46
] | python | en | ['en', 'fr', 'en'] | True |
MQTT.async_connect | (self) | Connect to the host. Does not process messages yet. | Connect to the host. Does not process messages yet. | async def async_connect(self) -> str:
"""Connect to the host. Does not process messages yet."""
# pylint: disable=import-outside-toplevel
import paho.mqtt.client as mqtt
result: int = None
try:
result = await self.hass.async_add_executor_job(
self._mq... | [
"async",
"def",
"async_connect",
"(",
"self",
")",
"->",
"str",
":",
"# pylint: disable=import-outside-toplevel",
"import",
"paho",
".",
"mqtt",
".",
"client",
"as",
"mqtt",
"result",
":",
"int",
"=",
"None",
"try",
":",
"result",
"=",
"await",
"self",
".",
... | [
797,
4
] | [
818,
32
] | python | en | ['en', 'en', 'en'] | True |
MQTT.async_disconnect | (self) | Stop the MQTT client. | Stop the MQTT client. | async def async_disconnect(self):
"""Stop the MQTT client."""
def stop():
"""Stop the MQTT client."""
# Do not disconnect, we want the broker to always publish will
self._mqttc.loop_stop()
await self.hass.async_add_executor_job(stop) | [
"async",
"def",
"async_disconnect",
"(",
"self",
")",
":",
"def",
"stop",
"(",
")",
":",
"\"\"\"Stop the MQTT client.\"\"\"",
"# Do not disconnect, we want the broker to always publish will",
"self",
".",
"_mqttc",
".",
"loop_stop",
"(",
")",
"await",
"self",
".",
"ha... | [
820,
4
] | [
828,
52
] | python | en | ['en', 'fr', 'en'] | True |
MQTT.async_subscribe | (
self,
topic: str,
msg_callback: MessageCallbackType,
qos: int,
encoding: Optional[str] = None,
) | Set up a subscription to a topic with the provided qos.
This method is a coroutine.
| Set up a subscription to a topic with the provided qos. | async def async_subscribe(
self,
topic: str,
msg_callback: MessageCallbackType,
qos: int,
encoding: Optional[str] = None,
) -> Callable[[], None]:
"""Set up a subscription to a topic with the provided qos.
This method is a coroutine.
"""
if no... | [
"async",
"def",
"async_subscribe",
"(",
"self",
",",
"topic",
":",
"str",
",",
"msg_callback",
":",
"MessageCallbackType",
",",
"qos",
":",
"int",
",",
"encoding",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
")",
"->",
"Callable",
"[",
"[",
"]"... | [
830,
4
] | [
871,
27
] | python | en | ['en', 'en', 'en'] | True |
MQTT._async_unsubscribe | (self, topic: str) | Unsubscribe from a topic.
This method is a coroutine.
| Unsubscribe from a topic. | async def _async_unsubscribe(self, topic: str) -> None:
"""Unsubscribe from a topic.
This method is a coroutine.
"""
async with self._paho_lock:
result: int = None
result, mid = await self.hass.async_add_executor_job(
self._mqttc.unsubscribe, topi... | [
"async",
"def",
"_async_unsubscribe",
"(",
"self",
",",
"topic",
":",
"str",
")",
"->",
"None",
":",
"async",
"with",
"self",
".",
"_paho_lock",
":",
"result",
":",
"int",
"=",
"None",
"result",
",",
"mid",
"=",
"await",
"self",
".",
"hass",
".",
"as... | [
873,
4
] | [
885,
37
] | python | en | ['en', 'en', 'en'] | True |
MQTT._async_perform_subscription | (self, topic: str, qos: int) | Perform a paho-mqtt subscription. | Perform a paho-mqtt subscription. | async def _async_perform_subscription(self, topic: str, qos: int) -> None:
"""Perform a paho-mqtt subscription."""
async with self._paho_lock:
result: int = None
result, mid = await self.hass.async_add_executor_job(
self._mqttc.subscribe, topic, qos
)
... | [
"async",
"def",
"_async_perform_subscription",
"(",
"self",
",",
"topic",
":",
"str",
",",
"qos",
":",
"int",
")",
"->",
"None",
":",
"async",
"with",
"self",
".",
"_paho_lock",
":",
"result",
":",
"int",
"=",
"None",
"result",
",",
"mid",
"=",
"await"... | [
887,
4
] | [
896,
37
] | python | ca | ['hu', 'ca', 'pt'] | False |
MQTT._mqtt_on_connect | (self, _mqttc, _userdata, _flags, result_code: int) | On connect callback.
Resubscribe to all topics we were subscribed to and publish birth
message.
| On connect callback. | def _mqtt_on_connect(self, _mqttc, _userdata, _flags, result_code: int) -> None:
"""On connect callback.
Resubscribe to all topics we were subscribed to and publish birth
message.
"""
# pylint: disable=import-outside-toplevel
import paho.mqtt.client as mqtt
if r... | [
"def",
"_mqtt_on_connect",
"(",
"self",
",",
"_mqttc",
",",
"_userdata",
",",
"_flags",
",",
"result_code",
":",
"int",
")",
"->",
"None",
":",
"# pylint: disable=import-outside-toplevel",
"import",
"paho",
".",
"mqtt",
".",
"client",
"as",
"mqtt",
"if",
"resu... | [
898,
4
] | [
946,
76
] | python | en | ['en', 'en', 'en'] | True |
MQTT._mqtt_on_message | (self, _mqttc, _userdata, msg) | Message received callback. | Message received callback. | def _mqtt_on_message(self, _mqttc, _userdata, msg) -> None:
"""Message received callback."""
self.hass.add_job(self._mqtt_handle_message, msg) | [
"def",
"_mqtt_on_message",
"(",
"self",
",",
"_mqttc",
",",
"_userdata",
",",
"msg",
")",
"->",
"None",
":",
"self",
".",
"hass",
".",
"add_job",
"(",
"self",
".",
"_mqtt_handle_message",
",",
"msg",
")"
] | [
948,
4
] | [
950,
57
] | python | en | ['en', 'en', 'en'] | True |
MQTT._mqtt_on_callback | (self, _mqttc, _userdata, mid, _granted_qos=None) | Publish / Subscribe / Unsubscribe callback. | Publish / Subscribe / Unsubscribe callback. | def _mqtt_on_callback(self, _mqttc, _userdata, mid, _granted_qos=None) -> None:
"""Publish / Subscribe / Unsubscribe callback."""
self.hass.add_job(self._mqtt_handle_mid, mid) | [
"def",
"_mqtt_on_callback",
"(",
"self",
",",
"_mqttc",
",",
"_userdata",
",",
"mid",
",",
"_granted_qos",
"=",
"None",
")",
"->",
"None",
":",
"self",
".",
"hass",
".",
"add_job",
"(",
"self",
".",
"_mqtt_handle_mid",
",",
"mid",
")"
] | [
1000,
4
] | [
1002,
53
] | python | en | ['en', 'en', 'en'] | True |
MQTT._mqtt_on_disconnect | (self, _mqttc, _userdata, result_code: int) | Disconnected callback. | Disconnected callback. | def _mqtt_on_disconnect(self, _mqttc, _userdata, result_code: int) -> None:
"""Disconnected callback."""
self.connected = False
dispatcher_send(self.hass, MQTT_DISCONNECTED)
_LOGGER.warning(
"Disconnected from MQTT server %s:%s (%s)",
self.conf[CONF_BROKER],
... | [
"def",
"_mqtt_on_disconnect",
"(",
"self",
",",
"_mqttc",
",",
"_userdata",
",",
"result_code",
":",
"int",
")",
"->",
"None",
":",
"self",
".",
"connected",
"=",
"False",
"dispatcher_send",
"(",
"self",
".",
"hass",
",",
"MQTT_DISCONNECTED",
")",
"_LOGGER",... | [
1012,
4
] | [
1021,
9
] | python | en | ['en', 'en', 'en'] | False |
MQTT._wait_for_mid | (self, mid) | Wait for ACK from broker. | Wait for ACK from broker. | async def _wait_for_mid(self, mid):
"""Wait for ACK from broker."""
# Create the mid event if not created, either _mqtt_handle_mid or _wait_for_mid
# may be executed first.
if mid not in self._pending_operations:
self._pending_operations[mid] = asyncio.Event()
try:
... | [
"async",
"def",
"_wait_for_mid",
"(",
"self",
",",
"mid",
")",
":",
"# Create the mid event if not created, either _mqtt_handle_mid or _wait_for_mid",
"# may be executed first.",
"if",
"mid",
"not",
"in",
"self",
".",
"_pending_operations",
":",
"self",
".",
"_pending_opera... | [
1023,
4
] | [
1034,
45
] | python | en | ['en', 'no', 'en'] | True |
MqttAttributes.__init__ | (self, config: dict) | Initialize the JSON attributes mixin. | Initialize the JSON attributes mixin. | def __init__(self, config: dict) -> None:
"""Initialize the JSON attributes mixin."""
self._attributes = None
self._attributes_sub_state = None
self._attributes_config = config | [
"def",
"__init__",
"(",
"self",
",",
"config",
":",
"dict",
")",
"->",
"None",
":",
"self",
".",
"_attributes",
"=",
"None",
"self",
".",
"_attributes_sub_state",
"=",
"None",
"self",
".",
"_attributes_config",
"=",
"config"
] | [
1081,
4
] | [
1085,
40
] | python | en | ['en', 'en', 'en'] | True |
MqttAttributes.async_added_to_hass | (self) | Subscribe MQTT events. | Subscribe MQTT events. | async def async_added_to_hass(self) -> None:
"""Subscribe MQTT events."""
await super().async_added_to_hass()
await self._attributes_subscribe_topics() | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
"->",
"None",
":",
"await",
"super",
"(",
")",
".",
"async_added_to_hass",
"(",
")",
"await",
"self",
".",
"_attributes_subscribe_topics",
"(",
")"
] | [
1087,
4
] | [
1090,
49
] | python | en | ['en', 'en', 'en'] | True |
MqttAttributes.attributes_discovery_update | (self, config: dict) | Handle updated discovery message. | Handle updated discovery message. | async def attributes_discovery_update(self, config: dict):
"""Handle updated discovery message."""
self._attributes_config = config
await self._attributes_subscribe_topics() | [
"async",
"def",
"attributes_discovery_update",
"(",
"self",
",",
"config",
":",
"dict",
")",
":",
"self",
".",
"_attributes_config",
"=",
"config",
"await",
"self",
".",
"_attributes_subscribe_topics",
"(",
")"
] | [
1092,
4
] | [
1095,
49
] | python | en | ['en', 'en', 'en'] | True |
MqttAttributes._attributes_subscribe_topics | (self) | (Re)Subscribe to topics. | (Re)Subscribe to topics. | async def _attributes_subscribe_topics(self):
"""(Re)Subscribe to topics."""
attr_tpl = self._attributes_config.get(CONF_JSON_ATTRS_TEMPLATE)
if attr_tpl is not None:
attr_tpl.hass = self.hass
@callback
@log_messages(self.hass, self.entity_id)
def attributes_... | [
"async",
"def",
"_attributes_subscribe_topics",
"(",
"self",
")",
":",
"attr_tpl",
"=",
"self",
".",
"_attributes_config",
".",
"get",
"(",
"CONF_JSON_ATTRS_TEMPLATE",
")",
"if",
"attr_tpl",
"is",
"not",
"None",
":",
"attr_tpl",
".",
"hass",
"=",
"self",
".",
... | [
1097,
4
] | [
1131,
9
] | python | en | ['en', 'en', 'en'] | True |
MqttAttributes.async_will_remove_from_hass | (self) | Unsubscribe when removed. | Unsubscribe when removed. | async def async_will_remove_from_hass(self):
"""Unsubscribe when removed."""
self._attributes_sub_state = await async_unsubscribe_topics(
self.hass, self._attributes_sub_state
) | [
"async",
"def",
"async_will_remove_from_hass",
"(",
"self",
")",
":",
"self",
".",
"_attributes_sub_state",
"=",
"await",
"async_unsubscribe_topics",
"(",
"self",
".",
"hass",
",",
"self",
".",
"_attributes_sub_state",
")"
] | [
1133,
4
] | [
1137,
9
] | python | en | ['en', 'en', 'en'] | True |
MqttAttributes.device_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def device_state_attributes(self):
"""Return the state attributes."""
return self._attributes | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"self",
".",
"_attributes"
] | [
1140,
4
] | [
1142,
31
] | python | en | ['en', 'en', 'en'] | True |
MqttAvailability.__init__ | (self, config: dict) | Initialize the availability mixin. | Initialize the availability mixin. | def __init__(self, config: dict) -> None:
"""Initialize the availability mixin."""
self._availability_sub_state = None
self._available = False
self._availability_setup_from_config(config) | [
"def",
"__init__",
"(",
"self",
",",
"config",
":",
"dict",
")",
"->",
"None",
":",
"self",
".",
"_availability_sub_state",
"=",
"None",
"self",
".",
"_available",
"=",
"False",
"self",
".",
"_availability_setup_from_config",
"(",
"config",
")"
] | [
1148,
4
] | [
1152,
52
] | python | en | ['en', 'en', 'en'] | True |
MqttAvailability.async_added_to_hass | (self) | Subscribe MQTT events. | Subscribe MQTT events. | async def async_added_to_hass(self) -> None:
"""Subscribe MQTT events."""
await super().async_added_to_hass()
await self._availability_subscribe_topics()
self.async_on_remove(
async_dispatcher_connect(self.hass, MQTT_CONNECTED, self.async_mqtt_connect)
)
self.... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
"->",
"None",
":",
"await",
"super",
"(",
")",
".",
"async_added_to_hass",
"(",
")",
"await",
"self",
".",
"_availability_subscribe_topics",
"(",
")",
"self",
".",
"async_on_remove",
"(",
"async_dispatcher... | [
1154,
4
] | [
1165,
9
] | python | en | ['en', 'en', 'en'] | True |
MqttAvailability.availability_discovery_update | (self, config: dict) | Handle updated discovery message. | Handle updated discovery message. | async def availability_discovery_update(self, config: dict):
"""Handle updated discovery message."""
self._availability_setup_from_config(config)
await self._availability_subscribe_topics() | [
"async",
"def",
"availability_discovery_update",
"(",
"self",
",",
"config",
":",
"dict",
")",
":",
"self",
".",
"_availability_setup_from_config",
"(",
"config",
")",
"await",
"self",
".",
"_availability_subscribe_topics",
"(",
")"
] | [
1167,
4
] | [
1170,
51
] | python | en | ['en', 'en', 'en'] | True |
MqttAvailability._availability_subscribe_topics | (self) | (Re)Subscribe to topics. | (Re)Subscribe to topics. | async def _availability_subscribe_topics(self):
"""(Re)Subscribe to topics."""
@callback
@log_messages(self.hass, self.entity_id)
def availability_message_received(msg: Message) -> None:
"""Handle a new received MQTT availability message."""
topic = msg.topic
... | [
"async",
"def",
"_availability_subscribe_topics",
"(",
"self",
")",
":",
"@",
"callback",
"@",
"log_messages",
"(",
"self",
".",
"hass",
",",
"self",
".",
"entity_id",
")",
"def",
"availability_message_received",
"(",
"msg",
":",
"Message",
")",
"->",
"None",
... | [
1190,
4
] | [
1217,
9
] | python | en | ['en', 'en', 'en'] | True |
MqttAvailability.async_mqtt_connect | (self) | Update state on connection/disconnection to MQTT broker. | Update state on connection/disconnection to MQTT broker. | def async_mqtt_connect(self):
"""Update state on connection/disconnection to MQTT broker."""
if not self.hass.is_stopping:
self.async_write_ha_state() | [
"def",
"async_mqtt_connect",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"hass",
".",
"is_stopping",
":",
"self",
".",
"async_write_ha_state",
"(",
")"
] | [
1220,
4
] | [
1223,
39
] | python | en | ['en', 'en', 'en'] | True |
MqttAvailability.async_will_remove_from_hass | (self) | Unsubscribe when removed. | Unsubscribe when removed. | async def async_will_remove_from_hass(self):
"""Unsubscribe when removed."""
self._availability_sub_state = await async_unsubscribe_topics(
self.hass, self._availability_sub_state
) | [
"async",
"def",
"async_will_remove_from_hass",
"(",
"self",
")",
":",
"self",
".",
"_availability_sub_state",
"=",
"await",
"async_unsubscribe_topics",
"(",
"self",
".",
"hass",
",",
"self",
".",
"_availability_sub_state",
")"
] | [
1225,
4
] | [
1229,
9
] | python | en | ['en', 'en', 'en'] | True |
MqttAvailability.available | (self) | Return if the device is available. | Return if the device is available. | def available(self) -> bool:
"""Return if the device is available."""
if not self.hass.data[DATA_MQTT].connected and not self.hass.is_stopping:
return False
return not self._avail_topics or self._available | [
"def",
"available",
"(",
"self",
")",
"->",
"bool",
":",
"if",
"not",
"self",
".",
"hass",
".",
"data",
"[",
"DATA_MQTT",
"]",
".",
"connected",
"and",
"not",
"self",
".",
"hass",
".",
"is_stopping",
":",
"return",
"False",
"return",
"not",
"self",
"... | [
1232,
4
] | [
1236,
56
] | python | en | ['en', 'en', 'en'] | True |
MqttDiscoveryUpdate.__init__ | (self, discovery_data, discovery_update=None) | Initialize the discovery update mixin. | Initialize the discovery update mixin. | def __init__(self, discovery_data, discovery_update=None) -> None:
"""Initialize the discovery update mixin."""
self._discovery_data = discovery_data
self._discovery_update = discovery_update
self._remove_signal = None
self._removed_from_hass = False | [
"def",
"__init__",
"(",
"self",
",",
"discovery_data",
",",
"discovery_update",
"=",
"None",
")",
"->",
"None",
":",
"self",
".",
"_discovery_data",
"=",
"discovery_data",
"self",
".",
"_discovery_update",
"=",
"discovery_update",
"self",
".",
"_remove_signal",
... | [
1261,
4
] | [
1266,
39
] | python | en | ['en', 'en', 'en'] | True |
MqttDiscoveryUpdate.async_added_to_hass | (self) | Subscribe to discovery updates. | Subscribe to discovery updates. | async def async_added_to_hass(self) -> None:
"""Subscribe to discovery updates."""
await super().async_added_to_hass()
self._removed_from_hass = False
discovery_hash = (
self._discovery_data[ATTR_DISCOVERY_HASH] if self._discovery_data else None
)
async def _... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
"->",
"None",
":",
"await",
"super",
"(",
")",
".",
"async_added_to_hass",
"(",
")",
"self",
".",
"_removed_from_hass",
"=",
"False",
"discovery_hash",
"=",
"(",
"self",
".",
"_discovery_data",
"[",
"A... | [
1268,
4
] | [
1325,
13
] | python | en | ['en', 'en', 'en'] | True |
MqttDiscoveryUpdate.async_removed_from_registry | (self) | Clear retained discovery topic in broker. | Clear retained discovery topic in broker. | async def async_removed_from_registry(self) -> None:
"""Clear retained discovery topic in broker."""
if not self._removed_from_hass:
discovery_topic = self._discovery_data[ATTR_DISCOVERY_TOPIC]
publish(
self.hass,
discovery_topic,
"... | [
"async",
"def",
"async_removed_from_registry",
"(",
"self",
")",
"->",
"None",
":",
"if",
"not",
"self",
".",
"_removed_from_hass",
":",
"discovery_topic",
"=",
"self",
".",
"_discovery_data",
"[",
"ATTR_DISCOVERY_TOPIC",
"]",
"publish",
"(",
"self",
".",
"hass"... | [
1327,
4
] | [
1336,
13
] | python | en | ['en', 'en', 'en'] | True |
MqttDiscoveryUpdate.async_will_remove_from_hass | (self) | Stop listening to signal and cleanup discovery data.. | Stop listening to signal and cleanup discovery data.. | async def async_will_remove_from_hass(self) -> None:
"""Stop listening to signal and cleanup discovery data.."""
self._cleanup_discovery_on_remove() | [
"async",
"def",
"async_will_remove_from_hass",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"_cleanup_discovery_on_remove",
"(",
")"
] | [
1338,
4
] | [
1340,
43
] | python | en | ['en', 'en', 'en'] | True |
MqttDiscoveryUpdate._cleanup_discovery_on_remove | (self) | Stop listening to signal and cleanup discovery data. | Stop listening to signal and cleanup discovery data. | def _cleanup_discovery_on_remove(self) -> None:
"""Stop listening to signal and cleanup discovery data."""
if self._discovery_data and not self._removed_from_hass:
debug_info.remove_entity_data(self.hass, self.entity_id)
clear_discovery_hash(self.hass, self._discovery_data[ATTR_D... | [
"def",
"_cleanup_discovery_on_remove",
"(",
"self",
")",
"->",
"None",
":",
"if",
"self",
".",
"_discovery_data",
"and",
"not",
"self",
".",
"_removed_from_hass",
":",
"debug_info",
".",
"remove_entity_data",
"(",
"self",
".",
"hass",
",",
"self",
".",
"entity... | [
1342,
4
] | [
1351,
38
] | python | en | ['en', 'en', 'en'] | True |
MqttEntityDeviceInfo.__init__ | (self, device_config: Optional[ConfigType], config_entry=None) | Initialize the device mixin. | Initialize the device mixin. | def __init__(self, device_config: Optional[ConfigType], config_entry=None) -> None:
"""Initialize the device mixin."""
self._device_config = device_config
self._config_entry = config_entry | [
"def",
"__init__",
"(",
"self",
",",
"device_config",
":",
"Optional",
"[",
"ConfigType",
"]",
",",
"config_entry",
"=",
"None",
")",
"->",
"None",
":",
"self",
".",
"_device_config",
"=",
"device_config",
"self",
".",
"_config_entry",
"=",
"config_entry"
] | [
1385,
4
] | [
1388,
41
] | python | en | ['en', 'en', 'en'] | True |
MqttEntityDeviceInfo.device_info_discovery_update | (self, config: dict) | Handle updated discovery message. | Handle updated discovery message. | async def device_info_discovery_update(self, config: dict):
"""Handle updated discovery message."""
self._device_config = config.get(CONF_DEVICE)
device_registry = await self.hass.helpers.device_registry.async_get_registry()
config_entry_id = self._config_entry.entry_id
device_in... | [
"async",
"def",
"device_info_discovery_update",
"(",
"self",
",",
"config",
":",
"dict",
")",
":",
"self",
".",
"_device_config",
"=",
"config",
".",
"get",
"(",
"CONF_DEVICE",
")",
"device_registry",
"=",
"await",
"self",
".",
"hass",
".",
"helpers",
".",
... | [
1390,
4
] | [
1399,
62
] | python | en | ['en', 'en', 'en'] | True |
MqttEntityDeviceInfo.device_info | (self) | Return a device description for device registry. | Return a device description for device registry. | def device_info(self):
"""Return a device description for device registry."""
return device_info_from_config(self._device_config) | [
"def",
"device_info",
"(",
"self",
")",
":",
"return",
"device_info_from_config",
"(",
"self",
".",
"_device_config",
")"
] | [
1402,
4
] | [
1404,
59
] | python | en | ['ro', 'fr', 'en'] | False |
device_reg | (hass) | Return an empty, loaded, registry. | Return an empty, loaded, registry. | def device_reg(hass):
"""Return an empty, loaded, registry."""
return mock_device_registry(hass) | [
"def",
"device_reg",
"(",
"hass",
")",
":",
"return",
"mock_device_registry",
"(",
"hass",
")"
] | [
21,
0
] | [
23,
37
] | python | en | ['en', 'fy', 'en'] | True |
entity_reg | (hass) | Return an empty, loaded, registry. | Return an empty, loaded, registry. | def entity_reg(hass):
"""Return an empty, loaded, registry."""
return mock_registry(hass) | [
"def",
"entity_reg",
"(",
"hass",
")",
":",
"return",
"mock_registry",
"(",
"hass",
")"
] | [
27,
0
] | [
29,
30
] | python | en | ['en', 'fy', 'en'] | True |
calls | (hass) | Track calls to a mock service. | Track calls to a mock service. | def calls(hass):
"""Track calls to a mock service."""
return async_mock_service(hass, "test", "automation") | [
"def",
"calls",
"(",
"hass",
")",
":",
"return",
"async_mock_service",
"(",
"hass",
",",
"\"test\"",
",",
"\"automation\"",
")"
] | [
33,
0
] | [
35,
57
] | python | en | ['en', 'en', 'en'] | True |
test_get_triggers | (hass, device_reg, entity_reg) | Test we get the expected triggers from a climate device. | Test we get the expected triggers from a climate device. | async def test_get_triggers(hass, device_reg, entity_reg):
"""Test we get the expected triggers from a climate device."""
config_entry = MockConfigEntry(domain="test", data={})
config_entry.add_to_hass(hass)
device_entry = device_reg.async_get_or_create(
config_entry_id=config_entry.entry_id,
... | [
"async",
"def",
"test_get_triggers",
"(",
"hass",
",",
"device_reg",
",",
"entity_reg",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"\"test\"",
",",
"data",
"=",
"{",
"}",
")",
"config_entry",
".",
"add_to_hass",
"(",
"hass",
")",
... | [
38,
0
] | [
81,
50
] | python | en | ['en', 'en', 'en'] | True |
test_if_fires_on_state_change | (hass, calls) | Test for turn_on and turn_off triggers firing. | Test for turn_on and turn_off triggers firing. | async def test_if_fires_on_state_change(hass, calls):
"""Test for turn_on and turn_off triggers firing."""
hass.states.async_set(
"climate.entity",
const.HVAC_MODE_COOL,
{
const.ATTR_HVAC_ACTION: const.CURRENT_HVAC_IDLE,
const.ATTR_CURRENT_HUMIDITY: 23,
... | [
"async",
"def",
"test_if_fires_on_state_change",
"(",
"hass",
",",
"calls",
")",
":",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"climate.entity\"",
",",
"const",
".",
"HVAC_MODE_COOL",
",",
"{",
"const",
".",
"ATTR_HVAC_ACTION",
":",
"const",
".",
"CURRE... | [
84,
0
] | [
187,
62
] | python | en | ['en', 'en', 'en'] | True |
test_get_trigger_capabilities_hvac_mode | (hass) | Test we get the expected capabilities from a climate trigger. | Test we get the expected capabilities from a climate trigger. | async def test_get_trigger_capabilities_hvac_mode(hass):
"""Test we get the expected capabilities from a climate trigger."""
capabilities = await device_trigger.async_get_trigger_capabilities(
hass,
{
"platform": "device",
"domain": "climate",
"type": "hvac_mo... | [
"async",
"def",
"test_get_trigger_capabilities_hvac_mode",
"(",
"hass",
")",
":",
"capabilities",
"=",
"await",
"device_trigger",
".",
"async_get_trigger_capabilities",
"(",
"hass",
",",
"{",
"\"platform\"",
":",
"\"device\"",
",",
"\"domain\"",
":",
"\"climate\"",
",... | [
190,
0
] | [
206,
81
] | python | en | ['en', 'en', 'en'] | True |
test_get_trigger_capabilities_temp_humid | (hass, type) | Test we get the expected capabilities from a climate trigger. | Test we get the expected capabilities from a climate trigger. | async def test_get_trigger_capabilities_temp_humid(hass, type):
"""Test we get the expected capabilities from a climate trigger."""
capabilities = await device_trigger.async_get_trigger_capabilities(
hass,
{
"platform": "device",
"domain": "climate",
"type": "... | [
"async",
"def",
"test_get_trigger_capabilities_temp_humid",
"(",
"hass",
",",
"type",
")",
":",
"capabilities",
"=",
"await",
"device_trigger",
".",
"async_get_trigger_capabilities",
"(",
"hass",
",",
"{",
"\"platform\"",
":",
"\"device\"",
",",
"\"domain\"",
":",
"... | [
212,
0
] | [
243,
5
] | python | en | ['en', 'en', 'en'] | True |
MasterAgent.start | (self) | Start agents.
Returns:
None.
| Start agents. | def start(self) -> None:
"""Start agents.
Returns:
None.
"""
job_tracking_agent = JobTrackingAgent(
local_cluster_details=self._local_cluster_details,
local_master_details=self._local_master_details
)
job_tracking_agent.start()
... | [
"def",
"start",
"(",
"self",
")",
"->",
"None",
":",
"job_tracking_agent",
"=",
"JobTrackingAgent",
"(",
"local_cluster_details",
"=",
"self",
".",
"_local_cluster_details",
",",
"local_master_details",
"=",
"self",
".",
"_local_master_details",
")",
"job_tracking_age... | [
38,
4
] | [
68,
32
] | python | en | ['en', 'de', 'en'] | False |
JobTrackingAgent.run | (self) | Start updating name_to_job_details.
Returns:
None.
| Start updating name_to_job_details. | def run(self) -> None:
"""Start updating name_to_job_details.
Returns:
None.
"""
while True:
logger.debug("Start in JobTrackingAgent.")
start_time = time.time()
self.update_name_to_job_details()
time.sleep(max(self._check_inter... | [
"def",
"run",
"(",
"self",
")",
"->",
"None",
":",
"while",
"True",
":",
"logger",
".",
"debug",
"(",
"\"Start in JobTrackingAgent.\"",
")",
"start_time",
"=",
"time",
".",
"time",
"(",
")",
"self",
".",
"update_name_to_job_details",
"(",
")",
"time",
".",... | [
88,
4
] | [
99,
52
] | python | en | ['en', 'jv', 'en'] | True |
JobTrackingAgent.update_name_to_job_details | (self) | Update name_to_job_details with name_to_container_details.
Returns:
None.
| Update name_to_job_details with name_to_container_details. | def update_name_to_job_details(self) -> None:
"""Update name_to_job_details with name_to_container_details.
Returns:
None.
"""
# Get details and mapping.
name_to_container_details = self._redis_controller.get_name_to_container_details()
name_to_job_details = ... | [
"def",
"update_name_to_job_details",
"(",
"self",
")",
"->",
"None",
":",
"# Get details and mapping.",
"name_to_container_details",
"=",
"self",
".",
"_redis_controller",
".",
"get_name_to_container_details",
"(",
")",
"name_to_job_details",
"=",
"self",
".",
"_redis_con... | [
101,
4
] | [
141,
17
] | python | en | ['en', 'en', 'en'] | True |
JobTrackingAgent._get_job_id_to_job_name | (name_to_job_details: dict) | Get job_id_to_job_name mapping from name_to_job_details.
Args:
name_to_job_details (dict): job_name to job_details mapping.
Returns:
dict[int, str]: job_id to job_name mapping.
| Get job_id_to_job_name mapping from name_to_job_details. | def _get_job_id_to_job_name(name_to_job_details: dict) -> dict:
"""Get job_id_to_job_name mapping from name_to_job_details.
Args:
name_to_job_details (dict): job_name to job_details mapping.
Returns:
dict[int, str]: job_id to job_name mapping.
"""
job_id... | [
"def",
"_get_job_id_to_job_name",
"(",
"name_to_job_details",
":",
"dict",
")",
"->",
"dict",
":",
"job_id_to_job_name",
"=",
"{",
"}",
"for",
"job_name",
",",
"job_details",
"in",
"name_to_job_details",
".",
"items",
"(",
")",
":",
"job_id_to_job_name",
"[",
"j... | [
145,
4
] | [
157,
33
] | python | en | ['en', 'en', 'en'] | True |
ContainerTrackingAgent.run | (self) | Start updating name_to_container_details.
Returns:
None.
| Start updating name_to_container_details. | def run(self) -> None:
"""Start updating name_to_container_details.
Returns:
None.
"""
while True:
logger.debug("Start in ContainerTrackingAgent.")
start_time = time.time()
self.update_name_to_container_details()
time.sleep(max... | [
"def",
"run",
"(",
"self",
")",
"->",
"None",
":",
"while",
"True",
":",
"logger",
".",
"debug",
"(",
"\"Start in ContainerTrackingAgent.\"",
")",
"start_time",
"=",
"time",
".",
"time",
"(",
")",
"self",
".",
"update_name_to_container_details",
"(",
")",
"t... | [
177,
4
] | [
188,
58
] | python | en | ['en', 'en', 'en'] | True |
ContainerTrackingAgent.update_name_to_container_details | (self) | Update name_to_container_details with name_to_node_details.
Returns:
None.
| Update name_to_container_details with name_to_node_details. | def update_name_to_container_details(self) -> None:
"""Update name_to_container_details with name_to_node_details.
Returns:
None.
"""
# Get details and init params.
name_to_node_details = self._redis_controller.get_name_to_node_details()
name_to_container_det... | [
"def",
"update_name_to_container_details",
"(",
"self",
")",
"->",
"None",
":",
"# Get details and init params.",
"name_to_node_details",
"=",
"self",
".",
"_redis_controller",
".",
"get_name_to_node_details",
"(",
")",
"name_to_container_details",
"=",
"{",
"}",
"# Itera... | [
190,
4
] | [
205,
114
] | python | en | ['en', 'en', 'en'] | True |
ContainerRuntimeAgent.run | (self) | Start tracking exited containers.
Returns:
None.
| Start tracking exited containers. | def run(self) -> None:
"""Start tracking exited containers.
Returns:
None.
"""
while True:
logger.debug("Start in ContainerRuntimeAgent.")
start_time = time.time()
self.iterate_container_status()
time.sleep(max(self._check_inte... | [
"def",
"run",
"(",
"self",
")",
"->",
"None",
":",
"while",
"True",
":",
"logger",
".",
"debug",
"(",
"\"Start in ContainerRuntimeAgent.\"",
")",
"start_time",
"=",
"time",
".",
"time",
"(",
")",
"self",
".",
"iterate_container_status",
"(",
")",
"time",
"... | [
228,
4
] | [
239,
57
] | python | en | ['en', 'en', 'en'] | True |
ContainerRuntimeAgent.iterate_container_status | (self) | Iterate container status.
Find the exited container and try to restart it if the rule exists.
Returns:
None.
| Iterate container status. | def iterate_container_status(self) -> None:
"""Iterate container status.
Find the exited container and try to restart it if the rule exists.
Returns:
None.
"""
# Get details.
name_to_container_details = self._redis_controller.get_name_to_container_details()
... | [
"def",
"iterate_container_status",
"(",
"self",
")",
"->",
"None",
":",
"# Get details.",
"name_to_container_details",
"=",
"self",
".",
"_redis_controller",
".",
"get_name_to_container_details",
"(",
")",
"# Iterate container status.",
"for",
"container_name",
",",
"cont... | [
241,
4
] | [
280,
107
] | python | en | ['en', 'la', 'sw'] | False |
ContainerRuntimeAgent._is_remove_container | (container_details: dict, job_runtime_details: dict) | Check if the container need to be removed.
Args:
container_details (dict): Details of the container.
job_runtime_details (dict): Runtime details of the job.
Returns:
bool: True or False.
| Check if the container need to be removed. | def _is_remove_container(container_details: dict, job_runtime_details: dict) -> bool:
"""Check if the container need to be removed.
Args:
container_details (dict): Details of the container.
job_runtime_details (dict): Runtime details of the job.
Returns:
boo... | [
"def",
"_is_remove_container",
"(",
"container_details",
":",
"dict",
",",
"job_runtime_details",
":",
"dict",
")",
"->",
"bool",
":",
"return",
"(",
"container_details",
"[",
"\"state\"",
"]",
"[",
"\"Status\"",
"]",
"==",
"\"exited\"",
"and",
"job_runtime_detail... | [
283,
4
] | [
297,
9
] | python | en | ['en', 'en', 'en'] | True |
ContainerRuntimeAgent._is_restart_container | (self, container_details: dict, job_runtime_details: dict) | Check if the container need to be removed.
Args:
container_details (dict): Details of the container.
job_runtime_details (dict): Runtime details of the job.
Returns:
bool: True or False.
| Check if the container need to be removed. | def _is_restart_container(self, container_details: dict, job_runtime_details: dict) -> bool:
"""Check if the container need to be removed.
Args:
container_details (dict): Details of the container.
job_runtime_details (dict): Runtime details of the job.
Returns:
... | [
"def",
"_is_restart_container",
"(",
"self",
",",
"container_details",
":",
"dict",
",",
"job_runtime_details",
":",
"dict",
")",
"->",
"bool",
":",
"exceed_maximum_restart_times",
"=",
"self",
".",
"_redis_controller",
".",
"get_rejoin_component_restart_times",
"(",
... | [
299,
4
] | [
319,
9
] | python | en | ['en', 'en', 'en'] | True |
ContainerRuntimeAgent._is_stop_job | (container_details: dict) | Check if the job need to be stop.
Args:
container_details (dict): Details of the container.
Returns:
bool: True of False.
| Check if the job need to be stop. | def _is_stop_job(container_details: dict) -> bool:
"""Check if the job need to be stop.
Args:
container_details (dict): Details of the container.
Returns:
bool: True of False.
"""
return (
container_details["state"]["Status"] == "exited"
... | [
"def",
"_is_stop_job",
"(",
"container_details",
":",
"dict",
")",
"->",
"bool",
":",
"return",
"(",
"container_details",
"[",
"\"state\"",
"]",
"[",
"\"Status\"",
"]",
"==",
"\"exited\"",
"and",
"container_details",
"[",
"\"state\"",
"]",
"[",
"\"ExitCode\"",
... | [
322,
4
] | [
334,
9
] | python | en | ['en', 'en', 'en'] | True |
ContainerRuntimeAgent._restart_container | (self, container_name: str, container_details: dict) | Restart container.
Args:
container_name (str): Name of the exited container.
container_details (dict): Details of the exited container.
Returns:
None.
| Restart container. | def _restart_container(self, container_name: str, container_details: dict) -> None:
"""Restart container.
Args:
container_name (str): Name of the exited container.
container_details (dict): Details of the exited container.
Returns:
None.
"""
... | [
"def",
"_restart_container",
"(",
"self",
",",
"container_name",
":",
"str",
",",
"container_details",
":",
"dict",
")",
"->",
"None",
":",
"# Get component_name_to_container_name.",
"rejoin_container_name_to_component_name",
"=",
"self",
".",
"_redis_controller",
".",
... | [
336,
4
] | [
403,
66
] | python | en | ['en', 'de', 'en'] | False |
ContainerRuntimeAgent._stop_job | (self, job_id: str, is_remove_container: bool) | Stop job.
Args:
job_id (str): Id of the job.
is_remove_container (bool): If the containers need to be removed.
Returns:
None.
| Stop job. | def _stop_job(self, job_id: str, is_remove_container: bool) -> None:
"""Stop job.
Args:
job_id (str): Id of the job.
is_remove_container (bool): If the containers need to be removed.
Returns:
None.
"""
# Delete mapping if fault tolerance is a... | [
"def",
"_stop_job",
"(",
"self",
",",
"job_id",
":",
"str",
",",
"is_remove_container",
":",
"bool",
")",
"->",
"None",
":",
"# Delete mapping if fault tolerance is activated.",
"self",
".",
"_redis_controller",
".",
"delete_rejoin_container_name_to_component_name",
"(",
... | [
405,
4
] | [
445,
21
] | python | en | ['fi', 'su', 'en'] | False |
ContainerRuntimeAgent._start_container | (self, container_name: str, node_details: dict, job_details: dict, component_name: str) | Start container.
Args:
container_name: Name of the container.
node_details: Details of the node.
job_details: Details of the job.
component_name: Name of the component from mapping.
Returns:
None.
| Start container. | def _start_container(self, container_name: str, node_details: dict, job_details: dict, component_name: str) -> None:
"""Start container.
Args:
container_name: Name of the container.
node_details: Details of the node.
job_details: Details of the job.
compo... | [
"def",
"_start_container",
"(",
"self",
",",
"container_name",
":",
"str",
",",
"node_details",
":",
"dict",
",",
"job_details",
":",
"dict",
",",
"component_name",
":",
"str",
")",
"->",
"None",
":",
"# Get mapping.",
"component_id_to_component_type",
"=",
"Job... | [
447,
4
] | [
532,
9
] | python | en | ['en', 'en', 'en'] | False |
PendingJobAgent.run | (self) | Start tracking pending job tickets.
Returns:
None.
| Start tracking pending job tickets. | def run(self) -> None:
"""Start tracking pending job tickets.
Returns:
None.
"""
while True:
logger.debug("Start in PendingJobAgent.")
start_time = time.time()
self.schedule_pending_job_tickets()
time.sleep(max(self._check_inte... | [
"def",
"run",
"(",
"self",
")",
"->",
"None",
":",
"while",
"True",
":",
"logger",
".",
"debug",
"(",
"\"Start in PendingJobAgent.\"",
")",
"start_time",
"=",
"time",
".",
"time",
"(",
")",
"self",
".",
"schedule_pending_job_tickets",
"(",
")",
"time",
"."... | [
557,
4
] | [
568,
51
] | python | en | ['en', 'lb', 'en'] | True |
PendingJobAgent.schedule_pending_job_tickets | (self) | Schedule pending job tickets.
Returns:
None.
| Schedule pending job tickets. | def schedule_pending_job_tickets(self) -> None:
"""Schedule pending job tickets.
Returns:
None.
"""
# Get tickets.
self._pending_jobs = self._redis_controller.get_pending_job_ticket()
# Get free resources at the very beginning.
free_resources = Resou... | [
"def",
"schedule_pending_job_tickets",
"(",
"self",
")",
"->",
"None",
":",
"# Get tickets.",
"self",
".",
"_pending_jobs",
"=",
"self",
".",
"_redis_controller",
".",
"get_pending_job_ticket",
"(",
")",
"# Get free resources at the very beginning.",
"free_resources",
"="... | [
570,
4
] | [
614,
66
] | python | en | ['ro', 'nl', 'en'] | False |
PendingJobAgent._start_container | (self, container_name: str, node_details: dict, job_details: dict) | Start container.
Args:
container_name: Name of the container.
node_details: Details of the node.
job_details: Details of the job.
Returns:
None.
| Start container. | def _start_container(self, container_name: str, node_details: dict, job_details: dict):
"""Start container.
Args:
container_name: Name of the container.
node_details: Details of the node.
job_details: Details of the job.
Returns:
None.
""... | [
"def",
"_start_container",
"(",
"self",
",",
"container_name",
":",
"str",
",",
"node_details",
":",
"dict",
",",
"job_details",
":",
"dict",
")",
":",
"# Get mapping.",
"component_id_to_component_type",
"=",
"JobController",
".",
"get_component_id_to_component_type",
... | [
616,
4
] | [
698,
9
] | python | en | ['en', 'en', 'en'] | False |
KilledJobAgent.run | (self) | Start tracking killed job tickets.
Returns:
None.
| Start tracking killed job tickets. | def run(self) -> None:
"""Start tracking killed job tickets.
Returns:
None.
"""
while True:
logger.debug("Start in KilledJobAgent.")
start_time = time.time()
self.schedule_killed_job_tickets()
time.sleep(max(self._check_interva... | [
"def",
"run",
"(",
"self",
")",
"->",
"None",
":",
"while",
"True",
":",
"logger",
".",
"debug",
"(",
"\"Start in KilledJobAgent.\"",
")",
"start_time",
"=",
"time",
".",
"time",
"(",
")",
"self",
".",
"schedule_killed_job_tickets",
"(",
")",
"time",
".",
... | [
721,
4
] | [
732,
50
] | python | en | ['en', 'mt', 'en'] | True |
KilledJobAgent.schedule_killed_job_tickets | (self) | Schedule killed job tickets.
Returns:
None.
| Schedule killed job tickets. | def schedule_killed_job_tickets(self):
"""Schedule killed job tickets.
Returns:
None.
"""
# Get tickets.
self._killed_job_tickets = self._redis_controller.get_killed_job_ticket()
# Iterate tickets.
for job_name in self._killed_job_tickets:
... | [
"def",
"schedule_killed_job_tickets",
"(",
"self",
")",
":",
"# Get tickets.",
"self",
".",
"_killed_job_tickets",
"=",
"self",
".",
"_redis_controller",
".",
"get_killed_job_ticket",
"(",
")",
"# Iterate tickets.",
"for",
"job_name",
"in",
"self",
".",
"_killed_job_t... | [
734,
4
] | [
757,
78
] | python | en | ['en', 'de', 'en'] | True |
KilledJobAgent._kill_job | (self, job_details: dict) | Kill job and stop containers.
Args:
job_details (dict): Details of the job.
Returns:
None.
| Kill job and stop containers. | def _kill_job(self, job_details: dict) -> None:
"""Kill job and stop containers.
Args:
job_details (dict): Details of the job.
Returns:
None.
"""
# Get params.
job_id = job_details["id"]
# Delete mapping if fault tolerance is activated.
... | [
"def",
"_kill_job",
"(",
"self",
",",
"job_details",
":",
"dict",
")",
"->",
"None",
":",
"# Get params.",
"job_id",
"=",
"job_details",
"[",
"\"id\"",
"]",
"# Delete mapping if fault tolerance is activated.",
"self",
".",
"_redis_controller",
".",
"delete_rejoin_cont... | [
759,
4
] | [
794,
17
] | 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.