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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
LxmertPreTrainedModel._init_weights | (self, module) | Initialize the weights | Initialize the weights | def _init_weights(self, module):
""" Initialize the weights """
if isinstance(module, nn.Linear):
# Slightly different from the TF version which uses truncated_normal for initialization
# cf https://github.com/pytorch/pytorch/pull/5617
module.weight.data.normal_(mean=... | [
"def",
"_init_weights",
"(",
"self",
",",
"module",
")",
":",
"if",
"isinstance",
"(",
"module",
",",
"nn",
".",
"Linear",
")",
":",
"# Slightly different from the TF version which uses truncated_normal for initialization",
"# cf https://github.com/pytorch/pytorch/pull/5617",
... | [
784,
4
] | [
798,
41
] | python | en | ['en', 'en', 'en'] | True |
_get_alarm_state | (area) | Get the alarm state. | Get the alarm state. | def _get_alarm_state(area):
"""Get the alarm state."""
if area.verified_alarm:
return STATE_ALARM_TRIGGERED
mode_to_state = {
AreaMode.UNSET: STATE_ALARM_DISARMED,
AreaMode.PART_SET_A: STATE_ALARM_ARMED_HOME,
AreaMode.PART_SET_B: STATE_ALARM_ARMED_NIGHT,
AreaMode.FU... | [
"def",
"_get_alarm_state",
"(",
"area",
")",
":",
"if",
"area",
".",
"verified_alarm",
":",
"return",
"STATE_ALARM_TRIGGERED",
"mode_to_state",
"=",
"{",
"AreaMode",
".",
"UNSET",
":",
"STATE_ALARM_DISARMED",
",",
"AreaMode",
".",
"PART_SET_A",
":",
"STATE_ALARM_A... | [
22,
0
] | [
34,
39
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up the SPC alarm control panel platform. | Set up the SPC alarm control panel platform. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the SPC alarm control panel platform."""
if discovery_info is None:
return
api = hass.data[DATA_API]
async_add_entities([SpcAlarm(area=area, api=api) for area in api.areas.values()]) | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"if",
"discovery_info",
"is",
"None",
":",
"return",
"api",
"=",
"hass",
".",
"data",
"[",
"DATA_API",
"]",
"async_ad... | [
37,
0
] | [
42,
85
] | python | en | ['en', 'ru', 'en'] | True |
SpcAlarm.__init__ | (self, area, api) | Initialize the SPC alarm panel. | Initialize the SPC alarm panel. | def __init__(self, area, api):
"""Initialize the SPC alarm panel."""
self._area = area
self._api = api | [
"def",
"__init__",
"(",
"self",
",",
"area",
",",
"api",
")",
":",
"self",
".",
"_area",
"=",
"area",
"self",
".",
"_api",
"=",
"api"
] | [
48,
4
] | [
51,
23
] | python | en | ['en', 'sr', 'en'] | True |
SpcAlarm.async_added_to_hass | (self) | Call for adding new entities. | Call for adding new entities. | async def async_added_to_hass(self):
"""Call for adding new entities."""
self.async_on_remove(
async_dispatcher_connect(
self.hass,
SIGNAL_UPDATE_ALARM.format(self._area.id),
self._update_callback,
)
) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"async_on_remove",
"(",
"async_dispatcher_connect",
"(",
"self",
".",
"hass",
",",
"SIGNAL_UPDATE_ALARM",
".",
"format",
"(",
"self",
".",
"_area",
".",
"id",
")",
",",
"self",
".",
... | [
53,
4
] | [
61,
9
] | python | en | ['en', 'en', 'en'] | True |
SpcAlarm._update_callback | (self) | Call update method. | Call update method. | def _update_callback(self):
"""Call update method."""
self.async_schedule_update_ha_state(True) | [
"def",
"_update_callback",
"(",
"self",
")",
":",
"self",
".",
"async_schedule_update_ha_state",
"(",
"True",
")"
] | [
64,
4
] | [
66,
49
] | python | en | ['en', 'sn', 'en'] | True |
SpcAlarm.should_poll | (self) | No polling needed. | No polling needed. | def should_poll(self):
"""No polling needed."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
69,
4
] | [
71,
20
] | python | en | ['en', 'en', 'en'] | True |
SpcAlarm.name | (self) | Return the name of the device. | Return the name of the device. | def name(self):
"""Return the name of the device."""
return self._area.name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_area",
".",
"name"
] | [
74,
4
] | [
76,
30
] | python | en | ['en', 'en', 'en'] | True |
SpcAlarm.changed_by | (self) | Return the user the last change was triggered by. | Return the user the last change was triggered by. | def changed_by(self):
"""Return the user the last change was triggered by."""
return self._area.last_changed_by | [
"def",
"changed_by",
"(",
"self",
")",
":",
"return",
"self",
".",
"_area",
".",
"last_changed_by"
] | [
79,
4
] | [
81,
41
] | python | en | ['en', 'en', 'en'] | True |
SpcAlarm.state | (self) | Return the state of the device. | Return the state of the device. | def state(self):
"""Return the state of the device."""
return _get_alarm_state(self._area) | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"_get_alarm_state",
"(",
"self",
".",
"_area",
")"
] | [
84,
4
] | [
86,
43
] | python | en | ['en', 'en', 'en'] | True |
SpcAlarm.supported_features | (self) | Return the list of supported features. | Return the list of supported features. | def supported_features(self) -> int:
"""Return the list of supported features."""
return SUPPORT_ALARM_ARM_HOME | SUPPORT_ALARM_ARM_AWAY | SUPPORT_ALARM_ARM_NIGHT | [
"def",
"supported_features",
"(",
"self",
")",
"->",
"int",
":",
"return",
"SUPPORT_ALARM_ARM_HOME",
"|",
"SUPPORT_ALARM_ARM_AWAY",
"|",
"SUPPORT_ALARM_ARM_NIGHT"
] | [
89,
4
] | [
91,
88
] | python | en | ['en', 'en', 'en'] | True |
SpcAlarm.async_alarm_disarm | (self, code=None) | Send disarm command. | Send disarm command. | async def async_alarm_disarm(self, code=None):
"""Send disarm command."""
await self._api.change_mode(area=self._area, new_mode=AreaMode.UNSET) | [
"async",
"def",
"async_alarm_disarm",
"(",
"self",
",",
"code",
"=",
"None",
")",
":",
"await",
"self",
".",
"_api",
".",
"change_mode",
"(",
"area",
"=",
"self",
".",
"_area",
",",
"new_mode",
"=",
"AreaMode",
".",
"UNSET",
")"
] | [
93,
4
] | [
96,
77
] | python | en | ['en', 'pt', 'en'] | True |
SpcAlarm.async_alarm_arm_home | (self, code=None) | Send arm home command. | Send arm home command. | async def async_alarm_arm_home(self, code=None):
"""Send arm home command."""
await self._api.change_mode(area=self._area, new_mode=AreaMode.PART_SET_A) | [
"async",
"def",
"async_alarm_arm_home",
"(",
"self",
",",
"code",
"=",
"None",
")",
":",
"await",
"self",
".",
"_api",
".",
"change_mode",
"(",
"area",
"=",
"self",
".",
"_area",
",",
"new_mode",
"=",
"AreaMode",
".",
"PART_SET_A",
")"
] | [
98,
4
] | [
101,
82
] | python | en | ['en', 'pt', 'en'] | True |
SpcAlarm.async_alarm_arm_night | (self, code=None) | Send arm home command. | Send arm home command. | async def async_alarm_arm_night(self, code=None):
"""Send arm home command."""
await self._api.change_mode(area=self._area, new_mode=AreaMode.PART_SET_B) | [
"async",
"def",
"async_alarm_arm_night",
"(",
"self",
",",
"code",
"=",
"None",
")",
":",
"await",
"self",
".",
"_api",
".",
"change_mode",
"(",
"area",
"=",
"self",
".",
"_area",
",",
"new_mode",
"=",
"AreaMode",
".",
"PART_SET_B",
")"
] | [
103,
4
] | [
106,
82
] | python | en | ['en', 'pt', 'en'] | True |
SpcAlarm.async_alarm_arm_away | (self, code=None) | Send arm away command. | Send arm away command. | async def async_alarm_arm_away(self, code=None):
"""Send arm away command."""
await self._api.change_mode(area=self._area, new_mode=AreaMode.FULL_SET) | [
"async",
"def",
"async_alarm_arm_away",
"(",
"self",
",",
"code",
"=",
"None",
")",
":",
"await",
"self",
".",
"_api",
".",
"change_mode",
"(",
"area",
"=",
"self",
".",
"_area",
",",
"new_mode",
"=",
"AreaMode",
".",
"FULL_SET",
")"
] | [
108,
4
] | [
111,
80
] | python | en | ['en', 'en', 'en'] | True |
devices_from_entities | (hass, entry) | Parse configuration and add HLK-SW16 switch devices. | Parse configuration and add HLK-SW16 switch devices. | def devices_from_entities(hass, entry):
"""Parse configuration and add HLK-SW16 switch devices."""
device_client = hass.data[DOMAIN][entry.entry_id][DATA_DEVICE_REGISTER]
devices = []
for i in range(16):
device_port = f"{i:01x}"
device = SW16Switch(device_port, entry.entry_id, device_cli... | [
"def",
"devices_from_entities",
"(",
"hass",
",",
"entry",
")",
":",
"device_client",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"entry",
".",
"entry_id",
"]",
"[",
"DATA_DEVICE_REGISTER",
"]",
"devices",
"=",
"[",
"]",
"for",
"i",
"in",
"range",... | [
9,
0
] | [
17,
18
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, entry, async_add_entities) | Set up the HLK-SW16 platform. | Set up the HLK-SW16 platform. | async def async_setup_entry(hass, entry, async_add_entities):
"""Set up the HLK-SW16 platform."""
async_add_entities(devices_from_entities(hass, entry)) | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"entry",
",",
"async_add_entities",
")",
":",
"async_add_entities",
"(",
"devices_from_entities",
"(",
"hass",
",",
"entry",
")",
")"
] | [
20,
0
] | [
22,
58
] | python | en | ['en', 'da', 'en'] | True |
SW16Switch.is_on | (self) | Return true if device is on. | Return true if device is on. | def is_on(self):
"""Return true if device is on."""
return self._is_on | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_is_on"
] | [
29,
4
] | [
31,
26
] | python | en | ['en', 'fy', 'en'] | True |
SW16Switch.async_turn_on | (self, **kwargs) | Turn the device on. | Turn the device on. | async def async_turn_on(self, **kwargs):
"""Turn the device on."""
await self._client.turn_on(self._device_port) | [
"async",
"def",
"async_turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"_client",
".",
"turn_on",
"(",
"self",
".",
"_device_port",
")"
] | [
33,
4
] | [
35,
53
] | python | en | ['en', 'en', 'en'] | True |
SW16Switch.async_turn_off | (self, **kwargs) | Turn the device off. | Turn the device off. | async def async_turn_off(self, **kwargs):
"""Turn the device off."""
await self._client.turn_off(self._device_port) | [
"async",
"def",
"async_turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"_client",
".",
"turn_off",
"(",
"self",
".",
"_device_port",
")"
] | [
37,
4
] | [
39,
54
] | python | en | ['en', 'en', 'en'] | True |
async_register | (hass, intent_type, utterances) | Register utterances and any custom intents for the default agent.
Registrations don't require conversations to be loaded. They will become
active once the conversation component is loaded.
| Register utterances and any custom intents for the default agent. | def async_register(hass, intent_type, utterances):
"""Register utterances and any custom intents for the default agent.
Registrations don't require conversations to be loaded. They will become
active once the conversation component is loaded.
"""
intents = hass.data.setdefault(DOMAIN, {})
conf ... | [
"def",
"async_register",
"(",
"hass",
",",
"intent_type",
",",
"utterances",
")",
":",
"intents",
"=",
"hass",
".",
"data",
".",
"setdefault",
"(",
"DOMAIN",
",",
"{",
"}",
")",
"conf",
"=",
"intents",
".",
"setdefault",
"(",
"intent_type",
",",
"[",
"... | [
35,
0
] | [
48,
50
] | python | en | ['en', 'en', 'en'] | True |
DefaultAgent.__init__ | (self, hass: core.HomeAssistant) | Initialize the default agent. | Initialize the default agent. | def __init__(self, hass: core.HomeAssistant):
"""Initialize the default agent."""
self.hass = hass | [
"def",
"__init__",
"(",
"self",
",",
"hass",
":",
"core",
".",
"HomeAssistant",
")",
":",
"self",
".",
"hass",
"=",
"hass"
] | [
54,
4
] | [
56,
24
] | python | en | ['en', 'en', 'en'] | True |
DefaultAgent.async_initialize | (self, config) | Initialize the default agent. | Initialize the default agent. | async def async_initialize(self, config):
"""Initialize the default agent."""
if "intent" not in self.hass.config.components:
await setup.async_setup_component(self.hass, "intent", {})
config = config.get(DOMAIN, {})
intents = self.hass.data.setdefault(DOMAIN, {})
f... | [
"async",
"def",
"async_initialize",
"(",
"self",
",",
"config",
")",
":",
"if",
"\"intent\"",
"not",
"in",
"self",
".",
"hass",
".",
"config",
".",
"components",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"self",
".",
"hass",
",",
"\"intent\... | [
58,
4
] | [
103,
47
] | python | en | ['en', 'en', 'en'] | True |
DefaultAgent.register_utterances | (self, component) | Register utterances for a component. | Register utterances for a component. | def register_utterances(self, component):
"""Register utterances for a component."""
if component not in UTTERANCES:
return
for intent_type, sentences in UTTERANCES[component].items():
async_register(self.hass, intent_type, sentences) | [
"def",
"register_utterances",
"(",
"self",
",",
"component",
")",
":",
"if",
"component",
"not",
"in",
"UTTERANCES",
":",
"return",
"for",
"intent_type",
",",
"sentences",
"in",
"UTTERANCES",
"[",
"component",
"]",
".",
"items",
"(",
")",
":",
"async_registe... | [
106,
4
] | [
111,
61
] | python | en | ['en', 'da', 'en'] | True |
DefaultAgent.async_process | (
self, text: str, context: core.Context, conversation_id: Optional[str] = None
) | Process a sentence. | Process a sentence. | async def async_process(
self, text: str, context: core.Context, conversation_id: Optional[str] = None
) -> intent.IntentResponse:
"""Process a sentence."""
intents = self.hass.data[DOMAIN]
for intent_type, matchers in intents.items():
for matcher in matchers:
... | [
"async",
"def",
"async_process",
"(",
"self",
",",
"text",
":",
"str",
",",
"context",
":",
"core",
".",
"Context",
",",
"conversation_id",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
")",
"->",
"intent",
".",
"IntentResponse",
":",
"intents",
"=",
... | [
113,
4
] | [
133,
17
] | python | en | ['en', 'mk', 'en'] | True |
TestMicrosoftFaceDetectSetup.setup_method | (self) | Set up things to be run when tests are started. | Set up things to be run when tests are started. | def setup_method(self):
"""Set up things to be run when tests are started."""
self.hass = get_test_home_assistant() | [
"def",
"setup_method",
"(",
"self",
")",
":",
"self",
".",
"hass",
"=",
"get_test_home_assistant",
"(",
")"
] | [
21,
4
] | [
23,
45
] | python | en | ['en', 'en', 'en'] | True |
TestMicrosoftFaceDetectSetup.teardown_method | (self) | Stop everything that was started. | Stop everything that was started. | def teardown_method(self):
"""Stop everything that was started."""
self.hass.stop() | [
"def",
"teardown_method",
"(",
"self",
")",
":",
"self",
".",
"hass",
".",
"stop",
"(",
")"
] | [
25,
4
] | [
27,
24
] | python | en | ['en', 'en', 'en'] | True |
TestMicrosoftFaceDetectSetup.test_setup_platform | (self, store_mock) | Set up platform with one entity. | Set up platform with one entity. | def test_setup_platform(self, store_mock):
"""Set up platform with one entity."""
config = {
ip.DOMAIN: {
"platform": "microsoft_face_detect",
"source": {"entity_id": "camera.demo_camera"},
"attributes": ["age", "gender"],
},
... | [
"def",
"test_setup_platform",
"(",
"self",
",",
"store_mock",
")",
":",
"config",
"=",
"{",
"ip",
".",
"DOMAIN",
":",
"{",
"\"platform\"",
":",
"\"microsoft_face_detect\"",
",",
"\"source\"",
":",
"{",
"\"entity_id\"",
":",
"\"camera.demo_camera\"",
"}",
",",
... | [
33,
4
] | [
49,
81
] | python | en | ['en', 'en', 'en'] | True |
TestMicrosoftFaceDetectSetup.test_setup_platform_name | (self, store_mock) | Set up platform with one entity and set name. | Set up platform with one entity and set name. | def test_setup_platform_name(self, store_mock):
"""Set up platform with one entity and set name."""
config = {
ip.DOMAIN: {
"platform": "microsoft_face_detect",
"source": {"entity_id": "camera.demo_camera", "name": "test local"},
},
"ca... | [
"def",
"test_setup_platform_name",
"(",
"self",
",",
"store_mock",
")",
":",
"config",
"=",
"{",
"ip",
".",
"DOMAIN",
":",
"{",
"\"platform\"",
":",
"\"microsoft_face_detect\"",
",",
"\"source\"",
":",
"{",
"\"entity_id\"",
":",
"\"camera.demo_camera\"",
",",
"\... | [
55,
4
] | [
70,
66
] | python | en | ['en', 'en', 'en'] | True |
TestMicrosoftFaceDetect.setup_method | (self) | Set up things to be run when tests are started. | Set up things to be run when tests are started. | def setup_method(self):
"""Set up things to be run when tests are started."""
self.hass = get_test_home_assistant()
self.config = {
ip.DOMAIN: {
"platform": "microsoft_face_detect",
"source": {"entity_id": "camera.demo_camera", "name": "test local"},
... | [
"def",
"setup_method",
"(",
"self",
")",
":",
"self",
".",
"hass",
"=",
"get_test_home_assistant",
"(",
")",
"self",
".",
"config",
"=",
"{",
"ip",
".",
"DOMAIN",
":",
"{",
"\"platform\"",
":",
"\"microsoft_face_detect\"",
",",
"\"source\"",
":",
"{",
"\"e... | [
76,
4
] | [
90,
63
] | python | en | ['en', 'en', 'en'] | True |
TestMicrosoftFaceDetect.teardown_method | (self) | Stop everything that was started. | Stop everything that was started. | def teardown_method(self):
"""Stop everything that was started."""
self.hass.stop() | [
"def",
"teardown_method",
"(",
"self",
")",
":",
"self",
".",
"hass",
".",
"stop",
"(",
")"
] | [
92,
4
] | [
94,
24
] | python | en | ['en', 'en', 'en'] | True |
TestMicrosoftFaceDetect.test_ms_detect_process_image | (self, poll_mock, aioclient_mock) | Set up and scan a picture and test plates from event. | Set up and scan a picture and test plates from event. | def test_ms_detect_process_image(self, poll_mock, aioclient_mock):
"""Set up and scan a picture and test plates from event."""
aioclient_mock.get(
self.endpoint_url.format("persongroups"),
text=load_fixture("microsoft_face_persongroups.json"),
)
aioclient_mock.get... | [
"def",
"test_ms_detect_process_image",
"(",
"self",
",",
"poll_mock",
",",
"aioclient_mock",
")",
":",
"aioclient_mock",
".",
"get",
"(",
"self",
".",
"endpoint_url",
".",
"format",
"(",
"\"persongroups\"",
")",
",",
"text",
"=",
"load_fixture",
"(",
"\"microsof... | [
101,
4
] | [
170,
33
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, entry, async_add_entities) | Set up OwnTracks based off an entry. | Set up OwnTracks based off an entry. | async def async_setup_entry(hass, entry, async_add_entities):
"""Set up OwnTracks based off an entry."""
entity = MobileAppEntity(entry)
async_add_entities([entity])
return True | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"entry",
",",
"async_add_entities",
")",
":",
"entity",
"=",
"MobileAppEntity",
"(",
"entry",
")",
"async_add_entities",
"(",
"[",
"entity",
"]",
")",
"return",
"True"
] | [
27,
0
] | [
31,
15
] | python | en | ['en', 'en', 'en'] | True |
MobileAppEntity.__init__ | (self, entry, data=None) | Set up OwnTracks entity. | Set up OwnTracks entity. | def __init__(self, entry, data=None):
"""Set up OwnTracks entity."""
self._entry = entry
self._data = data
self._dispatch_unsub = None | [
"def",
"__init__",
"(",
"self",
",",
"entry",
",",
"data",
"=",
"None",
")",
":",
"self",
".",
"_entry",
"=",
"entry",
"self",
".",
"_data",
"=",
"data",
"self",
".",
"_dispatch_unsub",
"=",
"None"
] | [
37,
4
] | [
41,
35
] | python | en | ['en', 'zu', 'en'] | True |
MobileAppEntity.unique_id | (self) | Return the unique ID. | Return the unique ID. | def unique_id(self):
"""Return the unique ID."""
return self._entry.data[ATTR_DEVICE_ID] | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_entry",
".",
"data",
"[",
"ATTR_DEVICE_ID",
"]"
] | [
44,
4
] | [
46,
47
] | python | en | ['en', 'la', 'en'] | True |
MobileAppEntity.battery_level | (self) | Return the battery level of the device. | Return the battery level of the device. | def battery_level(self):
"""Return the battery level of the device."""
return self._data.get(ATTR_BATTERY) | [
"def",
"battery_level",
"(",
"self",
")",
":",
"return",
"self",
".",
"_data",
".",
"get",
"(",
"ATTR_BATTERY",
")"
] | [
49,
4
] | [
51,
43
] | python | en | ['en', 'en', 'en'] | True |
MobileAppEntity.device_state_attributes | (self) | Return device specific attributes. | Return device specific attributes. | def device_state_attributes(self):
"""Return device specific attributes."""
attrs = {}
for key in ATTR_KEYS:
value = self._data.get(key)
if value is not None:
attrs[key] = value
return attrs | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"attrs",
"=",
"{",
"}",
"for",
"key",
"in",
"ATTR_KEYS",
":",
"value",
"=",
"self",
".",
"_data",
".",
"get",
"(",
"key",
")",
"if",
"value",
"is",
"not",
"None",
":",
"attrs",
"[",
"key",
"]... | [
54,
4
] | [
62,
20
] | python | en | ['fr', 'it', 'en'] | False |
MobileAppEntity.location_accuracy | (self) | Return the gps accuracy of the device. | Return the gps accuracy of the device. | def location_accuracy(self):
"""Return the gps accuracy of the device."""
return self._data.get(ATTR_GPS_ACCURACY) | [
"def",
"location_accuracy",
"(",
"self",
")",
":",
"return",
"self",
".",
"_data",
".",
"get",
"(",
"ATTR_GPS_ACCURACY",
")"
] | [
65,
4
] | [
67,
48
] | python | en | ['en', 'en', 'en'] | True |
MobileAppEntity.latitude | (self) | Return latitude value of the device. | Return latitude value of the device. | def latitude(self):
"""Return latitude value of the device."""
gps = self._data.get(ATTR_GPS)
if gps is None:
return None
return gps[0] | [
"def",
"latitude",
"(",
"self",
")",
":",
"gps",
"=",
"self",
".",
"_data",
".",
"get",
"(",
"ATTR_GPS",
")",
"if",
"gps",
"is",
"None",
":",
"return",
"None",
"return",
"gps",
"[",
"0",
"]"
] | [
70,
4
] | [
77,
21
] | python | en | ['en', 'en', 'en'] | True |
MobileAppEntity.longitude | (self) | Return longitude value of the device. | Return longitude value of the device. | def longitude(self):
"""Return longitude value of the device."""
gps = self._data.get(ATTR_GPS)
if gps is None:
return None
return gps[1] | [
"def",
"longitude",
"(",
"self",
")",
":",
"gps",
"=",
"self",
".",
"_data",
".",
"get",
"(",
"ATTR_GPS",
")",
"if",
"gps",
"is",
"None",
":",
"return",
"None",
"return",
"gps",
"[",
"1",
"]"
] | [
80,
4
] | [
87,
21
] | python | en | ['en', 'zu', 'en'] | True |
MobileAppEntity.location_name | (self) | Return a location name for the current location of the device. | Return a location name for the current location of the device. | def location_name(self):
"""Return a location name for the current location of the device."""
return self._data.get(ATTR_LOCATION_NAME) | [
"def",
"location_name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_data",
".",
"get",
"(",
"ATTR_LOCATION_NAME",
")"
] | [
90,
4
] | [
92,
49
] | python | en | ['en', 'en', 'en'] | True |
MobileAppEntity.name | (self) | Return the name of the device. | Return the name of the device. | def name(self):
"""Return the name of the device."""
return self._entry.data[ATTR_DEVICE_NAME] | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_entry",
".",
"data",
"[",
"ATTR_DEVICE_NAME",
"]"
] | [
95,
4
] | [
97,
49
] | python | en | ['en', 'en', 'en'] | True |
MobileAppEntity.source_type | (self) | Return the source type, eg gps or router, of the device. | Return the source type, eg gps or router, of the device. | def source_type(self):
"""Return the source type, eg gps or router, of the device."""
return SOURCE_TYPE_GPS | [
"def",
"source_type",
"(",
"self",
")",
":",
"return",
"SOURCE_TYPE_GPS"
] | [
100,
4
] | [
102,
30
] | python | en | ['en', 'en', 'en'] | True |
MobileAppEntity.device_info | (self) | Return the device info. | Return the device info. | def device_info(self):
"""Return the device info."""
return device_info(self._entry.data) | [
"def",
"device_info",
"(",
"self",
")",
":",
"return",
"device_info",
"(",
"self",
".",
"_entry",
".",
"data",
")"
] | [
105,
4
] | [
107,
44
] | python | en | ['en', 'en', 'en'] | True |
MobileAppEntity.async_added_to_hass | (self) | Call when entity about to be added to Home Assistant. | Call when entity about to be added to Home Assistant. | async def async_added_to_hass(self):
"""Call when entity about to be added to Home Assistant."""
await super().async_added_to_hass()
self._dispatch_unsub = self.hass.helpers.dispatcher.async_dispatcher_connect(
SIGNAL_LOCATION_UPDATE.format(self._entry.entry_id), self.update_data
... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"await",
"super",
"(",
")",
".",
"async_added_to_hass",
"(",
")",
"self",
".",
"_dispatch_unsub",
"=",
"self",
".",
"hass",
".",
"helpers",
".",
"dispatcher",
".",
"async_dispatcher_connect",
"(",
... | [
109,
4
] | [
133,
25
] | python | en | ['en', 'en', 'en'] | True |
MobileAppEntity.async_will_remove_from_hass | (self) | Call when entity is being removed from hass. | Call when entity is being removed from hass. | async def async_will_remove_from_hass(self):
"""Call when entity is being removed from hass."""
await super().async_will_remove_from_hass()
if self._dispatch_unsub:
self._dispatch_unsub()
self._dispatch_unsub = None | [
"async",
"def",
"async_will_remove_from_hass",
"(",
"self",
")",
":",
"await",
"super",
"(",
")",
".",
"async_will_remove_from_hass",
"(",
")",
"if",
"self",
".",
"_dispatch_unsub",
":",
"self",
".",
"_dispatch_unsub",
"(",
")",
"self",
".",
"_dispatch_unsub",
... | [
135,
4
] | [
141,
39
] | python | en | ['en', 'en', 'en'] | True |
MobileAppEntity.update_data | (self, data) | Mark the device as seen. | Mark the device as seen. | def update_data(self, data):
"""Mark the device as seen."""
self._data = data
self.async_write_ha_state() | [
"def",
"update_data",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"_data",
"=",
"data",
"self",
".",
"async_write_ha_state",
"(",
")"
] | [
144,
4
] | [
147,
35
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (
hass: HomeAssistant,
entry: ConfigEntry,
async_add_entities: Callable[[List[Entity], bool], None],
) | Set up Bond generic devices. | Set up Bond generic devices. | async def async_setup_entry(
hass: HomeAssistant,
entry: ConfigEntry,
async_add_entities: Callable[[List[Entity], bool], None],
) -> None:
"""Set up Bond generic devices."""
hub: BondHub = hass.data[DOMAIN][entry.entry_id]
switches = [
BondSwitch(hub, device)
for device in hub.d... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
",",
"async_add_entities",
":",
"Callable",
"[",
"[",
"List",
"[",
"Entity",
"]",
",",
"bool",
"]",
",",
"None",
"]",
",",
")",
"->",
"None",
":",
... | [
15,
0
] | [
29,
38
] | python | en | ['en', 'fr', 'en'] | True |
BondSwitch.__init__ | (self, hub: BondHub, device: BondDevice) | Create HA entity representing Bond generic device (switch). | Create HA entity representing Bond generic device (switch). | def __init__(self, hub: BondHub, device: BondDevice):
"""Create HA entity representing Bond generic device (switch)."""
super().__init__(hub, device)
self._power: Optional[bool] = None | [
"def",
"__init__",
"(",
"self",
",",
"hub",
":",
"BondHub",
",",
"device",
":",
"BondDevice",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"hub",
",",
"device",
")",
"self",
".",
"_power",
":",
"Optional",
"[",
"bool",
"]",
"=",
"None"
] | [
35,
4
] | [
39,
42
] | python | en | ['en', 'it', 'en'] | True |
BondSwitch.is_on | (self) | Return True if power is on. | Return True if power is on. | def is_on(self) -> bool:
"""Return True if power is on."""
return self._power == 1 | [
"def",
"is_on",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"_power",
"==",
"1"
] | [
45,
4
] | [
47,
31
] | python | en | ['en', 'fy', 'en'] | True |
BondSwitch.async_turn_on | (self, **kwargs: Any) | Turn the device on. | Turn the device on. | async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn the device on."""
await self._hub.bond.action(self._device.device_id, Action.turn_on()) | [
"async",
"def",
"async_turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"None",
":",
"await",
"self",
".",
"_hub",
".",
"bond",
".",
"action",
"(",
"self",
".",
"_device",
".",
"device_id",
",",
"Action",
".",
"turn_on",
"(",
... | [
49,
4
] | [
51,
77
] | python | en | ['en', 'en', 'en'] | True |
BondSwitch.async_turn_off | (self, **kwargs: Any) | Turn the device off. | Turn the device off. | async def async_turn_off(self, **kwargs: Any) -> None:
"""Turn the device off."""
await self._hub.bond.action(self._device.device_id, Action.turn_off()) | [
"async",
"def",
"async_turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"None",
":",
"await",
"self",
".",
"_hub",
".",
"bond",
".",
"action",
"(",
"self",
".",
"_device",
".",
"device_id",
",",
"Action",
".",
"turn_off",
"(",
... | [
53,
4
] | [
55,
78
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up the min/max/mean sensor. | Set up the min/max/mean sensor. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the min/max/mean sensor."""
entity_ids = config.get(CONF_ENTITY_IDS)
name = config.get(CONF_NAME)
sensor_type = config.get(CONF_TYPE)
round_digits = config.get(CONF_ROUND_DIGITS)
await async_setup_r... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"entity_ids",
"=",
"config",
".",
"get",
"(",
"CONF_ENTITY_IDS",
")",
"name",
"=",
"config",
".",
"get",
"(",
"CONF_N... | [
70,
0
] | [
79,
83
] | python | en | ['en', 'ca', 'en'] | True |
calc_min | (sensor_values) | Calculate min value, honoring unknown states. | Calculate min value, honoring unknown states. | def calc_min(sensor_values):
"""Calculate min value, honoring unknown states."""
val = None
entity_id = None
for sensor_id, sensor_value in sensor_values:
if sensor_value not in [STATE_UNKNOWN, STATE_UNAVAILABLE]:
if val is None or val > sensor_value:
entity_id, val =... | [
"def",
"calc_min",
"(",
"sensor_values",
")",
":",
"val",
"=",
"None",
"entity_id",
"=",
"None",
"for",
"sensor_id",
",",
"sensor_value",
"in",
"sensor_values",
":",
"if",
"sensor_value",
"not",
"in",
"[",
"STATE_UNKNOWN",
",",
"STATE_UNAVAILABLE",
"]",
":",
... | [
82,
0
] | [
90,
25
] | python | en | ['en', 'en', 'en'] | True |
calc_max | (sensor_values) | Calculate max value, honoring unknown states. | Calculate max value, honoring unknown states. | def calc_max(sensor_values):
"""Calculate max value, honoring unknown states."""
val = None
entity_id = None
for sensor_id, sensor_value in sensor_values:
if sensor_value not in [STATE_UNKNOWN, STATE_UNAVAILABLE]:
if val is None or val < sensor_value:
entity_id, val =... | [
"def",
"calc_max",
"(",
"sensor_values",
")",
":",
"val",
"=",
"None",
"entity_id",
"=",
"None",
"for",
"sensor_id",
",",
"sensor_value",
"in",
"sensor_values",
":",
"if",
"sensor_value",
"not",
"in",
"[",
"STATE_UNKNOWN",
",",
"STATE_UNAVAILABLE",
"]",
":",
... | [
93,
0
] | [
101,
25
] | python | en | ['en', 'en', 'en'] | True |
calc_mean | (sensor_values, round_digits) | Calculate mean value, honoring unknown states. | Calculate mean value, honoring unknown states. | def calc_mean(sensor_values, round_digits):
"""Calculate mean value, honoring unknown states."""
result = []
for _, sensor_value in sensor_values:
if sensor_value not in [STATE_UNKNOWN, STATE_UNAVAILABLE]:
result.append(sensor_value)
if len(result) == 0:
return None
retur... | [
"def",
"calc_mean",
"(",
"sensor_values",
",",
"round_digits",
")",
":",
"result",
"=",
"[",
"]",
"for",
"_",
",",
"sensor_value",
"in",
"sensor_values",
":",
"if",
"sensor_value",
"not",
"in",
"[",
"STATE_UNKNOWN",
",",
"STATE_UNAVAILABLE",
"]",
":",
"resul... | [
104,
0
] | [
112,
57
] | python | en | ['en', 'en', 'en'] | True |
calc_median | (sensor_values, round_digits) | Calculate median value, honoring unknown states. | Calculate median value, honoring unknown states. | def calc_median(sensor_values, round_digits):
"""Calculate median value, honoring unknown states."""
result = []
for _, sensor_value in sensor_values:
if sensor_value not in [STATE_UNKNOWN, STATE_UNAVAILABLE]:
result.append(sensor_value)
if len(result) == 0:
return None
r... | [
"def",
"calc_median",
"(",
"sensor_values",
",",
"round_digits",
")",
":",
"result",
"=",
"[",
"]",
"for",
"_",
",",
"sensor_value",
"in",
"sensor_values",
":",
"if",
"sensor_value",
"not",
"in",
"[",
"STATE_UNKNOWN",
",",
"STATE_UNAVAILABLE",
"]",
":",
"res... | [
115,
0
] | [
130,
38
] | python | en | ['en', 'en', 'en'] | True |
MinMaxSensor.__init__ | (self, entity_ids, name, sensor_type, round_digits) | Initialize the min/max sensor. | Initialize the min/max sensor. | def __init__(self, entity_ids, name, sensor_type, round_digits):
"""Initialize the min/max sensor."""
self._entity_ids = entity_ids
self._sensor_type = sensor_type
self._round_digits = round_digits
if name:
self._name = name
else:
self._name = f"{... | [
"def",
"__init__",
"(",
"self",
",",
"entity_ids",
",",
"name",
",",
"sensor_type",
",",
"round_digits",
")",
":",
"self",
".",
"_entity_ids",
"=",
"entity_ids",
"self",
".",
"_sensor_type",
"=",
"sensor_type",
"self",
".",
"_round_digits",
"=",
"round_digits"... | [
136,
4
] | [
151,
24
] | python | en | ['en', 'it', 'en'] | True |
MinMaxSensor.async_added_to_hass | (self) | Handle added to Hass. | Handle added to Hass. | async def async_added_to_hass(self):
"""Handle added to Hass."""
self.async_on_remove(
async_track_state_change_event(
self.hass, self._entity_ids, self._async_min_max_sensor_state_listener
)
)
self._calc_values() | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"async_on_remove",
"(",
"async_track_state_change_event",
"(",
"self",
".",
"hass",
",",
"self",
".",
"_entity_ids",
",",
"self",
".",
"_async_min_max_sensor_state_listener",
")",
")",
"sel... | [
153,
4
] | [
161,
27
] | python | en | ['en', 'en', 'en'] | True |
MinMaxSensor.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"
] | [
164,
4
] | [
166,
25
] | python | en | ['en', 'mi', 'en'] | True |
MinMaxSensor.state | (self) | Return the state of the sensor. | Return the state of the sensor. | def state(self):
"""Return the state of the sensor."""
if self._unit_of_measurement_mismatch:
return None
return getattr(
self, next(k for k, v in SENSOR_TYPES.items() if self._sensor_type == v)
) | [
"def",
"state",
"(",
"self",
")",
":",
"if",
"self",
".",
"_unit_of_measurement_mismatch",
":",
"return",
"None",
"return",
"getattr",
"(",
"self",
",",
"next",
"(",
"k",
"for",
"k",
",",
"v",
"in",
"SENSOR_TYPES",
".",
"items",
"(",
")",
"if",
"self",... | [
169,
4
] | [
175,
9
] | python | en | ['en', 'en', 'en'] | True |
MinMaxSensor.unit_of_measurement | (self) | Return the unit the value is expressed in. | Return the unit the value is expressed in. | def unit_of_measurement(self):
"""Return the unit the value is expressed in."""
if self._unit_of_measurement_mismatch:
return "ERR"
return self._unit_of_measurement | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"if",
"self",
".",
"_unit_of_measurement_mismatch",
":",
"return",
"\"ERR\"",
"return",
"self",
".",
"_unit_of_measurement"
] | [
178,
4
] | [
182,
40
] | python | en | ['en', 'en', 'en'] | True |
MinMaxSensor.should_poll | (self) | No polling needed. | No polling needed. | def should_poll(self):
"""No polling needed."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
185,
4
] | [
187,
20
] | python | en | ['en', 'en', 'en'] | True |
MinMaxSensor.device_state_attributes | (self) | Return the state attributes of the sensor. | Return the state attributes of the sensor. | def device_state_attributes(self):
"""Return the state attributes of the sensor."""
return {
attr: getattr(self, attr)
for attr in ATTR_TO_PROPERTY
if getattr(self, attr) is not None
} | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"{",
"attr",
":",
"getattr",
"(",
"self",
",",
"attr",
")",
"for",
"attr",
"in",
"ATTR_TO_PROPERTY",
"if",
"getattr",
"(",
"self",
",",
"attr",
")",
"is",
"not",
"None",
"}"
] | [
190,
4
] | [
196,
9
] | python | en | ['en', 'en', 'en'] | True |
MinMaxSensor.icon | (self) | Return the icon to use in the frontend, if any. | Return the icon to use in the frontend, if any. | def icon(self):
"""Return the icon to use in the frontend, if any."""
return ICON | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"ICON"
] | [
199,
4
] | [
201,
19
] | python | en | ['en', 'en', 'en'] | True |
MinMaxSensor._async_min_max_sensor_state_listener | (self, event) | Handle the sensor state changes. | Handle the sensor state changes. | def _async_min_max_sensor_state_listener(self, event):
"""Handle the sensor state changes."""
new_state = event.data.get("new_state")
entity = event.data.get("entity_id")
if new_state.state is None or new_state.state in [
STATE_UNKNOWN,
STATE_UNAVAILABLE,
... | [
"def",
"_async_min_max_sensor_state_listener",
"(",
"self",
",",
"event",
")",
":",
"new_state",
"=",
"event",
".",
"data",
".",
"get",
"(",
"\"new_state\"",
")",
"entity",
"=",
"event",
".",
"data",
".",
"get",
"(",
"\"entity_id\"",
")",
"if",
"new_state",
... | [
204,
4
] | [
241,
35
] | python | en | ['en', 'en', 'en'] | True |
MinMaxSensor._calc_values | (self) | Calculate the values. | Calculate the values. | def _calc_values(self):
"""Calculate the values."""
sensor_values = [
(entity_id, self.states[entity_id])
for entity_id in self._entity_ids
if entity_id in self.states
]
self.min_entity_id, self.min_value = calc_min(sensor_values)
self.max_enti... | [
"def",
"_calc_values",
"(",
"self",
")",
":",
"sensor_values",
"=",
"[",
"(",
"entity_id",
",",
"self",
".",
"states",
"[",
"entity_id",
"]",
")",
"for",
"entity_id",
"in",
"self",
".",
"_entity_ids",
"if",
"entity_id",
"in",
"self",
".",
"states",
"]",
... | [
244,
4
] | [
254,
68
] | python | en | ['en', 'en', 'en'] | True |
load_tf_weights_in_mobilebert | (model, config, tf_checkpoint_path) | Load tf checkpoints in a pytorch model. | Load tf checkpoints in a pytorch model. | def load_tf_weights_in_mobilebert(model, config, tf_checkpoint_path):
"""Load tf checkpoints in a pytorch model."""
try:
import re
import numpy as np
import tensorflow as tf
except ImportError:
logger.error(
"Loading a TensorFlow model in PyTorch, requires Tensor... | [
"def",
"load_tf_weights_in_mobilebert",
"(",
"model",
",",
"config",
",",
"tf_checkpoint_path",
")",
":",
"try",
":",
"import",
"re",
"import",
"numpy",
"as",
"np",
"import",
"tensorflow",
"as",
"tf",
"except",
"ImportError",
":",
"logger",
".",
"error",
"(",
... | [
65,
0
] | [
140,
16
] | python | en | ['en', 'en', 'en'] | True |
MobileBertPreTrainedModel._init_weights | (self, module) | Initialize the weights | Initialize the weights | def _init_weights(self, module):
""" Initialize the weights """
if isinstance(module, nn.Linear):
# Slightly different from the TF version which uses truncated_normal for initialization
# cf https://github.com/pytorch/pytorch/pull/5617
module.weight.data.normal_(mean=... | [
"def",
"_init_weights",
"(",
"self",
",",
"module",
")",
":",
"if",
"isinstance",
"(",
"module",
",",
"nn",
".",
"Linear",
")",
":",
"# Slightly different from the TF version which uses truncated_normal for initialization",
"# cf https://github.com/pytorch/pytorch/pull/5617",
... | [
670,
4
] | [
684,
41
] | python | en | ['en', 'en', 'en'] | True |
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 |
test_get_actions | (hass, device_reg, entity_reg) | Test we get the expected actions from a cover. | Test we get the expected actions from a cover. | async def test_get_actions(hass, device_reg, entity_reg):
"""Test we get the expected actions from a cover."""
platform = getattr(hass.components, f"test.{DOMAIN}")
platform.init()
ent = platform.ENTITIES[0]
config_entry = MockConfigEntry(domain="test", data={})
config_entry.add_to_hass(hass)
... | [
"async",
"def",
"test_get_actions",
"(",
"hass",
",",
"device_reg",
",",
"entity_reg",
")",
":",
"platform",
"=",
"getattr",
"(",
"hass",
".",
"components",
",",
"f\"test.{DOMAIN}\"",
")",
"platform",
".",
"init",
"(",
")",
"ent",
"=",
"platform",
".",
"EN... | [
32,
0
] | [
71,
48
] | python | en | ['en', 'en', 'en'] | True |
test_get_actions_tilt | (hass, device_reg, entity_reg) | Test we get the expected actions from a cover. | Test we get the expected actions from a cover. | async def test_get_actions_tilt(hass, device_reg, entity_reg):
"""Test we get the expected actions from a cover."""
platform = getattr(hass.components, f"test.{DOMAIN}")
platform.init()
ent = platform.ENTITIES[3]
config_entry = MockConfigEntry(domain="test", data={})
config_entry.add_to_hass(ha... | [
"async",
"def",
"test_get_actions_tilt",
"(",
"hass",
",",
"device_reg",
",",
"entity_reg",
")",
":",
"platform",
"=",
"getattr",
"(",
"hass",
".",
"components",
",",
"f\"test.{DOMAIN}\"",
")",
"platform",
".",
"init",
"(",
")",
"ent",
"=",
"platform",
".",
... | [
74,
0
] | [
125,
48
] | python | en | ['en', 'en', 'en'] | True |
test_get_actions_set_pos | (hass, device_reg, entity_reg) | Test we get the expected actions from a cover. | Test we get the expected actions from a cover. | async def test_get_actions_set_pos(hass, device_reg, entity_reg):
"""Test we get the expected actions from a cover."""
platform = getattr(hass.components, f"test.{DOMAIN}")
platform.init()
ent = platform.ENTITIES[1]
config_entry = MockConfigEntry(domain="test", data={})
config_entry.add_to_hass... | [
"async",
"def",
"test_get_actions_set_pos",
"(",
"hass",
",",
"device_reg",
",",
"entity_reg",
")",
":",
"platform",
"=",
"getattr",
"(",
"hass",
".",
"components",
",",
"f\"test.{DOMAIN}\"",
")",
"platform",
".",
"init",
"(",
")",
"ent",
"=",
"platform",
".... | [
128,
0
] | [
155,
48
] | python | en | ['en', 'en', 'en'] | True |
test_get_actions_set_tilt_pos | (hass, device_reg, entity_reg) | Test we get the expected actions from a cover. | Test we get the expected actions from a cover. | async def test_get_actions_set_tilt_pos(hass, device_reg, entity_reg):
"""Test we get the expected actions from a cover."""
platform = getattr(hass.components, f"test.{DOMAIN}")
platform.init()
ent = platform.ENTITIES[2]
config_entry = MockConfigEntry(domain="test", data={})
config_entry.add_to... | [
"async",
"def",
"test_get_actions_set_tilt_pos",
"(",
"hass",
",",
"device_reg",
",",
"entity_reg",
")",
":",
"platform",
"=",
"getattr",
"(",
"hass",
".",
"components",
",",
"f\"test.{DOMAIN}\"",
")",
"platform",
".",
"init",
"(",
")",
"ent",
"=",
"platform",... | [
158,
0
] | [
203,
48
] | python | en | ['en', 'en', 'en'] | True |
test_get_action_capabilities | (hass, device_reg, entity_reg) | Test we get the expected capabilities from a cover action. | Test we get the expected capabilities from a cover action. | async def test_get_action_capabilities(hass, device_reg, entity_reg):
"""Test we get the expected capabilities from a cover action."""
platform = getattr(hass.components, f"test.{DOMAIN}")
platform.init()
ent = platform.ENTITIES[0]
config_entry = MockConfigEntry(domain="test", data={})
config_e... | [
"async",
"def",
"test_get_action_capabilities",
"(",
"hass",
",",
"device_reg",
",",
"entity_reg",
")",
":",
"platform",
"=",
"getattr",
"(",
"hass",
".",
"components",
",",
"f\"test.{DOMAIN}\"",
")",
"platform",
".",
"init",
"(",
")",
"ent",
"=",
"platform",
... | [
206,
0
] | [
231,
51
] | python | en | ['en', 'en', 'en'] | True |
test_get_action_capabilities_set_pos | (hass, device_reg, entity_reg) | Test we get the expected capabilities from a cover action. | Test we get the expected capabilities from a cover action. | async def test_get_action_capabilities_set_pos(hass, device_reg, entity_reg):
"""Test we get the expected capabilities from a cover action."""
platform = getattr(hass.components, f"test.{DOMAIN}")
platform.init()
ent = platform.ENTITIES[1]
config_entry = MockConfigEntry(domain="test", data={})
... | [
"async",
"def",
"test_get_action_capabilities_set_pos",
"(",
"hass",
",",
"device_reg",
",",
"entity_reg",
")",
":",
"platform",
"=",
"getattr",
"(",
"hass",
".",
"components",
",",
"f\"test.{DOMAIN}\"",
")",
"platform",
".",
"init",
"(",
")",
"ent",
"=",
"pla... | [
234,
0
] | [
274,
55
] | python | en | ['en', 'en', 'en'] | True |
test_get_action_capabilities_set_tilt_pos | (hass, device_reg, entity_reg) | Test we get the expected capabilities from a cover action. | Test we get the expected capabilities from a cover action. | async def test_get_action_capabilities_set_tilt_pos(hass, device_reg, entity_reg):
"""Test we get the expected capabilities from a cover action."""
platform = getattr(hass.components, f"test.{DOMAIN}")
platform.init()
ent = platform.ENTITIES[2]
config_entry = MockConfigEntry(domain="test", data={})... | [
"async",
"def",
"test_get_action_capabilities_set_tilt_pos",
"(",
"hass",
",",
"device_reg",
",",
"entity_reg",
")",
":",
"platform",
"=",
"getattr",
"(",
"hass",
".",
"components",
",",
"f\"test.{DOMAIN}\"",
")",
"platform",
".",
"init",
"(",
")",
"ent",
"=",
... | [
277,
0
] | [
317,
55
] | python | en | ['en', 'en', 'en'] | True |
test_action | (hass) | Test for cover actions. | Test for cover actions. | async def test_action(hass):
"""Test for cover actions."""
platform = getattr(hass.components, f"test.{DOMAIN}")
platform.init()
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "test"}})
assert await async_setup_component(
hass,
automation.DOMAIN,
{... | [
"async",
"def",
"test_action",
"(",
"hass",
")",
":",
"platform",
"=",
"getattr",
"(",
"hass",
".",
"components",
",",
"f\"test.{DOMAIN}\"",
")",
"platform",
".",
"init",
"(",
")",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"DOMAIN",
",",
... | [
320,
0
] | [
383,
31
] | python | en | ['en', 'en', 'en'] | True |
test_action_tilt | (hass) | Test for cover tilt actions. | Test for cover tilt actions. | async def test_action_tilt(hass):
"""Test for cover tilt actions."""
platform = getattr(hass.components, f"test.{DOMAIN}")
platform.init()
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "test"}})
assert await async_setup_component(
hass,
automation.DOMAIN,... | [
"async",
"def",
"test_action_tilt",
"(",
"hass",
")",
":",
"platform",
"=",
"getattr",
"(",
"hass",
".",
"components",
",",
"f\"test.{DOMAIN}\"",
")",
"platform",
".",
"init",
"(",
")",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"DOMAIN",
... | [
386,
0
] | [
436,
32
] | python | en | ['da', 'en', 'en'] | True |
test_action_set_position | (hass) | Test for cover set position actions. | Test for cover set position actions. | async def test_action_set_position(hass):
"""Test for cover set position actions."""
platform = getattr(hass.components, f"test.{DOMAIN}")
platform.init()
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "test"}})
assert await async_setup_component(
hass,
au... | [
"async",
"def",
"test_action_set_position",
"(",
"hass",
")",
":",
"platform",
"=",
"getattr",
"(",
"hass",
".",
"components",
",",
"f\"test.{DOMAIN}\"",
")",
"platform",
".",
"init",
"(",
")",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"DOM... | [
439,
0
] | [
494,
56
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass, config) | Initialize OwnTracks component. | Initialize OwnTracks component. | async def async_setup(hass, config):
"""Initialize OwnTracks component."""
hass.data[DOMAIN] = {"config": config[DOMAIN], "devices": {}, "unsub": None}
if not hass.config_entries.async_entries(DOMAIN):
hass.async_create_task(
hass.config_entries.flow.async_init(
DOMAIN, c... | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"=",
"{",
"\"config\"",
":",
"config",
"[",
"DOMAIN",
"]",
",",
"\"devices\"",
":",
"{",
"}",
",",
"\"unsub\"",
":",
"None",
"}",
"if",
"n... | [
58,
0
] | [
68,
15
] | python | en | ['de', 'en', 'en'] | True |
async_setup_entry | (hass, entry) | Set up OwnTracks entry. | Set up OwnTracks entry. | async def async_setup_entry(hass, entry):
"""Set up OwnTracks entry."""
config = hass.data[DOMAIN]["config"]
max_gps_accuracy = config.get(CONF_MAX_GPS_ACCURACY)
waypoint_import = config.get(CONF_WAYPOINT_IMPORT)
waypoint_whitelist = config.get(CONF_WAYPOINT_WHITELIST)
secret = config.get(CONF_S... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"entry",
")",
":",
"config",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"\"config\"",
"]",
"max_gps_accuracy",
"=",
"config",
".",
"get",
"(",
"CONF_MAX_GPS_ACCURACY",
")",
"waypoint_import",
"="... | [
71,
0
] | [
111,
15
] | python | en | ['en', 'da', 'en'] | True |
async_unload_entry | (hass, entry) | Unload an OwnTracks config entry. | Unload an OwnTracks config entry. | async def async_unload_entry(hass, entry):
"""Unload an OwnTracks config entry."""
hass.components.webhook.async_unregister(entry.data[CONF_WEBHOOK_ID])
await hass.config_entries.async_forward_entry_unload(entry, "device_tracker")
hass.data[DOMAIN]["unsub"]()
return True | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
",",
"entry",
")",
":",
"hass",
".",
"components",
".",
"webhook",
".",
"async_unregister",
"(",
"entry",
".",
"data",
"[",
"CONF_WEBHOOK_ID",
"]",
")",
"await",
"hass",
".",
"config_entries",
".",
"async_fo... | [
114,
0
] | [
120,
15
] | python | en | ['en', 'en', 'en'] | True |
async_remove_entry | (hass, entry) | Remove an OwnTracks config entry. | Remove an OwnTracks config entry. | async def async_remove_entry(hass, entry):
"""Remove an OwnTracks config entry."""
if not entry.data.get("cloudhook"):
return
await hass.components.cloud.async_delete_cloudhook(entry.data[CONF_WEBHOOK_ID]) | [
"async",
"def",
"async_remove_entry",
"(",
"hass",
",",
"entry",
")",
":",
"if",
"not",
"entry",
".",
"data",
".",
"get",
"(",
"\"cloudhook\"",
")",
":",
"return",
"await",
"hass",
".",
"components",
".",
"cloud",
".",
"async_delete_cloudhook",
"(",
"entry... | [
123,
0
] | [
128,
83
] | python | en | ['en', 'en', 'en'] | True |
async_connect_mqtt | (hass, component) | Subscribe to MQTT topic. | Subscribe to MQTT topic. | async def async_connect_mqtt(hass, component):
"""Subscribe to MQTT topic."""
context = hass.data[DOMAIN]["context"]
async def async_handle_mqtt_message(msg):
"""Handle incoming OwnTracks message."""
try:
message = json.loads(msg.payload)
except ValueError:
#... | [
"async",
"def",
"async_connect_mqtt",
"(",
"hass",
",",
"component",
")",
":",
"context",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"\"context\"",
"]",
"async",
"def",
"async_handle_mqtt_message",
"(",
"msg",
")",
":",
"\"\"\"Handle incoming OwnTracks m... | [
131,
0
] | [
151,
15
] | python | en | ['en', 'en', 'en'] | True |
handle_webhook | (hass, webhook_id, request) | Handle webhook callback.
iOS sets the "topic" as part of the payload.
Android does not set a topic but adds headers to the request.
| Handle webhook callback. | async def handle_webhook(hass, webhook_id, request):
"""Handle webhook callback.
iOS sets the "topic" as part of the payload.
Android does not set a topic but adds headers to the request.
"""
context = hass.data[DOMAIN]["context"]
topic_base = re.sub("/#$", "", context.mqtt_topic)
try:
... | [
"async",
"def",
"handle_webhook",
"(",
"hass",
",",
"webhook_id",
",",
"request",
")",
":",
"context",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"\"context\"",
"]",
"topic_base",
"=",
"re",
".",
"sub",
"(",
"\"/#$\"",
",",
"\"\"",
",",
"contex... | [
154,
0
] | [
212,
34
] | python | en | ['en', 'xh', 'en'] | True |
OwnTracksContext.__init__ | (
self,
hass,
secret,
max_gps_accuracy,
import_waypoints,
waypoint_whitelist,
region_mapping,
events_only,
mqtt_topic,
) | Initialize an OwnTracks context. | Initialize an OwnTracks context. | def __init__(
self,
hass,
secret,
max_gps_accuracy,
import_waypoints,
waypoint_whitelist,
region_mapping,
events_only,
mqtt_topic,
):
"""Initialize an OwnTracks context."""
self.hass = hass
self.secret = secret
s... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"secret",
",",
"max_gps_accuracy",
",",
"import_waypoints",
",",
"waypoint_whitelist",
",",
"region_mapping",
",",
"events_only",
",",
"mqtt_topic",
",",
")",
":",
"self",
".",
"hass",
"=",
"hass",
"self",
".... | [
218,
4
] | [
240,
30
] | python | en | ['en', 'en', 'en'] | True |
OwnTracksContext.async_valid_accuracy | (self, message) | Check if we should ignore this message. | Check if we should ignore this message. | def async_valid_accuracy(self, message):
"""Check if we should ignore this message."""
acc = message.get("acc")
if acc is None:
return False
try:
acc = float(acc)
except ValueError:
return False
if acc == 0:
_LOGGER.warni... | [
"def",
"async_valid_accuracy",
"(",
"self",
",",
"message",
")",
":",
"acc",
"=",
"message",
".",
"get",
"(",
"\"acc\"",
")",
"if",
"acc",
"is",
"None",
":",
"return",
"False",
"try",
":",
"acc",
"=",
"float",
"(",
"acc",
")",
"except",
"ValueError",
... | [
243,
4
] | [
272,
19
] | python | en | ['en', 'en', 'en'] | True |
OwnTracksContext.set_async_see | (self, func) | Set a new async_see function. | Set a new async_see function. | def set_async_see(self, func):
"""Set a new async_see function."""
self.async_see = func
for msg in self._pending_msg:
func(**msg)
self._pending_msg.clear() | [
"def",
"set_async_see",
"(",
"self",
",",
"func",
")",
":",
"self",
".",
"async_see",
"=",
"func",
"for",
"msg",
"in",
"self",
".",
"_pending_msg",
":",
"func",
"(",
"*",
"*",
"msg",
")",
"self",
".",
"_pending_msg",
".",
"clear",
"(",
")"
] | [
275,
4
] | [
280,
33
] | python | en | ['en', 'en', 'en'] | True |
OwnTracksContext.async_see | (self, **data) | Send a see message to the device tracker. | Send a see message to the device tracker. | def async_see(self, **data):
"""Send a see message to the device tracker."""
self._pending_msg.append(data) | [
"def",
"async_see",
"(",
"self",
",",
"*",
"*",
"data",
")",
":",
"self",
".",
"_pending_msg",
".",
"append",
"(",
"data",
")"
] | [
284,
4
] | [
286,
38
] | python | en | ['en', 'en', 'en'] | True |
OwnTracksContext.async_see_beacons | (self, hass, dev_id, kwargs_param) | Set active beacons to the current location. | Set active beacons to the current location. | def async_see_beacons(self, hass, dev_id, kwargs_param):
"""Set active beacons to the current location."""
kwargs = kwargs_param.copy()
# Mobile beacons should always be set to the location of the
# tracking device. I get the device state and make the necessary
# changes to kwar... | [
"def",
"async_see_beacons",
"(",
"self",
",",
"hass",
",",
"dev_id",
",",
"kwargs_param",
")",
":",
"kwargs",
"=",
"kwargs_param",
".",
"copy",
"(",
")",
"# Mobile beacons should always be set to the location of the",
"# tracking device. I get the device state and make the ne... | [
289,
4
] | [
316,
36
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the BMW Connected Drive lock. | Set up the BMW Connected Drive lock. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the BMW Connected Drive lock."""
accounts = hass.data[BMW_DOMAIN]
_LOGGER.debug("Found BMW accounts: %s", ", ".join([a.name for a in accounts]))
devices = []
for account in accounts:
if not account.read_only:
... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"accounts",
"=",
"hass",
".",
"data",
"[",
"BMW_DOMAIN",
"]",
"_LOGGER",
".",
"debug",
"(",
"\"Found BMW accounts: %s\"",
",",
"\", \"",
"... | [
15,
0
] | [
25,
31
] | python | en | ['en', 'en', 'en'] | True |
BMWLock.__init__ | (self, account, vehicle, attribute: str, sensor_name) | Initialize the lock. | Initialize the lock. | def __init__(self, account, vehicle, attribute: str, sensor_name):
"""Initialize the lock."""
self._account = account
self._vehicle = vehicle
self._attribute = attribute
self._name = f"{self._vehicle.name} {self._attribute}"
self._unique_id = f"{self._vehicle.vin}-{self._... | [
"def",
"__init__",
"(",
"self",
",",
"account",
",",
"vehicle",
",",
"attribute",
":",
"str",
",",
"sensor_name",
")",
":",
"self",
".",
"_account",
"=",
"account",
"self",
".",
"_vehicle",
"=",
"vehicle",
"self",
".",
"_attribute",
"=",
"attribute",
"se... | [
31,
4
] | [
42,
9
] | python | en | ['en', 'en', 'en'] | True |
BMWLock.should_poll | (self) | Do not poll this class.
Updates are triggered from BMWConnectedDriveAccount.
| Do not poll this class. | def should_poll(self):
"""Do not poll this class.
Updates are triggered from BMWConnectedDriveAccount.
"""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
45,
4
] | [
50,
20
] | python | en | ['en', 'lb', 'en'] | True |
BMWLock.unique_id | (self) | Return the unique ID of the lock. | Return the unique ID of the lock. | def unique_id(self):
"""Return the unique ID of the lock."""
return self._unique_id | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unique_id"
] | [
53,
4
] | [
55,
30
] | python | en | ['en', 'la', 'en'] | True |
BMWLock.name | (self) | Return the name of the lock. | Return the name of the lock. | def name(self):
"""Return the name of the lock."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
58,
4
] | [
60,
25
] | python | en | ['en', 'en', 'en'] | True |
BMWLock.device_state_attributes | (self) | Return the state attributes of the lock. | Return the state attributes of the lock. | def device_state_attributes(self):
"""Return the state attributes of the lock."""
vehicle_state = self._vehicle.state
result = {
"car": self._vehicle.name,
ATTR_ATTRIBUTION: ATTRIBUTION,
}
if self.door_lock_state_available:
result["door_lock_st... | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"vehicle_state",
"=",
"self",
".",
"_vehicle",
".",
"state",
"result",
"=",
"{",
"\"car\"",
":",
"self",
".",
"_vehicle",
".",
"name",
",",
"ATTR_ATTRIBUTION",
":",
"ATTRIBUTION",
",",
"}",
"if",
"se... | [
63,
4
] | [
73,
21
] | python | en | ['en', 'en', 'en'] | True |
BMWLock.is_locked | (self) | Return true if lock is locked. | Return true if lock is locked. | def is_locked(self):
"""Return true if lock is locked."""
return self._state == STATE_LOCKED | [
"def",
"is_locked",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state",
"==",
"STATE_LOCKED"
] | [
76,
4
] | [
78,
42
] | python | en | ['en', 'mt', 'en'] | True |
BMWLock.lock | (self, **kwargs) | Lock the car. | Lock the car. | def lock(self, **kwargs):
"""Lock the car."""
_LOGGER.debug("%s: locking doors", self._vehicle.name)
# Optimistic state set here because it takes some time before the
# update callback response
self._state = STATE_LOCKED
self.schedule_update_ha_state()
self._vehic... | [
"def",
"lock",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"%s: locking doors\"",
",",
"self",
".",
"_vehicle",
".",
"name",
")",
"# Optimistic state set here because it takes some time before the",
"# update callback response",
"se... | [
80,
4
] | [
87,
64
] | python | en | ['en', 'ms', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.