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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
GenericThermostat._async_heater_turn_on | (self) | Turn heater toggleable device on. | Turn heater toggleable device on. | async def _async_heater_turn_on(self):
"""Turn heater toggleable device on."""
data = {ATTR_ENTITY_ID: self.heater_entity_id}
await self.hass.services.async_call(
HA_DOMAIN, SERVICE_TURN_ON, data, context=self._context
) | [
"async",
"def",
"_async_heater_turn_on",
"(",
"self",
")",
":",
"data",
"=",
"{",
"ATTR_ENTITY_ID",
":",
"self",
".",
"heater_entity_id",
"}",
"await",
"self",
".",
"hass",
".",
"services",
".",
"async_call",
"(",
"HA_DOMAIN",
",",
"SERVICE_TURN_ON",
",",
"d... | [
462,
4
] | [
467,
9
] | python | en | ['nl', 'en', 'en'] | True |
GenericThermostat._async_heater_turn_off | (self) | Turn heater toggleable device off. | Turn heater toggleable device off. | async def _async_heater_turn_off(self):
"""Turn heater toggleable device off."""
data = {ATTR_ENTITY_ID: self.heater_entity_id}
await self.hass.services.async_call(
HA_DOMAIN, SERVICE_TURN_OFF, data, context=self._context
) | [
"async",
"def",
"_async_heater_turn_off",
"(",
"self",
")",
":",
"data",
"=",
"{",
"ATTR_ENTITY_ID",
":",
"self",
".",
"heater_entity_id",
"}",
"await",
"self",
".",
"hass",
".",
"services",
".",
"async_call",
"(",
"HA_DOMAIN",
",",
"SERVICE_TURN_OFF",
",",
... | [
469,
4
] | [
474,
9
] | python | en | ['nl', 'en', 'en'] | True |
GenericThermostat.async_set_preset_mode | (self, preset_mode: str) | Set new preset mode. | Set new preset mode. | async def async_set_preset_mode(self, preset_mode: str):
"""Set new preset mode."""
if preset_mode == PRESET_AWAY and not self._is_away:
self._is_away = True
self._saved_target_temp = self._target_temp
self._target_temp = self._away_temp
await self._async_... | [
"async",
"def",
"async_set_preset_mode",
"(",
"self",
",",
"preset_mode",
":",
"str",
")",
":",
"if",
"preset_mode",
"==",
"PRESET_AWAY",
"and",
"not",
"self",
".",
"_is_away",
":",
"self",
".",
"_is_away",
"=",
"True",
"self",
".",
"_saved_target_temp",
"="... | [
476,
4
] | [
488,
35
] | python | en | ['en', 'sr', 'en'] | True |
dist | (proxy: Proxy, handler_dict: {object: Callable}) |
A decorator used to inject a ``communication module`` and ``message handlers``
to a local class so that it can be run in distributed mode.
|
A decorator used to inject a ``communication module`` and ``message handlers``
to a local class so that it can be run in distributed mode.
| def dist(proxy: Proxy, handler_dict: {object: Callable}):
"""
A decorator used to inject a ``communication module`` and ``message handlers``
to a local class so that it can be run in distributed mode.
"""
def dist_decorator(cls):
class Wrapper:
"""A wrapper class for ``cls``, the... | [
"def",
"dist",
"(",
"proxy",
":",
"Proxy",
",",
"handler_dict",
":",
"{",
"object",
":",
"Callable",
"}",
")",
":",
"def",
"dist_decorator",
"(",
"cls",
")",
":",
"class",
"Wrapper",
":",
"\"\"\"A wrapper class for ``cls``, the class to be decorated.\n\n ... | [
12,
0
] | [
52,
25
] | python | en | ['en', 'error', 'th'] | False |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the USGS Earthquake Hazards Program Feed platform. | Set up the USGS Earthquake Hazards Program Feed platform. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the USGS Earthquake Hazards Program Feed platform."""
scan_interval = config.get(CONF_SCAN_INTERVAL, SCAN_INTERVAL)
feed_type = config[CONF_FEED_TYPE]
coordinates = (
config.get(CONF_LATITUDE, hass.config.latitude),
... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"scan_interval",
"=",
"config",
".",
"get",
"(",
"CONF_SCAN_INTERVAL",
",",
"SCAN_INTERVAL",
")",
"feed_type",
"=",
"config",
"[",
"CONF_FEE... | [
86,
0
] | [
111,
71
] | python | en | ['en', 'da', 'en'] | True |
UsgsEarthquakesFeedEntityManager.__init__ | (
self,
hass,
add_entities,
scan_interval,
coordinates,
feed_type,
radius_in_km,
minimum_magnitude,
) | Initialize the Feed Entity Manager. | Initialize the Feed Entity Manager. | def __init__(
self,
hass,
add_entities,
scan_interval,
coordinates,
feed_type,
radius_in_km,
minimum_magnitude,
):
"""Initialize the Feed Entity Manager."""
self._hass = hass
self._feed_manager = UsgsEarthquakeHazardsProgramFee... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"add_entities",
",",
"scan_interval",
",",
"coordinates",
",",
"feed_type",
",",
"radius_in_km",
",",
"minimum_magnitude",
",",
")",
":",
"self",
".",
"_hass",
"=",
"hass",
"self",
".",
"_feed_manager",
"=",
... | [
117,
4
] | [
140,
43
] | python | en | ['en', 'en', 'en'] | True |
UsgsEarthquakesFeedEntityManager.startup | (self) | Start up this manager. | Start up this manager. | def startup(self):
"""Start up this manager."""
self._feed_manager.update()
self._init_regular_updates() | [
"def",
"startup",
"(",
"self",
")",
":",
"self",
".",
"_feed_manager",
".",
"update",
"(",
")",
"self",
".",
"_init_regular_updates",
"(",
")"
] | [
142,
4
] | [
145,
36
] | python | en | ['en', 'en', 'en'] | True |
UsgsEarthquakesFeedEntityManager._init_regular_updates | (self) | Schedule regular updates at the specified interval. | Schedule regular updates at the specified interval. | def _init_regular_updates(self):
"""Schedule regular updates at the specified interval."""
track_time_interval(
self._hass, lambda now: self._feed_manager.update(), self._scan_interval
) | [
"def",
"_init_regular_updates",
"(",
"self",
")",
":",
"track_time_interval",
"(",
"self",
".",
"_hass",
",",
"lambda",
"now",
":",
"self",
".",
"_feed_manager",
".",
"update",
"(",
")",
",",
"self",
".",
"_scan_interval",
")"
] | [
147,
4
] | [
151,
9
] | python | en | ['en', 'en', 'en'] | True |
UsgsEarthquakesFeedEntityManager.get_entry | (self, external_id) | Get feed entry by external id. | Get feed entry by external id. | def get_entry(self, external_id):
"""Get feed entry by external id."""
return self._feed_manager.feed_entries.get(external_id) | [
"def",
"get_entry",
"(",
"self",
",",
"external_id",
")",
":",
"return",
"self",
".",
"_feed_manager",
".",
"feed_entries",
".",
"get",
"(",
"external_id",
")"
] | [
153,
4
] | [
155,
63
] | python | en | ['en', 'en', 'en'] | True |
UsgsEarthquakesFeedEntityManager._generate_entity | (self, external_id) | Generate new entity. | Generate new entity. | def _generate_entity(self, external_id):
"""Generate new entity."""
new_entity = UsgsEarthquakesEvent(self, external_id)
# Add new entities to HA.
self._add_entities([new_entity], True) | [
"def",
"_generate_entity",
"(",
"self",
",",
"external_id",
")",
":",
"new_entity",
"=",
"UsgsEarthquakesEvent",
"(",
"self",
",",
"external_id",
")",
"# Add new entities to HA.",
"self",
".",
"_add_entities",
"(",
"[",
"new_entity",
"]",
",",
"True",
")"
] | [
157,
4
] | [
161,
46
] | python | en | ['en', 'en', 'en'] | True |
UsgsEarthquakesFeedEntityManager._update_entity | (self, external_id) | Update entity. | Update entity. | def _update_entity(self, external_id):
"""Update entity."""
dispatcher_send(self._hass, SIGNAL_UPDATE_ENTITY.format(external_id)) | [
"def",
"_update_entity",
"(",
"self",
",",
"external_id",
")",
":",
"dispatcher_send",
"(",
"self",
".",
"_hass",
",",
"SIGNAL_UPDATE_ENTITY",
".",
"format",
"(",
"external_id",
")",
")"
] | [
163,
4
] | [
165,
77
] | python | en | ['es', 'en', 'en'] | False |
UsgsEarthquakesFeedEntityManager._remove_entity | (self, external_id) | Remove entity. | Remove entity. | def _remove_entity(self, external_id):
"""Remove entity."""
dispatcher_send(self._hass, SIGNAL_DELETE_ENTITY.format(external_id)) | [
"def",
"_remove_entity",
"(",
"self",
",",
"external_id",
")",
":",
"dispatcher_send",
"(",
"self",
".",
"_hass",
",",
"SIGNAL_DELETE_ENTITY",
".",
"format",
"(",
"external_id",
")",
")"
] | [
167,
4
] | [
169,
77
] | python | en | ['es', 'it', 'en'] | False |
UsgsEarthquakesEvent.__init__ | (self, feed_manager, external_id) | Initialize entity with data from feed entry. | Initialize entity with data from feed entry. | def __init__(self, feed_manager, external_id):
"""Initialize entity with data from feed entry."""
self._feed_manager = feed_manager
self._external_id = external_id
self._name = None
self._distance = None
self._latitude = None
self._longitude = None
self._a... | [
"def",
"__init__",
"(",
"self",
",",
"feed_manager",
",",
"external_id",
")",
":",
"self",
".",
"_feed_manager",
"=",
"feed_manager",
"self",
".",
"_external_id",
"=",
"external_id",
"self",
".",
"_name",
"=",
"None",
"self",
".",
"_distance",
"=",
"None",
... | [
175,
4
] | [
192,
41
] | python | en | ['en', 'en', 'en'] | True |
UsgsEarthquakesEvent.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."""
self._remove_signal_delete = async_dispatcher_connect(
self.hass,
SIGNAL_DELETE_ENTITY.format(self._external_id),
self._delete_callback,
)
self._remove_signal_update = async_... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"_remove_signal_delete",
"=",
"async_dispatcher_connect",
"(",
"self",
".",
"hass",
",",
"SIGNAL_DELETE_ENTITY",
".",
"format",
"(",
"self",
".",
"_external_id",
")",
",",
"self",
".",
... | [
194,
4
] | [
205,
9
] | python | en | ['en', 'en', 'en'] | True |
UsgsEarthquakesEvent._delete_callback | (self) | Remove this entity. | Remove this entity. | def _delete_callback(self):
"""Remove this entity."""
self._remove_signal_delete()
self._remove_signal_update()
self.hass.async_create_task(self.async_remove()) | [
"def",
"_delete_callback",
"(",
"self",
")",
":",
"self",
".",
"_remove_signal_delete",
"(",
")",
"self",
".",
"_remove_signal_update",
"(",
")",
"self",
".",
"hass",
".",
"async_create_task",
"(",
"self",
".",
"async_remove",
"(",
")",
")"
] | [
208,
4
] | [
212,
56
] | python | en | ['en', 'en', 'en'] | True |
UsgsEarthquakesEvent._update_callback | (self) | Call update method. | Call update method. | def _update_callback(self):
"""Call update method."""
self.async_schedule_update_ha_state(True) | [
"def",
"_update_callback",
"(",
"self",
")",
":",
"self",
".",
"async_schedule_update_ha_state",
"(",
"True",
")"
] | [
215,
4
] | [
217,
49
] | python | en | ['en', 'sn', 'en'] | True |
UsgsEarthquakesEvent.should_poll | (self) | No polling needed for USGS Earthquake events. | No polling needed for USGS Earthquake events. | def should_poll(self):
"""No polling needed for USGS Earthquake events."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
220,
4
] | [
222,
20
] | python | en | ['en', 'en', 'en'] | True |
UsgsEarthquakesEvent.async_update | (self) | Update this entity from the data held in the feed manager. | Update this entity from the data held in the feed manager. | async def async_update(self):
"""Update this entity from the data held in the feed manager."""
_LOGGER.debug("Updating %s", self._external_id)
feed_entry = self._feed_manager.get_entry(self._external_id)
if feed_entry:
self._update_from_feed(feed_entry) | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Updating %s\"",
",",
"self",
".",
"_external_id",
")",
"feed_entry",
"=",
"self",
".",
"_feed_manager",
".",
"get_entry",
"(",
"self",
".",
"_external_id",
")",
"if",
"... | [
224,
4
] | [
229,
46
] | python | en | ['en', 'en', 'en'] | True |
UsgsEarthquakesEvent._update_from_feed | (self, feed_entry) | Update the internal state from the provided feed entry. | Update the internal state from the provided feed entry. | def _update_from_feed(self, feed_entry):
"""Update the internal state from the provided feed entry."""
self._name = feed_entry.title
self._distance = feed_entry.distance_to_home
self._latitude = feed_entry.coordinates[0]
self._longitude = feed_entry.coordinates[1]
self._a... | [
"def",
"_update_from_feed",
"(",
"self",
",",
"feed_entry",
")",
":",
"self",
".",
"_name",
"=",
"feed_entry",
".",
"title",
"self",
".",
"_distance",
"=",
"feed_entry",
".",
"distance_to_home",
"self",
".",
"_latitude",
"=",
"feed_entry",
".",
"coordinates",
... | [
231,
4
] | [
244,
38
] | python | en | ['en', 'en', 'en'] | True |
UsgsEarthquakesEvent.icon | (self) | Return the icon to use in the frontend. | Return the icon to use in the frontend. | def icon(self):
"""Return the icon to use in the frontend."""
return "mdi:pulse" | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"\"mdi:pulse\""
] | [
247,
4
] | [
249,
26
] | python | en | ['en', 'en', 'en'] | True |
UsgsEarthquakesEvent.source | (self) | Return source value of this external event. | Return source value of this external event. | def source(self) -> str:
"""Return source value of this external event."""
return SOURCE | [
"def",
"source",
"(",
"self",
")",
"->",
"str",
":",
"return",
"SOURCE"
] | [
252,
4
] | [
254,
21
] | python | en | ['en', 'en', 'en'] | True |
UsgsEarthquakesEvent.name | (self) | Return the name of the entity. | Return the name of the entity. | def name(self) -> Optional[str]:
"""Return the name of the entity."""
return self._name | [
"def",
"name",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"return",
"self",
".",
"_name"
] | [
257,
4
] | [
259,
25
] | python | en | ['en', 'en', 'en'] | True |
UsgsEarthquakesEvent.distance | (self) | Return distance value of this external event. | Return distance value of this external event. | def distance(self) -> Optional[float]:
"""Return distance value of this external event."""
return self._distance | [
"def",
"distance",
"(",
"self",
")",
"->",
"Optional",
"[",
"float",
"]",
":",
"return",
"self",
".",
"_distance"
] | [
262,
4
] | [
264,
29
] | python | en | ['en', 'en', 'en'] | True |
UsgsEarthquakesEvent.latitude | (self) | Return latitude value of this external event. | Return latitude value of this external event. | def latitude(self) -> Optional[float]:
"""Return latitude value of this external event."""
return self._latitude | [
"def",
"latitude",
"(",
"self",
")",
"->",
"Optional",
"[",
"float",
"]",
":",
"return",
"self",
".",
"_latitude"
] | [
267,
4
] | [
269,
29
] | python | en | ['en', 'la', 'en'] | True |
UsgsEarthquakesEvent.longitude | (self) | Return longitude value of this external event. | Return longitude value of this external event. | def longitude(self) -> Optional[float]:
"""Return longitude value of this external event."""
return self._longitude | [
"def",
"longitude",
"(",
"self",
")",
"->",
"Optional",
"[",
"float",
"]",
":",
"return",
"self",
".",
"_longitude"
] | [
272,
4
] | [
274,
30
] | python | en | ['en', 'en', 'en'] | True |
UsgsEarthquakesEvent.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 DEFAULT_UNIT_OF_MEASUREMENT | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"DEFAULT_UNIT_OF_MEASUREMENT"
] | [
277,
4
] | [
279,
42
] | python | en | ['en', 'la', 'en'] | True |
UsgsEarthquakesEvent.device_state_attributes | (self) | Return the device state attributes. | Return the device state attributes. | def device_state_attributes(self):
"""Return the device state attributes."""
attributes = {}
for key, value in (
(ATTR_EXTERNAL_ID, self._external_id),
(ATTR_PLACE, self._place),
(ATTR_MAGNITUDE, self._magnitude),
(ATTR_TIME, self._time),
... | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"attributes",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"(",
"(",
"ATTR_EXTERNAL_ID",
",",
"self",
".",
"_external_id",
")",
",",
"(",
"ATTR_PLACE",
",",
"self",
".",
"_place",
")",
",",
"... | [
282,
4
] | [
298,
25
] | python | en | ['en', 'en', 'en'] | True |
create_mnist_model | (hyper_params, input_shape=(H, W, 1), num_classes=NUM_CLASSES) |
Create simple convolutional model
|
Create simple convolutional model
| def create_mnist_model(hyper_params, input_shape=(H, W, 1), num_classes=NUM_CLASSES):
'''
Create simple convolutional model
'''
layers = [
Conv2D(32, kernel_size=(3, 3), activation='relu', input_shape=input_shape),
Conv2D(64, (3, 3), activation='relu'),
MaxPooling2D(pool_size=(2,... | [
"def",
"create_mnist_model",
"(",
"hyper_params",
",",
"input_shape",
"=",
"(",
"H",
",",
"W",
",",
"1",
")",
",",
"num_classes",
"=",
"NUM_CLASSES",
")",
":",
"layers",
"=",
"[",
"Conv2D",
"(",
"32",
",",
"kernel_size",
"=",
"(",
"3",
",",
"3",
")",... | [
38,
0
] | [
59,
16
] | python | en | ['en', 'error', 'th'] | False |
load_mnist_data | (args) |
Load MNIST dataset
|
Load MNIST dataset
| def load_mnist_data(args):
'''
Load MNIST dataset
'''
(x_train, y_train), (x_test, y_test) = mnist.load_data()
x_train = (np.expand_dims(x_train, -1).astype(np.float) / 255.)[:args.num_train]
x_test = (np.expand_dims(x_test, -1).astype(np.float) / 255.)[:args.num_test]
y_train = keras.utils... | [
"def",
"load_mnist_data",
"(",
"args",
")",
":",
"(",
"x_train",
",",
"y_train",
")",
",",
"(",
"x_test",
",",
"y_test",
")",
"=",
"mnist",
".",
"load_data",
"(",
")",
"x_train",
"=",
"(",
"np",
".",
"expand_dims",
"(",
"x_train",
",",
"-",
"1",
")... | [
61,
0
] | [
75,
43
] | python | en | ['en', 'error', 'th'] | False |
train | (args, params) |
Train model
|
Train model
| def train(args, params):
'''
Train model
'''
x_train, y_train, x_test, y_test = load_mnist_data(args)
model = create_mnist_model(params)
# nni
model.fit(x_train, y_train, batch_size=args.batch_size, epochs=args.epochs, verbose=1,
validation_data=(x_test, y_test), callbacks=[SendMetr... | [
"def",
"train",
"(",
"args",
",",
"params",
")",
":",
"x_train",
",",
"y_train",
",",
"x_test",
",",
"y_test",
"=",
"load_mnist_data",
"(",
"args",
")",
"model",
"=",
"create_mnist_model",
"(",
"params",
")",
"# nni",
"model",
".",
"fit",
"(",
"x_train",... | [
92,
0
] | [
105,
32
] | python | en | ['en', 'error', 'th'] | False |
generate_default_params | () |
Generate default hyper parameters
|
Generate default hyper parameters
| def generate_default_params():
'''
Generate default hyper parameters
'''
return {
'optimizer': 'Adam',
'learning_rate': 0.001
} | [
"def",
"generate_default_params",
"(",
")",
":",
"return",
"{",
"'optimizer'",
":",
"'Adam'",
",",
"'learning_rate'",
":",
"0.001",
"}"
] | [
107,
0
] | [
114,
5
] | python | en | ['en', 'error', 'th'] | False |
SendMetrics.on_epoch_end | (self, epoch, logs={}) |
Run on end of each epoch
|
Run on end of each epoch
| def on_epoch_end(self, epoch, logs={}):
'''
Run on end of each epoch
'''
LOG.debug(logs)
# TensorFlow 2.0 API reference claims the key is `val_acc`, but in fact it's `val_accuracy`
if 'val_acc' in logs:
nni.report_intermediate_result(logs['val_acc'])
e... | [
"def",
"on_epoch_end",
"(",
"self",
",",
"epoch",
",",
"logs",
"=",
"{",
"}",
")",
":",
"LOG",
".",
"debug",
"(",
"logs",
")",
"# TensorFlow 2.0 API reference claims the key is `val_acc`, but in fact it's `val_accuracy`",
"if",
"'val_acc'",
"in",
"logs",
":",
"nni",... | [
81,
4
] | [
90,
64
] | python | en | ['en', 'error', 'th'] | False |
AlbertTokenizerFast.build_inputs_with_special_tokens | (
self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None
) |
Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and
adding special tokens. An ALBERT sequence has the following format:
- single sequence: ``[CLS] X [SEP]``
- pair of sequences: ``[CLS] A [SEP] B [SEP]``
Args:
... |
Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and
adding special tokens. An ALBERT sequence has the following format: | def build_inputs_with_special_tokens(
self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None
) -> List[int]:
"""
Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and
adding special tokens. An ALBERT sequence ha... | [
"def",
"build_inputs_with_special_tokens",
"(",
"self",
",",
"token_ids_0",
":",
"List",
"[",
"int",
"]",
",",
"token_ids_1",
":",
"Optional",
"[",
"List",
"[",
"int",
"]",
"]",
"=",
"None",
")",
"->",
"List",
"[",
"int",
"]",
":",
"sep",
"=",
"[",
"... | [
161,
4
] | [
184,
58
] | python | en | ['en', 'error', 'th'] | False |
AlbertTokenizerFast.get_special_tokens_mask | (
self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None, already_has_special_tokens: bool = False
) |
Retrieves sequence ids from a token list that has no special tokens added. This method is called when adding
special tokens using the tokenizer ``prepare_for_model`` method.
Args:
token_ids_0 (:obj:`List[int]`):
List of ids.
token_ids_1 (:obj:`List[int]`... |
Retrieves sequence ids from a token list that has no special tokens added. This method is called when adding
special tokens using the tokenizer ``prepare_for_model`` method. | def get_special_tokens_mask(
self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None, already_has_special_tokens: bool = False
) -> List[int]:
"""
Retrieves sequence ids from a token list that has no special tokens added. This method is called when adding
special tokens... | [
"def",
"get_special_tokens_mask",
"(",
"self",
",",
"token_ids_0",
":",
"List",
"[",
"int",
"]",
",",
"token_ids_1",
":",
"Optional",
"[",
"List",
"[",
"int",
"]",
"]",
"=",
"None",
",",
"already_has_special_tokens",
":",
"bool",
"=",
"False",
")",
"->",
... | [
186,
4
] | [
215,
51
] | python | en | ['en', 'error', 'th'] | False |
AlbertTokenizerFast.create_token_type_ids_from_sequences | (
self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None
) |
Creates a mask from the two sequences passed to be used in a sequence-pair classification task. An ALBERT
sequence pair mask has the following format:
::
0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1
| first sequence | second sequence |
if token_ids_1 is None, on... |
Creates a mask from the two sequences passed to be used in a sequence-pair classification task. An ALBERT
sequence pair mask has the following format: | def create_token_type_ids_from_sequences(
self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None
) -> List[int]:
"""
Creates a mask from the two sequences passed to be used in a sequence-pair classification task. An ALBERT
sequence pair mask has the following format:
... | [
"def",
"create_token_type_ids_from_sequences",
"(",
"self",
",",
"token_ids_0",
":",
"List",
"[",
"int",
"]",
",",
"token_ids_1",
":",
"Optional",
"[",
"List",
"[",
"int",
"]",
"]",
"=",
"None",
")",
"->",
"List",
"[",
"int",
"]",
":",
"sep",
"=",
"[",... | [
217,
4
] | [
246,
80
] | python | en | ['en', 'error', 'th'] | False |
test_validate_python | (mock_exit) | Test validate Python version method. | Test validate Python version method. | def test_validate_python(mock_exit):
"""Test validate Python version method."""
with patch("sys.version_info", new_callable=PropertyMock(return_value=(2, 7, 8))):
main.validate_python()
assert mock_exit.called is True
mock_exit.reset_mock()
with patch("sys.version_info", new_callable=P... | [
"def",
"test_validate_python",
"(",
"mock_exit",
")",
":",
"with",
"patch",
"(",
"\"sys.version_info\"",
",",
"new_callable",
"=",
"PropertyMock",
"(",
"return_value",
"=",
"(",
"2",
",",
"7",
",",
"8",
")",
")",
")",
":",
"main",
".",
"validate_python",
"... | [
8,
0
] | [
62,
26
] | python | en | ['nl', 'et', 'en'] | False |
WeatherUpdateCoordinator.__init__ | (self, owm, latitude, longitude, forecast_mode, hass) | Initialize coordinator. | Initialize coordinator. | def __init__(self, owm, latitude, longitude, forecast_mode, hass):
"""Initialize coordinator."""
self._owm_client = owm
self._latitude = latitude
self._longitude = longitude
self._forecast_mode = forecast_mode
self._forecast_limit = None
if forecast_mode == FORECA... | [
"def",
"__init__",
"(",
"self",
",",
"owm",
",",
"latitude",
",",
"longitude",
",",
"forecast_mode",
",",
"hass",
")",
":",
"self",
".",
"_owm_client",
"=",
"owm",
"self",
".",
"_latitude",
"=",
"latitude",
"self",
".",
"_longitude",
"=",
"longitude",
"s... | [
47,
4
] | [
59,
9
] | python | it | ['it', 'ro', 'it'] | False |
WeatherUpdateCoordinator._get_owm_weather | (self) | Poll weather data from OWM. | Poll weather data from OWM. | async def _get_owm_weather(self):
"""Poll weather data from OWM."""
if (
self._forecast_mode == FORECAST_MODE_ONECALL_HOURLY
or self._forecast_mode == FORECAST_MODE_ONECALL_DAILY
):
weather = await self.hass.async_add_executor_job(
self._owm_cl... | [
"async",
"def",
"_get_owm_weather",
"(",
"self",
")",
":",
"if",
"(",
"self",
".",
"_forecast_mode",
"==",
"FORECAST_MODE_ONECALL_HOURLY",
"or",
"self",
".",
"_forecast_mode",
"==",
"FORECAST_MODE_ONECALL_DAILY",
")",
":",
"weather",
"=",
"await",
"self",
".",
"... | [
71,
4
] | [
85,
22
] | python | en | ['en', 'en', 'en'] | True |
WeatherUpdateCoordinator._get_legacy_weather_and_forecast | (self) | Get weather and forecast data from OWM. | Get weather and forecast data from OWM. | def _get_legacy_weather_and_forecast(self):
"""Get weather and forecast data from OWM."""
interval = self._get_forecast_interval()
weather = self._owm_client.weather_at_coords(self._latitude, self._longitude)
forecast = self._owm_client.forecast_at_coords(
self._latitude, sel... | [
"def",
"_get_legacy_weather_and_forecast",
"(",
"self",
")",
":",
"interval",
"=",
"self",
".",
"_get_forecast_interval",
"(",
")",
"weather",
"=",
"self",
".",
"_owm_client",
".",
"weather_at_coords",
"(",
"self",
".",
"_latitude",
",",
"self",
".",
"_longitude... | [
87,
4
] | [
94,
73
] | python | en | ['en', 'en', 'en'] | True |
WeatherUpdateCoordinator._get_forecast_interval | (self) | Get the correct forecast interval depending on the forecast mode. | Get the correct forecast interval depending on the forecast mode. | def _get_forecast_interval(self):
"""Get the correct forecast interval depending on the forecast mode."""
interval = "daily"
if self._forecast_mode == FORECAST_MODE_HOURLY:
interval = "3h"
return interval | [
"def",
"_get_forecast_interval",
"(",
"self",
")",
":",
"interval",
"=",
"\"daily\"",
"if",
"self",
".",
"_forecast_mode",
"==",
"FORECAST_MODE_HOURLY",
":",
"interval",
"=",
"\"3h\"",
"return",
"interval"
] | [
96,
4
] | [
101,
23
] | python | en | ['en', 'en', 'en'] | True |
WeatherUpdateCoordinator._convert_weather_response | (self, weather_response) | Format the weather response correctly. | Format the weather response correctly. | def _convert_weather_response(self, weather_response):
"""Format the weather response correctly."""
current_weather = weather_response.current
forecast_weather = self._get_forecast_from_weather_response(weather_response)
return {
ATTR_API_TEMPERATURE: current_weather.tempera... | [
"def",
"_convert_weather_response",
"(",
"self",
",",
"weather_response",
")",
":",
"current_weather",
"=",
"weather_response",
".",
"current",
"forecast_weather",
"=",
"self",
".",
"_get_forecast_from_weather_response",
"(",
"weather_response",
")",
"return",
"{",
"ATT... | [
103,
4
] | [
121,
9
] | python | en | ['en', 'en', 'en'] | True |
WeatherUpdateCoordinator._get_rain | (rain) | Get rain data from weather data. | Get rain data from weather data. | def _get_rain(rain):
"""Get rain data from weather data."""
if "all" in rain:
return round(rain["all"], 0)
if "1h" in rain:
return round(rain["1h"], 0)
return "not raining" | [
"def",
"_get_rain",
"(",
"rain",
")",
":",
"if",
"\"all\"",
"in",
"rain",
":",
"return",
"round",
"(",
"rain",
"[",
"\"all\"",
"]",
",",
"0",
")",
"if",
"\"1h\"",
"in",
"rain",
":",
"return",
"round",
"(",
"rain",
"[",
"\"1h\"",
"]",
",",
"0",
")... | [
154,
4
] | [
160,
28
] | python | en | ['en', 'en', 'en'] | True |
WeatherUpdateCoordinator._get_snow | (snow) | Get snow data from weather data. | Get snow data from weather data. | def _get_snow(snow):
"""Get snow data from weather data."""
if snow:
if "all" in snow:
return round(snow["all"], 0)
if "1h" in snow:
return round(snow["1h"], 0)
return "not snowing"
return "not snowing" | [
"def",
"_get_snow",
"(",
"snow",
")",
":",
"if",
"snow",
":",
"if",
"\"all\"",
"in",
"snow",
":",
"return",
"round",
"(",
"snow",
"[",
"\"all\"",
"]",
",",
"0",
")",
"if",
"\"1h\"",
"in",
"snow",
":",
"return",
"round",
"(",
"snow",
"[",
"\"1h\"",
... | [
163,
4
] | [
171,
28
] | python | en | ['en', 'en', 'en'] | True |
WeatherUpdateCoordinator._calc_precipitation | (rain, snow) | Calculate the precipitation. | Calculate the precipitation. | def _calc_precipitation(rain, snow):
"""Calculate the precipitation."""
rain_value = 0
if WeatherUpdateCoordinator._get_rain(rain) != "not raining":
rain_value = WeatherUpdateCoordinator._get_rain(rain)
snow_value = 0
if WeatherUpdateCoordinator._get_snow(snow) != "n... | [
"def",
"_calc_precipitation",
"(",
"rain",
",",
"snow",
")",
":",
"rain_value",
"=",
"0",
"if",
"WeatherUpdateCoordinator",
".",
"_get_rain",
"(",
"rain",
")",
"!=",
"\"not raining\"",
":",
"rain_value",
"=",
"WeatherUpdateCoordinator",
".",
"_get_rain",
"(",
"r... | [
174,
4
] | [
186,
48
] | python | en | ['en', 'it', 'en'] | True |
WeatherUpdateCoordinator._get_condition | (weather_code) | Get weather condition from weather data. | Get weather condition from weather data. | def _get_condition(weather_code):
"""Get weather condition from weather data."""
return [k for k, v in CONDITION_CLASSES.items() if weather_code in v][0] | [
"def",
"_get_condition",
"(",
"weather_code",
")",
":",
"return",
"[",
"k",
"for",
"k",
",",
"v",
"in",
"CONDITION_CLASSES",
".",
"items",
"(",
")",
"if",
"weather_code",
"in",
"v",
"]",
"[",
"0",
"]"
] | [
189,
4
] | [
191,
80
] | python | en | ['en', 'en', 'en'] | True |
LegacyWeather.__init__ | (self, current_weather, forecast) | Initialize weather object. | Initialize weather object. | def __init__(self, current_weather, forecast):
"""Initialize weather object."""
self.current = current_weather
self.forecast = forecast | [
"def",
"__init__",
"(",
"self",
",",
"current_weather",
",",
"forecast",
")",
":",
"self",
".",
"current",
"=",
"current_weather",
"self",
".",
"forecast",
"=",
"forecast"
] | [
197,
4
] | [
200,
32
] | python | en | ['en', 'en', 'en'] | True |
KeyedRateLimit.__init__ | (
self,
hass: HomeAssistant,
) | Initialize ratelimit tracker. | Initialize ratelimit tracker. | def __init__(
self,
hass: HomeAssistant,
):
"""Initialize ratelimit tracker."""
self.hass = hass
self._last_triggered: Dict[Hashable, datetime] = {}
self._rate_limit_timers: Dict[Hashable, asyncio.TimerHandle] = {} | [
"def",
"__init__",
"(",
"self",
",",
"hass",
":",
"HomeAssistant",
",",
")",
":",
"self",
".",
"hass",
"=",
"hass",
"self",
".",
"_last_triggered",
":",
"Dict",
"[",
"Hashable",
",",
"datetime",
"]",
"=",
"{",
"}",
"self",
".",
"_rate_limit_timers",
":... | [
15,
4
] | [
22,
73
] | python | en | ['en', 'en', 'en'] | True |
KeyedRateLimit.async_has_timer | (self, key: Hashable) | Check if a rate limit timer is running. | Check if a rate limit timer is running. | def async_has_timer(self, key: Hashable) -> bool:
"""Check if a rate limit timer is running."""
if not self._rate_limit_timers:
return False
return key in self._rate_limit_timers | [
"def",
"async_has_timer",
"(",
"self",
",",
"key",
":",
"Hashable",
")",
"->",
"bool",
":",
"if",
"not",
"self",
".",
"_rate_limit_timers",
":",
"return",
"False",
"return",
"key",
"in",
"self",
".",
"_rate_limit_timers"
] | [
25,
4
] | [
29,
45
] | python | en | ['en', 'en', 'en'] | True |
KeyedRateLimit.async_triggered | (self, key: Hashable, now: Optional[datetime] = None) | Call when the action we are tracking was triggered. | Call when the action we are tracking was triggered. | def async_triggered(self, key: Hashable, now: Optional[datetime] = None) -> None:
"""Call when the action we are tracking was triggered."""
self.async_cancel_timer(key)
self._last_triggered[key] = now or dt_util.utcnow() | [
"def",
"async_triggered",
"(",
"self",
",",
"key",
":",
"Hashable",
",",
"now",
":",
"Optional",
"[",
"datetime",
"]",
"=",
"None",
")",
"->",
"None",
":",
"self",
".",
"async_cancel_timer",
"(",
"key",
")",
"self",
".",
"_last_triggered",
"[",
"key",
... | [
32,
4
] | [
35,
59
] | python | en | ['en', 'en', 'en'] | True |
KeyedRateLimit.async_cancel_timer | (self, key: Hashable) | Cancel a rate limit time that will call the action. | Cancel a rate limit time that will call the action. | def async_cancel_timer(self, key: Hashable) -> None:
"""Cancel a rate limit time that will call the action."""
if not self._rate_limit_timers or not self.async_has_timer(key):
return
self._rate_limit_timers.pop(key).cancel() | [
"def",
"async_cancel_timer",
"(",
"self",
",",
"key",
":",
"Hashable",
")",
"->",
"None",
":",
"if",
"not",
"self",
".",
"_rate_limit_timers",
"or",
"not",
"self",
".",
"async_has_timer",
"(",
"key",
")",
":",
"return",
"self",
".",
"_rate_limit_timers",
"... | [
38,
4
] | [
43,
49
] | python | en | ['en', 'en', 'en'] | True |
KeyedRateLimit.async_remove | (self) | Remove all timers. | Remove all timers. | def async_remove(self) -> None:
"""Remove all timers."""
for timer in self._rate_limit_timers.values():
timer.cancel()
self._rate_limit_timers.clear() | [
"def",
"async_remove",
"(",
"self",
")",
"->",
"None",
":",
"for",
"timer",
"in",
"self",
".",
"_rate_limit_timers",
".",
"values",
"(",
")",
":",
"timer",
".",
"cancel",
"(",
")",
"self",
".",
"_rate_limit_timers",
".",
"clear",
"(",
")"
] | [
46,
4
] | [
50,
39
] | python | en | ['en', 'en', 'en'] | True |
KeyedRateLimit.async_schedule_action | (
self,
key: Hashable,
rate_limit: Optional[timedelta],
now: datetime,
action: Callable,
*args: Any,
) | Check rate limits and schedule an action if we hit the limit.
If the rate limit is hit:
Schedules the action for when the rate limit expires
if there are no pending timers. The action must
be called in async.
Returns the time the rate limit will expire
... | Check rate limits and schedule an action if we hit the limit. | def async_schedule_action(
self,
key: Hashable,
rate_limit: Optional[timedelta],
now: datetime,
action: Callable,
*args: Any,
) -> Optional[datetime]:
"""Check rate limits and schedule an action if we hit the limit.
If the rate limit is hit:
... | [
"def",
"async_schedule_action",
"(",
"self",
",",
"key",
":",
"Hashable",
",",
"rate_limit",
":",
"Optional",
"[",
"timedelta",
"]",
",",
"now",
":",
"datetime",
",",
"action",
":",
"Callable",
",",
"*",
"args",
":",
"Any",
",",
")",
"->",
"Optional",
... | [
53,
4
] | [
101,
29
] | python | en | ['en', 'en', 'en'] | True |
Subprocess.run | (command: str, timeout: int = None) | Run one-time command with subprocess.run().
Args:
command (str): command to be executed.
timeout (int): timeout in seconds.
Returns:
str: return stdout of the command.
| Run one-time command with subprocess.run(). | def run(command: str, timeout: int = None) -> None:
"""Run one-time command with subprocess.run().
Args:
command (str): command to be executed.
timeout (int): timeout in seconds.
Returns:
str: return stdout of the command.
"""
# TODO: Windows... | [
"def",
"run",
"(",
"command",
":",
"str",
",",
"timeout",
":",
"int",
"=",
"None",
")",
"->",
"None",
":",
"# TODO: Windows node",
"completed_process",
"=",
"subprocess",
".",
"run",
"(",
"command",
",",
"shell",
"=",
"True",
",",
"executable",
"=",
"\"/... | [
55,
4
] | [
77,
50
] | python | en | ['en', 'en', 'en'] | True |
_get_config_schema | (input_dict: Dict[str, Any] = None) |
Return schema defaults for init step based on user input/config dict.
Retain info already provided for future form views by setting them
as defaults in schema.
|
Return schema defaults for init step based on user input/config dict. | def _get_config_schema(input_dict: Dict[str, Any] = None) -> vol.Schema:
"""
Return schema defaults for init step based on user input/config dict.
Retain info already provided for future form views by setting them
as defaults in schema.
"""
if input_dict is None:
input_dict = {}
re... | [
"def",
"_get_config_schema",
"(",
"input_dict",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
"=",
"None",
")",
"->",
"vol",
".",
"Schema",
":",
"if",
"input_dict",
"is",
"None",
":",
"input_dict",
"=",
"{",
"}",
"return",
"vol",
".",
"Schema",
"(",
"{",... | [
50,
0
] | [
75,
5
] | python | en | ['en', 'error', 'th'] | False |
_get_pairing_schema | (input_dict: Dict[str, Any] = None) |
Return schema defaults for pairing data based on user input.
Retain info already provided for future form views by setting
them as defaults in schema.
|
Return schema defaults for pairing data based on user input. | def _get_pairing_schema(input_dict: Dict[str, Any] = None) -> vol.Schema:
"""
Return schema defaults for pairing data based on user input.
Retain info already provided for future form views by setting
them as defaults in schema.
"""
if input_dict is None:
input_dict = {}
return vol... | [
"def",
"_get_pairing_schema",
"(",
"input_dict",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
"=",
"None",
")",
"->",
"vol",
".",
"Schema",
":",
"if",
"input_dict",
"is",
"None",
":",
"input_dict",
"=",
"{",
"}",
"return",
"vol",
".",
"Schema",
"(",
"{"... | [
78,
0
] | [
90,
5
] | python | en | ['en', 'error', 'th'] | False |
_host_is_same | (host1: str, host2: str) | Check if host1 and host2 are the same. | Check if host1 and host2 are the same. | def _host_is_same(host1: str, host2: str) -> bool:
"""Check if host1 and host2 are the same."""
host1 = host1.split(":")[0]
host1 = host1 if is_ip_address(host1) else socket.gethostbyname(host1)
host2 = host2.split(":")[0]
host2 = host2 if is_ip_address(host2) else socket.gethostbyname(host2)
re... | [
"def",
"_host_is_same",
"(",
"host1",
":",
"str",
",",
"host2",
":",
"str",
")",
"->",
"bool",
":",
"host1",
"=",
"host1",
".",
"split",
"(",
"\":\"",
")",
"[",
"0",
"]",
"host1",
"=",
"host1",
"if",
"is_ip_address",
"(",
"host1",
")",
"else",
"soc... | [
93,
0
] | [
99,
25
] | python | en | ['en', 'en', 'en'] | True |
VizioOptionsConfigFlow.__init__ | (self, config_entry: ConfigEntry) | Initialize vizio options flow. | Initialize vizio options flow. | def __init__(self, config_entry: ConfigEntry) -> None:
"""Initialize vizio options flow."""
self.config_entry = config_entry | [
"def",
"__init__",
"(",
"self",
",",
"config_entry",
":",
"ConfigEntry",
")",
"->",
"None",
":",
"self",
".",
"config_entry",
"=",
"config_entry"
] | [
105,
4
] | [
107,
40
] | python | it | ['it', 'fr', 'it'] | True |
VizioOptionsConfigFlow.async_step_init | (
self, user_input: Dict[str, Any] = None
) | Manage the vizio options. | Manage the vizio options. | async def async_step_init(
self, user_input: Dict[str, Any] = None
) -> Dict[str, Any]:
"""Manage the vizio options."""
if user_input is not None:
if user_input.get(CONF_APPS_TO_INCLUDE_OR_EXCLUDE):
user_input[CONF_APPS] = {
user_input[CONF_INC... | [
"async",
"def",
"async_step_init",
"(",
"self",
",",
"user_input",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
"=",
"None",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"if",
"user_input",
"is",
"not",
"None",
":",
"if",
"user_input",
".",
"g... | [
109,
4
] | [
169,
72
] | python | en | ['en', 'fa', 'en'] | True |
VizioConfigFlow.async_get_options_flow | (config_entry: ConfigEntry) | Get the options flow for this handler. | Get the options flow for this handler. | def async_get_options_flow(config_entry: ConfigEntry) -> VizioOptionsConfigFlow:
"""Get the options flow for this handler."""
return VizioOptionsConfigFlow(config_entry) | [
"def",
"async_get_options_flow",
"(",
"config_entry",
":",
"ConfigEntry",
")",
"->",
"VizioOptionsConfigFlow",
":",
"return",
"VizioOptionsConfigFlow",
"(",
"config_entry",
")"
] | [
180,
4
] | [
182,
51
] | python | en | ['en', 'en', 'en'] | True |
VizioConfigFlow.__init__ | (self) | Initialize config flow. | Initialize config flow. | def __init__(self) -> None:
"""Initialize config flow."""
self._user_schema = None
self._must_show_form = None
self._ch_type = None
self._pairing_token = None
self._data = None
self._apps = {} | [
"def",
"__init__",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"_user_schema",
"=",
"None",
"self",
".",
"_must_show_form",
"=",
"None",
"self",
".",
"_ch_type",
"=",
"None",
"self",
".",
"_pairing_token",
"=",
"None",
"self",
".",
"_data",
"=",
... | [
184,
4
] | [
191,
23
] | python | en | ['de', 'en', 'en'] | True |
VizioConfigFlow._create_entry | (self, input_dict: Dict[str, Any]) | Create vizio config entry. | Create vizio config entry. | async def _create_entry(self, input_dict: Dict[str, Any]) -> Dict[str, Any]:
"""Create vizio config entry."""
# Remove extra keys that will not be used by entry setup
input_dict.pop(CONF_APPS_TO_INCLUDE_OR_EXCLUDE, None)
input_dict.pop(CONF_INCLUDE_OR_EXCLUDE, None)
if self._app... | [
"async",
"def",
"_create_entry",
"(",
"self",
",",
"input_dict",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"# Remove extra keys that will not be used by entry setup",
"input_dict",
".",
"pop",
"(",
"CONF_APP... | [
193,
4
] | [
202,
84
] | python | it | ['it', 'gl', 'it'] | True |
VizioConfigFlow.async_step_user | (
self, user_input: Dict[str, Any] = None
) | Handle a flow initialized by the user. | Handle a flow initialized by the user. | async def async_step_user(
self, user_input: Dict[str, Any] = None
) -> Dict[str, Any]:
"""Handle a flow initialized by the user."""
assert self.hass
errors = {}
if user_input is not None:
# Store current values in case setup fails and user needs to edit
... | [
"async",
"def",
"async_step_user",
"(",
"self",
",",
"user_input",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
"=",
"None",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"assert",
"self",
".",
"hass",
"errors",
"=",
"{",
"}",
"if",
"user_input... | [
204,
4
] | [
280,
86
] | python | en | ['en', 'en', 'en'] | True |
VizioConfigFlow.async_step_import | (self, import_config: Dict[str, Any]) | Import a config entry from configuration.yaml. | Import a config entry from configuration.yaml. | async def async_step_import(self, import_config: Dict[str, Any]) -> Dict[str, Any]:
"""Import a config entry from configuration.yaml."""
# Check if new config entry matches any existing config entries
for entry in self.hass.config_entries.async_entries(DOMAIN):
# If source is ignore ... | [
"async",
"def",
"async_step_import",
"(",
"self",
",",
"import_config",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"# Check if new config entry matches any existing config entries",
"for",
"entry",
"in",
"self"... | [
282,
4
] | [
342,
67
] | python | en | ['en', 'en', 'en'] | True |
VizioConfigFlow.async_step_zeroconf | (
self, discovery_info: Optional[DiscoveryInfoType] = None
) | Handle zeroconf discovery. | Handle zeroconf discovery. | async def async_step_zeroconf(
self, discovery_info: Optional[DiscoveryInfoType] = None
) -> Dict[str, Any]:
"""Handle zeroconf discovery."""
assert self.hass
# If host already has port, no need to add it again
if ":" not in discovery_info[CONF_HOST]:
discovery_i... | [
"async",
"def",
"async_step_zeroconf",
"(",
"self",
",",
"discovery_info",
":",
"Optional",
"[",
"DiscoveryInfoType",
"]",
"=",
"None",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"assert",
"self",
".",
"hass",
"# If host already has port, no need to ad... | [
344,
4
] | [
381,
68
] | python | de | ['de', 'sr', 'en'] | False |
VizioConfigFlow.async_step_pair_tv | (
self, user_input: Dict[str, Any] = None
) |
Start pairing process for TV.
Ask user for PIN to complete pairing process.
|
Start pairing process for TV. | async def async_step_pair_tv(
self, user_input: Dict[str, Any] = None
) -> Dict[str, Any]:
"""
Start pairing process for TV.
Ask user for PIN to complete pairing process.
"""
errors = {}
# Start pairing process if it hasn't already started
if not sel... | [
"async",
"def",
"async_step_pair_tv",
"(",
"self",
",",
"user_input",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
"=",
"None",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"errors",
"=",
"{",
"}",
"# Start pairing process if it hasn't already started",... | [
383,
4
] | [
449,
9
] | python | en | ['en', 'error', 'th'] | False |
VizioConfigFlow._pairing_complete | (self, step_id: str) | Handle config flow completion. | Handle config flow completion. | async def _pairing_complete(self, step_id: str) -> Dict[str, Any]:
"""Handle config flow completion."""
if not self._must_show_form:
return await self._create_entry(self._data)
self._must_show_form = False
return self.async_show_form(
step_id=step_id,
... | [
"async",
"def",
"_pairing_complete",
"(",
"self",
",",
"step_id",
":",
"str",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"if",
"not",
"self",
".",
"_must_show_form",
":",
"return",
"await",
"self",
".",
"_create_entry",
"(",
"self",
".",
"_da... | [
451,
4
] | [
461,
9
] | python | en | ['en', 'en', 'en'] | True |
VizioConfigFlow.async_step_pairing_complete | (
self, user_input: Dict[str, Any] = None
) |
Complete non-import sourced config flow.
Display final message to user confirming pairing.
|
Complete non-import sourced config flow. | async def async_step_pairing_complete(
self, user_input: Dict[str, Any] = None
) -> Dict[str, Any]:
"""
Complete non-import sourced config flow.
Display final message to user confirming pairing.
"""
return await self._pairing_complete("pairing_complete") | [
"async",
"def",
"async_step_pairing_complete",
"(",
"self",
",",
"user_input",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
"=",
"None",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"return",
"await",
"self",
".",
"_pairing_complete",
"(",
"\"pairin... | [
463,
4
] | [
471,
63
] | python | en | ['en', 'error', 'th'] | False |
VizioConfigFlow.async_step_pairing_complete_import | (
self, user_input: Dict[str, Any] = None
) |
Complete import sourced config flow.
Display final message to user confirming pairing and displaying
access token.
|
Complete import sourced config flow. | async def async_step_pairing_complete_import(
self, user_input: Dict[str, Any] = None
) -> Dict[str, Any]:
"""
Complete import sourced config flow.
Display final message to user confirming pairing and displaying
access token.
"""
return await self._pairing_co... | [
"async",
"def",
"async_step_pairing_complete_import",
"(",
"self",
",",
"user_input",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
"=",
"None",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"return",
"await",
"self",
".",
"_pairing_complete",
"(",
"\... | [
473,
4
] | [
482,
70
] | python | en | ['en', 'error', 'th'] | False |
test_subscribing_config_topic | (hass, mqtt_mock, setup_tasmota) | Test setting up discovery. | Test setting up discovery. | async def test_subscribing_config_topic(hass, mqtt_mock, setup_tasmota):
"""Test setting up discovery."""
discovery_topic = DEFAULT_PREFIX
assert mqtt_mock.async_subscribe.called
call_args = mqtt_mock.async_subscribe.mock_calls[0][1]
assert call_args[0] == discovery_topic + "/#"
assert call_arg... | [
"async",
"def",
"test_subscribing_config_topic",
"(",
"hass",
",",
"mqtt_mock",
",",
"setup_tasmota",
")",
":",
"discovery_topic",
"=",
"DEFAULT_PREFIX",
"assert",
"mqtt_mock",
".",
"async_subscribe",
".",
"called",
"call_args",
"=",
"mqtt_mock",
".",
"async_subscribe... | [
14,
0
] | [
21,
28
] | python | en | ['en', 'en', 'en'] | True |
test_future_discovery_message | (hass, mqtt_mock, caplog) | Test we handle backwards compatible discovery messages. | Test we handle backwards compatible discovery messages. | async def test_future_discovery_message(hass, mqtt_mock, caplog):
"""Test we handle backwards compatible discovery messages."""
config = copy.deepcopy(DEFAULT_CONFIG)
config["future_option"] = "BEST_SINCE_SLICED_BREAD"
config["so"]["another_future_option"] = "EVEN_BETTER"
with patch(
"homea... | [
"async",
"def",
"test_future_discovery_message",
"(",
"hass",
",",
"mqtt_mock",
",",
"caplog",
")",
":",
"config",
"=",
"copy",
".",
"deepcopy",
"(",
"DEFAULT_CONFIG",
")",
"config",
"[",
"\"future_option\"",
"]",
"=",
"\"BEST_SINCE_SLICED_BREAD\"",
"config",
"[",... | [
24,
0
] | [
40,
52
] | python | en | ['en', 'en', 'en'] | True |
test_valid_discovery_message | (hass, mqtt_mock, caplog) | Test discovery callback called. | Test discovery callback called. | async def test_valid_discovery_message(hass, mqtt_mock, caplog):
"""Test discovery callback called."""
config = copy.deepcopy(DEFAULT_CONFIG)
with patch(
"homeassistant.components.tasmota.discovery.tasmota_get_device_config",
return_value={},
) as mock_tasmota_get_device_config:
... | [
"async",
"def",
"test_valid_discovery_message",
"(",
"hass",
",",
"mqtt_mock",
",",
"caplog",
")",
":",
"config",
"=",
"copy",
".",
"deepcopy",
"(",
"DEFAULT_CONFIG",
")",
"with",
"patch",
"(",
"\"homeassistant.components.tasmota.discovery.tasmota_get_device_config\"",
... | [
43,
0
] | [
57,
52
] | python | en | ['en', 'en', 'en'] | True |
test_invalid_topic | (hass, mqtt_mock) | Test receiving discovery message on wrong topic. | Test receiving discovery message on wrong topic. | async def test_invalid_topic(hass, mqtt_mock):
"""Test receiving discovery message on wrong topic."""
with patch(
"homeassistant.components.tasmota.discovery.tasmota_get_device_config"
) as mock_tasmota_get_device_config:
await setup_tasmota_helper(hass)
async_fire_mqtt_message(hass... | [
"async",
"def",
"test_invalid_topic",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.tasmota.discovery.tasmota_get_device_config\"",
")",
"as",
"mock_tasmota_get_device_config",
":",
"await",
"setup_tasmota_helper",
"(",
"hass",
"... | [
60,
0
] | [
69,
56
] | python | en | ['en', 'en', 'en'] | True |
test_invalid_message | (hass, mqtt_mock, caplog) | Test receiving an invalid message. | Test receiving an invalid message. | async def test_invalid_message(hass, mqtt_mock, caplog):
"""Test receiving an invalid message."""
with patch(
"homeassistant.components.tasmota.discovery.tasmota_get_device_config"
) as mock_tasmota_get_device_config:
await setup_tasmota_helper(hass)
async_fire_mqtt_message(hass, f"... | [
"async",
"def",
"test_invalid_message",
"(",
"hass",
",",
"mqtt_mock",
",",
"caplog",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.tasmota.discovery.tasmota_get_device_config\"",
")",
"as",
"mock_tasmota_get_device_config",
":",
"await",
"setup_tasmota_helper",... | [
72,
0
] | [
82,
56
] | python | en | ['en', 'en', 'en'] | True |
test_invalid_mac | (hass, mqtt_mock, caplog) | Test topic is not matching device MAC. | Test topic is not matching device MAC. | async def test_invalid_mac(hass, mqtt_mock, caplog):
"""Test topic is not matching device MAC."""
config = copy.deepcopy(DEFAULT_CONFIG)
with patch(
"homeassistant.components.tasmota.discovery.tasmota_get_device_config"
) as mock_tasmota_get_device_config:
await setup_tasmota_helper(has... | [
"async",
"def",
"test_invalid_mac",
"(",
"hass",
",",
"mqtt_mock",
",",
"caplog",
")",
":",
"config",
"=",
"copy",
".",
"deepcopy",
"(",
"DEFAULT_CONFIG",
")",
"with",
"patch",
"(",
"\"homeassistant.components.tasmota.discovery.tasmota_get_device_config\"",
")",
"as",... | [
85,
0
] | [
99,
56
] | python | en | ['en', 'en', 'en'] | True |
test_correct_config_discovery | (
hass, mqtt_mock, caplog, device_reg, entity_reg, setup_tasmota
) | Test receiving valid discovery message. | Test receiving valid discovery message. | async def test_correct_config_discovery(
hass, mqtt_mock, caplog, device_reg, entity_reg, setup_tasmota
):
"""Test receiving valid discovery message."""
config = copy.deepcopy(DEFAULT_CONFIG)
config["rl"][0] = 1
mac = config["mac"]
async_fire_mqtt_message(
hass,
f"{DEFAULT_PREFI... | [
"async",
"def",
"test_correct_config_discovery",
"(",
"hass",
",",
"mqtt_mock",
",",
"caplog",
",",
"device_reg",
",",
"entity_reg",
",",
"setup_tasmota",
")",
":",
"config",
"=",
"copy",
".",
"deepcopy",
"(",
"DEFAULT_CONFIG",
")",
"config",
"[",
"\"rl\"",
"]... | [
102,
0
] | [
127,
71
] | python | en | ['nl', 'en', 'en'] | True |
test_device_discover | (
hass, mqtt_mock, caplog, device_reg, entity_reg, setup_tasmota
) | Test setting up a device. | Test setting up a device. | async def test_device_discover(
hass, mqtt_mock, caplog, device_reg, entity_reg, setup_tasmota
):
"""Test setting up a device."""
config = copy.deepcopy(DEFAULT_CONFIG)
mac = config["mac"]
async_fire_mqtt_message(
hass,
f"{DEFAULT_PREFIX}/{mac}/config",
json.dumps(config),
... | [
"async",
"def",
"test_device_discover",
"(",
"hass",
",",
"mqtt_mock",
",",
"caplog",
",",
"device_reg",
",",
"entity_reg",
",",
"setup_tasmota",
")",
":",
"config",
"=",
"copy",
".",
"deepcopy",
"(",
"DEFAULT_CONFIG",
")",
"mac",
"=",
"config",
"[",
"\"mac\... | [
130,
0
] | [
150,
50
] | python | en | ['en', 'en', 'en'] | True |
test_device_discover_deprecated | (
hass, mqtt_mock, caplog, device_reg, entity_reg, setup_tasmota
) | Test setting up a device with deprecated discovery message. | Test setting up a device with deprecated discovery message. | async def test_device_discover_deprecated(
hass, mqtt_mock, caplog, device_reg, entity_reg, setup_tasmota
):
"""Test setting up a device with deprecated discovery message."""
config = copy.deepcopy(DEFAULT_CONFIG_9_0_0_3)
mac = config["mac"]
async_fire_mqtt_message(
hass,
f"{DEFAULT... | [
"async",
"def",
"test_device_discover_deprecated",
"(",
"hass",
",",
"mqtt_mock",
",",
"caplog",
",",
"device_reg",
",",
"entity_reg",
",",
"setup_tasmota",
")",
":",
"config",
"=",
"copy",
".",
"deepcopy",
"(",
"DEFAULT_CONFIG_9_0_0_3",
")",
"mac",
"=",
"config... | [
153,
0
] | [
173,
50
] | python | en | ['en', 'en', 'en'] | True |
test_device_update | (
hass, mqtt_mock, caplog, device_reg, entity_reg, setup_tasmota
) | Test updating a device. | Test updating a device. | async def test_device_update(
hass, mqtt_mock, caplog, device_reg, entity_reg, setup_tasmota
):
"""Test updating a device."""
config = copy.deepcopy(DEFAULT_CONFIG)
config["md"] = "Model 1"
config["dn"] = "Name 1"
config["sw"] = "v1.2.3.4"
mac = config["mac"]
async_fire_mqtt_message(
... | [
"async",
"def",
"test_device_update",
"(",
"hass",
",",
"mqtt_mock",
",",
"caplog",
",",
"device_reg",
",",
"entity_reg",
",",
"setup_tasmota",
")",
":",
"config",
"=",
"copy",
".",
"deepcopy",
"(",
"DEFAULT_CONFIG",
")",
"config",
"[",
"\"md\"",
"]",
"=",
... | [
176,
0
] | [
214,
46
] | python | en | ['es', 'en', 'en'] | True |
test_device_remove | (
hass, mqtt_mock, caplog, device_reg, entity_reg, setup_tasmota
) | Test removing a discovered device. | Test removing a discovered device. | async def test_device_remove(
hass, mqtt_mock, caplog, device_reg, entity_reg, setup_tasmota
):
"""Test removing a discovered device."""
config = copy.deepcopy(DEFAULT_CONFIG)
mac = config["mac"]
async_fire_mqtt_message(
hass,
f"{DEFAULT_PREFIX}/{mac}/config",
json.dumps(con... | [
"async",
"def",
"test_device_remove",
"(",
"hass",
",",
"mqtt_mock",
",",
"caplog",
",",
"device_reg",
",",
"entity_reg",
",",
"setup_tasmota",
")",
":",
"config",
"=",
"copy",
".",
"deepcopy",
"(",
"DEFAULT_CONFIG",
")",
"mac",
"=",
"config",
"[",
"\"mac\""... | [
217,
0
] | [
244,
31
] | python | en | ['en', 'en', 'en'] | True |
test_device_remove_stale | (hass, mqtt_mock, caplog, device_reg, setup_tasmota) | Test removing a stale (undiscovered) device does not throw. | Test removing a stale (undiscovered) device does not throw. | async def test_device_remove_stale(hass, mqtt_mock, caplog, device_reg, setup_tasmota):
"""Test removing a stale (undiscovered) device does not throw."""
mac = "00000049A3BC"
config_entry = hass.config_entries.async_entries("tasmota")[0]
# Create a device
device_reg.async_get_or_create(
co... | [
"async",
"def",
"test_device_remove_stale",
"(",
"hass",
",",
"mqtt_mock",
",",
"caplog",
",",
"device_reg",
",",
"setup_tasmota",
")",
":",
"mac",
"=",
"\"00000049A3BC\"",
"config_entry",
"=",
"hass",
".",
"config_entries",
".",
"async_entries",
"(",
"\"tasmota\"... | [
247,
0
] | [
268,
31
] | python | en | ['en', 'en', 'en'] | True |
test_device_rediscover | (
hass, mqtt_mock, caplog, device_reg, entity_reg, setup_tasmota
) | Test removing a device. | Test removing a device. | async def test_device_rediscover(
hass, mqtt_mock, caplog, device_reg, entity_reg, setup_tasmota
):
"""Test removing a device."""
config = copy.deepcopy(DEFAULT_CONFIG)
mac = config["mac"]
async_fire_mqtt_message(
hass,
f"{DEFAULT_PREFIX}/{mac}/config",
json.dumps(config),
... | [
"async",
"def",
"test_device_rediscover",
"(",
"hass",
",",
"mqtt_mock",
",",
"caplog",
",",
"device_reg",
",",
"entity_reg",
",",
"setup_tasmota",
")",
":",
"config",
"=",
"copy",
".",
"deepcopy",
"(",
"DEFAULT_CONFIG",
")",
"mac",
"=",
"config",
"[",
"\"ma... | [
271,
0
] | [
310,
46
] | python | en | ['en', 'en', 'en'] | True |
test_entity_duplicate_discovery | (hass, mqtt_mock, caplog, setup_tasmota) | Test entities are not duplicated. | Test entities are not duplicated. | async def test_entity_duplicate_discovery(hass, mqtt_mock, caplog, setup_tasmota):
"""Test entities are not duplicated."""
config = copy.deepcopy(DEFAULT_CONFIG)
config["rl"][0] = 1
mac = config["mac"]
async_fire_mqtt_message(
hass,
f"{DEFAULT_PREFIX}/{mac}/config",
json.dum... | [
"async",
"def",
"test_entity_duplicate_discovery",
"(",
"hass",
",",
"mqtt_mock",
",",
"caplog",
",",
"setup_tasmota",
")",
":",
"config",
"=",
"copy",
".",
"deepcopy",
"(",
"DEFAULT_CONFIG",
")",
"config",
"[",
"\"rl\"",
"]",
"[",
"0",
"]",
"=",
"1",
"mac... | [
313,
0
] | [
340,
5
] | python | en | ['en', 'en', 'en'] | True |
test_entity_duplicate_removal | (hass, mqtt_mock, caplog, setup_tasmota) | Test removing entity twice. | Test removing entity twice. | async def test_entity_duplicate_removal(hass, mqtt_mock, caplog, setup_tasmota):
"""Test removing entity twice."""
config = copy.deepcopy(DEFAULT_CONFIG)
config["rl"][0] = 1
mac = config["mac"]
async_fire_mqtt_message(
hass,
f"{DEFAULT_PREFIX}/{mac}/config",
json.dumps(confi... | [
"async",
"def",
"test_entity_duplicate_removal",
"(",
"hass",
",",
"mqtt_mock",
",",
"caplog",
",",
"setup_tasmota",
")",
":",
"config",
"=",
"copy",
".",
"deepcopy",
"(",
"DEFAULT_CONFIG",
")",
"config",
"[",
"\"rl\"",
"]",
"[",
"0",
"]",
"=",
"1",
"mac",... | [
343,
0
] | [
363,
55
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up the Smappee sensor. | Set up the Smappee sensor. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up the Smappee sensor."""
smappee_base = hass.data[DOMAIN][config_entry.entry_id]
entities = []
for service_location in smappee_base.smappee.service_locations.values():
# Add all basic sensors (realtime values and aggre... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"smappee_base",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"config_entry",
".",
"entry_id",
"]",
"entities",
"=",
"[",
"]",
"for",
"service_lo... | [
143,
0
] | [
238,
38
] | python | en | ['en', 'st', 'en'] | True |
SmappeeSensor.__init__ | (self, smappee_base, service_location, sensor, attributes) | Initialize the Smappee sensor. | Initialize the Smappee sensor. | def __init__(self, smappee_base, service_location, sensor, attributes):
"""Initialize the Smappee sensor."""
self._smappee_base = smappee_base
self._service_location = service_location
self._sensor = sensor
self.data = None
self._state = None
self._name = attribut... | [
"def",
"__init__",
"(",
"self",
",",
"smappee_base",
",",
"service_location",
",",
"sensor",
",",
"attributes",
")",
":",
"self",
".",
"_smappee_base",
"=",
"smappee_base",
"self",
".",
"_service_location",
"=",
"service_location",
"self",
".",
"_sensor",
"=",
... | [
244,
4
] | [
255,
42
] | python | en | ['en', 'en', 'en'] | True |
SmappeeSensor.name | (self) | Return the name for this sensor. | Return the name for this sensor. | def name(self):
"""Return the name for this sensor."""
if self._sensor in ["sensor", "load"]:
return (
f"{self._service_location.service_location_name} - "
f"{self._sensor.title()} - {self._name}"
)
return f"{self._service_location.service... | [
"def",
"name",
"(",
"self",
")",
":",
"if",
"self",
".",
"_sensor",
"in",
"[",
"\"sensor\"",
",",
"\"load\"",
"]",
":",
"return",
"(",
"f\"{self._service_location.service_location_name} - \"",
"f\"{self._sensor.title()} - {self._name}\"",
")",
"return",
"f\"{self._servi... | [
258,
4
] | [
266,
79
] | python | en | ['en', 'ceb', 'en'] | True |
SmappeeSensor.icon | (self) | Icon to use in the frontend. | Icon to use in the frontend. | def icon(self):
"""Icon to use in the frontend."""
return self._icon | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"self",
".",
"_icon"
] | [
269,
4
] | [
271,
25
] | python | en | ['en', 'en', 'en'] | True |
SmappeeSensor.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"
] | [
274,
4
] | [
276,
26
] | python | en | ['en', 'en', 'en'] | True |
SmappeeSensor.device_class | (self) | Return the class of this device, from component DEVICE_CLASSES. | Return the class of this device, from component DEVICE_CLASSES. | def device_class(self):
"""Return the class of this device, from component DEVICE_CLASSES."""
return self._device_class | [
"def",
"device_class",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device_class"
] | [
279,
4
] | [
281,
33
] | python | en | ['en', 'en', 'en'] | True |
SmappeeSensor.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"
] | [
284,
4
] | [
286,
40
] | python | en | ['en', 'en', 'en'] | True |
SmappeeSensor.unique_id | (
self,
) | Return the unique ID for this sensor. | Return the unique ID for this sensor. | def unique_id(
self,
):
"""Return the unique ID for this sensor."""
if self._sensor in ["load", "sensor"]:
return (
f"{self._service_location.device_serial_number}-"
f"{self._service_location.service_location_id}-"
f"{self._sensor}-... | [
"def",
"unique_id",
"(",
"self",
",",
")",
":",
"if",
"self",
".",
"_sensor",
"in",
"[",
"\"load\"",
",",
"\"sensor\"",
"]",
":",
"return",
"(",
"f\"{self._service_location.device_serial_number}-\"",
"f\"{self._service_location.service_location_id}-\"",
"f\"{self._sensor}... | [
289,
4
] | [
304,
9
] | python | en | ['en', 'la', 'en'] | True |
SmappeeSensor.device_info | (self) | Return the device info for this sensor. | Return the device info for this sensor. | def device_info(self):
"""Return the device info for this sensor."""
return {
"identifiers": {(DOMAIN, self._service_location.device_serial_number)},
"name": self._service_location.service_location_name,
"manufacturer": "Smappee",
"model": self._service_lo... | [
"def",
"device_info",
"(",
"self",
")",
":",
"return",
"{",
"\"identifiers\"",
":",
"{",
"(",
"DOMAIN",
",",
"self",
".",
"_service_location",
".",
"device_serial_number",
")",
"}",
",",
"\"name\"",
":",
"self",
".",
"_service_location",
".",
"service_location... | [
307,
4
] | [
315,
9
] | python | en | ['en', 'en', 'en'] | True |
SmappeeSensor.async_update | (self) | Get the latest data from Smappee and update the state. | Get the latest data from Smappee and update the state. | async def async_update(self):
"""Get the latest data from Smappee and update the state."""
await self._smappee_base.async_update()
if self._sensor == "total_power":
self._state = self._service_location.total_power
elif self._sensor == "total_reactive_power":
self... | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"await",
"self",
".",
"_smappee_base",
".",
"async_update",
"(",
")",
"if",
"self",
".",
"_sensor",
"==",
"\"total_power\"",
":",
"self",
".",
"_state",
"=",
"self",
".",
"_service_location",
".",
"tot... | [
317,
4
] | [
370,
60
] | python | en | ['en', 'en', 'en'] | True |
post_stix | (manager, content_block, collection_ids, service_id) |
Callback function for when our taxii server gets new data
Will convert it to a MISPEvent and push to the server
|
Callback function for when our taxii server gets new data
Will convert it to a MISPEvent and push to the server
| def post_stix(manager, content_block, collection_ids, service_id):
'''
Callback function for when our taxii server gets new data
Will convert it to a MISPEvent and push to the server
'''
# Load the package
log.info("Posting STIX...")
block = content_block.content
if isinstance(b... | [
"def",
"post_stix",
"(",
"manager",
",",
"content_block",
",",
"collection_ids",
",",
"service_id",
")",
":",
"# Load the package",
"log",
".",
"info",
"(",
"\"Posting STIX...\"",
")",
"block",
"=",
"content_block",
".",
"content",
"if",
"isinstance",
"(",
"bloc... | [
49,
0
] | [
82,
49
] | python | en | ['en', 'error', 'th'] | False |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the MyChevy sensors. | Set up the MyChevy sensors. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the MyChevy sensors."""
if discovery_info is None:
return
hub = hass.data[MYCHEVY_DOMAIN]
sensors = [MyChevyStatus()]
for sconfig in SENSORS:
for car in hub.cars:
sensors.append(EVSensor(hub, ... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"if",
"discovery_info",
"is",
"None",
":",
"return",
"hub",
"=",
"hass",
".",
"data",
"[",
"MYCHEVY_DOMAIN",
"]",
"sensors",
"=",
"[",
... | [
34,
0
] | [
45,
25
] | python | en | ['en', 'fr', 'en'] | True |
MyChevyStatus.__init__ | (self) | Initialize sensor with car connection. | Initialize sensor with car connection. | def __init__(self):
"""Initialize sensor with car connection."""
self._state = None | [
"def",
"__init__",
"(",
"self",
")",
":",
"self",
".",
"_state",
"=",
"None"
] | [
54,
4
] | [
56,
26
] | python | en | ['en', 'en', 'en'] | True |
MyChevyStatus.async_added_to_hass | (self) | Register callbacks. | Register callbacks. | async def async_added_to_hass(self):
"""Register callbacks."""
self.async_on_remove(
self.hass.helpers.dispatcher.async_dispatcher_connect(
UPDATE_TOPIC, self.success
)
)
self.async_on_remove(
self.hass.helpers.dispatcher.async_dispatc... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"async_on_remove",
"(",
"self",
".",
"hass",
".",
"helpers",
".",
"dispatcher",
".",
"async_dispatcher_connect",
"(",
"UPDATE_TOPIC",
",",
"self",
".",
"success",
")",
")",
"self",
".... | [
58,
4
] | [
70,
9
] | python | en | ['en', 'no', 'en'] | False |
MyChevyStatus.success | (self) | Update state, trigger updates. | Update state, trigger updates. | def success(self):
"""Update state, trigger updates."""
if self._state != MYCHEVY_SUCCESS:
_LOGGER.debug("Successfully connected to mychevy website")
self._state = MYCHEVY_SUCCESS
self.async_write_ha_state() | [
"def",
"success",
"(",
"self",
")",
":",
"if",
"self",
".",
"_state",
"!=",
"MYCHEVY_SUCCESS",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Successfully connected to mychevy website\"",
")",
"self",
".",
"_state",
"=",
"MYCHEVY_SUCCESS",
"self",
".",
"async_write_ha_stat... | [
73,
4
] | [
78,
35
] | python | co | ['da', 'co', 'en'] | False |
MyChevyStatus.error | (self) | Update state, trigger updates. | Update state, trigger updates. | def error(self):
"""Update state, trigger updates."""
_LOGGER.error(
"Connection to mychevy website failed. "
"This probably means the mychevy to OnStar link is down"
)
self._state = MYCHEVY_ERROR
self.async_write_ha_state() | [
"def",
"error",
"(",
"self",
")",
":",
"_LOGGER",
".",
"error",
"(",
"\"Connection to mychevy website failed. \"",
"\"This probably means the mychevy to OnStar link is down\"",
")",
"self",
".",
"_state",
"=",
"MYCHEVY_ERROR",
"self",
".",
"async_write_ha_state",
"(",
")"... | [
81,
4
] | [
88,
35
] | python | co | ['da', 'co', 'en'] | False |
MyChevyStatus.icon | (self) | Return the icon. | Return the icon. | def icon(self):
"""Return the icon."""
return self._icon | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"self",
".",
"_icon"
] | [
91,
4
] | [
93,
25
] | python | en | ['en', 'sr', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.