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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
add_group | (organisation, group) |
Create a group for the given organisation.
|
Create a group for the given organisation.
| def add_group(organisation, group):
"""
Create a group for the given organisation.
"""
groupobj = organisation.add_group(group)
if groupobj is None:
msg = "Group {} already exists in organisation {}."
sys.exit(msg.format(group, organisation))
else:
mark_imperative(organis... | [
"def",
"add_group",
"(",
"organisation",
",",
"group",
")",
":",
"groupobj",
"=",
"organisation",
".",
"add_group",
"(",
"group",
")",
"if",
"groupobj",
"is",
"None",
":",
"msg",
"=",
"\"Group {} already exists in organisation {}.\"",
"sys",
".",
"exit",
"(",
... | [
616,
0
] | [
625,
67
] | python | en | ['en', 'error', 'th'] | False |
del_group | (organisation, group) |
Delete a group from the given organisation.
|
Delete a group from the given organisation.
| def del_group(organisation, group):
"""
Delete a group from the given organisation.
"""
organisation.del_group(group)
click("Group {} deleted.".format(group), err=True) | [
"def",
"del_group",
"(",
"organisation",
",",
"group",
")",
":",
"organisation",
".",
"del_group",
"(",
"group",
")",
"click",
"(",
"\"Group {} deleted.\"",
".",
"format",
"(",
"group",
")",
",",
"err",
"=",
"True",
")"
] | [
631,
0
] | [
636,
54
] | python | en | ['en', 'error', 'th'] | False |
add_or_delete | (old, new, add_fun, del_fun) |
Given an 'old' and 'new' list, figure out the intersections and invoke
'add_fun' against every element that is not in the 'old' list and 'del_fun'
against every element that is not in the 'new' list.
Returns a tuple where the first element is the list of elements that were
added and the second ele... |
Given an 'old' and 'new' list, figure out the intersections and invoke
'add_fun' against every element that is not in the 'old' list and 'del_fun'
against every element that is not in the 'new' list. | def add_or_delete(old, new, add_fun, del_fun):
"""
Given an 'old' and 'new' list, figure out the intersections and invoke
'add_fun' against every element that is not in the 'old' list and 'del_fun'
against every element that is not in the 'new' list.
Returns a tuple where the first element is the l... | [
"def",
"add_or_delete",
"(",
"old",
",",
"new",
",",
"add_fun",
",",
"del_fun",
")",
":",
"old_set",
"=",
"set",
"(",
"old",
")",
"new_set",
"=",
"set",
"(",
"new",
")",
"to_delete",
"=",
"old_set",
"-",
"new_set",
"to_add",
"=",
"new_set",
"-",
"old... | [
639,
0
] | [
656,
28
] | python | en | ['en', 'error', 'th'] | False |
process_json | (json_file) |
Create and delete users, groups and organisations based on a JSON file.
The structure of this file is exactly the same as the
'services.taskserver.organisations' option of the NixOS module and is used
for declaratively adding and deleting users.
Hence this subcommand is not recommended outside of... |
Create and delete users, groups and organisations based on a JSON file. | def process_json(json_file):
"""
Create and delete users, groups and organisations based on a JSON file.
The structure of this file is exactly the same as the
'services.taskserver.organisations' option of the NixOS module and is used
for declaratively adding and deleting users.
Hence this subc... | [
"def",
"process_json",
"(",
"json_file",
")",
":",
"data",
"=",
"json",
".",
"load",
"(",
"json_file",
")",
"mgr",
"=",
"Manager",
"(",
"ignore_imperative",
"=",
"True",
")",
"add_or_delete",
"(",
"mgr",
".",
"orgs",
".",
"keys",
"(",
")",
",",
"data",... | [
661,
0
] | [
683,
51
] | python | en | ['en', 'error', 'th'] | False |
Organisation.add_user | (self, name) |
Create a new user along with a certificate and key.
Returns a 'User' object or None if the user already exists.
|
Create a new user along with a certificate and key. | def add_user(self, name):
"""
Create a new user along with a certificate and key.
Returns a 'User' object or None if the user already exists.
"""
if self.ignore_imperative and is_imperative(self.name):
return None
if name not in self.users.keys():
... | [
"def",
"add_user",
"(",
"self",
",",
"name",
")",
":",
"if",
"self",
".",
"ignore_imperative",
"and",
"is_imperative",
"(",
"self",
".",
"name",
")",
":",
"return",
"None",
"if",
"name",
"not",
"in",
"self",
".",
"users",
".",
"keys",
"(",
")",
":",
... | [
293,
4
] | [
313,
19
] | python | en | ['en', 'error', 'th'] | False |
Organisation.del_user | (self, name) |
Delete a user and revoke its keys.
|
Delete a user and revoke its keys.
| def del_user(self, name):
"""
Delete a user and revoke its keys.
"""
if name in self.users.keys():
user = self.get_user(name)
if self.ignore_imperative and \
is_imperative(self.name, "users", user.key):
return
# Work aro... | [
"def",
"del_user",
"(",
"self",
",",
"name",
")",
":",
"if",
"name",
"in",
"self",
".",
"users",
".",
"keys",
"(",
")",
":",
"user",
"=",
"self",
".",
"get_user",
"(",
"name",
")",
"if",
"self",
".",
"ignore_imperative",
"and",
"is_imperative",
"(",
... | [
315,
4
] | [
329,
38
] | python | en | ['en', 'error', 'th'] | False |
Organisation.add_group | (self, name) |
Create a new group.
Returns a 'Group' object or None if the group already exists.
|
Create a new group. | def add_group(self, name):
"""
Create a new group.
Returns a 'Group' object or None if the group already exists.
"""
if self.ignore_imperative and is_imperative(self.name):
return None
if name not in self.groups.keys():
taskd_cmd("add", "group", s... | [
"def",
"add_group",
"(",
"self",
",",
"name",
")",
":",
"if",
"self",
".",
"ignore_imperative",
"and",
"is_imperative",
"(",
"self",
".",
"name",
")",
":",
"return",
"None",
"if",
"name",
"not",
"in",
"self",
".",
"groups",
".",
"keys",
"(",
")",
":"... | [
331,
4
] | [
344,
19
] | python | en | ['en', 'error', 'th'] | False |
Organisation.del_group | (self, name) |
Delete a group.
|
Delete a group.
| def del_group(self, name):
"""
Delete a group.
"""
if name in self.users.keys():
if self.ignore_imperative and \
is_imperative(self.name, "groups", name):
return
taskd_cmd("remove", "group", self.name, name)
del self._laz... | [
"def",
"del_group",
"(",
"self",
",",
"name",
")",
":",
"if",
"name",
"in",
"self",
".",
"users",
".",
"keys",
"(",
")",
":",
"if",
"self",
".",
"ignore_imperative",
"and",
"is_imperative",
"(",
"self",
".",
"name",
",",
"\"groups\"",
",",
"name",
")... | [
346,
4
] | [
355,
39
] | python | en | ['en', 'error', 'th'] | False |
Manager.__init__ | (self, ignore_imperative=False) |
Instantiates an organisations manager.
If ignore_imperative is True, all actions that modify data are checked
whether they're created imperatively and if so, they will result in no
operation.
|
Instantiates an organisations manager. | def __init__(self, ignore_imperative=False):
"""
Instantiates an organisations manager.
If ignore_imperative is True, all actions that modify data are checked
whether they're created imperatively and if so, they will result in no
operation.
"""
self.ignore_impera... | [
"def",
"__init__",
"(",
"self",
",",
"ignore_imperative",
"=",
"False",
")",
":",
"self",
".",
"ignore_imperative",
"=",
"ignore_imperative"
] | [
381,
4
] | [
389,
50
] | python | en | ['en', 'error', 'th'] | False |
Manager.add_org | (self, name) |
Create a new organisation.
Returns an 'Organisation' object or None if the organisation already
exists.
|
Create a new organisation. | def add_org(self, name):
"""
Create a new organisation.
Returns an 'Organisation' object or None if the organisation already
exists.
"""
if name not in self.orgs.keys():
taskd_cmd("add", "org", name)
neworg = Organisation(name, self.ignore_imperat... | [
"def",
"add_org",
"(",
"self",
",",
"name",
")",
":",
"if",
"name",
"not",
"in",
"self",
".",
"orgs",
".",
"keys",
"(",
")",
":",
"taskd_cmd",
"(",
"\"add\"",
",",
"\"org\"",
",",
"name",
")",
"neworg",
"=",
"Organisation",
"(",
"name",
",",
"self"... | [
391,
4
] | [
403,
19
] | python | en | ['en', 'error', 'th'] | False |
Manager.del_org | (self, name) |
Delete and revoke keys of an organisation with all its users and
groups.
|
Delete and revoke keys of an organisation with all its users and
groups.
| def del_org(self, name):
"""
Delete and revoke keys of an organisation with all its users and
groups.
"""
org = self.get_org(name)
if org is not None:
if self.ignore_imperative and is_imperative(name):
return
for user in org.users.k... | [
"def",
"del_org",
"(",
"self",
",",
"name",
")",
":",
"org",
"=",
"self",
".",
"get_org",
"(",
"name",
")",
"if",
"org",
"is",
"not",
"None",
":",
"if",
"self",
".",
"ignore_imperative",
"and",
"is_imperative",
"(",
"name",
")",
":",
"return",
"for",... | [
405,
4
] | [
419,
37
] | python | en | ['en', 'error', 'th'] | False |
async_setup | (hass) | Set up the Group config API. | Set up the Group config API. | async def async_setup(hass):
"""Set up the Group config API."""
async def hook(action, config_key):
"""post_write_hook for Config View that reloads groups."""
await hass.services.async_call(DOMAIN, SERVICE_RELOAD)
hass.http.register_view(
EditKeyBasedConfigView(
"group"... | [
"async",
"def",
"async_setup",
"(",
"hass",
")",
":",
"async",
"def",
"hook",
"(",
"action",
",",
"config_key",
")",
":",
"\"\"\"post_write_hook for Config View that reloads groups.\"\"\"",
"await",
"hass",
".",
"services",
".",
"async_call",
"(",
"DOMAIN",
",",
"... | [
15,
0
] | [
32,
15
] | python | en | ['en', 'pt', 'en'] | True |
async_describe_on_off_states | (
hass: HomeAssistantType, registry: GroupIntegrationRegistry
) | Describe group on off states. | Describe group on off states. | def async_describe_on_off_states(
hass: HomeAssistantType, registry: GroupIntegrationRegistry
) -> None:
"""Describe group on off states."""
return | [
"def",
"async_describe_on_off_states",
"(",
"hass",
":",
"HomeAssistantType",
",",
"registry",
":",
"GroupIntegrationRegistry",
")",
"->",
"None",
":",
"return"
] | [
36,
0
] | [
40,
10
] | python | en | ['en', 'en', 'en'] | True |
convert | (value: float, unit_1: str, unit_2: str) | Convert one unit of measurement to another. | Convert one unit of measurement to another. | def convert(value: float, unit_1: str, unit_2: str) -> float:
"""Convert one unit of measurement to another."""
if unit_1 not in VALID_UNITS:
raise ValueError(UNIT_NOT_RECOGNIZED_TEMPLATE.format(unit_1, PRESSURE))
if unit_2 not in VALID_UNITS:
raise ValueError(UNIT_NOT_RECOGNIZED_TEMPLATE.fo... | [
"def",
"convert",
"(",
"value",
":",
"float",
",",
"unit_1",
":",
"str",
",",
"unit_2",
":",
"str",
")",
"->",
"float",
":",
"if",
"unit_1",
"not",
"in",
"VALID_UNITS",
":",
"raise",
"ValueError",
"(",
"UNIT_NOT_RECOGNIZED_TEMPLATE",
".",
"format",
"(",
... | [
24,
0
] | [
38,
44
] | python | en | ['en', 'en', 'en'] | True |
test_sync_turn_on | (hass) | Test if async turn_on calls sync turn_on. | Test if async turn_on calls sync turn_on. | async def test_sync_turn_on(hass):
"""Test if async turn_on calls sync turn_on."""
humidifier = MockHumidifierEntity()
humidifier.hass = hass
humidifier.turn_on = MagicMock()
await humidifier.async_turn_on()
assert humidifier.turn_on.called | [
"async",
"def",
"test_sync_turn_on",
"(",
"hass",
")",
":",
"humidifier",
"=",
"MockHumidifierEntity",
"(",
")",
"humidifier",
".",
"hass",
"=",
"hass",
"humidifier",
".",
"turn_on",
"=",
"MagicMock",
"(",
")",
"await",
"humidifier",
".",
"async_turn_on",
"(",... | [
15,
0
] | [
23,
36
] | python | en | ['en', 'cy', 'en'] | True |
test_sync_turn_off | (hass) | Test if async turn_off calls sync turn_off. | Test if async turn_off calls sync turn_off. | async def test_sync_turn_off(hass):
"""Test if async turn_off calls sync turn_off."""
humidifier = MockHumidifierEntity()
humidifier.hass = hass
humidifier.turn_off = MagicMock()
await humidifier.async_turn_off()
assert humidifier.turn_off.called | [
"async",
"def",
"test_sync_turn_off",
"(",
"hass",
")",
":",
"humidifier",
"=",
"MockHumidifierEntity",
"(",
")",
"humidifier",
".",
"hass",
"=",
"hass",
"humidifier",
".",
"turn_off",
"=",
"MagicMock",
"(",
")",
"await",
"humidifier",
".",
"async_turn_off",
"... | [
26,
0
] | [
34,
37
] | python | en | ['en', 'cy', 'en'] | True |
MockHumidifierEntity.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 0 | [
"def",
"supported_features",
"(",
"self",
")",
"->",
"int",
":",
"return",
"0"
] | [
10,
4
] | [
12,
16
] | python | en | ['en', 'en', 'en'] | True |
test_setup_config_full | (hass) | Test setup with all data. | Test setup with all data. | async def test_setup_config_full(hass):
"""Test setup with all data."""
config = {"logentries": {"token": "secret"}}
hass.bus.listen = MagicMock()
assert await async_setup_component(hass, logentries.DOMAIN, config)
assert hass.bus.listen.called
assert EVENT_STATE_CHANGED == hass.bus.listen.call_... | [
"async",
"def",
"test_setup_config_full",
"(",
"hass",
")",
":",
"config",
"=",
"{",
"\"logentries\"",
":",
"{",
"\"token\"",
":",
"\"secret\"",
"}",
"}",
"hass",
".",
"bus",
".",
"listen",
"=",
"MagicMock",
"(",
")",
"assert",
"await",
"async_setup_componen... | [
11,
0
] | [
17,
73
] | python | en | ['en', 'en', 'en'] | True |
test_setup_config_defaults | (hass) | Test setup with defaults. | Test setup with defaults. | async def test_setup_config_defaults(hass):
"""Test setup with defaults."""
config = {"logentries": {"token": "token"}}
hass.bus.listen = MagicMock()
assert await async_setup_component(hass, logentries.DOMAIN, config)
assert hass.bus.listen.called
assert EVENT_STATE_CHANGED == hass.bus.listen.ca... | [
"async",
"def",
"test_setup_config_defaults",
"(",
"hass",
")",
":",
"config",
"=",
"{",
"\"logentries\"",
":",
"{",
"\"token\"",
":",
"\"token\"",
"}",
"}",
"hass",
".",
"bus",
".",
"listen",
"=",
"MagicMock",
"(",
")",
"assert",
"await",
"async_setup_compo... | [
20,
0
] | [
26,
73
] | python | en | ['en', 'en', 'en'] | True |
mock_dump | () | Mock json dumps. | Mock json dumps. | def mock_dump():
"""Mock json dumps."""
with patch("json.dumps") as mock_dump:
yield mock_dump | [
"def",
"mock_dump",
"(",
")",
":",
"with",
"patch",
"(",
"\"json.dumps\"",
")",
"as",
"mock_dump",
":",
"yield",
"mock_dump"
] | [
30,
0
] | [
33,
23
] | python | fr | ['fr', 'fr', 'en'] | True |
mock_requests | () | Mock requests. | Mock requests. | def mock_requests():
"""Mock requests."""
with patch.object(logentries, "requests") as mock_requests:
yield mock_requests | [
"def",
"mock_requests",
"(",
")",
":",
"with",
"patch",
".",
"object",
"(",
"logentries",
",",
"\"requests\"",
")",
"as",
"mock_requests",
":",
"yield",
"mock_requests"
] | [
37,
0
] | [
40,
27
] | python | en | ['en', 'nl', 'en'] | False |
test_event_listener | (hass, mock_dump, mock_requests) | Test event listener. | Test event listener. | async def test_event_listener(hass, mock_dump, mock_requests):
"""Test event listener."""
mock_dump.side_effect = lambda x: x
mock_post = mock_requests.post
mock_requests.exceptions.RequestException = Exception
config = {"logentries": {"token": "token"}}
hass.bus.listen = MagicMock()
assert ... | [
"async",
"def",
"test_event_listener",
"(",
"hass",
",",
"mock_dump",
",",
"mock_requests",
")",
":",
"mock_dump",
".",
"side_effect",
"=",
"lambda",
"x",
":",
"x",
"mock_post",
"=",
"mock_requests",
".",
"post",
"mock_requests",
".",
"exceptions",
".",
"Reque... | [
43,
0
] | [
73,
30
] | python | de | ['fr', 'de', 'nl'] | False |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Tikteck platform. | Set up the Tikteck platform. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Tikteck platform."""
lights = []
for address, device_config in config[CONF_DEVICES].items():
device = {}
device["name"] = device_config[CONF_NAME]
device["password"] = device_config[CONF_PASSWORD]
... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"lights",
"=",
"[",
"]",
"for",
"address",
",",
"device_config",
"in",
"config",
"[",
"CONF_DEVICES",
"]",
".",
"items",
"(",
")",
":"... | [
31,
0
] | [
43,
24
] | python | en | ['en', 'lv', 'en'] | True |
TikteckLight.__init__ | (self, device) | Initialize the light. | Initialize the light. | def __init__(self, device):
"""Initialize the light."""
self._name = device["name"]
self._address = device["address"]
self._password = device["password"]
self._brightness = 255
self._hs = [0, 0]
self._state = False
self.is_valid = True
self._bulb ... | [
"def",
"__init__",
"(",
"self",
",",
"device",
")",
":",
"self",
".",
"_name",
"=",
"device",
"[",
"\"name\"",
"]",
"self",
".",
"_address",
"=",
"device",
"[",
"\"address\"",
"]",
"self",
".",
"_password",
"=",
"device",
"[",
"\"password\"",
"]",
"sel... | [
49,
4
] | [
62,
88
] | python | en | ['en', 'en', 'en'] | True |
TikteckLight.unique_id | (self) | Return the ID of this light. | Return the ID of this light. | def unique_id(self):
"""Return the ID of this light."""
return self._address | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_address"
] | [
65,
4
] | [
67,
28
] | python | en | ['en', 'en', 'en'] | True |
TikteckLight.name | (self) | Return the name of the device if any. | Return the name of the device if any. | def name(self):
"""Return the name of the device if any."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
70,
4
] | [
72,
25
] | python | en | ['en', 'en', 'en'] | True |
TikteckLight.is_on | (self) | Return true if device is on. | Return true if device is on. | def is_on(self):
"""Return true if device is on."""
return self._state | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
75,
4
] | [
77,
26
] | python | en | ['en', 'fy', 'en'] | True |
TikteckLight.brightness | (self) | Return the brightness of this light between 0..255. | Return the brightness of this light between 0..255. | def brightness(self):
"""Return the brightness of this light between 0..255."""
return self._brightness | [
"def",
"brightness",
"(",
"self",
")",
":",
"return",
"self",
".",
"_brightness"
] | [
80,
4
] | [
82,
31
] | python | en | ['en', 'en', 'en'] | True |
TikteckLight.hs_color | (self) | Return the color property. | Return the color property. | def hs_color(self):
"""Return the color property."""
return self._hs | [
"def",
"hs_color",
"(",
"self",
")",
":",
"return",
"self",
".",
"_hs"
] | [
85,
4
] | [
87,
23
] | python | en | ['en', 'en', 'en'] | True |
TikteckLight.supported_features | (self) | Flag supported features. | Flag supported features. | def supported_features(self):
"""Flag supported features."""
return SUPPORT_TIKTECK_LED | [
"def",
"supported_features",
"(",
"self",
")",
":",
"return",
"SUPPORT_TIKTECK_LED"
] | [
90,
4
] | [
92,
34
] | python | en | ['da', 'en', 'en'] | True |
TikteckLight.should_poll | (self) | Return the polling state. | Return the polling state. | def should_poll(self):
"""Return the polling state."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
95,
4
] | [
97,
20
] | python | en | ['en', 'en', 'en'] | True |
TikteckLight.assumed_state | (self) | Return the assumed state. | Return the assumed state. | def assumed_state(self):
"""Return the assumed state."""
return True | [
"def",
"assumed_state",
"(",
"self",
")",
":",
"return",
"True"
] | [
100,
4
] | [
102,
19
] | python | en | ['en', 'en', 'en'] | True |
TikteckLight.set_state | (self, red, green, blue, brightness) | Set the bulb state. | Set the bulb state. | def set_state(self, red, green, blue, brightness):
"""Set the bulb state."""
return self._bulb.set_state(red, green, blue, brightness) | [
"def",
"set_state",
"(",
"self",
",",
"red",
",",
"green",
",",
"blue",
",",
"brightness",
")",
":",
"return",
"self",
".",
"_bulb",
".",
"set_state",
"(",
"red",
",",
"green",
",",
"blue",
",",
"brightness",
")"
] | [
104,
4
] | [
106,
65
] | python | en | ['en', 'en', 'en'] | True |
TikteckLight.turn_on | (self, **kwargs) | Turn the specified light on. | Turn the specified light on. | def turn_on(self, **kwargs):
"""Turn the specified light on."""
self._state = True
hs_color = kwargs.get(ATTR_HS_COLOR)
brightness = kwargs.get(ATTR_BRIGHTNESS)
if hs_color is not None:
self._hs = hs_color
if brightness is not None:
self._brightn... | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_state",
"=",
"True",
"hs_color",
"=",
"kwargs",
".",
"get",
"(",
"ATTR_HS_COLOR",
")",
"brightness",
"=",
"kwargs",
".",
"get",
"(",
"ATTR_BRIGHTNESS",
")",
"if",
"hs_colo... | [
108,
4
] | [
123,
39
] | python | en | ['en', 'en', 'en'] | True |
TikteckLight.turn_off | (self, **kwargs) | Turn the specified light off. | Turn the specified light off. | def turn_off(self, **kwargs):
"""Turn the specified light off."""
self._state = False
self.set_state(0, 0, 0, 0)
self.schedule_update_ha_state() | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_state",
"=",
"False",
"self",
".",
"set_state",
"(",
"0",
",",
"0",
",",
"0",
",",
"0",
")",
"self",
".",
"schedule_update_ha_state",
"(",
")"
] | [
125,
4
] | [
129,
39
] | python | en | ['en', 'en', 'en'] | True |
RadioType.list | (cls) | Return a list of descriptions. | Return a list of descriptions. | def list(cls) -> List[str]:
"""Return a list of descriptions."""
return [e.description for e in RadioType] | [
"def",
"list",
"(",
"cls",
")",
"->",
"List",
"[",
"str",
"]",
":",
"return",
"[",
"e",
".",
"description",
"for",
"e",
"in",
"RadioType",
"]"
] | [
200,
4
] | [
202,
49
] | python | en | ['en', 'ca', 'en'] | True |
RadioType.get_by_description | (cls, description: str) | Get radio by description. | Get radio by description. | def get_by_description(cls, description: str) -> str:
"""Get radio by description."""
for radio in cls:
if radio.description == description:
return radio.name
raise ValueError | [
"def",
"get_by_description",
"(",
"cls",
",",
"description",
":",
"str",
")",
"->",
"str",
":",
"for",
"radio",
"in",
"cls",
":",
"if",
"radio",
".",
"description",
"==",
"description",
":",
"return",
"radio",
".",
"name",
"raise",
"ValueError"
] | [
205,
4
] | [
210,
24
] | python | en | ['en', 'es', 'en'] | True |
RadioType.__init__ | (self, description: str, controller_cls: CALLABLE_T) | Init instance. | Init instance. | def __init__(self, description: str, controller_cls: CALLABLE_T):
"""Init instance."""
self._desc = description
self._ctrl_cls = controller_cls | [
"def",
"__init__",
"(",
"self",
",",
"description",
":",
"str",
",",
"controller_cls",
":",
"CALLABLE_T",
")",
":",
"self",
".",
"_desc",
"=",
"description",
"self",
".",
"_ctrl_cls",
"=",
"controller_cls"
] | [
212,
4
] | [
215,
39
] | python | en | ['en', 'en', 'en'] | False |
RadioType.controller | (self) | Return controller class. | Return controller class. | def controller(self) -> CALLABLE_T:
"""Return controller class."""
return self._ctrl_cls | [
"def",
"controller",
"(",
"self",
")",
"->",
"CALLABLE_T",
":",
"return",
"self",
".",
"_ctrl_cls"
] | [
218,
4
] | [
220,
29
] | python | en | ['sv', 'lb', 'en'] | False |
RadioType.description | (self) | Return radio type description. | Return radio type description. | def description(self) -> str:
"""Return radio type description."""
return self._desc | [
"def",
"description",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_desc"
] | [
223,
4
] | [
225,
25
] | python | en | ['it', 'la', 'en'] | False |
async_setup_entry | (hass: HomeAssistantType, config_entry, async_add_entities) | Set up switches. | Set up switches. | async def async_setup_entry(hass: HomeAssistantType, config_entry, async_add_entities):
"""Set up switches."""
entities = await hass.async_add_executor_job(
add_available_devices, hass, CONF_SWITCH, SmartPlugSwitch
)
if entities:
async_add_entities(entities, update_before_add=True)
... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistantType",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"entities",
"=",
"await",
"hass",
".",
"async_add_executor_job",
"(",
"add_available_devices",
",",
"hass",
",",
"CONF_SWITCH",
",",... | [
31,
0
] | [
41,
30
] | python | en | ['en', 'en', 'en'] | True |
SmartPlugSwitch.__init__ | (self, smartplug: SmartPlug) | Initialize the switch. | Initialize the switch. | def __init__(self, smartplug: SmartPlug):
"""Initialize the switch."""
self.smartplug = smartplug
self._sysinfo = None
self._state = None
self._is_available = False
# Set up emeter cache
self._emeter_params = {}
self._mac = None
self._alias = None... | [
"def",
"__init__",
"(",
"self",
",",
"smartplug",
":",
"SmartPlug",
")",
":",
"self",
".",
"smartplug",
"=",
"smartplug",
"self",
".",
"_sysinfo",
"=",
"None",
"self",
".",
"_state",
"=",
"None",
"self",
".",
"_is_available",
"=",
"False",
"# Set up emeter... | [
47,
4
] | [
60,
25
] | python | en | ['en', 'en', 'en'] | True |
SmartPlugSwitch.unique_id | (self) | Return a unique ID. | Return a unique ID. | def unique_id(self):
"""Return a unique ID."""
return self._device_id | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device_id"
] | [
63,
4
] | [
65,
30
] | python | ca | ['fr', 'ca', 'en'] | False |
SmartPlugSwitch.name | (self) | Return the name of the Smart Plug. | Return the name of the Smart Plug. | def name(self):
"""Return the name of the Smart Plug."""
return self._alias | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_alias"
] | [
68,
4
] | [
70,
26
] | python | en | ['en', 'ceb', 'en'] | True |
SmartPlugSwitch.device_info | (self) | Return information about the device. | Return information about the device. | def device_info(self):
"""Return information about the device."""
return {
"name": self._alias,
"model": self._model,
"manufacturer": "TP-Link",
"connections": {(dr.CONNECTION_NETWORK_MAC, self._mac)},
"sw_version": self._sysinfo["sw_ver"],
... | [
"def",
"device_info",
"(",
"self",
")",
":",
"return",
"{",
"\"name\"",
":",
"self",
".",
"_alias",
",",
"\"model\"",
":",
"self",
".",
"_model",
",",
"\"manufacturer\"",
":",
"\"TP-Link\"",
",",
"\"connections\"",
":",
"{",
"(",
"dr",
".",
"CONNECTION_NET... | [
73,
4
] | [
81,
9
] | python | en | ['en', 'en', 'en'] | True |
SmartPlugSwitch.available | (self) | Return if switch is available. | Return if switch is available. | def available(self) -> bool:
"""Return if switch is available."""
return self._is_available | [
"def",
"available",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"_is_available"
] | [
84,
4
] | [
86,
33
] | python | en | ['en', 'en', 'en'] | True |
SmartPlugSwitch.is_on | (self) | Return true if switch is on. | Return true if switch is on. | def is_on(self):
"""Return true if switch is on."""
return self._state | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
89,
4
] | [
91,
26
] | python | en | ['en', 'fy', 'en'] | True |
SmartPlugSwitch.turn_on | (self, **kwargs) | Turn the switch on. | Turn the switch on. | def turn_on(self, **kwargs):
"""Turn the switch on."""
self.smartplug.turn_on() | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"smartplug",
".",
"turn_on",
"(",
")"
] | [
93,
4
] | [
95,
32
] | python | en | ['en', 'en', 'en'] | True |
SmartPlugSwitch.turn_off | (self, **kwargs) | Turn the switch off. | Turn the switch off. | def turn_off(self, **kwargs):
"""Turn the switch off."""
self.smartplug.turn_off() | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"smartplug",
".",
"turn_off",
"(",
")"
] | [
97,
4
] | [
99,
33
] | python | en | ['en', 'en', 'en'] | True |
SmartPlugSwitch.device_state_attributes | (self) | Return the state attributes of the device. | Return the state attributes of the device. | def device_state_attributes(self):
"""Return the state attributes of the device."""
return self._emeter_params | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"self",
".",
"_emeter_params"
] | [
102,
4
] | [
104,
34
] | python | en | ['en', 'en', 'en'] | True |
SmartPlugSwitch._plug_from_context | (self) | Return the plug from the context. | Return the plug from the context. | def _plug_from_context(self):
"""Return the plug from the context."""
children = self.smartplug.sys_info["children"]
return next(c for c in children if c["id"] == self.smartplug.context) | [
"def",
"_plug_from_context",
"(",
"self",
")",
":",
"children",
"=",
"self",
".",
"smartplug",
".",
"sys_info",
"[",
"\"children\"",
"]",
"return",
"next",
"(",
"c",
"for",
"c",
"in",
"children",
"if",
"c",
"[",
"\"id\"",
"]",
"==",
"self",
".",
"smart... | [
107,
4
] | [
110,
77
] | python | en | ['en', 'en', 'en'] | True |
SmartPlugSwitch.update_state | (self) | Update the TP-Link switch's state. | Update the TP-Link switch's state. | def update_state(self):
"""Update the TP-Link switch's state."""
if self.smartplug.context is None:
self._state = self.smartplug.state == self.smartplug.SWITCH_STATE_ON
else:
self._state = self._plug_from_context["state"] == 1 | [
"def",
"update_state",
"(",
"self",
")",
":",
"if",
"self",
".",
"smartplug",
".",
"context",
"is",
"None",
":",
"self",
".",
"_state",
"=",
"self",
".",
"smartplug",
".",
"state",
"==",
"self",
".",
"smartplug",
".",
"SWITCH_STATE_ON",
"else",
":",
"s... | [
112,
4
] | [
117,
63
] | python | en | ['en', 'en', 'en'] | True |
SmartPlugSwitch.attempt_update | (self, update_attempt) | Attempt to get details from the TP-Link switch. | Attempt to get details from the TP-Link switch. | def attempt_update(self, update_attempt):
"""Attempt to get details from the TP-Link switch."""
try:
if not self._sysinfo:
self._sysinfo = self.smartplug.sys_info
self._mac = self._sysinfo["mac"]
self._model = self._sysinfo["model"]
... | [
"def",
"attempt_update",
"(",
"self",
",",
"update_attempt",
")",
":",
"try",
":",
"if",
"not",
"self",
".",
"_sysinfo",
":",
"self",
".",
"_sysinfo",
"=",
"self",
".",
"smartplug",
".",
"sys_info",
"self",
".",
"_mac",
"=",
"self",
".",
"_sysinfo",
"[... | [
119,
4
] | [
170,
24
] | python | en | ['en', 'en', 'en'] | True |
SmartPlugSwitch.async_update | (self) | Update the TP-Link switch's state. | Update the TP-Link switch's state. | async def async_update(self):
"""Update the TP-Link switch's state."""
for update_attempt in range(MAX_ATTEMPTS):
is_ready = await self.hass.async_add_executor_job(
self.attempt_update, update_attempt
)
if is_ready:
self._is_available ... | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"for",
"update_attempt",
"in",
"range",
"(",
"MAX_ATTEMPTS",
")",
":",
"is_ready",
"=",
"await",
"self",
".",
"hass",
".",
"async_add_executor_job",
"(",
"self",
".",
"attempt_update",
",",
"update_attempt... | [
172,
4
] | [
196,
38
] | python | en | ['en', 'en', 'en'] | True |
clear_discovery_hash | (hass, discovery_hash) | Clear entry in ALREADY_DISCOVERED list. | Clear entry in ALREADY_DISCOVERED list. | def clear_discovery_hash(hass, discovery_hash):
"""Clear entry in ALREADY_DISCOVERED list."""
if ALREADY_DISCOVERED not in hass.data:
# Discovery is shutting down
return
del hass.data[ALREADY_DISCOVERED][discovery_hash] | [
"def",
"clear_discovery_hash",
"(",
"hass",
",",
"discovery_hash",
")",
":",
"if",
"ALREADY_DISCOVERED",
"not",
"in",
"hass",
".",
"data",
":",
"# Discovery is shutting down",
"return",
"del",
"hass",
".",
"data",
"[",
"ALREADY_DISCOVERED",
"]",
"[",
"discovery_ha... | [
28,
0
] | [
33,
53
] | python | en | ['en', 'en', 'en'] | True |
set_discovery_hash | (hass, discovery_hash) | Set entry in ALREADY_DISCOVERED list. | Set entry in ALREADY_DISCOVERED list. | def set_discovery_hash(hass, discovery_hash):
"""Set entry in ALREADY_DISCOVERED list."""
hass.data[ALREADY_DISCOVERED][discovery_hash] = {} | [
"def",
"set_discovery_hash",
"(",
"hass",
",",
"discovery_hash",
")",
":",
"hass",
".",
"data",
"[",
"ALREADY_DISCOVERED",
"]",
"[",
"discovery_hash",
"]",
"=",
"{",
"}"
] | [
36,
0
] | [
38,
54
] | python | en | ['en', 'en', 'en'] | True |
async_start | (
hass: HomeAssistantType, discovery_topic, config_entry, tasmota_mqtt, setup_device
) | Start Tasmota device discovery. | Start Tasmota device discovery. | async def async_start(
hass: HomeAssistantType, discovery_topic, config_entry, tasmota_mqtt, setup_device
) -> bool:
"""Start Tasmota device discovery."""
async def _discover_entity(tasmota_entity_config, discovery_hash, platform):
"""Handle adding or updating a discovered entity."""
if not... | [
"async",
"def",
"async_start",
"(",
"hass",
":",
"HomeAssistantType",
",",
"discovery_topic",
",",
"config_entry",
",",
"tasmota_mqtt",
",",
"setup_device",
")",
"->",
"bool",
":",
"async",
"def",
"_discover_entity",
"(",
"tasmota_entity_config",
",",
"discovery_has... | [
41,
0
] | [
165,
61
] | python | en | ['it', 'ru-Latn', 'en'] | False |
async_stop | (hass: HomeAssistantType) | Stop Tasmota device discovery. | Stop Tasmota device discovery. | async def async_stop(hass: HomeAssistantType) -> bool:
"""Stop Tasmota device discovery."""
hass.data.pop(ALREADY_DISCOVERED)
tasmota_discovery = hass.data.pop(TASMOTA_DISCOVERY_INSTANCE)
await tasmota_discovery.stop_discovery() | [
"async",
"def",
"async_stop",
"(",
"hass",
":",
"HomeAssistantType",
")",
"->",
"bool",
":",
"hass",
".",
"data",
".",
"pop",
"(",
"ALREADY_DISCOVERED",
")",
"tasmota_discovery",
"=",
"hass",
".",
"data",
".",
"pop",
"(",
"TASMOTA_DISCOVERY_INSTANCE",
")",
"... | [
168,
0
] | [
172,
44
] | python | en | ['it', 'lt', 'en'] | False |
_state_validator | (config) | Validate the state. | Validate the state. | def _state_validator(config):
"""Validate the state."""
config = copy.deepcopy(config)
for state in SUPPORTED_PRETRIGGER_STATES:
if CONF_DELAY_TIME not in config[state]:
config[state][CONF_DELAY_TIME] = config[CONF_DELAY_TIME]
if CONF_TRIGGER_TIME not in config[state]:
... | [
"def",
"_state_validator",
"(",
"config",
")",
":",
"config",
"=",
"copy",
".",
"deepcopy",
"(",
"config",
")",
"for",
"state",
"in",
"SUPPORTED_PRETRIGGER_STATES",
":",
"if",
"CONF_DELAY_TIME",
"not",
"in",
"config",
"[",
"state",
"]",
":",
"config",
"[",
... | [
73,
0
] | [
85,
17
] | python | en | ['en', 'en', 'en'] | True |
_state_schema | (state) | Validate the state. | Validate the state. | def _state_schema(state):
"""Validate the state."""
schema = {}
if state in SUPPORTED_PRETRIGGER_STATES:
schema[vol.Optional(CONF_DELAY_TIME)] = vol.All(
cv.time_period, cv.positive_timedelta
)
schema[vol.Optional(CONF_TRIGGER_TIME)] = vol.All(
cv.time_period,... | [
"def",
"_state_schema",
"(",
"state",
")",
":",
"schema",
"=",
"{",
"}",
"if",
"state",
"in",
"SUPPORTED_PRETRIGGER_STATES",
":",
"schema",
"[",
"vol",
".",
"Optional",
"(",
"CONF_DELAY_TIME",
")",
"]",
"=",
"vol",
".",
"All",
"(",
"cv",
".",
"time_perio... | [
88,
0
] | [
102,
29
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the manual alarm platform. | Set up the manual alarm platform. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the manual alarm platform."""
add_entities(
[
ManualAlarm(
hass,
config[CONF_NAME],
config.get(CONF_CODE),
config.get(CONF_CODE_TEMPLATE),
... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"add_entities",
"(",
"[",
"ManualAlarm",
"(",
"hass",
",",
"config",
"[",
"CONF_NAME",
"]",
",",
"config",
".",
"get",
"(",
"CONF_CODE",... | [
149,
0
] | [
163,
5
] | python | en | ['en', 'su', 'en'] | True |
ManualAlarm.__init__ | (
self,
hass,
name,
code,
code_template,
code_arm_required,
disarm_after_trigger,
config,
) | Init the manual alarm panel. | Init the manual alarm panel. | def __init__(
self,
hass,
name,
code,
code_template,
code_arm_required,
disarm_after_trigger,
config,
):
"""Init the manual alarm panel."""
self._state = STATE_ALARM_DISARMED
self._hass = hass
self._name = name
i... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"name",
",",
"code",
",",
"code_template",
",",
"code_arm_required",
",",
"disarm_after_trigger",
",",
"config",
",",
")",
":",
"self",
".",
"_state",
"=",
"STATE_ALARM_DISARMED",
"self",
".",
"_hass",
"=",
... | [
177,
4
] | [
211,
9
] | python | en | ['en', 'ja', 'en'] | True |
ManualAlarm.should_poll | (self) | Return the polling state. | Return the polling state. | def should_poll(self):
"""Return the polling state."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
214,
4
] | [
216,
20
] | python | en | ['en', 'en', 'en'] | True |
ManualAlarm.name | (self) | Return the name of the device. | Return the name of the device. | def name(self):
"""Return the name of the device."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
219,
4
] | [
221,
25
] | python | en | ['en', 'en', 'en'] | True |
ManualAlarm.state | (self) | Return the state of the device. | Return the state of the device. | def state(self):
"""Return the state of the device."""
if self._state == STATE_ALARM_TRIGGERED:
if self._within_pending_time(self._state):
return STATE_ALARM_PENDING
trigger_time = self._trigger_time_by_state[self._previous_state]
if (
... | [
"def",
"state",
"(",
"self",
")",
":",
"if",
"self",
".",
"_state",
"==",
"STATE_ALARM_TRIGGERED",
":",
"if",
"self",
".",
"_within_pending_time",
"(",
"self",
".",
"_state",
")",
":",
"return",
"STATE_ALARM_PENDING",
"trigger_time",
"=",
"self",
".",
"_trig... | [
224,
4
] | [
243,
26
] | python | en | ['en', 'en', 'en'] | True |
ManualAlarm.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
| SUPPORT_ALARM_TRIGGER
| SUPPORT_ALARM_ARM_CUSTOM_BYPASS
) | [
"def",
"supported_features",
"(",
"self",
")",
"->",
"int",
":",
"return",
"(",
"SUPPORT_ALARM_ARM_HOME",
"|",
"SUPPORT_ALARM_ARM_AWAY",
"|",
"SUPPORT_ALARM_ARM_NIGHT",
"|",
"SUPPORT_ALARM_TRIGGER",
"|",
"SUPPORT_ALARM_ARM_CUSTOM_BYPASS",
")"
] | [
246,
4
] | [
254,
9
] | python | en | ['en', 'en', 'en'] | True |
ManualAlarm._active_state | (self) | Get the current state. | Get the current state. | def _active_state(self):
"""Get the current state."""
if self.state in (STATE_ALARM_PENDING, STATE_ALARM_ARMING):
return self._previous_state
return self._state | [
"def",
"_active_state",
"(",
"self",
")",
":",
"if",
"self",
".",
"state",
"in",
"(",
"STATE_ALARM_PENDING",
",",
"STATE_ALARM_ARMING",
")",
":",
"return",
"self",
".",
"_previous_state",
"return",
"self",
".",
"_state"
] | [
257,
4
] | [
261,
26
] | python | en | ['en', 'en', 'en'] | True |
ManualAlarm._arming_time | (self, state) | Get the arming time. | Get the arming time. | def _arming_time(self, state):
"""Get the arming time."""
return self._arming_time_by_state[state] | [
"def",
"_arming_time",
"(",
"self",
",",
"state",
")",
":",
"return",
"self",
".",
"_arming_time_by_state",
"[",
"state",
"]"
] | [
263,
4
] | [
265,
48
] | python | en | ['en', 'en', 'en'] | True |
ManualAlarm._pending_time | (self, state) | Get the pending time. | Get the pending time. | def _pending_time(self, state):
"""Get the pending time."""
return self._delay_time_by_state[self._previous_state] | [
"def",
"_pending_time",
"(",
"self",
",",
"state",
")",
":",
"return",
"self",
".",
"_delay_time_by_state",
"[",
"self",
".",
"_previous_state",
"]"
] | [
267,
4
] | [
269,
62
] | python | en | ['en', 'en', 'en'] | True |
ManualAlarm._within_arming_time | (self, state) | Get if the action is in the arming time window. | Get if the action is in the arming time window. | def _within_arming_time(self, state):
"""Get if the action is in the arming time window."""
return self._state_ts + self._arming_time(state) > dt_util.utcnow() | [
"def",
"_within_arming_time",
"(",
"self",
",",
"state",
")",
":",
"return",
"self",
".",
"_state_ts",
"+",
"self",
".",
"_arming_time",
"(",
"state",
")",
">",
"dt_util",
".",
"utcnow",
"(",
")"
] | [
271,
4
] | [
273,
75
] | python | en | ['en', 'en', 'en'] | True |
ManualAlarm._within_pending_time | (self, state) | Get if the action is in the pending time window. | Get if the action is in the pending time window. | def _within_pending_time(self, state):
"""Get if the action is in the pending time window."""
return self._state_ts + self._pending_time(state) > dt_util.utcnow() | [
"def",
"_within_pending_time",
"(",
"self",
",",
"state",
")",
":",
"return",
"self",
".",
"_state_ts",
"+",
"self",
".",
"_pending_time",
"(",
"state",
")",
">",
"dt_util",
".",
"utcnow",
"(",
")"
] | [
275,
4
] | [
277,
76
] | python | en | ['en', 'en', 'en'] | True |
ManualAlarm.code_format | (self) | Return one or more digits/characters. | Return one or more digits/characters. | def code_format(self):
"""Return one or more digits/characters."""
if self._code is None:
return None
if isinstance(self._code, str) and re.search("^\\d+$", self._code):
return alarm.FORMAT_NUMBER
return alarm.FORMAT_TEXT | [
"def",
"code_format",
"(",
"self",
")",
":",
"if",
"self",
".",
"_code",
"is",
"None",
":",
"return",
"None",
"if",
"isinstance",
"(",
"self",
".",
"_code",
",",
"str",
")",
"and",
"re",
".",
"search",
"(",
"\"^\\\\d+$\"",
",",
"self",
".",
"_code",
... | [
280,
4
] | [
286,
32
] | python | en | ['en', 'en', 'en'] | True |
ManualAlarm.code_arm_required | (self) | Whether the code is required for arm actions. | Whether the code is required for arm actions. | def code_arm_required(self):
"""Whether the code is required for arm actions."""
return self._code_arm_required | [
"def",
"code_arm_required",
"(",
"self",
")",
":",
"return",
"self",
".",
"_code_arm_required"
] | [
289,
4
] | [
291,
38
] | python | en | ['en', 'en', 'en'] | True |
ManualAlarm.alarm_disarm | (self, code=None) | Send disarm command. | Send disarm command. | def alarm_disarm(self, code=None):
"""Send disarm command."""
if not self._validate_code(code, STATE_ALARM_DISARMED):
return
self._state = STATE_ALARM_DISARMED
self._state_ts = dt_util.utcnow()
self.schedule_update_ha_state() | [
"def",
"alarm_disarm",
"(",
"self",
",",
"code",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"_validate_code",
"(",
"code",
",",
"STATE_ALARM_DISARMED",
")",
":",
"return",
"self",
".",
"_state",
"=",
"STATE_ALARM_DISARMED",
"self",
".",
"_state_ts",
... | [
293,
4
] | [
300,
39
] | python | en | ['en', 'pt', 'en'] | True |
ManualAlarm.alarm_arm_home | (self, code=None) | Send arm home command. | Send arm home command. | def alarm_arm_home(self, code=None):
"""Send arm home command."""
if self._code_arm_required and not self._validate_code(
code, STATE_ALARM_ARMED_HOME
):
return
self._update_state(STATE_ALARM_ARMED_HOME) | [
"def",
"alarm_arm_home",
"(",
"self",
",",
"code",
"=",
"None",
")",
":",
"if",
"self",
".",
"_code_arm_required",
"and",
"not",
"self",
".",
"_validate_code",
"(",
"code",
",",
"STATE_ALARM_ARMED_HOME",
")",
":",
"return",
"self",
".",
"_update_state",
"(",... | [
302,
4
] | [
309,
50
] | python | en | ['en', 'pt', 'en'] | True |
ManualAlarm.alarm_arm_away | (self, code=None) | Send arm away command. | Send arm away command. | def alarm_arm_away(self, code=None):
"""Send arm away command."""
if self._code_arm_required and not self._validate_code(
code, STATE_ALARM_ARMED_AWAY
):
return
self._update_state(STATE_ALARM_ARMED_AWAY) | [
"def",
"alarm_arm_away",
"(",
"self",
",",
"code",
"=",
"None",
")",
":",
"if",
"self",
".",
"_code_arm_required",
"and",
"not",
"self",
".",
"_validate_code",
"(",
"code",
",",
"STATE_ALARM_ARMED_AWAY",
")",
":",
"return",
"self",
".",
"_update_state",
"(",... | [
311,
4
] | [
318,
50
] | python | en | ['en', 'en', 'en'] | True |
ManualAlarm.alarm_arm_night | (self, code=None) | Send arm night command. | Send arm night command. | def alarm_arm_night(self, code=None):
"""Send arm night command."""
if self._code_arm_required and not self._validate_code(
code, STATE_ALARM_ARMED_NIGHT
):
return
self._update_state(STATE_ALARM_ARMED_NIGHT) | [
"def",
"alarm_arm_night",
"(",
"self",
",",
"code",
"=",
"None",
")",
":",
"if",
"self",
".",
"_code_arm_required",
"and",
"not",
"self",
".",
"_validate_code",
"(",
"code",
",",
"STATE_ALARM_ARMED_NIGHT",
")",
":",
"return",
"self",
".",
"_update_state",
"(... | [
320,
4
] | [
327,
51
] | python | en | ['en', 'zh', 'en'] | True |
ManualAlarm.alarm_arm_custom_bypass | (self, code=None) | Send arm custom bypass command. | Send arm custom bypass command. | def alarm_arm_custom_bypass(self, code=None):
"""Send arm custom bypass command."""
if self._code_arm_required and not self._validate_code(
code, STATE_ALARM_ARMED_CUSTOM_BYPASS
):
return
self._update_state(STATE_ALARM_ARMED_CUSTOM_BYPASS) | [
"def",
"alarm_arm_custom_bypass",
"(",
"self",
",",
"code",
"=",
"None",
")",
":",
"if",
"self",
".",
"_code_arm_required",
"and",
"not",
"self",
".",
"_validate_code",
"(",
"code",
",",
"STATE_ALARM_ARMED_CUSTOM_BYPASS",
")",
":",
"return",
"self",
".",
"_upd... | [
329,
4
] | [
336,
59
] | python | en | ['en', 'ga', 'en'] | True |
ManualAlarm.alarm_trigger | (self, code=None) |
Send alarm trigger command.
No code needed, a trigger time of zero for the current state
disables the alarm.
|
Send alarm trigger command. | def alarm_trigger(self, code=None):
"""
Send alarm trigger command.
No code needed, a trigger time of zero for the current state
disables the alarm.
"""
if not self._trigger_time_by_state[self._active_state]:
return
self._update_state(STATE_ALARM_TRIG... | [
"def",
"alarm_trigger",
"(",
"self",
",",
"code",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"_trigger_time_by_state",
"[",
"self",
".",
"_active_state",
"]",
":",
"return",
"self",
".",
"_update_state",
"(",
"STATE_ALARM_TRIGGERED",
")"
] | [
338,
4
] | [
347,
49
] | python | en | ['en', 'error', 'th'] | False |
ManualAlarm._update_state | (self, state) | Update the state. | Update the state. | def _update_state(self, state):
"""Update the state."""
if self._state == state:
return
self._previous_state = self._state
self._state = state
self._state_ts = dt_util.utcnow()
self.schedule_update_ha_state()
if state == STATE_ALARM_TRIGGERED:
... | [
"def",
"_update_state",
"(",
"self",
",",
"state",
")",
":",
"if",
"self",
".",
"_state",
"==",
"state",
":",
"return",
"self",
".",
"_previous_state",
"=",
"self",
".",
"_state",
"self",
".",
"_state",
"=",
"state",
"self",
".",
"_state_ts",
"=",
"dt_... | [
349,
4
] | [
378,
17
] | python | en | ['en', 'en', 'en'] | True |
ManualAlarm._validate_code | (self, code, state) | Validate given code. | Validate given code. | def _validate_code(self, code, state):
"""Validate given code."""
if self._code is None:
return True
if isinstance(self._code, str):
alarm_code = self._code
else:
alarm_code = self._code.render(
parse_result=False, from_state=self._stat... | [
"def",
"_validate_code",
"(",
"self",
",",
"code",
",",
"state",
")",
":",
"if",
"self",
".",
"_code",
"is",
"None",
":",
"return",
"True",
"if",
"isinstance",
"(",
"self",
".",
"_code",
",",
"str",
")",
":",
"alarm_code",
"=",
"self",
".",
"_code",
... | [
380,
4
] | [
393,
20
] | python | en | ['en', 'en', 'en'] | True |
ManualAlarm.device_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def device_state_attributes(self):
"""Return the state attributes."""
if self.state == STATE_ALARM_PENDING or self.state == STATE_ALARM_ARMING:
return {
ATTR_PREVIOUS_STATE: self._previous_state,
ATTR_NEXT_STATE: self._state,
}
return {} | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"if",
"self",
".",
"state",
"==",
"STATE_ALARM_PENDING",
"or",
"self",
".",
"state",
"==",
"STATE_ALARM_ARMING",
":",
"return",
"{",
"ATTR_PREVIOUS_STATE",
":",
"self",
".",
"_previous_state",
",",
"ATTR_N... | [
396,
4
] | [
403,
17
] | python | en | ['en', 'en', 'en'] | True |
ManualAlarm.async_scheduled_update | (self, now) | Update state at a scheduled point in time. | Update state at a scheduled point in time. | def async_scheduled_update(self, now):
"""Update state at a scheduled point in time."""
self.async_write_ha_state() | [
"def",
"async_scheduled_update",
"(",
"self",
",",
"now",
")",
":",
"self",
".",
"async_write_ha_state",
"(",
")"
] | [
406,
4
] | [
408,
35
] | python | en | ['en', 'en', 'en'] | True |
ManualAlarm.async_added_to_hass | (self) | Run when entity about to be added to hass. | Run when entity about to be added to hass. | async def async_added_to_hass(self):
"""Run when entity about to be added to hass."""
await super().async_added_to_hass()
state = await self.async_get_last_state()
if state:
if (
(
state.state == STATE_ALARM_PENDING
or s... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"await",
"super",
"(",
")",
".",
"async_added_to_hass",
"(",
")",
"state",
"=",
"await",
"self",
".",
"async_get_last_state",
"(",
")",
"if",
"state",
":",
"if",
"(",
"(",
"state",
".",
"state... | [
410,
4
] | [
428,
51
] | python | en | ['en', 'en', 'en'] | True |
test_moon_day1 | (hass) | Test the Moon sensor. | Test the Moon sensor. | async def test_moon_day1(hass):
"""Test the Moon sensor."""
config = {"sensor": {"platform": "moon", "name": "moon_day1"}}
await async_setup_component(hass, HA_DOMAIN, {})
assert await async_setup_component(hass, "sensor", config)
await hass.async_block_till_done()
assert hass.states.get("sens... | [
"async",
"def",
"test_moon_day1",
"(",
"hass",
")",
":",
"config",
"=",
"{",
"\"sensor\"",
":",
"{",
"\"platform\"",
":",
"\"moon\"",
",",
"\"name\"",
":",
"\"moon_day1\"",
"}",
"}",
"await",
"async_setup_component",
"(",
"hass",
",",
"HA_DOMAIN",
",",
"{",
... | [
17,
0
] | [
32,
73
] | python | en | ['en', 'st', 'en'] | True |
test_moon_day2 | (hass) | Test the Moon sensor. | Test the Moon sensor. | async def test_moon_day2(hass):
"""Test the Moon sensor."""
config = {"sensor": {"platform": "moon", "name": "moon_day2"}}
await async_setup_component(hass, HA_DOMAIN, {})
assert await async_setup_component(hass, "sensor", config)
await hass.async_block_till_done()
assert hass.states.get("sens... | [
"async",
"def",
"test_moon_day2",
"(",
"hass",
")",
":",
"config",
"=",
"{",
"\"sensor\"",
":",
"{",
"\"platform\"",
":",
"\"moon\"",
",",
"\"name\"",
":",
"\"moon_day2\"",
"}",
"}",
"await",
"async_setup_component",
"(",
"hass",
",",
"HA_DOMAIN",
",",
"{",
... | [
35,
0
] | [
50,
72
] | python | en | ['en', 'st', 'en'] | True |
async_update_entity | (hass, entity_id) | Run an update action for an entity. | Run an update action for an entity. | async def async_update_entity(hass, entity_id):
"""Run an update action for an entity."""
await hass.services.async_call(
HA_DOMAIN,
SERVICE_UPDATE_ENTITY,
{ATTR_ENTITY_ID: entity_id},
blocking=True,
)
await hass.async_block_till_done() | [
"async",
"def",
"async_update_entity",
"(",
"hass",
",",
"entity_id",
")",
":",
"await",
"hass",
".",
"services",
".",
"async_call",
"(",
"HA_DOMAIN",
",",
"SERVICE_UPDATE_ENTITY",
",",
"{",
"ATTR_ENTITY_ID",
":",
"entity_id",
"}",
",",
"blocking",
"=",
"True"... | [
53,
0
] | [
61,
38
] | python | en | ['br', 'en', 'en'] | True |
is_datetime | (val: str, tzone=None) | Check if a string is datetime, return the datetime if yes. | Check if a string is datetime, return the datetime if yes. | def is_datetime(val: str, tzone=None):
"""Check if a string is datetime, return the datetime if yes."""
try:
# default time zone
if tzone is None:
tzone = UTC
else:
tzone = gettz(tzone)
dt = parse_dt(val)
dt = dt.replace(tzinfo=tzone)
re... | [
"def",
"is_datetime",
"(",
"val",
":",
"str",
",",
"tzone",
"=",
"None",
")",
":",
"try",
":",
"# default time zone",
"if",
"tzone",
"is",
"None",
":",
"tzone",
"=",
"UTC",
"else",
":",
"tzone",
"=",
"gettz",
"(",
"tzone",
")",
"dt",
"=",
"parse_dt",... | [
14,
0
] | [
31,
22
] | python | en | ['en', 'en', 'en'] | True |
convert_val | (val: str, dtype: str, tzone) | A simple function to convert str value into specified data type. | A simple function to convert str value into specified data type. | def convert_val(val: str, dtype: str, tzone):
"""A simple function to convert str value into specified data type."""
result = None
# process the value first
# clear
val = val.strip("\"\'")
# clear space at 2 side
val = val.strip()
# NOTE: we only support numeric value for now
t = d... | [
"def",
"convert_val",
"(",
"val",
":",
"str",
",",
"dtype",
":",
"str",
",",
"tzone",
")",
":",
"result",
"=",
"None",
"# process the value first",
"# clear",
"val",
"=",
"val",
".",
"strip",
"(",
"\"\\\"\\'\"",
")",
"# clear space at 2 side",
"val",
"=",
... | [
34,
0
] | [
64,
17
] | python | en | ['en', 'en', 'en'] | True |
BinaryConverter.add_csv | (self, csv_file: str) | Convert specified csv file into current binary file, this converter will not sort the item.
This method can be called several times to convert multiple csv file into one binary,
the order will be same as calling sequence.
Args:
csv_file(str): Csv to convert.
| Convert specified csv file into current binary file, this converter will not sort the item.
This method can be called several times to convert multiple csv file into one binary,
the order will be same as calling sequence. | def add_csv(self, csv_file: str):
"""Convert specified csv file into current binary file, this converter will not sort the item.
This method can be called several times to convert multiple csv file into one binary,
the order will be same as calling sequence.
Args:
csv_file(s... | [
"def",
"add_csv",
"(",
"self",
",",
"csv_file",
":",
"str",
")",
":",
"with",
"open",
"(",
"csv_file",
",",
"newline",
"=",
"''",
")",
"as",
"csv_fp",
":",
"reader",
"=",
"DictReader",
"(",
"csv_fp",
")",
"# write items",
"self",
".",
"_write_items",
"... | [
113,
4
] | [
125,
37
] | python | en | ['en', 'en', 'en'] | True |
BinaryConverter.flush | (self) | Flush the result into output file. | Flush the result into output file. | def flush(self):
"""Flush the result into output file."""
self._update_header() | [
"def",
"flush",
"(",
"self",
")",
":",
"self",
".",
"_update_header",
"(",
")"
] | [
127,
4
] | [
129,
29
] | python | en | ['en', 'en', 'en'] | True |
BinaryConverter._update_header | (self) | Update file header. | Update file header. | def _update_header(self):
"""Update file header."""
header_bytes = header_struct.pack(
b"MARO",
SINGLE_BIN_FILE_TYPE,
VERSION,
self._item_count,
self._item_size,
self._meta_offset,
self._meta_size,
self._data... | [
"def",
"_update_header",
"(",
"self",
")",
":",
"header_bytes",
"=",
"header_struct",
".",
"pack",
"(",
"b\"MARO\"",
",",
"SINGLE_BIN_FILE_TYPE",
",",
"VERSION",
",",
"self",
".",
"_item_count",
",",
"self",
".",
"_item_size",
",",
"self",
".",
"_meta_offset",... | [
139,
4
] | [
160,
34
] | python | en | ['en', 'de', 'en'] | True |
BinaryConverter._write_meta | (self) | Write file meta. | Write file meta. | def _write_meta(self):
"""Write file meta."""
meta_bytes = self._meta.to_bytes()
# update header info
self._data_offset = self._meta_offset + len(meta_bytes)
self._meta_size = len(meta_bytes)
self._output_fp.write(meta_bytes) | [
"def",
"_write_meta",
"(",
"self",
")",
":",
"meta_bytes",
"=",
"self",
".",
"_meta",
".",
"to_bytes",
"(",
")",
"# update header info",
"self",
".",
"_data_offset",
"=",
"self",
".",
"_meta_offset",
"+",
"len",
"(",
"meta_bytes",
")",
"self",
".",
"_meta_... | [
162,
4
] | [
170,
41
] | python | en | ['fr', 'mi', 'en'] | False |
BinaryConverter._write_items | (self, reader: DictReader) | Write items into binary. | Write items into binary. | def _write_items(self, reader: DictReader):
"""Write items into binary."""
# columns need to convert
columns = self._meta.columns
# values buffer from each row, used to pack into binary
values = [0] * len(columns.keys())
# item binary buffer
buffer = memoryview(by... | [
"def",
"_write_items",
"(",
"self",
",",
"reader",
":",
"DictReader",
")",
":",
"# columns need to convert",
"columns",
"=",
"self",
".",
"_meta",
".",
"columns",
"# values buffer from each row, used to pack into binary",
"values",
"=",
"[",
"0",
"]",
"*",
"len",
... | [
172,
4
] | [
225,
50
] | python | en | ['en', 'lt', 'en'] | True |
validate_mqtt_light | (value) | Validate MQTT light schema. | Validate MQTT light schema. | def validate_mqtt_light(value):
"""Validate MQTT light schema."""
schemas = {
"basic": PLATFORM_SCHEMA_BASIC,
"json": PLATFORM_SCHEMA_JSON,
"template": PLATFORM_SCHEMA_TEMPLATE,
}
return schemas[value[CONF_SCHEMA]](value) | [
"def",
"validate_mqtt_light",
"(",
"value",
")",
":",
"schemas",
"=",
"{",
"\"basic\"",
":",
"PLATFORM_SCHEMA_BASIC",
",",
"\"json\"",
":",
"PLATFORM_SCHEMA_JSON",
",",
"\"template\"",
":",
"PLATFORM_SCHEMA_TEMPLATE",
",",
"}",
"return",
"schemas",
"[",
"value",
"... | [
24,
0
] | [
31,
45
] | python | de | ['de', 'de', 'it'] | True |
async_setup_platform | (
hass: HomeAssistantType, config: ConfigType, async_add_entities, discovery_info=None
) | Set up MQTT light through configuration.yaml. | Set up MQTT light through configuration.yaml. | async def async_setup_platform(
hass: HomeAssistantType, config: ConfigType, async_add_entities, discovery_info=None
):
"""Set up MQTT light through configuration.yaml."""
await async_setup_reload_service(hass, DOMAIN, PLATFORMS)
await _async_setup_entity(hass, config, async_add_entities) | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
":",
"HomeAssistantType",
",",
"config",
":",
"ConfigType",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"await",
"async_setup_reload_service",
"(",
"hass",
",",
"DOMAIN",
",",
"PLATF... | [
39,
0
] | [
44,
63
] | python | en | ['en', 'zh', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up MQTT light dynamically through MQTT discovery. | Set up MQTT light dynamically through MQTT discovery. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up MQTT light dynamically through MQTT discovery."""
async def async_discover(discovery_payload):
"""Discover and add a MQTT light."""
discovery_data = discovery_payload.discovery_data
try:
config = ... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"async",
"def",
"async_discover",
"(",
"discovery_payload",
")",
":",
"\"\"\"Discover and add a MQTT light.\"\"\"",
"discovery_data",
"=",
"discovery_payload",
".",... | [
47,
0
] | [
64,
5
] | python | en | ['en', 'lb', 'en'] | True |
_async_setup_entity | (
hass, config, async_add_entities, config_entry=None, discovery_data=None
) | Set up a MQTT Light. | Set up a MQTT Light. | async def _async_setup_entity(
hass, config, async_add_entities, config_entry=None, discovery_data=None
):
"""Set up a MQTT Light."""
setup_entity = {
"basic": async_setup_entity_basic,
"json": async_setup_entity_json,
"template": async_setup_entity_template,
}
await setup_en... | [
"async",
"def",
"_async_setup_entity",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"config_entry",
"=",
"None",
",",
"discovery_data",
"=",
"None",
")",
":",
"setup_entity",
"=",
"{",
"\"basic\"",
":",
"async_setup_entity_basic",
",",
"\"json\"",
... | [
67,
0
] | [
78,
5
] | python | en | ['en', 'lb', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up an OpenTherm Gateway climate entity. | Set up an OpenTherm Gateway climate entity. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up an OpenTherm Gateway climate entity."""
ents = []
ents.append(
OpenThermClimate(
hass.data[DATA_OPENTHERM_GW][DATA_GATEWAYS][config_entry.data[CONF_ID]],
config_entry.options,
)
)
... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"ents",
"=",
"[",
"]",
"ents",
".",
"append",
"(",
"OpenThermClimate",
"(",
"hass",
".",
"data",
"[",
"DATA_OPENTHERM_GW",
"]",
"[",
"DATA_GATEWAYS",
... | [
39,
0
] | [
49,
28
] | python | en | ['en', 'en', 'en'] | True |
OpenThermClimate.__init__ | (self, gw_dev, options) | Initialize the device. | Initialize the device. | def __init__(self, gw_dev, options):
"""Initialize the device."""
self._gateway = gw_dev
self.entity_id = async_generate_entity_id(
ENTITY_ID_FORMAT, gw_dev.gw_id, hass=gw_dev.hass
)
self.friendly_name = gw_dev.name
self.floor_temp = options.get(CONF_FLOOR_TEM... | [
"def",
"__init__",
"(",
"self",
",",
"gw_dev",
",",
"options",
")",
":",
"self",
".",
"_gateway",
"=",
"gw_dev",
"self",
".",
"entity_id",
"=",
"async_generate_entity_id",
"(",
"ENTITY_ID_FORMAT",
",",
"gw_dev",
".",
"gw_id",
",",
"hass",
"=",
"gw_dev",
".... | [
55,
4
] | [
75,
34
] | 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.