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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
FroniusMeterDevice._update | (self) | Get the values for the current state. | Get the values for the current state. | async def _update(self):
"""Get the values for the current state."""
return await self.bridge.current_meter_data(self._device) | [
"async",
"def",
"_update",
"(",
"self",
")",
":",
"return",
"await",
"self",
".",
"bridge",
".",
"current_meter_data",
"(",
"self",
".",
"_device",
")"
] | [
227,
4
] | [
229,
65
] | python | en | ['en', 'en', 'en'] | True |
FroniusPowerFlow._update | (self) | Get the values for the current state. | Get the values for the current state. | async def _update(self):
"""Get the values for the current state."""
return await self.bridge.current_power_flow() | [
"async",
"def",
"_update",
"(",
"self",
")",
":",
"return",
"await",
"self",
".",
"bridge",
".",
"current_power_flow",
"(",
")"
] | [
235,
4
] | [
237,
53
] | python | en | ['en', 'en', 'en'] | True |
FroniusTemplateSensor.__init__ | (self, parent: FroniusAdapter, name) | Initialize a singular value sensor. | Initialize a singular value sensor. | def __init__(self, parent: FroniusAdapter, name):
"""Initialize a singular value sensor."""
self._name = name
self.parent = parent
self._state = None
self._unit = None | [
"def",
"__init__",
"(",
"self",
",",
"parent",
":",
"FroniusAdapter",
",",
"name",
")",
":",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"parent",
"=",
"parent",
"self",
".",
"_state",
"=",
"None",
"self",
".",
"_unit",
"=",
"None"
] | [
243,
4
] | [
248,
25
] | python | en | ['es', 'pt', 'en'] | False |
FroniusTemplateSensor.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
return f"{self._name.replace('_', ' ').capitalize()} {self.parent.name}" | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"f\"{self._name.replace('_', ' ').capitalize()} {self.parent.name}\""
] | [
251,
4
] | [
253,
80
] | python | en | ['en', 'mi', 'en'] | True |
FroniusTemplateSensor.state | (self) | Return the current state. | Return the current state. | def state(self):
"""Return the current state."""
return self._state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
256,
4
] | [
258,
26
] | python | en | ['en', 'en', 'en'] | True |
FroniusTemplateSensor.unit_of_measurement | (self) | Return the unit of measurement. | Return the unit of measurement. | def unit_of_measurement(self):
"""Return the unit of measurement."""
return self._unit | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unit"
] | [
261,
4
] | [
263,
25
] | python | en | ['en', 'la', 'en'] | True |
FroniusTemplateSensor.should_poll | (self) | Device should not be polled, returns False. | Device should not be polled, returns False. | def should_poll(self):
"""Device should not be polled, returns False."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
266,
4
] | [
268,
20
] | python | en | ['en', 'en', 'en'] | True |
FroniusTemplateSensor.async_update | (self) | Update the internal state. | Update the internal state. | async def async_update(self):
"""Update the internal state."""
state = self.parent.data.get(self._name)
self._state = state.get("value")
self._unit = state.get("unit") | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"state",
"=",
"self",
".",
"parent",
".",
"data",
".",
"get",
"(",
"self",
".",
"_name",
")",
"self",
".",
"_state",
"=",
"state",
".",
"get",
"(",
"\"value\"",
")",
"self",
".",
"_unit",
"=",
... | [
270,
4
] | [
274,
38
] | python | en | ['en', 'en', 'en'] | True |
FroniusTemplateSensor.async_added_to_hass | (self) | Register at parent component for updates. | Register at parent component for updates. | async def async_added_to_hass(self):
"""Register at parent component for updates."""
await self.parent.register(self) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"await",
"self",
".",
"parent",
".",
"register",
"(",
"self",
")"
] | [
276,
4
] | [
278,
40
] | python | da | ['da', 'da', 'en'] | True |
FroniusTemplateSensor.__hash__ | (self) | Hash sensor by hashing its name. | Hash sensor by hashing its name. | def __hash__(self):
"""Hash sensor by hashing its name."""
return hash(self.name) | [
"def",
"__hash__",
"(",
"self",
")",
":",
"return",
"hash",
"(",
"self",
".",
"name",
")"
] | [
280,
4
] | [
282,
30
] | python | en | ['en', 'zh-Latn', 'en'] | True |
async_see | (
hass: HomeAssistantType,
mac: str = None,
dev_id: str = None,
host_name: str = None,
location_name: str = None,
gps: GPSType = None,
gps_accuracy=None,
battery: int = None,
attributes: dict = None,
) | Call service to notify you see device. | Call service to notify you see device. | def async_see(
hass: HomeAssistantType,
mac: str = None,
dev_id: str = None,
host_name: str = None,
location_name: str = None,
gps: GPSType = None,
gps_accuracy=None,
battery: int = None,
attributes: dict = None,
):
"""Call service to notify you see device."""
data = {
... | [
"def",
"async_see",
"(",
"hass",
":",
"HomeAssistantType",
",",
"mac",
":",
"str",
"=",
"None",
",",
"dev_id",
":",
"str",
"=",
"None",
",",
"host_name",
":",
"str",
"=",
"None",
",",
"location_name",
":",
"str",
"=",
"None",
",",
"gps",
":",
"GPSTyp... | [
24,
0
] | [
51,
75
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up the binary sensors from a config entry. | Set up the binary sensors from a config entry. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up the binary sensors from a config entry."""
board_api = hass.data[DOMAIN][config_entry.entry_id]
input_count = config_entry.data["input_count"]
binary_sensors = []
async def async_update_data():
"""Fetch data from... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"board_api",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"config_entry",
".",
"entry_id",
"]",
"input_count",
"=",
"config_entry",
".",
"data",
... | [
20,
0
] | [
49,
38
] | python | en | ['en', 'en', 'en'] | True |
ProgettihwswBinarySensor.__init__ | (self, coordinator, name, sensor: Input) | Set initializing values. | Set initializing values. | def __init__(self, coordinator, name, sensor: Input):
"""Set initializing values."""
super().__init__(coordinator)
self._name = name
self._sensor = sensor | [
"def",
"__init__",
"(",
"self",
",",
"coordinator",
",",
"name",
",",
"sensor",
":",
"Input",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"coordinator",
")",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"_sensor",
"=",
"sensor"
] | [
55,
4
] | [
59,
29
] | python | en | ['nl', 'zu', 'en'] | False |
ProgettihwswBinarySensor.name | (self) | Return the sensor name. | Return the sensor name. | def name(self):
"""Return the sensor name."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
62,
4
] | [
64,
25
] | python | en | ['en', 'mi', 'en'] | True |
ProgettihwswBinarySensor.is_on | (self) | Get sensor state. | Get sensor state. | def is_on(self):
"""Get sensor state."""
return self.coordinator.data[self._sensor.id] | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"coordinator",
".",
"data",
"[",
"self",
".",
"_sensor",
".",
"id",
"]"
] | [
67,
4
] | [
69,
53
] | python | en | ['en', 'bs', 'en'] | True |
async_extract_config | (hass, config) | Extract device tracker config and split between legacy and modern. | Extract device tracker config and split between legacy and modern. | async def async_extract_config(hass, config):
"""Extract device tracker config and split between legacy and modern."""
legacy = []
for platform in await asyncio.gather(
*(
async_create_platform_type(hass, config, p_type, p_config)
for p_type, p_config in config_per_platform(... | [
"async",
"def",
"async_extract_config",
"(",
"hass",
",",
"config",
")",
":",
"legacy",
"=",
"[",
"]",
"for",
"platform",
"in",
"await",
"asyncio",
".",
"gather",
"(",
"*",
"(",
"async_create_platform_type",
"(",
"hass",
",",
"config",
",",
"p_type",
",",
... | [
94,
0
] | [
114,
17
] | python | en | ['en', 'en', 'en'] | True |
async_create_platform_type | (
hass, config, p_type, p_config
) | Determine type of platform. | Determine type of platform. | async def async_create_platform_type(
hass, config, p_type, p_config
) -> Optional[DeviceTrackerPlatform]:
"""Determine type of platform."""
platform = await async_prepare_setup_platform(hass, config, DOMAIN, p_type)
if platform is None:
return None
return DeviceTrackerPlatform(p_type, pla... | [
"async",
"def",
"async_create_platform_type",
"(",
"hass",
",",
"config",
",",
"p_type",
",",
"p_config",
")",
"->",
"Optional",
"[",
"DeviceTrackerPlatform",
"]",
":",
"platform",
"=",
"await",
"async_prepare_setup_platform",
"(",
"hass",
",",
"config",
",",
"D... | [
117,
0
] | [
126,
60
] | python | en | ['en', 'de', 'en'] | True |
async_setup_scanner_platform | (
hass: HomeAssistantType,
config: ConfigType,
scanner: Any,
async_see_device: Callable,
platform: str,
) | Set up the connect scanner-based platform to device tracker.
This method must be run in the event loop.
| Set up the connect scanner-based platform to device tracker. | def async_setup_scanner_platform(
hass: HomeAssistantType,
config: ConfigType,
scanner: Any,
async_see_device: Callable,
platform: str,
):
"""Set up the connect scanner-based platform to device tracker.
This method must be run in the event loop.
"""
interval = config.get(CONF_SCAN_I... | [
"def",
"async_setup_scanner_platform",
"(",
"hass",
":",
"HomeAssistantType",
",",
"config",
":",
"ConfigType",
",",
"scanner",
":",
"Any",
",",
"async_see_device",
":",
"Callable",
",",
"platform",
":",
"str",
",",
")",
":",
"interval",
"=",
"config",
".",
... | [
130,
0
] | [
195,
59
] | python | en | ['en', 'en', 'en'] | True |
problem3_3 | (month, day, year) | Takes date of form mm/dd/yyyy and writes it in form June 17, 2016
Example3_3: problem3_3(6, 17, 2016) gives June 17, 2016 | Takes date of form mm/dd/yyyy and writes it in form June 17, 2016
Example3_3: problem3_3(6, 17, 2016) gives June 17, 2016 | def problem3_3(month, day, year):
""" Takes date of form mm/dd/yyyy and writes it in form June 17, 2016
Example3_3: problem3_3(6, 17, 2016) gives June 17, 2016 """
mappping = {1:'January',
2:"Febuary",
3:"March",
4:"April",
5:"May",
6:"June",
7:"July",
8:"August",
... | [
"def",
"problem3_3",
"(",
"month",
",",
"day",
",",
"year",
")",
":",
"mappping",
"=",
"{",
"1",
":",
"'January'",
",",
"2",
":",
"\"Febuary\"",
",",
"3",
":",
"\"March\"",
",",
"4",
":",
"\"April\"",
",",
"5",
":",
"\"May\"",
",",
"6",
":",
"\"J... | [
24,
0
] | [
40,
57
] | python | en | ['en', 'en', 'en'] | True |
test_reproduce_group | (hass) | Test reproduce_state with group. | Test reproduce_state with group. | async def test_reproduce_group(hass):
"""Test reproduce_state with group."""
context = Context()
def clone_state(state, entity_id):
"""Return a cloned state with different entity_id."""
return State(
entity_id,
state.state,
state.attributes,
l... | [
"async",
"def",
"test_reproduce_group",
"(",
"hass",
")",
":",
"context",
"=",
"Context",
"(",
")",
"def",
"clone_state",
"(",
"state",
",",
"entity_id",
")",
":",
"\"\"\"Return a cloned state with different entity_id.\"\"\"",
"return",
"State",
"(",
"entity_id",
",... | [
10,
0
] | [
53,
9
] | python | en | ['en', 'en', 'en'] | True |
suggest_recipe | (query) |
Quick wrapper for KNNRecommender.recommend()
:param query:
:return:
|
Quick wrapper for KNNRecommender.recommend()
:param query:
:return:
| def suggest_recipe(query):
"""
Quick wrapper for KNNRecommender.recommend()
:param query:
:return:
"""
corpus = HTMLPickledCorpusReader('../mini_food_corpus_proc')
docs = list(corpus.docs())
titles = list(corpus.titles())
tree = BallTreeRecommender(k=3)
tree.fit_transform(docs)
... | [
"def",
"suggest_recipe",
"(",
"query",
")",
":",
"corpus",
"=",
"HTMLPickledCorpusReader",
"(",
"'../mini_food_corpus_proc'",
")",
"docs",
"=",
"list",
"(",
"corpus",
".",
"docs",
"(",
")",
")",
"titles",
"=",
"list",
"(",
"corpus",
".",
"titles",
"(",
")"... | [
210,
0
] | [
222,
49
] | python | en | ['en', 'error', 'th'] | False |
KNNTransformer.__init__ | (self, k=3, **kwargs) |
Note: tried LSHForest, still too slow
:param k:
:param kwargs:
|
Note: tried LSHForest, still too slow
:param k:
:param kwargs:
| def __init__(self, k=3, **kwargs):
"""
Note: tried LSHForest, still too slow
:param k:
:param kwargs:
"""
self.model = NearestNeighbors(n_neighbors=k, **kwargs) | [
"def",
"__init__",
"(",
"self",
",",
"k",
"=",
"3",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"model",
"=",
"NearestNeighbors",
"(",
"n_neighbors",
"=",
"k",
",",
"*",
"*",
"kwargs",
")"
] | [
26,
4
] | [
32,
62
] | python | en | ['en', 'error', 'th'] | False |
KNNRecommender.load | (self) |
Load a pickled vectorizer and vectorized corpus from disk,
if they exist.
|
Load a pickled vectorizer and vectorized corpus from disk,
if they exist.
| def load(self):
"""
Load a pickled vectorizer and vectorized corpus from disk,
if they exist.
"""
if os.path.exists(self.vect_path):
joblib.load(open(self.vect_path, 'rb'))
joblib.load(open(self.lex_path, 'rb'))
else:
self.vectorizer = ... | [
"def",
"load",
"(",
"self",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"vect_path",
")",
":",
"joblib",
".",
"load",
"(",
"open",
"(",
"self",
".",
"vect_path",
",",
"'rb'",
")",
")",
"joblib",
".",
"load",
"(",
"open",
... | [
95,
4
] | [
105,
31
] | python | en | ['en', 'error', 'th'] | False |
KNNRecommender.save | (self) |
It takes a long time to fit, so just do it once!
|
It takes a long time to fit, so just do it once!
| def save(self):
"""
It takes a long time to fit, so just do it once!
"""
joblib.dump(self.vect, open(self.vect_path, 'wb'))
joblib.dump(self.lexicon, open(self.lex_path, 'wb')) | [
"def",
"save",
"(",
"self",
")",
":",
"joblib",
".",
"dump",
"(",
"self",
".",
"vect",
",",
"open",
"(",
"self",
".",
"vect_path",
",",
"'wb'",
")",
")",
"joblib",
".",
"dump",
"(",
"self",
".",
"lexicon",
",",
"open",
"(",
"self",
".",
"lex_path... | [
107,
4
] | [
112,
60
] | python | en | ['en', 'error', 'th'] | False |
KNNRecommender.recommend | (self, terms) |
Given input list of ingredient terms,
return the k closest matching recipes.
:param terms: list of strings
:return: list of document indices of documents
|
Given input list of ingredient terms,
return the k closest matching recipes. | def recommend(self, terms):
"""
Given input list of ingredient terms,
return the k closest matching recipes.
:param terms: list of strings
:return: list of document indices of documents
"""
vect_doc = self.vect.transform(wordpunct_tokenize(terms))
distanc... | [
"def",
"recommend",
"(",
"self",
",",
"terms",
")",
":",
"vect_doc",
"=",
"self",
".",
"vect",
".",
"transform",
"(",
"wordpunct_tokenize",
"(",
"terms",
")",
")",
"distance_matches",
"=",
"self",
".",
"knn",
".",
"transform",
"(",
"vect_doc",
")",
"# th... | [
132,
4
] | [
145,
22
] | python | en | ['en', 'error', 'th'] | False |
BallTreeRecommender.load | (self) |
Load a pickled transformer and tree from disk,
if they exist.
|
Load a pickled transformer and tree from disk,
if they exist.
| def load(self):
"""
Load a pickled transformer and tree from disk,
if they exist.
"""
if os.path.exists(self.trans_path):
self.transformer = joblib.load(open(self.trans_path, 'rb'))
self.tree = joblib.load(open(self.tree_path, 'rb'))
else:
... | [
"def",
"load",
"(",
"self",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"trans_path",
")",
":",
"self",
".",
"transformer",
"=",
"joblib",
".",
"load",
"(",
"open",
"(",
"self",
".",
"trans_path",
",",
"'rb'",
")",
")",
"s... | [
160,
4
] | [
170,
28
] | python | en | ['en', 'error', 'th'] | False |
BallTreeRecommender.save | (self) |
It takes a long time to fit, so just do it once!
|
It takes a long time to fit, so just do it once!
| def save(self):
"""
It takes a long time to fit, so just do it once!
"""
joblib.dump(self.transformer, open(self.trans_path, 'wb'))
joblib.dump(self.tree, open(self.tree_path, 'wb')) | [
"def",
"save",
"(",
"self",
")",
":",
"joblib",
".",
"dump",
"(",
"self",
".",
"transformer",
",",
"open",
"(",
"self",
".",
"trans_path",
",",
"'wb'",
")",
")",
"joblib",
".",
"dump",
"(",
"self",
".",
"tree",
",",
"open",
"(",
"self",
".",
"tre... | [
172,
4
] | [
177,
58
] | python | en | ['en', 'error', 'th'] | False |
BallTreeRecommender.query | (self, terms) |
Given input list of ingredient terms,
return the k closest matching recipes.
:param terms: list of strings
:return: list of document indices of documents
|
Given input list of ingredient terms,
return the k closest matching recipes. | def query(self, terms):
"""
Given input list of ingredient terms,
return the k closest matching recipes.
:param terms: list of strings
:return: list of document indices of documents
"""
vect_doc = self.transformer.named_steps['transform'].fit_transform(
... | [
"def",
"query",
"(",
"self",
",",
"terms",
")",
":",
"vect_doc",
"=",
"self",
".",
"transformer",
".",
"named_steps",
"[",
"'transform'",
"]",
".",
"fit_transform",
"(",
"wordpunct_tokenize",
"(",
"terms",
")",
")",
"dists",
",",
"inds",
"=",
"self",
"."... | [
195,
4
] | [
207,
22
] | python | en | ['en', 'error', 'th'] | False |
async_setup_entry | (
hass: HomeAssistant,
entry: ConfigEntry,
async_add_entities: Callable[[List[Entity], bool], None],
) | Set up the sensor config entry. | Set up the sensor config entry. | async def async_setup_entry(
hass: HomeAssistant,
entry: ConfigEntry,
async_add_entities: Callable[[List[Entity], bool], None],
) -> None:
"""Set up the sensor config entry."""
entities = await async_create_entities(
hass, entry, WithingsHealthBinarySensor, BINARY_SENSOR_DOMAIN
)
as... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
",",
"async_add_entities",
":",
"Callable",
"[",
"[",
"List",
"[",
"Entity",
"]",
",",
"bool",
"]",
",",
"None",
"]",
",",
")",
"->",
"None",
":",
... | [
15,
0
] | [
25,
38
] | python | en | ['en', 'pt', 'en'] | True |
WithingsHealthBinarySensor.is_on | (self) | Return true if the binary sensor is on. | Return true if the binary sensor is on. | def is_on(self) -> bool:
"""Return true if the binary sensor is on."""
return self._state_data | [
"def",
"is_on",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"_state_data"
] | [
32,
4
] | [
34,
31
] | python | en | ['en', 'fy', 'en'] | True |
WithingsHealthBinarySensor.device_class | (self) | Provide the device class. | Provide the device class. | def device_class(self) -> str:
"""Provide the device class."""
return DEVICE_CLASS_OCCUPANCY | [
"def",
"device_class",
"(",
"self",
")",
"->",
"str",
":",
"return",
"DEVICE_CLASS_OCCUPANCY"
] | [
37,
4
] | [
39,
37
] | python | en | ['en', 'en', 'en'] | True |
test_async_setup_no_domain_config | (hass: HomeAssistant) | Test setup without configuration is noop. | Test setup without configuration is noop. | async def test_async_setup_no_domain_config(hass: HomeAssistant):
"""Test setup without configuration is noop."""
result = await async_setup_component(hass, DOMAIN, {})
assert result is True
assert DOMAIN not in hass.data | [
"async",
"def",
"test_async_setup_no_domain_config",
"(",
"hass",
":",
"HomeAssistant",
")",
":",
"result",
"=",
"await",
"async_setup_component",
"(",
"hass",
",",
"DOMAIN",
",",
"{",
"}",
")",
"assert",
"result",
"is",
"True",
"assert",
"DOMAIN",
"not",
"in"... | [
12,
0
] | [
17,
34
] | python | en | ['en', 'en', 'en'] | True |
test_async_setup_imports_from_config | (hass: HomeAssistant) | Test that specifying config will setup an entry. | Test that specifying config will setup an entry. | async def test_async_setup_imports_from_config(hass: HomeAssistant):
"""Test that specifying config will setup an entry."""
with patch(
"homeassistant.components.plum_lightpad.utils.Plum.loadCloudData"
) as mock_loadCloudData, patch(
"homeassistant.components.plum_lightpad.async_setup_entry"... | [
"async",
"def",
"test_async_setup_imports_from_config",
"(",
"hass",
":",
"HomeAssistant",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.plum_lightpad.utils.Plum.loadCloudData\"",
")",
"as",
"mock_loadCloudData",
",",
"patch",
"(",
"\"homeassistant.components.plum... | [
20,
0
] | [
42,
54
] | python | en | ['en', 'en', 'en'] | True |
test_async_setup_entry_sets_up_light | (hass: HomeAssistant) | Test that configuring entry sets up light domain. | Test that configuring entry sets up light domain. | async def test_async_setup_entry_sets_up_light(hass: HomeAssistant):
"""Test that configuring entry sets up light domain."""
config_entry = MockConfigEntry(
domain=DOMAIN,
data={"username": "test-plum-username", "password": "test-plum-password"},
)
config_entry.add_to_hass(hass)
wit... | [
"async",
"def",
"test_async_setup_entry_sets_up_light",
"(",
"hass",
":",
"HomeAssistant",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"data",
"=",
"{",
"\"username\"",
":",
"\"test-plum-username\"",
",",
"\"password\"",
":",... | [
45,
0
] | [
64,
60
] | python | en | ['en', 'en', 'en'] | True |
test_async_setup_entry_handles_auth_error | (hass: HomeAssistant) | Test that configuring entry handles Plum Cloud authentication error. | Test that configuring entry handles Plum Cloud authentication error. | async def test_async_setup_entry_handles_auth_error(hass: HomeAssistant):
"""Test that configuring entry handles Plum Cloud authentication error."""
config_entry = MockConfigEntry(
domain=DOMAIN,
data={"username": "test-plum-username", "password": "test-plum-password"},
)
config_entry.ad... | [
"async",
"def",
"test_async_setup_entry_handles_auth_error",
"(",
"hass",
":",
"HomeAssistant",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"data",
"=",
"{",
"\"username\"",
":",
"\"test-plum-username\"",
",",
"\"password\"",
... | [
67,
0
] | [
84,
60
] | python | en | ['en', 'fr', 'en'] | True |
test_async_setup_entry_handles_http_error | (hass: HomeAssistant) | Test that configuring entry handles HTTP error. | Test that configuring entry handles HTTP error. | async def test_async_setup_entry_handles_http_error(hass: HomeAssistant):
"""Test that configuring entry handles HTTP error."""
config_entry = MockConfigEntry(
domain=DOMAIN,
data={"username": "test-plum-username", "password": "test-plum-password"},
)
config_entry.add_to_hass(hass)
... | [
"async",
"def",
"test_async_setup_entry_handles_http_error",
"(",
"hass",
":",
"HomeAssistant",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"data",
"=",
"{",
"\"username\"",
":",
"\"test-plum-username\"",
",",
"\"password\"",
... | [
87,
0
] | [
104,
60
] | python | en | ['en', 'en', 'en'] | True |
mock_hub | (config, response) | Extensively mock out a verisure hub. | Extensively mock out a verisure hub. | def mock_hub(config, response):
"""Extensively mock out a verisure hub."""
hub_prefix = "homeassistant.components.verisure.binary_sensor.hub"
verisure_prefix = "verisure.Session"
with patch(verisure_prefix) as session, patch(hub_prefix) as hub:
session.login.return_value = True
hub.conf... | [
"def",
"mock_hub",
"(",
"config",
",",
"response",
")",
":",
"hub_prefix",
"=",
"\"homeassistant.components.verisure.binary_sensor.hub\"",
"verisure_prefix",
"=",
"\"verisure.Session\"",
"with",
"patch",
"(",
"verisure_prefix",
")",
"as",
"session",
",",
"patch",
"(",
... | [
25,
0
] | [
36,
17
] | python | en | ['en', 'en', 'en'] | True |
setup_verisure | (hass, config, response) | Set up mock verisure. | Set up mock verisure. | async def setup_verisure(hass, config, response):
"""Set up mock verisure."""
with mock_hub(config, response):
await async_setup_component(hass, VERISURE_DOMAIN, config)
await hass.async_block_till_done() | [
"async",
"def",
"setup_verisure",
"(",
"hass",
",",
"config",
",",
"response",
")",
":",
"with",
"mock_hub",
"(",
"config",
",",
"response",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"VERISURE_DOMAIN",
",",
"config",
")",
"await",
"hass",... | [
39,
0
] | [
43,
42
] | python | en | ['en', 'da', 'en'] | True |
test_verisure_no_ethernet_status | (hass) | Test no data from API. | Test no data from API. | async def test_verisure_no_ethernet_status(hass):
"""Test no data from API."""
await setup_verisure(hass, CONFIG, {})
assert len(hass.states.async_all()) == 1
entity_id = hass.states.async_entity_ids()[0]
assert hass.states.get(entity_id).state == STATE_UNAVAILABLE | [
"async",
"def",
"test_verisure_no_ethernet_status",
"(",
"hass",
")",
":",
"await",
"setup_verisure",
"(",
"hass",
",",
"CONFIG",
",",
"{",
"}",
")",
"assert",
"len",
"(",
"hass",
".",
"states",
".",
"async_all",
"(",
")",
")",
"==",
"1",
"entity_id",
"=... | [
46,
0
] | [
51,
64
] | python | en | ['en', 'en', 'en'] | True |
test_verisure_ethernet_status_disconnected | (hass) | Test disconnected. | Test disconnected. | async def test_verisure_ethernet_status_disconnected(hass):
"""Test disconnected."""
await setup_verisure(hass, CONFIG, {"ethernetConnectedNow": False})
assert len(hass.states.async_all()) == 1
entity_id = hass.states.async_entity_ids()[0]
assert hass.states.get(entity_id).state == "off" | [
"async",
"def",
"test_verisure_ethernet_status_disconnected",
"(",
"hass",
")",
":",
"await",
"setup_verisure",
"(",
"hass",
",",
"CONFIG",
",",
"{",
"\"ethernetConnectedNow\"",
":",
"False",
"}",
")",
"assert",
"len",
"(",
"hass",
".",
"states",
".",
"async_all... | [
54,
0
] | [
59,
52
] | python | en | ['fr', 'en', 'en'] | False |
test_verisure_ethernet_status_connected | (hass) | Test connected. | Test connected. | async def test_verisure_ethernet_status_connected(hass):
"""Test connected."""
await setup_verisure(hass, CONFIG, {"ethernetConnectedNow": True})
assert len(hass.states.async_all()) == 1
entity_id = hass.states.async_entity_ids()[0]
assert hass.states.get(entity_id).state == "on" | [
"async",
"def",
"test_verisure_ethernet_status_connected",
"(",
"hass",
")",
":",
"await",
"setup_verisure",
"(",
"hass",
",",
"CONFIG",
",",
"{",
"\"ethernetConnectedNow\"",
":",
"True",
"}",
")",
"assert",
"len",
"(",
"hass",
".",
"states",
".",
"async_all",
... | [
62,
0
] | [
67,
51
] | python | en | ['en', 'en', 'en'] | False |
init | (empty=False) | Initialize the platform with entities. | Initialize the platform with entities. | def init(empty=False):
"""Initialize the platform with entities."""
global ENTITIES
ENTITIES = (
{}
if empty
else {
device_class: MockBinarySensor(
name=f"{device_class} sensor",
is_on=True,
unique_id=f"unique_{device_class... | [
"def",
"init",
"(",
"empty",
"=",
"False",
")",
":",
"global",
"ENTITIES",
"ENTITIES",
"=",
"(",
"{",
"}",
"if",
"empty",
"else",
"{",
"device_class",
":",
"MockBinarySensor",
"(",
"name",
"=",
"f\"{device_class} sensor\"",
",",
"is_on",
"=",
"True",
",",
... | [
12,
0
] | [
28,
5
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (
hass, config, async_add_entities_callback, discovery_info=None
) | Return mock entities. | Return mock entities. | async def async_setup_platform(
hass, config, async_add_entities_callback, discovery_info=None
):
"""Return mock entities."""
async_add_entities_callback(list(ENTITIES.values())) | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities_callback",
",",
"discovery_info",
"=",
"None",
")",
":",
"async_add_entities_callback",
"(",
"list",
"(",
"ENTITIES",
".",
"values",
"(",
")",
")",
")"
] | [
31,
0
] | [
35,
56
] | python | af | ['nl', 'af', 'en'] | False |
MockBinarySensor.is_on | (self) | Return true if the binary sensor is on. | Return true if the binary sensor is on. | def is_on(self):
"""Return true if the binary sensor is on."""
return self._handle("is_on") | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_handle",
"(",
"\"is_on\"",
")"
] | [
42,
4
] | [
44,
36
] | python | en | ['en', 'fy', 'en'] | True |
MockBinarySensor.device_class | (self) | Return the class of this sensor. | Return the class of this sensor. | def device_class(self):
"""Return the class of this sensor."""
return self._handle("device_class") | [
"def",
"device_class",
"(",
"self",
")",
":",
"return",
"self",
".",
"_handle",
"(",
"\"device_class\"",
")"
] | [
47,
4
] | [
49,
43
] | python | en | ['en', 'en', 'en'] | True |
test_islamic_prayer_times_sensors | (hass, legacy_patchable_time) | Test minimum Islamic prayer times configuration. | Test minimum Islamic prayer times configuration. | async def test_islamic_prayer_times_sensors(hass, legacy_patchable_time):
"""Test minimum Islamic prayer times configuration."""
entry = MockConfigEntry(domain=islamic_prayer_times.DOMAIN, data={})
entry.add_to_hass(hass)
with patch(
"prayer_times_calculator.PrayerTimesCalculator.fetch_prayer_t... | [
"async",
"def",
"test_islamic_prayer_times_sensors",
"(",
"hass",
",",
"legacy_patchable_time",
")",
":",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"islamic_prayer_times",
".",
"DOMAIN",
",",
"data",
"=",
"{",
"}",
")",
"entry",
".",
"add_to_hass",
"(... | [
10,
0
] | [
28,
13
] | python | en | ['en', 'zh', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the FRITZ!Box monitor sensors. | Set up the FRITZ!Box monitor sensors. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the FRITZ!Box monitor sensors."""
name = config[CONF_NAME]
host = config[CONF_HOST]
try:
fstatus = FritzStatus(address=host)
except (ValueError, TypeError, FritzConnectionException):
fstatus = None
i... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"name",
"=",
"config",
"[",
"CONF_NAME",
"]",
"host",
"=",
"config",
"[",
"CONF_HOST",
"]",
"try",
":",
"fstatus",
"=",
"FritzStatus",
... | [
46,
0
] | [
61,
62
] | python | en | ['en', 'fil', 'en'] | True |
FritzboxMonitorSensor.__init__ | (self, name, fstatus) | Initialize the sensor. | Initialize the sensor. | def __init__(self, name, fstatus):
"""Initialize the sensor."""
self._name = name
self._fstatus = fstatus
self._state = STATE_UNAVAILABLE
self._is_linked = self._is_connected = None
self._external_ip = self._uptime = None
self._bytes_sent = self._bytes_received = ... | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"fstatus",
")",
":",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"_fstatus",
"=",
"fstatus",
"self",
".",
"_state",
"=",
"STATE_UNAVAILABLE",
"self",
".",
"_is_linked",
"=",
"self",
".",
"_is_connecte... | [
67,
4
] | [
77,
64
] | python | en | ['en', 'en', 'en'] | True |
FritzboxMonitorSensor.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.rstrip() | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name",
".",
"rstrip",
"(",
")"
] | [
80,
4
] | [
82,
34
] | python | en | ['en', 'mi', 'en'] | True |
FritzboxMonitorSensor.icon | (self) | Icon to use in the frontend, if any. | Icon to use in the frontend, if any. | def icon(self):
"""Icon to use in the frontend, if any."""
return ICON | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"ICON"
] | [
85,
4
] | [
87,
19
] | python | en | ['en', 'en', 'en'] | True |
FritzboxMonitorSensor.state | (self) | Return the state of the device. | Return the state of the device. | def state(self):
"""Return the state of the device."""
return self._state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
90,
4
] | [
92,
26
] | python | en | ['en', 'en', 'en'] | True |
FritzboxMonitorSensor.state_attributes | (self) | Return the device state attributes. | Return the device state attributes. | def state_attributes(self):
"""Return the device state attributes."""
# Don't return attributes if FritzBox is unreachable
if self._state == STATE_UNAVAILABLE:
return {}
return {
ATTR_IS_LINKED: self._is_linked,
ATTR_IS_CONNECTED: self._is_connected,
... | [
"def",
"state_attributes",
"(",
"self",
")",
":",
"# Don't return attributes if FritzBox is unreachable",
"if",
"self",
".",
"_state",
"==",
"STATE_UNAVAILABLE",
":",
"return",
"{",
"}",
"return",
"{",
"ATTR_IS_LINKED",
":",
"self",
".",
"_is_linked",
",",
"ATTR_IS_... | [
95,
4
] | [
111,
9
] | python | en | ['en', 'en', 'en'] | True |
FritzboxMonitorSensor.update | (self) | Retrieve information from the FritzBox. | Retrieve information from the FritzBox. | def update(self):
"""Retrieve information from the FritzBox."""
try:
self._is_linked = self._fstatus.is_linked
self._is_connected = self._fstatus.is_connected
self._external_ip = self._fstatus.external_ip
self._uptime = self._fstatus.uptime
sel... | [
"def",
"update",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"_is_linked",
"=",
"self",
".",
"_fstatus",
".",
"is_linked",
"self",
".",
"_is_connected",
"=",
"self",
".",
"_fstatus",
".",
"is_connected",
"self",
".",
"_external_ip",
"=",
"self",
".",... | [
114,
4
] | [
131,
65
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Bbox sensor. | Set up the Bbox sensor. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Bbox sensor."""
# Create a data fetcher to support all of the configured sensors. Then make
# the first call to init the data.
try:
bbox_data = BboxData()
bbox_data.update()
except requests.exceptions.... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"# Create a data fetcher to support all of the configured sensors. Then make",
"# the first call to init the data.",
"try",
":",
"bbox_data",
"=",
"BboxData... | [
65,
0
] | [
85,
31
] | python | en | ['en', 'bg', 'en'] | True |
BboxUptimeSensor.__init__ | (self, bbox_data, sensor_type, name) | Initialize the sensor. | Initialize the sensor. | def __init__(self, bbox_data, sensor_type, name):
"""Initialize the sensor."""
self.client_name = name
self.type = sensor_type
self._name = SENSOR_TYPES[sensor_type][0]
self._unit_of_measurement = SENSOR_TYPES[sensor_type][1]
self._icon = SENSOR_TYPES[sensor_type][2]
... | [
"def",
"__init__",
"(",
"self",
",",
"bbox_data",
",",
"sensor_type",
",",
"name",
")",
":",
"self",
".",
"client_name",
"=",
"name",
"self",
".",
"type",
"=",
"sensor_type",
"self",
".",
"_name",
"=",
"SENSOR_TYPES",
"[",
"sensor_type",
"]",
"[",
"0",
... | [
91,
4
] | [
99,
26
] | python | en | ['en', 'en', 'en'] | True |
BboxUptimeSensor.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
return f"{self.client_name} {self._name}" | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"f\"{self.client_name} {self._name}\""
] | [
102,
4
] | [
104,
49
] | python | en | ['en', 'mi', 'en'] | True |
BboxUptimeSensor.state | (self) | Return the state of the sensor. | Return the state of the sensor. | def state(self):
"""Return the state of the sensor."""
return self._state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
107,
4
] | [
109,
26
] | python | en | ['en', 'en', 'en'] | True |
BboxUptimeSensor.icon | (self) | Icon to use in the frontend, if any. | Icon to use in the frontend, if any. | def icon(self):
"""Icon to use in the frontend, if any."""
return self._icon | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"self",
".",
"_icon"
] | [
112,
4
] | [
114,
25
] | python | en | ['en', 'en', 'en'] | True |
BboxUptimeSensor.device_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def device_state_attributes(self):
"""Return the state attributes."""
return {ATTR_ATTRIBUTION: ATTRIBUTION} | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"{",
"ATTR_ATTRIBUTION",
":",
"ATTRIBUTION",
"}"
] | [
117,
4
] | [
119,
46
] | python | en | ['en', 'en', 'en'] | True |
BboxUptimeSensor.device_class | (self) | Return the class of this sensor. | Return the class of this sensor. | def device_class(self):
"""Return the class of this sensor."""
return DEVICE_CLASS_TIMESTAMP | [
"def",
"device_class",
"(",
"self",
")",
":",
"return",
"DEVICE_CLASS_TIMESTAMP"
] | [
122,
4
] | [
124,
37
] | python | en | ['en', 'en', 'en'] | True |
BboxUptimeSensor.update | (self) | Get the latest data from Bbox and update the state. | Get the latest data from Bbox and update the state. | def update(self):
"""Get the latest data from Bbox and update the state."""
self.bbox_data.update()
uptime = utcnow() - timedelta(
seconds=self.bbox_data.router_infos["device"]["uptime"]
)
self._state = uptime.replace(microsecond=0).isoformat() | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"bbox_data",
".",
"update",
"(",
")",
"uptime",
"=",
"utcnow",
"(",
")",
"-",
"timedelta",
"(",
"seconds",
"=",
"self",
".",
"bbox_data",
".",
"router_infos",
"[",
"\"device\"",
"]",
"[",
"\"uptime\"... | [
126,
4
] | [
132,
63
] | python | en | ['en', 'en', 'en'] | True |
BboxSensor.__init__ | (self, bbox_data, sensor_type, name) | Initialize the sensor. | Initialize the sensor. | def __init__(self, bbox_data, sensor_type, name):
"""Initialize the sensor."""
self.client_name = name
self.type = sensor_type
self._name = SENSOR_TYPES[sensor_type][0]
self._unit_of_measurement = SENSOR_TYPES[sensor_type][1]
self._icon = SENSOR_TYPES[sensor_type][2]
... | [
"def",
"__init__",
"(",
"self",
",",
"bbox_data",
",",
"sensor_type",
",",
"name",
")",
":",
"self",
".",
"client_name",
"=",
"name",
"self",
".",
"type",
"=",
"sensor_type",
"self",
".",
"_name",
"=",
"SENSOR_TYPES",
"[",
"sensor_type",
"]",
"[",
"0",
... | [
138,
4
] | [
146,
26
] | python | en | ['en', 'en', 'en'] | True |
BboxSensor.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
return f"{self.client_name} {self._name}" | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"f\"{self.client_name} {self._name}\""
] | [
149,
4
] | [
151,
49
] | python | en | ['en', 'mi', 'en'] | True |
BboxSensor.state | (self) | Return the state of the sensor. | Return the state of the sensor. | def state(self):
"""Return the state of the sensor."""
return self._state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
154,
4
] | [
156,
26
] | python | en | ['en', 'en', 'en'] | True |
BboxSensor.unit_of_measurement | (self) | Return the unit of measurement of this entity, if any. | Return the unit of measurement of this entity, if any. | def unit_of_measurement(self):
"""Return the unit of measurement of this entity, if any."""
return self._unit_of_measurement | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unit_of_measurement"
] | [
159,
4
] | [
161,
40
] | python | en | ['en', 'en', 'en'] | True |
BboxSensor.icon | (self) | Icon to use in the frontend, if any. | Icon to use in the frontend, if any. | def icon(self):
"""Icon to use in the frontend, if any."""
return self._icon | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"self",
".",
"_icon"
] | [
164,
4
] | [
166,
25
] | python | en | ['en', 'en', 'en'] | True |
BboxSensor.device_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def device_state_attributes(self):
"""Return the state attributes."""
return {ATTR_ATTRIBUTION: ATTRIBUTION} | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"{",
"ATTR_ATTRIBUTION",
":",
"ATTRIBUTION",
"}"
] | [
169,
4
] | [
171,
46
] | python | en | ['en', 'en', 'en'] | True |
BboxSensor.update | (self) | Get the latest data from Bbox and update the state. | Get the latest data from Bbox and update the state. | def update(self):
"""Get the latest data from Bbox and update the state."""
self.bbox_data.update()
if self.type == "down_max_bandwidth":
self._state = round(self.bbox_data.data["rx"]["maxBandwidth"] / 1000, 2)
elif self.type == "up_max_bandwidth":
self._state = r... | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"bbox_data",
".",
"update",
"(",
")",
"if",
"self",
".",
"type",
"==",
"\"down_max_bandwidth\"",
":",
"self",
".",
"_state",
"=",
"round",
"(",
"self",
".",
"bbox_data",
".",
"data",
"[",
"\"rx\"",
... | [
173,
4
] | [
185,
80
] | python | en | ['en', 'en', 'en'] | True |
BboxData.__init__ | (self) | Initialize the data object. | Initialize the data object. | def __init__(self):
"""Initialize the data object."""
self.data = None
self.router_infos = None | [
"def",
"__init__",
"(",
"self",
")",
":",
"self",
".",
"data",
"=",
"None",
"self",
".",
"router_infos",
"=",
"None"
] | [
191,
4
] | [
194,
32
] | python | en | ['en', 'en', 'en'] | True |
BboxData.update | (self) | Get the latest data from the Bbox. | Get the latest data from the Bbox. | def update(self):
"""Get the latest data from the Bbox."""
try:
box = pybbox.Bbox()
self.data = box.get_ip_stats()
self.router_infos = box.get_bbox_info()
except requests.exceptions.HTTPError as error:
_LOGGER.error(error)
self.data = ... | [
"def",
"update",
"(",
"self",
")",
":",
"try",
":",
"box",
"=",
"pybbox",
".",
"Bbox",
"(",
")",
"self",
".",
"data",
"=",
"box",
".",
"get_ip_stats",
"(",
")",
"self",
".",
"router_infos",
"=",
"box",
".",
"get_bbox_info",
"(",
")",
"except",
"req... | [
197,
4
] | [
208,
24
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass, config) | Set up the Minut Point component. | Set up the Minut Point component. | async def async_setup(hass, config):
"""Set up the Minut Point component."""
if DOMAIN not in config:
return True
conf = config[DOMAIN]
config_flow.register_flow_implementation(
hass, DOMAIN, conf[CONF_CLIENT_ID], conf[CONF_CLIENT_SECRET]
)
hass.async_create_task(
hass... | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"if",
"DOMAIN",
"not",
"in",
"config",
":",
"return",
"True",
"conf",
"=",
"config",
"[",
"DOMAIN",
"]",
"config_flow",
".",
"register_flow_implementation",
"(",
"hass",
",",
"DOMAIN",
",... | [
54,
0
] | [
71,
15
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass: HomeAssistantType, entry: ConfigEntry) | Set up Point from a config entry. | Set up Point from a config entry. | async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry):
"""Set up Point from a config entry."""
async def token_saver(token, **kwargs):
_LOGGER.debug("Saving updated token %s", token)
hass.config_entries.async_update_entry(
entry, data={**entry.data, CONF_TOKEN: to... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistantType",
",",
"entry",
":",
"ConfigEntry",
")",
":",
"async",
"def",
"token_saver",
"(",
"token",
",",
"*",
"*",
"kwargs",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Saving updated token %s\"",... | [
74,
0
] | [
104,
15
] | python | en | ['en', 'en', 'en'] | True |
async_setup_webhook | (hass: HomeAssistantType, entry: ConfigEntry, session) | Set up a webhook to handle binary sensor events. | Set up a webhook to handle binary sensor events. | async def async_setup_webhook(hass: HomeAssistantType, entry: ConfigEntry, session):
"""Set up a webhook to handle binary sensor events."""
if CONF_WEBHOOK_ID not in entry.data:
webhook_id = hass.components.webhook.async_generate_id()
webhook_url = hass.components.webhook.async_generate_url(webh... | [
"async",
"def",
"async_setup_webhook",
"(",
"hass",
":",
"HomeAssistantType",
",",
"entry",
":",
"ConfigEntry",
",",
"session",
")",
":",
"if",
"CONF_WEBHOOK_ID",
"not",
"in",
"entry",
".",
"data",
":",
"webhook_id",
"=",
"hass",
".",
"components",
".",
"web... | [
107,
0
] | [
130,
5
] | python | en | ['en', 'haw', 'en'] | True |
async_unload_entry | (hass: HomeAssistantType, entry: ConfigEntry) | Unload a config entry. | Unload a config entry. | async def async_unload_entry(hass: HomeAssistantType, entry: ConfigEntry):
"""Unload a config entry."""
hass.components.webhook.async_unregister(entry.data[CONF_WEBHOOK_ID])
session = hass.data[DOMAIN].pop(entry.entry_id)
await session.remove_webhook()
for component in ("binary_sensor", "sensor"):
... | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
":",
"HomeAssistantType",
",",
"entry",
":",
"ConfigEntry",
")",
":",
"hass",
".",
"components",
".",
"webhook",
".",
"async_unregister",
"(",
"entry",
".",
"data",
"[",
"CONF_WEBHOOK_ID",
"]",
")",
"session",... | [
133,
0
] | [
145,
15
] | python | en | ['en', 'es', 'en'] | True |
handle_webhook | (hass, webhook_id, request) | Handle webhook callback. | Handle webhook callback. | async def handle_webhook(hass, webhook_id, request):
"""Handle webhook callback."""
try:
data = await request.json()
_LOGGER.debug("Webhook %s: %s", webhook_id, data)
except ValueError:
return None
if isinstance(data, dict):
data["webhook_id"] = webhook_id
async_... | [
"async",
"def",
"handle_webhook",
"(",
"hass",
",",
"webhook_id",
",",
"request",
")",
":",
"try",
":",
"data",
"=",
"await",
"request",
".",
"json",
"(",
")",
"_LOGGER",
".",
"debug",
"(",
"\"Webhook %s: %s\"",
",",
"webhook_id",
",",
"data",
")",
"exce... | [
148,
0
] | [
159,
45
] | python | en | ['en', 'xh', 'en'] | True |
MinutPointClient.__init__ | (self, hass: HomeAssistantType, config_entry: ConfigEntry, session) | Initialize the Minut data object. | Initialize the Minut data object. | def __init__(self, hass: HomeAssistantType, config_entry: ConfigEntry, session):
"""Initialize the Minut data object."""
self._known_devices = set()
self._known_homes = set()
self._hass = hass
self._config_entry = config_entry
self._is_available = True
self._clien... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
":",
"HomeAssistantType",
",",
"config_entry",
":",
"ConfigEntry",
",",
"session",
")",
":",
"self",
".",
"_known_devices",
"=",
"set",
"(",
")",
"self",
".",
"_known_homes",
"=",
"set",
"(",
")",
"self",
".",... | [
165,
4
] | [
174,
73
] | python | en | ['en', 'en', 'en'] | True |
MinutPointClient.update | (self, *args) | Periodically poll the cloud for current state. | Periodically poll the cloud for current state. | async def update(self, *args):
"""Periodically poll the cloud for current state."""
await self._sync() | [
"async",
"def",
"update",
"(",
"self",
",",
"*",
"args",
")",
":",
"await",
"self",
".",
"_sync",
"(",
")"
] | [
176,
4
] | [
178,
26
] | python | en | ['en', 'en', 'en'] | True |
MinutPointClient._sync | (self) | Update local list of devices. | Update local list of devices. | async def _sync(self):
"""Update local list of devices."""
if not await self._client.update() and self._is_available:
self._is_available = False
_LOGGER.warning("Device is unavailable")
async_dispatcher_send(self._hass, SIGNAL_UPDATE_ENTITY)
return
... | [
"async",
"def",
"_sync",
"(",
"self",
")",
":",
"if",
"not",
"await",
"self",
".",
"_client",
".",
"update",
"(",
")",
"and",
"self",
".",
"_is_available",
":",
"self",
".",
"_is_available",
"=",
"False",
"_LOGGER",
".",
"warning",
"(",
"\"Device is unav... | [
180,
4
] | [
212,
63
] | python | en | ['en', 'en', 'en'] | True |
MinutPointClient.device | (self, device_id) | Return device representation. | Return device representation. | def device(self, device_id):
"""Return device representation."""
return self._client.device(device_id) | [
"def",
"device",
"(",
"self",
",",
"device_id",
")",
":",
"return",
"self",
".",
"_client",
".",
"device",
"(",
"device_id",
")"
] | [
214,
4
] | [
216,
45
] | python | en | ['es', 'it', 'en'] | False |
MinutPointClient.is_available | (self, device_id) | Return device availability. | Return device availability. | def is_available(self, device_id):
"""Return device availability."""
if not self._is_available:
return False
return device_id in self._client.device_ids | [
"def",
"is_available",
"(",
"self",
",",
"device_id",
")",
":",
"if",
"not",
"self",
".",
"_is_available",
":",
"return",
"False",
"return",
"device_id",
"in",
"self",
".",
"_client",
".",
"device_ids"
] | [
218,
4
] | [
222,
51
] | python | en | ['fr', 'ga', 'en'] | False |
MinutPointClient.remove_webhook | (self) | Remove the session webhook. | Remove the session webhook. | async def remove_webhook(self):
"""Remove the session webhook."""
return await self._client.remove_webhook() | [
"async",
"def",
"remove_webhook",
"(",
"self",
")",
":",
"return",
"await",
"self",
".",
"_client",
".",
"remove_webhook",
"(",
")"
] | [
224,
4
] | [
226,
50
] | python | en | ['en', 'en', 'en'] | True |
MinutPointClient.homes | (self) | Return known homes. | Return known homes. | def homes(self):
"""Return known homes."""
return self._client.homes | [
"def",
"homes",
"(",
"self",
")",
":",
"return",
"self",
".",
"_client",
".",
"homes"
] | [
229,
4
] | [
231,
33
] | python | en | ['en', 'en', 'en'] | True |
MinutPointClient.async_alarm_disarm | (self, home_id) | Send alarm disarm command. | Send alarm disarm command. | async def async_alarm_disarm(self, home_id):
"""Send alarm disarm command."""
return await self._client.alarm_disarm(home_id) | [
"async",
"def",
"async_alarm_disarm",
"(",
"self",
",",
"home_id",
")",
":",
"return",
"await",
"self",
".",
"_client",
".",
"alarm_disarm",
"(",
"home_id",
")"
] | [
233,
4
] | [
235,
55
] | python | en | ['en', 'fa', 'en'] | True |
MinutPointClient.async_alarm_arm | (self, home_id) | Send alarm arm command. | Send alarm arm command. | async def async_alarm_arm(self, home_id):
"""Send alarm arm command."""
return await self._client.alarm_arm(home_id) | [
"async",
"def",
"async_alarm_arm",
"(",
"self",
",",
"home_id",
")",
":",
"return",
"await",
"self",
".",
"_client",
".",
"alarm_arm",
"(",
"home_id",
")"
] | [
237,
4
] | [
239,
52
] | python | en | ['en', 'sr', 'en'] | True |
MinutPointEntity.__init__ | (self, point_client, device_id, device_class) | Initialize the entity. | Initialize the entity. | def __init__(self, point_client, device_id, device_class):
"""Initialize the entity."""
self._async_unsub_dispatcher_connect = None
self._client = point_client
self._id = device_id
self._name = self.device.name
self._device_class = device_class
self._updated = utc... | [
"def",
"__init__",
"(",
"self",
",",
"point_client",
",",
"device_id",
",",
"device_class",
")",
":",
"self",
".",
"_async_unsub_dispatcher_connect",
"=",
"None",
"self",
".",
"_client",
"=",
"point_client",
"self",
".",
"_id",
"=",
"device_id",
"self",
".",
... | [
245,
4
] | [
253,
26
] | python | en | ['en', 'en', 'en'] | True |
MinutPointEntity.__str__ | (self) | Return string representation of device. | Return string representation of device. | def __str__(self):
"""Return string representation of device."""
return f"MinutPoint {self.name}" | [
"def",
"__str__",
"(",
"self",
")",
":",
"return",
"f\"MinutPoint {self.name}\""
] | [
255,
4
] | [
257,
40
] | python | en | ['en', 'sl', 'en'] | True |
MinutPointEntity.async_added_to_hass | (self) | Call when entity is added to hass. | Call when entity is added to hass. | async def async_added_to_hass(self):
"""Call when entity is added to hass."""
_LOGGER.debug("Created device %s", self)
self._async_unsub_dispatcher_connect = async_dispatcher_connect(
self.hass, SIGNAL_UPDATE_ENTITY, self._update_callback
)
await self._update_callback... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Created device %s\"",
",",
"self",
")",
"self",
".",
"_async_unsub_dispatcher_connect",
"=",
"async_dispatcher_connect",
"(",
"self",
".",
"hass",
",",
"SIGNAL_UPDATE_ENTI... | [
259,
4
] | [
265,
37
] | python | en | ['en', 'en', 'en'] | True |
MinutPointEntity.async_will_remove_from_hass | (self) | Disconnect dispatcher listener when removed. | Disconnect dispatcher listener when removed. | async def async_will_remove_from_hass(self):
"""Disconnect dispatcher listener when removed."""
if self._async_unsub_dispatcher_connect:
self._async_unsub_dispatcher_connect() | [
"async",
"def",
"async_will_remove_from_hass",
"(",
"self",
")",
":",
"if",
"self",
".",
"_async_unsub_dispatcher_connect",
":",
"self",
".",
"_async_unsub_dispatcher_connect",
"(",
")"
] | [
267,
4
] | [
270,
50
] | python | en | ['en', 'en', 'en'] | True |
MinutPointEntity._update_callback | (self) | Update the value of the sensor. | Update the value of the sensor. | async def _update_callback(self):
"""Update the value of the sensor.""" | [
"async",
"def",
"_update_callback",
"(",
"self",
")",
":"
] | [
272,
4
] | [
273,
45
] | python | en | ['en', 'en', 'en'] | True |
MinutPointEntity.available | (self) | Return true if device is not offline. | Return true if device is not offline. | def available(self):
"""Return true if device is not offline."""
return self._client.is_available(self.device_id) | [
"def",
"available",
"(",
"self",
")",
":",
"return",
"self",
".",
"_client",
".",
"is_available",
"(",
"self",
".",
"device_id",
")"
] | [
276,
4
] | [
278,
56
] | python | en | ['en', 'fy', 'en'] | True |
MinutPointEntity.device | (self) | Return the representation of the device. | Return the representation of the device. | def device(self):
"""Return the representation of the device."""
return self._client.device(self.device_id) | [
"def",
"device",
"(",
"self",
")",
":",
"return",
"self",
".",
"_client",
".",
"device",
"(",
"self",
".",
"device_id",
")"
] | [
281,
4
] | [
283,
50
] | python | en | ['en', 'en', 'en'] | True |
MinutPointEntity.device_class | (self) | Return the device class. | Return the device class. | def device_class(self):
"""Return the device class."""
return self._device_class | [
"def",
"device_class",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device_class"
] | [
286,
4
] | [
288,
33
] | python | en | ['en', 'en', 'en'] | True |
MinutPointEntity.device_id | (self) | Return the id of the device. | Return the id of the device. | def device_id(self):
"""Return the id of the device."""
return self._id | [
"def",
"device_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_id"
] | [
291,
4
] | [
293,
23
] | python | en | ['en', 'en', 'en'] | True |
MinutPointEntity.device_state_attributes | (self) | Return status of device. | Return status of device. | def device_state_attributes(self):
"""Return status of device."""
attrs = self.device.device_status
attrs["last_heard_from"] = as_local(self.last_update).strftime(
"%Y-%m-%d %H:%M:%S"
)
return attrs | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"attrs",
"=",
"self",
".",
"device",
".",
"device_status",
"attrs",
"[",
"\"last_heard_from\"",
"]",
"=",
"as_local",
"(",
"self",
".",
"last_update",
")",
".",
"strftime",
"(",
"\"%Y-%m-%d %H:%M:%S\"",
... | [
296,
4
] | [
302,
20
] | python | en | ['en', 'ja', 'en'] | True |
MinutPointEntity.device_info | (self) | Return a device description for device registry. | Return a device description for device registry. | def device_info(self):
"""Return a device description for device registry."""
device = self.device.device
return {
"connections": {("mac", device["device_mac"])},
"identifieres": device["device_id"],
"manufacturer": "Minut",
"model": f"Point v{devi... | [
"def",
"device_info",
"(",
"self",
")",
":",
"device",
"=",
"self",
".",
"device",
".",
"device",
"return",
"{",
"\"connections\"",
":",
"{",
"(",
"\"mac\"",
",",
"device",
"[",
"\"device_mac\"",
"]",
")",
"}",
",",
"\"identifieres\"",
":",
"device",
"["... | [
305,
4
] | [
316,
9
] | python | en | ['ro', 'fr', 'en'] | False |
MinutPointEntity.name | (self) | Return the display name of this device. | Return the display name of this device. | def name(self):
"""Return the display name of this device."""
return f"{self._name} {self.device_class.capitalize()}" | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"f\"{self._name} {self.device_class.capitalize()}\""
] | [
319,
4
] | [
321,
63
] | python | en | ['en', 'en', 'en'] | True |
MinutPointEntity.is_updated | (self) | Return true if sensor have been updated. | Return true if sensor have been updated. | def is_updated(self):
"""Return true if sensor have been updated."""
return self.last_update > self._updated | [
"def",
"is_updated",
"(",
"self",
")",
":",
"return",
"self",
".",
"last_update",
">",
"self",
".",
"_updated"
] | [
324,
4
] | [
326,
47
] | python | en | ['en', 'nl', 'en'] | True |
MinutPointEntity.last_update | (self) | Return the last_update time for the device. | Return the last_update time for the device. | def last_update(self):
"""Return the last_update time for the device."""
last_update = parse_datetime(self.device.last_update)
return last_update | [
"def",
"last_update",
"(",
"self",
")",
":",
"last_update",
"=",
"parse_datetime",
"(",
"self",
".",
"device",
".",
"last_update",
")",
"return",
"last_update"
] | [
329,
4
] | [
332,
26
] | python | en | ['en', 'en', 'en'] | True |
MinutPointEntity.should_poll | (self) | No polling needed for point. | No polling needed for point. | def should_poll(self):
"""No polling needed for point."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
335,
4
] | [
337,
20
] | python | en | ['en', 'en', 'en'] | True |
MinutPointEntity.unique_id | (self) | Return the unique id of the sensor. | Return the unique id of the sensor. | def unique_id(self):
"""Return the unique id of the sensor."""
return f"point.{self._id}-{self.device_class}" | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"f\"point.{self._id}-{self.device_class}\""
] | [
340,
4
] | [
342,
54
] | python | en | ['en', 'la', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.