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
FritzBoxCallSensor.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" ]
[ 128, 4 ]
[ 130, 26 ]
python
en
['en', 'en', 'en']
True
FritzBoxCallSensor.name
(self)
Return the name of the sensor.
Return the name of the sensor.
def name(self): """Return the name of the sensor.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 133, 4 ]
[ 135, 25 ]
python
en
['en', 'mi', 'en']
True
FritzBoxCallSensor.device_state_attributes
(self)
Return the state attributes.
Return the state attributes.
def device_state_attributes(self): """Return the state attributes.""" return self._attributes
[ "def", "device_state_attributes", "(", "self", ")", ":", "return", "self", ".", "_attributes" ]
[ 138, 4 ]
[ 140, 31 ]
python
en
['en', 'en', 'en']
True
FritzBoxCallSensor.number_to_name
(self, number)
Return a name for a given phone number.
Return a name for a given phone number.
def number_to_name(self, number): """Return a name for a given phone number.""" if self.phonebook is None: return "unknown" return self.phonebook.get_name(number)
[ "def", "number_to_name", "(", "self", ",", "number", ")", ":", "if", "self", ".", "phonebook", "is", "None", ":", "return", "\"unknown\"", "return", "self", ".", "phonebook", ".", "get_name", "(", "number", ")" ]
[ 142, 4 ]
[ 146, 46 ]
python
en
['en', 'en', 'en']
True
FritzBoxCallSensor.update
(self)
Update the phonebook if it is defined.
Update the phonebook if it is defined.
def update(self): """Update the phonebook if it is defined.""" if self.phonebook is not None: self.phonebook.update_phonebook()
[ "def", "update", "(", "self", ")", ":", "if", "self", ".", "phonebook", "is", "not", "None", ":", "self", ".", "phonebook", ".", "update_phonebook", "(", ")" ]
[ 148, 4 ]
[ 151, 45 ]
python
en
['en', 'en', 'en']
True
FritzBoxCallMonitor.__init__
(self, host, port, sensor)
Initialize Fritz!Box monitor instance.
Initialize Fritz!Box monitor instance.
def __init__(self, host, port, sensor): """Initialize Fritz!Box monitor instance.""" self.host = host self.port = port self.sock = None self._sensor = sensor self.stopped = threading.Event()
[ "def", "__init__", "(", "self", ",", "host", ",", "port", ",", "sensor", ")", ":", "self", ".", "host", "=", "host", "self", ".", "port", "=", "port", "self", ".", "sock", "=", "None", "self", ".", "_sensor", "=", "sensor", "self", ".", "stopped", ...
[ 157, 4 ]
[ 163, 40 ]
python
en
['eu', 'en', 'en']
True
FritzBoxCallMonitor.connect
(self)
Connect to the Fritz!Box.
Connect to the Fritz!Box.
def connect(self): """Connect to the Fritz!Box.""" _LOGGER.debug("Setting up socket...") self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock.settimeout(10) self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) try: self.sock.conne...
[ "def", "connect", "(", "self", ")", ":", "_LOGGER", ".", "debug", "(", "\"Setting up socket...\"", ")", "self", ".", "sock", "=", "socket", ".", "socket", "(", "socket", ".", "AF_INET", ",", "socket", ".", "SOCK_STREAM", ")", "self", ".", "sock", ".", ...
[ 165, 4 ]
[ 178, 13 ]
python
en
['en', 'en', 'en']
True
FritzBoxCallMonitor._listen
(self)
Listen to incoming or outgoing calls.
Listen to incoming or outgoing calls.
def _listen(self): """Listen to incoming or outgoing calls.""" _LOGGER.debug("Connection established, waiting for response...") while not self.stopped.isSet(): try: response = self.sock.recv(2048) except socket.timeout: # if no response aft...
[ "def", "_listen", "(", "self", ")", ":", "_LOGGER", ".", "debug", "(", "\"Connection established, waiting for response...\"", ")", "while", "not", "self", ".", "stopped", ".", "isSet", "(", ")", ":", "try", ":", "response", "=", "self", ".", "sock", ".", "...
[ 180, 4 ]
[ 203, 29 ]
python
en
['en', 'en', 'en']
True
FritzBoxCallMonitor._parse
(self, line)
Parse the call information and set the sensor states.
Parse the call information and set the sensor states.
def _parse(self, line): """Parse the call information and set the sensor states.""" line = line.split(";") df_in = "%d.%m.%y %H:%M:%S" df_out = "%Y-%m-%dT%H:%M:%S" isotime = datetime.datetime.strptime(line[0], df_in).strftime(df_out) if line[1] == "RING": self...
[ "def", "_parse", "(", "self", ",", "line", ")", ":", "line", "=", "line", ".", "split", "(", "\";\"", ")", "df_in", "=", "\"%d.%m.%y %H:%M:%S\"", "df_out", "=", "\"%Y-%m-%dT%H:%M:%S\"", "isotime", "=", "datetime", ".", "datetime", ".", "strptime", "(", "li...
[ 205, 4 ]
[ 242, 47 ]
python
en
['en', 'en', 'en']
True
FritzBoxPhonebook.__init__
(self, host, port, username, password, phonebook_id=0, prefixes=None)
Initialize the class.
Initialize the class.
def __init__(self, host, port, username, password, phonebook_id=0, prefixes=None): """Initialize the class.""" self.host = host self.username = username self.password = password self.port = port self.phonebook_id = phonebook_id self.phonebook_dict = None s...
[ "def", "__init__", "(", "self", ",", "host", ",", "port", ",", "username", ",", "password", ",", "phonebook_id", "=", "0", ",", "prefixes", "=", "None", ")", ":", "self", ".", "host", "=", "host", "self", ".", "username", "=", "username", "self", "."...
[ 248, 4 ]
[ 267, 31 ]
python
en
['en', 'en', 'en']
True
FritzBoxPhonebook.update_phonebook
(self)
Update the phone book dictionary.
Update the phone book dictionary.
def update_phonebook(self): """Update the phone book dictionary.""" self.phonebook_dict = self.fph.get_all_names(self.phonebook_id) self.number_dict = { re.sub(r"[^\d\+]", "", nr): name for name, nrs in self.phonebook_dict.items() for nr in nrs } ...
[ "def", "update_phonebook", "(", "self", ")", ":", "self", ".", "phonebook_dict", "=", "self", ".", "fph", ".", "get_all_names", "(", "self", ".", "phonebook_id", ")", "self", ".", "number_dict", "=", "{", "re", ".", "sub", "(", "r\"[^\\d\\+]\"", ",", "\"...
[ 270, 4 ]
[ 278, 65 ]
python
en
['en', 'en', 'en']
True
FritzBoxPhonebook.get_name
(self, number)
Return a name for a given phone number.
Return a name for a given phone number.
def get_name(self, number): """Return a name for a given phone number.""" number = re.sub(r"[^\d\+]", "", str(number)) if self.number_dict is None: return "unknown" try: return self.number_dict[number] except KeyError: pass if self.pref...
[ "def", "get_name", "(", "self", ",", "number", ")", ":", "number", "=", "re", ".", "sub", "(", "r\"[^\\d\\+]\"", ",", "\"\"", ",", "str", "(", "number", ")", ")", "if", "self", ".", "number_dict", "is", "None", ":", "return", "\"unknown\"", "try", ":...
[ 280, 4 ]
[ 299, 24 ]
python
en
['en', 'en', 'en']
True
_request_app_setup
(hass, config)
Assist user with configuring the Wink dev application.
Assist user with configuring the Wink dev application.
def _request_app_setup(hass, config): """Assist user with configuring the Wink dev application.""" hass.data[DOMAIN]["configurator"] = True configurator = hass.components.configurator def wink_configuration_callback(callback_data): """Handle configuration updates.""" _config_path = hass...
[ "def", "_request_app_setup", "(", "hass", ",", "config", ")", ":", "hass", ".", "data", "[", "DOMAIN", "]", "[", "\"configurator\"", "]", "=", "True", "configurator", "=", "hass", ".", "components", ".", "configurator", "def", "wink_configuration_callback", "(...
[ 210, 0 ]
[ 255, 5 ]
python
en
['en', 'en', 'en']
True
_request_oauth_completion
(hass, config)
Request user complete Wink OAuth2 flow.
Request user complete Wink OAuth2 flow.
def _request_oauth_completion(hass, config): """Request user complete Wink OAuth2 flow.""" hass.data[DOMAIN]["configurator"] = True configurator = hass.components.configurator if DOMAIN in hass.data[DOMAIN]["configuring"]: configurator.notify_errors( hass.data[DOMAIN]["configuring"][...
[ "def", "_request_oauth_completion", "(", "hass", ",", "config", ")", ":", "hass", ".", "data", "[", "DOMAIN", "]", "[", "\"configurator\"", "]", "=", "True", "configurator", "=", "hass", ".", "components", ".", "configurator", "if", "DOMAIN", "in", "hass", ...
[ 258, 0 ]
[ 279, 5 ]
python
en
['en', 'nl', 'en']
True
setup
(hass, config)
Set up the Wink component.
Set up the Wink component.
def setup(hass, config): """Set up the Wink component.""" if hass.data.get(DOMAIN) is None: hass.data[DOMAIN] = { "unique_ids": [], "entities": {}, "oauth": {}, "configuring": {}, "pubnub": None, "configurator": False, } ...
[ "def", "setup", "(", "hass", ",", "config", ")", ":", "if", "hass", ".", "data", ".", "get", "(", "DOMAIN", ")", "is", "None", ":", "hass", ".", "data", "[", "DOMAIN", "]", "=", "{", "\"unique_ids\"", ":", "[", "]", ",", "\"entities\"", ":", "{",...
[ 282, 0 ]
[ 671, 15 ]
python
en
['en', 'en', 'en']
True
WinkAuthCallbackView.__init__
(self, config, config_file, request_token)
Initialize the OAuth callback view.
Initialize the OAuth callback view.
def __init__(self, config, config_file, request_token): """Initialize the OAuth callback view.""" self.config = config self.config_file = config_file self.request_token = request_token
[ "def", "__init__", "(", "self", ",", "config", ",", "config_file", ",", "request_token", ")", ":", "self", ".", "config", "=", "config", "self", ".", "config_file", "=", "config_file", "self", ".", "request_token", "=", "request_token" ]
[ 681, 4 ]
[ 685, 42 ]
python
en
['en', 'en', 'en']
True
WinkAuthCallbackView.get
(self, request)
Finish OAuth callback request.
Finish OAuth callback request.
def get(self, request): """Finish OAuth callback request.""" hass = request.app["hass"] data = request.query response_message = """Wink has been successfully authorized! You can close this window now! For the best results you should reboot Home Assistant""" htm...
[ "def", "get", "(", "self", ",", "request", ")", ":", "hass", "=", "request", ".", "app", "[", "\"hass\"", "]", "data", "=", "request", ".", "query", "response_message", "=", "\"\"\"Wink has been successfully authorized!\n You can close this window now! For the b...
[ 688, 4 ]
[ 720, 87 ]
python
en
['en', 'en', 'en']
True
WinkDevice.__init__
(self, wink, hass)
Initialize the Wink device.
Initialize the Wink device.
def __init__(self, wink, hass): """Initialize the Wink device.""" self.hass = hass self.wink = wink hass.data[DOMAIN]["pubnub"].add_subscription( self.wink.pubnub_channel, self._pubnub_update ) hass.data[DOMAIN]["unique_ids"].append(self.wink.object_id() + sel...
[ "def", "__init__", "(", "self", ",", "wink", ",", "hass", ")", ":", "self", ".", "hass", "=", "hass", "self", ".", "wink", "=", "wink", "hass", ".", "data", "[", "DOMAIN", "]", "[", "\"pubnub\"", "]", ".", "add_subscription", "(", "self", ".", "win...
[ 726, 4 ]
[ 733, 88 ]
python
en
['en', 'en', 'en']
True
WinkDevice.name
(self)
Return the name of the device.
Return the name of the device.
def name(self): """Return the name of the device.""" return self.wink.name()
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "wink", ".", "name", "(", ")" ]
[ 754, 4 ]
[ 756, 31 ]
python
en
['en', 'en', 'en']
True
WinkDevice.unique_id
(self)
Return the unique id of the Wink device.
Return the unique id of the Wink device.
def unique_id(self): """Return the unique id of the Wink device.""" if hasattr(self.wink, "capability") and self.wink.capability() is not None: return f"{self.wink.object_id()}_{self.wink.capability()}" return self.wink.object_id()
[ "def", "unique_id", "(", "self", ")", ":", "if", "hasattr", "(", "self", ".", "wink", ",", "\"capability\"", ")", "and", "self", ".", "wink", ".", "capability", "(", ")", "is", "not", "None", ":", "return", "f\"{self.wink.object_id()}_{self.wink.capability()}\...
[ 759, 4 ]
[ 763, 36 ]
python
en
['en', 'en', 'en']
True
WinkDevice.available
(self)
Return true if connection == True.
Return true if connection == True.
def available(self): """Return true if connection == True.""" return self.wink.available()
[ "def", "available", "(", "self", ")", ":", "return", "self", ".", "wink", ".", "available", "(", ")" ]
[ 766, 4 ]
[ 768, 36 ]
python
en
['en', 'de', 'en']
True
WinkDevice.update
(self)
Update state of the device.
Update state of the device.
def update(self): """Update state of the device.""" self.wink.update_state()
[ "def", "update", "(", "self", ")", ":", "self", ".", "wink", ".", "update_state", "(", ")" ]
[ 770, 4 ]
[ 772, 32 ]
python
en
['en', 'en', 'en']
True
WinkDevice.should_poll
(self)
Only poll if we are not subscribed to pubnub.
Only poll if we are not subscribed to pubnub.
def should_poll(self): """Only poll if we are not subscribed to pubnub.""" return self.wink.pubnub_channel is None
[ "def", "should_poll", "(", "self", ")", ":", "return", "self", ".", "wink", ".", "pubnub_channel", "is", "None" ]
[ 775, 4 ]
[ 777, 47 ]
python
en
['en', 'en', 'en']
True
WinkDevice.device_state_attributes
(self)
Return the state attributes.
Return the state attributes.
def device_state_attributes(self): """Return the state attributes.""" attributes = {} battery = self._battery_level if battery: attributes[ATTR_BATTERY_LEVEL] = battery man_dev_model = self._manufacturer_device_model if man_dev_model: attributes["m...
[ "def", "device_state_attributes", "(", "self", ")", ":", "attributes", "=", "{", "}", "battery", "=", "self", ".", "_battery_level", "if", "battery", ":", "attributes", "[", "ATTR_BATTERY_LEVEL", "]", "=", "battery", "man_dev_model", "=", "self", ".", "_manufa...
[ 780, 4 ]
[ 801, 25 ]
python
en
['en', 'en', 'en']
True
WinkDevice._battery_level
(self)
Return the battery level.
Return the battery level.
def _battery_level(self): """Return the battery level.""" if self.wink.battery_level() is not None: return self.wink.battery_level() * 100
[ "def", "_battery_level", "(", "self", ")", ":", "if", "self", ".", "wink", ".", "battery_level", "(", ")", "is", "not", "None", ":", "return", "self", ".", "wink", ".", "battery_level", "(", ")", "*", "100" ]
[ 804, 4 ]
[ 807, 50 ]
python
en
['en', 'no', 'en']
True
WinkDevice._manufacturer_device_model
(self)
Return the manufacturer device model.
Return the manufacturer device model.
def _manufacturer_device_model(self): """Return the manufacturer device model.""" return self.wink.manufacturer_device_model()
[ "def", "_manufacturer_device_model", "(", "self", ")", ":", "return", "self", ".", "wink", ".", "manufacturer_device_model", "(", ")" ]
[ 810, 4 ]
[ 812, 52 ]
python
en
['en', 'da', 'en']
True
WinkDevice._manufacturer_device_id
(self)
Return the manufacturer device id.
Return the manufacturer device id.
def _manufacturer_device_id(self): """Return the manufacturer device id.""" return self.wink.manufacturer_device_id()
[ "def", "_manufacturer_device_id", "(", "self", ")", ":", "return", "self", ".", "wink", ".", "manufacturer_device_id", "(", ")" ]
[ 815, 4 ]
[ 817, 49 ]
python
en
['en', 'en', 'en']
True
WinkDevice._device_manufacturer
(self)
Return the device manufacturer.
Return the device manufacturer.
def _device_manufacturer(self): """Return the device manufacturer.""" return self.wink.device_manufacturer()
[ "def", "_device_manufacturer", "(", "self", ")", ":", "return", "self", ".", "wink", ".", "device_manufacturer", "(", ")" ]
[ 820, 4 ]
[ 822, 46 ]
python
en
['en', 'en', 'en']
True
WinkDevice._model_name
(self)
Return the model name.
Return the model name.
def _model_name(self): """Return the model name.""" return self.wink.model_name()
[ "def", "_model_name", "(", "self", ")", ":", "return", "self", ".", "wink", ".", "model_name", "(", ")" ]
[ 825, 4 ]
[ 827, 37 ]
python
en
['en', 'ig', 'en']
True
WinkDevice._tamper
(self)
Return the devices tamper status.
Return the devices tamper status.
def _tamper(self): """Return the devices tamper status.""" if hasattr(self.wink, "tamper_detected"): return self.wink.tamper_detected() return None
[ "def", "_tamper", "(", "self", ")", ":", "if", "hasattr", "(", "self", ".", "wink", ",", "\"tamper_detected\"", ")", ":", "return", "self", ".", "wink", ".", "tamper_detected", "(", ")", "return", "None" ]
[ 830, 4 ]
[ 834, 19 ]
python
en
['en', 'en', 'en']
True
WinkSirenDevice.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.hass.data[DOMAIN]["entities"]["switch"].append(self)
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "self", ".", "hass", ".", "data", "[", "DOMAIN", "]", "[", "\"entities\"", "]", "[", "\"switch\"", "]", ".", "append", "(", "self", ")" ]
[ 840, 4 ]
[ 842, 65 ]
python
en
['en', 'en', 'en']
True
WinkSirenDevice.state
(self)
Return sirens state.
Return sirens state.
def state(self): """Return sirens state.""" if self.wink.state(): return STATE_ON return STATE_OFF
[ "def", "state", "(", "self", ")", ":", "if", "self", ".", "wink", ".", "state", "(", ")", ":", "return", "STATE_ON", "return", "STATE_OFF" ]
[ 845, 4 ]
[ 849, 24 ]
python
en
['no', 'ig', 'en']
False
WinkSirenDevice.icon
(self)
Return the icon to use in the frontend, if any.
Return the icon to use in the frontend, if any.
def icon(self): """Return the icon to use in the frontend, if any.""" return "mdi:bell-ring"
[ "def", "icon", "(", "self", ")", ":", "return", "\"mdi:bell-ring\"" ]
[ 852, 4 ]
[ 854, 30 ]
python
en
['en', 'en', 'en']
True
WinkSirenDevice.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 = super().device_state_attributes auto_shutoff = self.wink.auto_shutoff() if auto_shutoff is not None: attributes["auto_shutoff"] = auto_shutoff siren_volume = self.wink.siren_vo...
[ "def", "device_state_attributes", "(", "self", ")", ":", "attributes", "=", "super", "(", ")", ".", "device_state_attributes", "auto_shutoff", "=", "self", ".", "wink", ".", "auto_shutoff", "(", ")", "if", "auto_shutoff", "is", "not", "None", ":", "attributes"...
[ 857, 4 ]
[ 889, 25 ]
python
en
['en', 'en', 'en']
True
WinkNimbusDialDevice.__init__
(self, nimbus, dial, hass)
Initialize the Nimbus dial.
Initialize the Nimbus dial.
def __init__(self, nimbus, dial, hass): """Initialize the Nimbus dial.""" super().__init__(dial, hass) self.parent = nimbus
[ "def", "__init__", "(", "self", ",", "nimbus", ",", "dial", ",", "hass", ")", ":", "super", "(", ")", ".", "__init__", "(", "dial", ",", "hass", ")", "self", ".", "parent", "=", "nimbus" ]
[ 895, 4 ]
[ 898, 28 ]
python
en
['en', 'en', 'en']
True
WinkNimbusDialDevice.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.hass.data[DOMAIN]["entities"]["sensor"].append(self)
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "self", ".", "hass", ".", "data", "[", "DOMAIN", "]", "[", "\"entities\"", "]", "[", "\"sensor\"", "]", ".", "append", "(", "self", ")" ]
[ 900, 4 ]
[ 902, 65 ]
python
en
['en', 'en', 'en']
True
WinkNimbusDialDevice.state
(self)
Return dials current value.
Return dials current value.
def state(self): """Return dials current value.""" return self.wink.state()
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "wink", ".", "state", "(", ")" ]
[ 905, 4 ]
[ 907, 32 ]
python
ca
['nl', 'ca', 'en']
False
WinkNimbusDialDevice.name
(self)
Return the name of the device.
Return the name of the device.
def name(self): """Return the name of the device.""" return f"{self.parent.name()} dial {self.wink.index() + 1}"
[ "def", "name", "(", "self", ")", ":", "return", "f\"{self.parent.name()} dial {self.wink.index() + 1}\"" ]
[ 910, 4 ]
[ 912, 67 ]
python
en
['en', 'en', 'en']
True
WinkNimbusDialDevice.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 = super().device_state_attributes dial_attributes = self.dial_attributes() return {**attributes, **dial_attributes}
[ "def", "device_state_attributes", "(", "self", ")", ":", "attributes", "=", "super", "(", ")", ".", "device_state_attributes", "dial_attributes", "=", "self", ".", "dial_attributes", "(", ")", "return", "{", "*", "*", "attributes", ",", "*", "*", "dial_attribu...
[ 915, 4 ]
[ 920, 48 ]
python
en
['en', 'en', 'en']
True
WinkNimbusDialDevice.dial_attributes
(self)
Return the dial only attributes.
Return the dial only attributes.
def dial_attributes(self): """Return the dial only attributes.""" return { "labels": self.wink.labels(), "position": self.wink.position(), "rotation": self.wink.rotation(), "max_value": self.wink.max_value(), "min_value": self.wink.min_value(),...
[ "def", "dial_attributes", "(", "self", ")", ":", "return", "{", "\"labels\"", ":", "self", ".", "wink", ".", "labels", "(", ")", ",", "\"position\"", ":", "self", ".", "wink", ".", "position", "(", ")", ",", "\"rotation\"", ":", "self", ".", "wink", ...
[ 922, 4 ]
[ 934, 9 ]
python
en
['en', 'en', 'en']
True
WinkNimbusDialDevice.set_configuration
(self, **kwargs)
Set the dial config. Anything not sent will default to current setting.
Set the dial config.
def set_configuration(self, **kwargs): """ Set the dial config. Anything not sent will default to current setting. """ attributes = {**self.dial_attributes(), **kwargs} min_value = attributes["min_value"] max_value = attributes["max_value"] rotation = at...
[ "def", "set_configuration", "(", "self", ",", "*", "*", "kwargs", ")", ":", "attributes", "=", "{", "*", "*", "self", ".", "dial_attributes", "(", ")", ",", "*", "*", "kwargs", "}", "min_value", "=", "attributes", "[", "\"min_value\"", "]", "max_value", ...
[ 936, 4 ]
[ 960, 9 ]
python
en
['en', 'error', 'th']
False
setup
(hass, config)
Set up the Nissan Leaf component.
Set up the Nissan Leaf component.
def setup(hass, config): """Set up the Nissan Leaf component.""" async def async_handle_update(service): """Handle service to update leaf data from Nissan servers.""" # It would be better if this was changed to use nickname, or # an entity name rather than a vin. vin = service.d...
[ "def", "setup", "(", "hass", ",", "config", ")", ":", "async", "def", "async_handle_update", "(", "service", ")", ":", "\"\"\"Handle service to update leaf data from Nissan servers.\"\"\"", "# It would be better if this was changed to use nickname, or", "# an entity name rather tha...
[ 96, 0 ]
[ 194, 15 ]
python
en
['en', 'da', 'en']
True
LeafDataStore.__init__
(self, hass, leaf, car_config)
Initialise the data store.
Initialise the data store.
def __init__(self, hass, leaf, car_config): """Initialise the data store.""" self.hass = hass self.leaf = leaf self.car_config = car_config self.force_miles = car_config[CONF_FORCE_MILES] self.data = {} self.data[DATA_CLIMATE] = False self.data[DATA_BATTER...
[ "def", "__init__", "(", "self", ",", "hass", ",", "leaf", ",", "car_config", ")", ":", "self", ".", "hass", "=", "hass", "self", ".", "leaf", "=", "leaf", "self", ".", "car_config", "=", "car_config", "self", ".", "force_miles", "=", "car_config", "[",...
[ 200, 4 ]
[ 219, 36 ]
python
en
['en', 'en', 'en']
True
LeafDataStore.async_update_data
(self, now)
Update data from nissan leaf.
Update data from nissan leaf.
async def async_update_data(self, now): """Update data from nissan leaf.""" # Prevent against a previously scheduled update and an ad-hoc update # started from an update from both being triggered. if self._remove_listener: self._remove_listener() self._remove_list...
[ "async", "def", "async_update_data", "(", "self", ",", "now", ")", ":", "# Prevent against a previously scheduled update and an ad-hoc update", "# started from an update from both being triggered.", "if", "self", ".", "_remove_listener", ":", "self", ".", "_remove_listener", "(...
[ 221, 4 ]
[ 237, 9 ]
python
en
['en', 'en', 'en']
True
LeafDataStore.get_next_interval
(self)
Calculate when the next update should occur.
Calculate when the next update should occur.
def get_next_interval(self): """Calculate when the next update should occur.""" base_interval = self.car_config[CONF_INTERVAL] climate_interval = self.car_config[CONF_CLIMATE_INTERVAL] charging_interval = self.car_config[CONF_CHARGING_INTERVAL] # The 12V battery is used when com...
[ "def", "get_next_interval", "(", "self", ")", ":", "base_interval", "=", "self", ".", "car_config", "[", "CONF_INTERVAL", "]", "climate_interval", "=", "self", ".", "car_config", "[", "CONF_CLIMATE_INTERVAL", "]", "charging_interval", "=", "self", ".", "car_config...
[ 239, 4 ]
[ 270, 34 ]
python
en
['en', 'en', 'en']
True
LeafDataStore.async_refresh_data
(self, now)
Refresh the leaf data and update the datastore.
Refresh the leaf data and update the datastore.
async def async_refresh_data(self, now): """Refresh the leaf data and update the datastore.""" if self.request_in_progress: _LOGGER.debug("Refresh currently in progress for %s", self.leaf.nickname) return _LOGGER.debug("Updating Nissan Leaf Data") self.last_che...
[ "async", "def", "async_refresh_data", "(", "self", ",", "now", ")", ":", "if", "self", ".", "request_in_progress", ":", "_LOGGER", ".", "debug", "(", "\"Refresh currently in progress for %s\"", ",", "self", ".", "leaf", ".", "nickname", ")", "return", "_LOGGER",...
[ 272, 4 ]
[ 326, 60 ]
python
en
['en', 'en', 'en']
True
LeafDataStore._extract_start_date
(battery_info)
Extract the server date from the battery response.
Extract the server date from the battery response.
def _extract_start_date(battery_info): """Extract the server date from the battery response.""" try: return battery_info.answer["BatteryStatusRecords"]["OperationDateAndTime"] except KeyError: return None
[ "def", "_extract_start_date", "(", "battery_info", ")", ":", "try", ":", "return", "battery_info", ".", "answer", "[", "\"BatteryStatusRecords\"", "]", "[", "\"OperationDateAndTime\"", "]", "except", "KeyError", ":", "return", "None" ]
[ 329, 4 ]
[ 334, 23 ]
python
en
['en', 'en', 'en']
True
LeafDataStore.async_get_battery
(self)
Request battery update from Nissan servers.
Request battery update from Nissan servers.
async def async_get_battery(self): """Request battery update from Nissan servers.""" try: # Request battery update from the car _LOGGER.debug("Requesting battery update, %s", self.leaf.vin) request = await self.hass.async_add_executor_job(self.leaf.request_update) ...
[ "async", "def", "async_get_battery", "(", "self", ")", ":", "try", ":", "# Request battery update from the car", "_LOGGER", ".", "debug", "(", "\"Requesting battery update, %s\"", ",", "self", ".", "leaf", ".", "vin", ")", "request", "=", "await", "self", ".", "...
[ 336, 4 ]
[ 386, 23 ]
python
en
['en', 'en', 'en']
True
LeafDataStore.async_get_climate
(self)
Request climate data from Nissan servers.
Request climate data from Nissan servers.
async def async_get_climate(self): """Request climate data from Nissan servers.""" try: return await self.hass.async_add_executor_job( self.leaf.get_latest_hvac_status ) except CarwingsError: _LOGGER.error( "An error occurred c...
[ "async", "def", "async_get_climate", "(", "self", ")", ":", "try", ":", "return", "await", "self", ".", "hass", ".", "async_add_executor_job", "(", "self", ".", "leaf", ".", "get_latest_hvac_status", ")", "except", "CarwingsError", ":", "_LOGGER", ".", "error"...
[ 388, 4 ]
[ 399, 23 ]
python
en
['en', 'en', 'en']
True
LeafDataStore.async_set_climate
(self, toggle)
Set climate control mode via Nissan servers.
Set climate control mode via Nissan servers.
async def async_set_climate(self, toggle): """Set climate control mode via Nissan servers.""" climate_result = None if toggle: _LOGGER.debug("Requesting climate turn on for %s", self.leaf.vin) set_function = self.leaf.start_climate_control result_function = se...
[ "async", "def", "async_set_climate", "(", "self", ",", "toggle", ")", ":", "climate_result", "=", "None", "if", "toggle", ":", "_LOGGER", ".", "debug", "(", "\"Requesting climate turn on for %s\"", ",", "self", ".", "leaf", ".", "vin", ")", "set_function", "="...
[ 401, 4 ]
[ 437, 20 ]
python
en
['fr', 'pt', 'en']
False
LeafEntity.__init__
(self, car)
Store LeafDataStore upon init.
Store LeafDataStore upon init.
def __init__(self, car): """Store LeafDataStore upon init.""" self.car = car
[ "def", "__init__", "(", "self", ",", "car", ")", ":", "self", ".", "car", "=", "car" ]
[ 443, 4 ]
[ 445, 22 ]
python
en
['en', 'la', 'en']
True
LeafEntity.log_registration
(self)
Log registration.
Log registration.
def log_registration(self): """Log registration.""" _LOGGER.debug( "Registered %s integration for VIN %s", self.__class__.__name__, self.car.leaf.vin, )
[ "def", "log_registration", "(", "self", ")", ":", "_LOGGER", ".", "debug", "(", "\"Registered %s integration for VIN %s\"", ",", "self", ".", "__class__", ".", "__name__", ",", "self", ".", "car", ".", "leaf", ".", "vin", ",", ")" ]
[ 447, 4 ]
[ 453, 9 ]
python
da
['da', 'da', 'en']
False
LeafEntity.device_state_attributes
(self)
Return default attributes for Nissan leaf entities.
Return default attributes for Nissan leaf entities.
def device_state_attributes(self): """Return default attributes for Nissan leaf entities.""" return { "next_update": self.car.next_update, "last_attempt": self.car.last_check, "updated_on": self.car.last_battery_response, "update_in_progress": self.car.req...
[ "def", "device_state_attributes", "(", "self", ")", ":", "return", "{", "\"next_update\"", ":", "self", ".", "car", ".", "next_update", ",", "\"last_attempt\"", ":", "self", ".", "car", ".", "last_check", ",", "\"updated_on\"", ":", "self", ".", "car", ".", ...
[ 456, 4 ]
[ 464, 9 ]
python
da
['da', 'da', 'en']
True
LeafEntity.async_added_to_hass
(self)
Register callbacks.
Register callbacks.
async def async_added_to_hass(self): """Register callbacks.""" self.log_registration() self.async_on_remove( async_dispatcher_connect( self.car.hass, SIGNAL_UPDATE_LEAF, self._update_callback ) )
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "self", ".", "log_registration", "(", ")", "self", ".", "async_on_remove", "(", "async_dispatcher_connect", "(", "self", ".", "car", ".", "hass", ",", "SIGNAL_UPDATE_LEAF", ",", "self", ".", "_updat...
[ 466, 4 ]
[ 473, 9 ]
python
en
['en', 'no', 'en']
False
LeafEntity._update_callback
(self)
Update the state.
Update the state.
def _update_callback(self): """Update the state.""" self.async_schedule_update_ha_state(True)
[ "def", "_update_callback", "(", "self", ")", ":", "self", ".", "async_schedule_update_ha_state", "(", "True", ")" ]
[ 476, 4 ]
[ 478, 49 ]
python
en
['en', 'en', 'en']
True
get_scanner
(hass, config)
Validate the configuration and return a Ubee scanner.
Validate the configuration and return a Ubee scanner.
def get_scanner(hass, config): """Validate the configuration and return a Ubee scanner.""" info = config[DOMAIN] host = info[CONF_HOST] username = info[CONF_USERNAME] password = info[CONF_PASSWORD] model = info[CONF_MODEL] ubee = Ubee(host, username, password, model) if not ubee.login()...
[ "def", "get_scanner", "(", "hass", ",", "config", ")", ":", "info", "=", "config", "[", "DOMAIN", "]", "host", "=", "info", "[", "CONF_HOST", "]", "username", "=", "info", "[", "CONF_USERNAME", "]", "password", "=", "info", "[", "CONF_PASSWORD", "]", "...
[ 38, 0 ]
[ 52, 18 ]
python
en
['en', 'en', 'en']
True
UbeeDeviceScanner.__init__
(self, ubee)
Initialize the Ubee scanner.
Initialize the Ubee scanner.
def __init__(self, ubee): """Initialize the Ubee scanner.""" self._ubee = ubee self._mac2name = {}
[ "def", "__init__", "(", "self", ",", "ubee", ")", ":", "self", ".", "_ubee", "=", "ubee", "self", ".", "_mac2name", "=", "{", "}" ]
[ 58, 4 ]
[ 61, 27 ]
python
en
['en', 'en', 'en']
True
UbeeDeviceScanner.scan_devices
(self)
Scan for new devices and return a list with found device IDs.
Scan for new devices and return a list with found device IDs.
def scan_devices(self): """Scan for new devices and return a list with found device IDs.""" devices = self._get_connected_devices() self._mac2name = devices return list(devices)
[ "def", "scan_devices", "(", "self", ")", ":", "devices", "=", "self", ".", "_get_connected_devices", "(", ")", "self", ".", "_mac2name", "=", "devices", "return", "list", "(", "devices", ")" ]
[ 63, 4 ]
[ 67, 28 ]
python
en
['en', 'en', 'en']
True
UbeeDeviceScanner.get_device_name
(self, device)
Return the name of the given device or None if we don't know.
Return the name of the given device or None if we don't know.
def get_device_name(self, device): """Return the name of the given device or None if we don't know.""" return self._mac2name.get(device)
[ "def", "get_device_name", "(", "self", ",", "device", ")", ":", "return", "self", ".", "_mac2name", ".", "get", "(", "device", ")" ]
[ 69, 4 ]
[ 71, 41 ]
python
en
['en', 'en', 'en']
True
UbeeDeviceScanner._get_connected_devices
(self)
List connected devices with pyubee.
List connected devices with pyubee.
def _get_connected_devices(self): """List connected devices with pyubee.""" if not self._ubee.session_active(): self._ubee.login() return self._ubee.get_connected_devices()
[ "def", "_get_connected_devices", "(", "self", ")", ":", "if", "not", "self", ".", "_ubee", ".", "session_active", "(", ")", ":", "self", ".", "_ubee", ".", "login", "(", ")", "return", "self", ".", "_ubee", ".", "get_connected_devices", "(", ")" ]
[ 73, 4 ]
[ 78, 49 ]
python
en
['en', 'en', 'en']
True
split_text
(text: str, n=100, character=" ")
Split the text every ``n``-th occurrence of ``character``
Split the text every ``n``-th occurrence of ``character``
def split_text(text: str, n=100, character=" ") -> List[str]: """Split the text every ``n``-th occurrence of ``character``""" text = text.split(character) return [character.join(text[i : i + n]).strip() for i in range(0, len(text), n)]
[ "def", "split_text", "(", "text", ":", "str", ",", "n", "=", "100", ",", "character", "=", "\" \"", ")", "->", "List", "[", "str", "]", ":", "text", "=", "text", ".", "split", "(", "character", ")", "return", "[", "character", ".", "join", "(", "...
[ 27, 0 ]
[ 30, 84 ]
python
en
['en', 'en', 'en']
True
split_documents
(documents: dict)
Split documents into passages
Split documents into passages
def split_documents(documents: dict) -> dict: """Split documents into passages""" titles, texts = [], [] for title, text in zip(documents["title"], documents["text"]): if text is not None: for passage in split_text(text): titles.append(title if title is not None else "") ...
[ "def", "split_documents", "(", "documents", ":", "dict", ")", "->", "dict", ":", "titles", ",", "texts", "=", "[", "]", ",", "[", "]", "for", "title", ",", "text", "in", "zip", "(", "documents", "[", "\"title\"", "]", ",", "documents", "[", "\"text\"...
[ 33, 0 ]
[ 41, 43 ]
python
en
['en', 'fr', 'en']
True
embed
(documents: dict, ctx_encoder: DPRContextEncoder, ctx_tokenizer: DPRContextEncoderTokenizerFast)
Compute the DPR embeddings of document passages
Compute the DPR embeddings of document passages
def embed(documents: dict, ctx_encoder: DPRContextEncoder, ctx_tokenizer: DPRContextEncoderTokenizerFast) -> dict: """Compute the DPR embeddings of document passages""" input_ids = ctx_tokenizer( documents["title"], documents["text"], truncation=True, padding="longest", return_tensors="pt" )["input_...
[ "def", "embed", "(", "documents", ":", "dict", ",", "ctx_encoder", ":", "DPRContextEncoder", ",", "ctx_tokenizer", ":", "DPRContextEncoderTokenizerFast", ")", "->", "dict", ":", "input_ids", "=", "ctx_tokenizer", "(", "documents", "[", "\"title\"", "]", ",", "do...
[ 44, 0 ]
[ 50, 60 ]
python
en
['en', 'en', 'en']
True
test_from_event_to_db_event
()
Test converting event to db event.
Test converting event to db event.
def test_from_event_to_db_event(): """Test converting event to db event.""" event = ha.Event("test_event", {"some_data": 15}) assert event == Events.from_event(event).to_native()
[ "def", "test_from_event_to_db_event", "(", ")", ":", "event", "=", "ha", ".", "Event", "(", "\"test_event\"", ",", "{", "\"some_data\"", ":", "15", "}", ")", "assert", "event", "==", "Events", ".", "from_event", "(", "event", ")", ".", "to_native", "(", ...
[ 23, 0 ]
[ 26, 56 ]
python
en
['en', 'en', 'en']
True
test_from_event_to_db_state
()
Test converting event to db state.
Test converting event to db state.
def test_from_event_to_db_state(): """Test converting event to db state.""" state = ha.State("sensor.temperature", "18") event = ha.Event( EVENT_STATE_CHANGED, {"entity_id": "sensor.temperature", "old_state": None, "new_state": state}, context=state.context, ) # We don't rest...
[ "def", "test_from_event_to_db_state", "(", ")", ":", "state", "=", "ha", ".", "State", "(", "\"sensor.temperature\"", ",", "\"18\"", ")", "event", "=", "ha", ".", "Event", "(", "EVENT_STATE_CHANGED", ",", "{", "\"entity_id\"", ":", "\"sensor.temperature\"", ",",...
[ 29, 0 ]
[ 40, 56 ]
python
en
['en', 'en', 'en']
True
test_from_event_to_delete_state
()
Test converting deleting state event to db state.
Test converting deleting state event to db state.
def test_from_event_to_delete_state(): """Test converting deleting state event to db state.""" event = ha.Event( EVENT_STATE_CHANGED, { "entity_id": "sensor.temperature", "old_state": ha.State("sensor.temperature", "18"), "new_state": None, }, ) ...
[ "def", "test_from_event_to_delete_state", "(", ")", ":", "event", "=", "ha", ".", "Event", "(", "EVENT_STATE_CHANGED", ",", "{", "\"entity_id\"", ":", "\"sensor.temperature\"", ",", "\"old_state\"", ":", "ha", ".", "State", "(", "\"sensor.temperature\"", ",", "\"1...
[ 43, 0 ]
[ 59, 52 ]
python
en
['en', 'en', 'en']
True
test_entity_ids
()
Test if entity ids helper method works.
Test if entity ids helper method works.
def test_entity_ids(): """Test if entity ids helper method works.""" engine = create_engine("sqlite://") Base.metadata.create_all(engine) session_factory = sessionmaker(bind=engine) session = scoped_session(session_factory) session.query(Events).delete() session.query(States).delete() s...
[ "def", "test_entity_ids", "(", ")", ":", "engine", "=", "create_engine", "(", "\"sqlite://\"", ")", "Base", ".", "metadata", ".", "create_all", "(", "engine", ")", "session_factory", "=", "sessionmaker", "(", "bind", "=", "engine", ")", "session", "=", "scop...
[ 62, 0 ]
[ 127, 57 ]
python
en
['en', 'cy', 'en']
True
test_states_from_native_invalid_entity_id
()
Test loading a state from an invalid entity ID.
Test loading a state from an invalid entity ID.
def test_states_from_native_invalid_entity_id(): """Test loading a state from an invalid entity ID.""" state = States() state.entity_id = "test.invalid__id" state.attributes = "{}" with pytest.raises(InvalidEntityFormatError): state = state.to_native() state = state.to_native(validate_e...
[ "def", "test_states_from_native_invalid_entity_id", "(", ")", ":", "state", "=", "States", "(", ")", "state", ".", "entity_id", "=", "\"test.invalid__id\"", "state", ".", "attributes", "=", "\"{}\"", "with", "pytest", ".", "raises", "(", "InvalidEntityFormatError", ...
[ 130, 0 ]
[ 139, 48 ]
python
en
['en', 'en', 'en']
True
test_process_timestamp
()
Test processing time stamp to UTC.
Test processing time stamp to UTC.
async def test_process_timestamp(): """Test processing time stamp to UTC.""" datetime_with_tzinfo = datetime(2016, 7, 9, 11, 0, 0, tzinfo=dt.UTC) datetime_without_tzinfo = datetime(2016, 7, 9, 11, 0, 0) est = pytz.timezone("US/Eastern") datetime_est_timezone = datetime(2016, 7, 9, 11, 0, 0, tzinfo=e...
[ "async", "def", "test_process_timestamp", "(", ")", ":", "datetime_with_tzinfo", "=", "datetime", "(", "2016", ",", "7", ",", "9", ",", "11", ",", "0", ",", "0", ",", "tzinfo", "=", "dt", ".", "UTC", ")", "datetime_without_tzinfo", "=", "datetime", "(", ...
[ 142, 0 ]
[ 168, 42 ]
python
en
['en', 'en', 'en']
True
test_process_timestamp_to_utc_isoformat
()
Test processing time stamp to UTC isoformat.
Test processing time stamp to UTC isoformat.
async def test_process_timestamp_to_utc_isoformat(): """Test processing time stamp to UTC isoformat.""" datetime_with_tzinfo = datetime(2016, 7, 9, 11, 0, 0, tzinfo=dt.UTC) datetime_without_tzinfo = datetime(2016, 7, 9, 11, 0, 0) est = pytz.timezone("US/Eastern") datetime_est_timezone = datetime(201...
[ "async", "def", "test_process_timestamp_to_utc_isoformat", "(", ")", ":", "datetime_with_tzinfo", "=", "datetime", "(", "2016", ",", "7", ",", "9", ",", "11", ",", "0", ",", "0", ",", "tzinfo", "=", "dt", ".", "UTC", ")", "datetime_without_tzinfo", "=", "d...
[ 171, 0 ]
[ 204, 59 ]
python
en
['en', 'en', 'en']
True
test_event_to_db_model
()
Test we can round trip Event conversion.
Test we can round trip Event conversion.
async def test_event_to_db_model(): """Test we can round trip Event conversion.""" event = ha.Event( "state_changed", {"some": "attr"}, ha.EventOrigin.local, dt_util.utcnow() ) native = Events.from_event(event).to_native() assert native == event native = Events.from_event(event, event_d...
[ "async", "def", "test_event_to_db_model", "(", ")", ":", "event", "=", "ha", ".", "Event", "(", "\"state_changed\"", ",", "{", "\"some\"", ":", "\"attr\"", "}", ",", "ha", ".", "EventOrigin", ".", "local", ",", "dt_util", ".", "utcnow", "(", ")", ")", ...
[ 207, 0 ]
[ 217, 26 ]
python
en
['en', 'en', 'en']
True
async_setup
(hass, config)
Ecobee uses config flow for configuration. But, an "ecobee:" entry in configuration.yaml will trigger an import flow if a config entry doesn't already exist. If ecobee.conf exists, the import flow will attempt to import it and create a config entry, to assist users migrating from the old ecobee co...
Ecobee uses config flow for configuration.
async def async_setup(hass, config): """ Ecobee uses config flow for configuration. But, an "ecobee:" entry in configuration.yaml will trigger an import flow if a config entry doesn't already exist. If ecobee.conf exists, the import flow will attempt to import it and create a config entry, to assis...
[ "async", "def", "async_setup", "(", "hass", ",", "config", ")", ":", "hass", ".", "data", "[", "DATA_ECOBEE_CONFIG", "]", "=", "config", ".", "get", "(", "DOMAIN", ",", "{", "}", ")", "if", "not", "hass", ".", "config_entries", ".", "async_entries", "(...
[ 27, 0 ]
[ 47, 15 ]
python
en
['en', 'error', 'th']
False
async_setup_entry
(hass, entry)
Set up ecobee via a config entry.
Set up ecobee via a config entry.
async def async_setup_entry(hass, entry): """Set up ecobee via a config entry.""" api_key = entry.data[CONF_API_KEY] refresh_token = entry.data[CONF_REFRESH_TOKEN] data = EcobeeData(hass, entry, api_key=api_key, refresh_token=refresh_token) if not await data.refresh(): return False aw...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "entry", ")", ":", "api_key", "=", "entry", ".", "data", "[", "CONF_API_KEY", "]", "refresh_token", "=", "entry", ".", "data", "[", "CONF_REFRESH_TOKEN", "]", "data", "=", "EcobeeData", "(", "hass", ",...
[ 50, 0 ]
[ 73, 15 ]
python
en
['en', 'pt', 'en']
True
async_unload_entry
(hass, config_entry)
Unload the config entry and platforms.
Unload the config entry and platforms.
async def async_unload_entry(hass, config_entry): """Unload the config entry and platforms.""" hass.data.pop(DOMAIN) tasks = [] for platform in ECOBEE_PLATFORMS: tasks.append( hass.config_entries.async_forward_entry_unload(config_entry, platform) ) return all(await asyn...
[ "async", "def", "async_unload_entry", "(", "hass", ",", "config_entry", ")", ":", "hass", ".", "data", ".", "pop", "(", "DOMAIN", ")", "tasks", "=", "[", "]", "for", "platform", "in", "ECOBEE_PLATFORMS", ":", "tasks", ".", "append", "(", "hass", ".", "...
[ 117, 0 ]
[ 127, 44 ]
python
en
['en', 'en', 'en']
True
EcobeeData.__init__
(self, hass, entry, api_key, refresh_token)
Initialize the Ecobee data object.
Initialize the Ecobee data object.
def __init__(self, hass, entry, api_key, refresh_token): """Initialize the Ecobee data object.""" self._hass = hass self._entry = entry self.ecobee = Ecobee( config={ECOBEE_API_KEY: api_key, ECOBEE_REFRESH_TOKEN: refresh_token} )
[ "def", "__init__", "(", "self", ",", "hass", ",", "entry", ",", "api_key", ",", "refresh_token", ")", ":", "self", ".", "_hass", "=", "hass", "self", ".", "_entry", "=", "entry", "self", ".", "ecobee", "=", "Ecobee", "(", "config", "=", "{", "ECOBEE_...
[ 83, 4 ]
[ 89, 9 ]
python
en
['en', 'en', 'en']
True
EcobeeData.update
(self)
Get the latest data from ecobee.com.
Get the latest data from ecobee.com.
async def update(self): """Get the latest data from ecobee.com.""" try: await self._hass.async_add_executor_job(self.ecobee.update) _LOGGER.debug("Updating ecobee") except ExpiredTokenError: _LOGGER.debug("Refreshing expired ecobee tokens") await s...
[ "async", "def", "update", "(", "self", ")", ":", "try", ":", "await", "self", ".", "_hass", ".", "async_add_executor_job", "(", "self", ".", "ecobee", ".", "update", ")", "_LOGGER", ".", "debug", "(", "\"Updating ecobee\"", ")", "except", "ExpiredTokenError"...
[ 92, 4 ]
[ 99, 32 ]
python
en
['en', 'en', 'en']
True
EcobeeData.refresh
(self)
Refresh ecobee tokens and update config entry.
Refresh ecobee tokens and update config entry.
async def refresh(self) -> bool: """Refresh ecobee tokens and update config entry.""" _LOGGER.debug("Refreshing ecobee tokens and updating config entry") if await self._hass.async_add_executor_job(self.ecobee.refresh_tokens): self._hass.config_entries.async_update_entry( ...
[ "async", "def", "refresh", "(", "self", ")", "->", "bool", ":", "_LOGGER", ".", "debug", "(", "\"Refreshing ecobee tokens and updating config entry\"", ")", "if", "await", "self", ".", "_hass", ".", "async_add_executor_job", "(", "self", ".", "ecobee", ".", "ref...
[ 101, 4 ]
[ 114, 20 ]
python
en
['en', 'en', 'en']
True
MultiAgentWrapper.load_model
(self, model_dict: dict)
Load models from memory for each agent.
Load models from memory for each agent.
def load_model(self, model_dict: dict): """Load models from memory for each agent.""" for agent_id, model in model_dict.items(): self.agent_dict[agent_id].load_model(model)
[ "def", "load_model", "(", "self", ",", "model_dict", ":", "dict", ")", ":", "for", "agent_id", ",", "model", "in", "model_dict", ".", "items", "(", ")", ":", "self", ".", "agent_dict", "[", "agent_id", "]", ".", "load_model", "(", "model", ")" ]
[ 28, 4 ]
[ 31, 55 ]
python
en
['en', 'en', 'en']
True
MultiAgentWrapper.dump_model
(self, agent_ids: Union[str, List[str]] = None)
Get agents' underlying models. This is usually used in distributed mode where models need to be broadcast to remote roll-out actors.
Get agents' underlying models.
def dump_model(self, agent_ids: Union[str, List[str]] = None): """Get agents' underlying models. This is usually used in distributed mode where models need to be broadcast to remote roll-out actors. """ if agent_ids is None: return {agent_id: agent.dump_model() for agent_id,...
[ "def", "dump_model", "(", "self", ",", "agent_ids", ":", "Union", "[", "str", ",", "List", "[", "str", "]", "]", "=", "None", ")", ":", "if", "agent_ids", "is", "None", ":", "return", "{", "agent_id", ":", "agent", ".", "dump_model", "(", ")", "for...
[ 33, 4 ]
[ 43, 101 ]
python
en
['en', 'da', 'en']
True
MultiAgentWrapper.load_model_from_file
(self, dir_path)
Load models from disk for each agent.
Load models from disk for each agent.
def load_model_from_file(self, dir_path): """Load models from disk for each agent.""" for agent_id, agent in self.agent_dict.items(): agent.load_model_from_file(os.path.join(dir_path, agent_id))
[ "def", "load_model_from_file", "(", "self", ",", "dir_path", ")", ":", "for", "agent_id", ",", "agent", "in", "self", ".", "agent_dict", ".", "items", "(", ")", ":", "agent", ".", "load_model_from_file", "(", "os", ".", "path", ".", "join", "(", "dir_pat...
[ 45, 4 ]
[ 48, 72 ]
python
en
['en', 'en', 'en']
True
MultiAgentWrapper.dump_model_to_file
(self, dir_path: str, agent_ids: Union[str, List[str]] = None)
Dump agents' models to disk. Each agent will use its own name to create a separate file under ``dir_path`` for dumping.
Dump agents' models to disk.
def dump_model_to_file(self, dir_path: str, agent_ids: Union[str, List[str]] = None): """Dump agents' models to disk. Each agent will use its own name to create a separate file under ``dir_path`` for dumping. """ os.makedirs(dir_path, exist_ok=True) if agent_ids is None: ...
[ "def", "dump_model_to_file", "(", "self", ",", "dir_path", ":", "str", ",", "agent_ids", ":", "Union", "[", "str", ",", "List", "[", "str", "]", "]", "=", "None", ")", ":", "os", ".", "makedirs", "(", "dir_path", ",", "exist_ok", "=", "True", ")", ...
[ 50, 4 ]
[ 63, 94 ]
python
en
['en', 'da', 'en']
True
test_services
(hass, config_entry, aioclient_mock_fixture, aioclient_mock)
Test Flo services.
Test Flo services.
async def test_services(hass, config_entry, aioclient_mock_fixture, aioclient_mock): """Test Flo services.""" config_entry.add_to_hass(hass) assert await async_setup_component( hass, FLO_DOMAIN, {CONF_USERNAME: TEST_USER_ID, CONF_PASSWORD: TEST_PASSWORD} ) await hass.async_block_till_done() ...
[ "async", "def", "test_services", "(", "hass", ",", "config_entry", ",", "aioclient_mock_fixture", ",", "aioclient_mock", ")", ":", "config_entry", ".", "add_to_hass", "(", "hass", ")", "assert", "await", "async_setup_component", "(", "hass", ",", "FLO_DOMAIN", ","...
[ 19, 0 ]
[ 68, 41 ]
python
en
['it', 'fr', 'en']
False
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the file size sensor.
Set up the file size sensor.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the file size sensor.""" setup_reload_service(hass, DOMAIN, PLATFORMS) sensors = [] for path in config.get(CONF_FILE_PATHS): if not hass.config.is_allowed_path(path): _LOGGER.error("Filepath %s is not va...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "setup_reload_service", "(", "hass", ",", "DOMAIN", ",", "PLATFORMS", ")", "sensors", "=", "[", "]", "for", "path", "in", "config", ".",...
[ 26, 0 ]
[ 39, 35 ]
python
en
['en', 'da', 'en']
True
Filesize.__init__
(self, path)
Initialize the data object.
Initialize the data object.
def __init__(self, path): """Initialize the data object.""" self._path = path # Need to check its a valid path self._size = None self._last_updated = None self._name = path.split("/")[-1] self._unit_of_measurement = DATA_MEGABYTES
[ "def", "__init__", "(", "self", ",", "path", ")", ":", "self", ".", "_path", "=", "path", "# Need to check its a valid path", "self", ".", "_size", "=", "None", "self", ".", "_last_updated", "=", "None", "self", ".", "_name", "=", "path", ".", "split", "...
[ 45, 4 ]
[ 51, 50 ]
python
en
['en', 'en', 'en']
True
Filesize.update
(self)
Update the sensor.
Update the sensor.
def update(self): """Update the sensor.""" statinfo = os.stat(self._path) self._size = statinfo.st_size last_updated = datetime.datetime.fromtimestamp(statinfo.st_mtime) self._last_updated = last_updated.isoformat()
[ "def", "update", "(", "self", ")", ":", "statinfo", "=", "os", ".", "stat", "(", "self", ".", "_path", ")", "self", ".", "_size", "=", "statinfo", ".", "st_size", "last_updated", "=", "datetime", ".", "datetime", ".", "fromtimestamp", "(", "statinfo", ...
[ 53, 4 ]
[ 58, 53 ]
python
en
['en', 'nl', 'en']
True
Filesize.name
(self)
Return the name of the sensor.
Return the name of the sensor.
def name(self): """Return the name of the sensor.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 61, 4 ]
[ 63, 25 ]
python
en
['en', 'mi', 'en']
True
Filesize.state
(self)
Return the size of the file in MB.
Return the size of the file in MB.
def state(self): """Return the size of the file in MB.""" decimals = 2 state_mb = round(self._size / 1e6, decimals) return state_mb
[ "def", "state", "(", "self", ")", ":", "decimals", "=", "2", "state_mb", "=", "round", "(", "self", ".", "_size", "/", "1e6", ",", "decimals", ")", "return", "state_mb" ]
[ 66, 4 ]
[ 70, 23 ]
python
en
['en', 'en', 'en']
True
Filesize.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" ]
[ 73, 4 ]
[ 75, 19 ]
python
en
['en', 'en', 'en']
True
Filesize.device_state_attributes
(self)
Return other details about the sensor state.
Return other details about the sensor state.
def device_state_attributes(self): """Return other details about the sensor state.""" return { "path": self._path, "last_updated": self._last_updated, "bytes": self._size, }
[ "def", "device_state_attributes", "(", "self", ")", ":", "return", "{", "\"path\"", ":", "self", ".", "_path", ",", "\"last_updated\"", ":", "self", ".", "_last_updated", ",", "\"bytes\"", ":", "self", ".", "_size", ",", "}" ]
[ 78, 4 ]
[ 84, 9 ]
python
en
['en', 'en', 'en']
True
Filesize.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" ]
[ 87, 4 ]
[ 89, 40 ]
python
en
['en', 'en', 'en']
True
get_service
(hass, config, discovery_info=None)
Get the CiscoWebexTeams notification service.
Get the CiscoWebexTeams notification service.
def get_service(hass, config, discovery_info=None): """Get the CiscoWebexTeams notification service.""" client = WebexTeamsAPI(access_token=config[CONF_TOKEN]) try: # Validate the token & room_id client.rooms.get(config[CONF_ROOM_ID]) except exceptions.ApiError as error: _LOGGER...
[ "def", "get_service", "(", "hass", ",", "config", ",", "discovery_info", "=", "None", ")", ":", "client", "=", "WebexTeamsAPI", "(", "access_token", "=", "config", "[", "CONF_TOKEN", "]", ")", "try", ":", "# Validate the token & room_id", "client", ".", "rooms...
[ 23, 0 ]
[ 34, 75 ]
python
en
['en', 'es', 'en']
True
CiscoWebexTeamsNotificationService.__init__
(self, client, room)
Initialize the service.
Initialize the service.
def __init__(self, client, room): """Initialize the service.""" self.room = room self.client = client
[ "def", "__init__", "(", "self", ",", "client", ",", "room", ")", ":", "self", ".", "room", "=", "room", "self", ".", "client", "=", "client" ]
[ 40, 4 ]
[ 43, 28 ]
python
en
['en', 'en', 'en']
True
CiscoWebexTeamsNotificationService.send_message
(self, message="", **kwargs)
Send a message to a user.
Send a message to a user.
def send_message(self, message="", **kwargs): """Send a message to a user.""" title = "" if kwargs.get(ATTR_TITLE) is not None: title = f"{kwargs.get(ATTR_TITLE)}<br>" try: self.client.messages.create(roomId=self.room, html=f"{title}{message}") except Ap...
[ "def", "send_message", "(", "self", ",", "message", "=", "\"\"", ",", "*", "*", "kwargs", ")", ":", "title", "=", "\"\"", "if", "kwargs", ".", "get", "(", "ATTR_TITLE", ")", "is", "not", "None", ":", "title", "=", "f\"{kwargs.get(ATTR_TITLE)}<br>\"", "tr...
[ 45, 4 ]
[ 57, 13 ]
python
en
['en', 'en', 'en']
True
wsdiscovery
()
Get ONVIF Profile S devices from network.
Get ONVIF Profile S devices from network.
def wsdiscovery() -> List[Service]: """Get ONVIF Profile S devices from network.""" discovery = WSDiscovery(ttl=4) discovery.start() services = discovery.searchServices( scopes=[Scope("onvif://www.onvif.org/Profile/Streaming")] ) discovery.stop() return services
[ "def", "wsdiscovery", "(", ")", "->", "List", "[", "Service", "]", ":", "discovery", "=", "WSDiscovery", "(", "ttl", "=", "4", ")", "discovery", ".", "start", "(", ")", "services", "=", "discovery", ".", "searchServices", "(", "scopes", "=", "[", "Scop...
[ 38, 0 ]
[ 46, 19 ]
python
en
['en', 'en', 'en']
True
async_discovery
(hass)
Return if there are devices that can be discovered.
Return if there are devices that can be discovered.
async def async_discovery(hass) -> bool: """Return if there are devices that can be discovered.""" LOGGER.debug("Starting ONVIF discovery...") services = await hass.async_add_executor_job(wsdiscovery) devices = [] for service in services: url = urlparse(service.getXAddrs()[0]) devic...
[ "async", "def", "async_discovery", "(", "hass", ")", "->", "bool", ":", "LOGGER", ".", "debug", "(", "\"Starting ONVIF discovery...\"", ")", "services", "=", "await", "hass", ".", "async_add_executor_job", "(", "wsdiscovery", ")", "devices", "=", "[", "]", "fo...
[ 49, 0 ]
[ 71, 18 ]
python
en
['en', 'en', 'en']
True
OnvifFlowHandler.async_get_options_flow
(config_entry)
Get the options flow for this handler.
Get the options flow for this handler.
def async_get_options_flow(config_entry): """Get the options flow for this handler.""" return OnvifOptionsFlowHandler(config_entry)
[ "def", "async_get_options_flow", "(", "config_entry", ")", ":", "return", "OnvifOptionsFlowHandler", "(", "config_entry", ")" ]
[ 82, 4 ]
[ 84, 52 ]
python
en
['en', 'en', 'en']
True
OnvifFlowHandler.__init__
(self)
Initialize the ONVIF config flow.
Initialize the ONVIF config flow.
def __init__(self): """Initialize the ONVIF config flow.""" self.device_id = None self.devices = [] self.onvif_config = {}
[ "def", "__init__", "(", "self", ")", ":", "self", ".", "device_id", "=", "None", "self", ".", "devices", "=", "[", "]", "self", ".", "onvif_config", "=", "{", "}" ]
[ 86, 4 ]
[ 90, 30 ]
python
en
['en', 'en', 'en']
True
OnvifFlowHandler.async_step_user
(self, user_input=None)
Handle user flow.
Handle user flow.
async def async_step_user(self, user_input=None): """Handle user flow.""" if user_input is not None: return await self.async_step_device() return self.async_show_form(step_id="user")
[ "async", "def", "async_step_user", "(", "self", ",", "user_input", "=", "None", ")", ":", "if", "user_input", "is", "not", "None", ":", "return", "await", "self", ".", "async_step_device", "(", ")", "return", "self", ".", "async_show_form", "(", "step_id", ...
[ 92, 4 ]
[ 97, 51 ]
python
da
['da', 'nl', 'en']
False
OnvifFlowHandler.async_step_device
(self, user_input=None)
Handle WS-Discovery. Let user choose between discovered devices and manual configuration. If no device is found allow user to manually input configuration.
Handle WS-Discovery.
async def async_step_device(self, user_input=None): """Handle WS-Discovery. Let user choose between discovered devices and manual configuration. If no device is found allow user to manually input configuration. """ if user_input: if CONF_MANUAL_INPUT == user_input[C...
[ "async", "def", "async_step_device", "(", "self", ",", "user_input", "=", "None", ")", ":", "if", "user_input", ":", "if", "CONF_MANUAL_INPUT", "==", "user_input", "[", "CONF_HOST", "]", ":", "return", "await", "self", ".", "async_step_manual_input", "(", ")",...
[ 99, 4 ]
[ 145, 51 ]
python
en
['en', 'en', 'en']
False
OnvifFlowHandler.async_step_manual_input
(self, user_input=None)
Manual configuration.
Manual configuration.
async def async_step_manual_input(self, user_input=None): """Manual configuration.""" if user_input: self.onvif_config = user_input return await self.async_step_auth() return self.async_show_form( step_id="manual_input", data_schema=vol.Schema( ...
[ "async", "def", "async_step_manual_input", "(", "self", ",", "user_input", "=", "None", ")", ":", "if", "user_input", ":", "self", ".", "onvif_config", "=", "user_input", "return", "await", "self", ".", "async_step_auth", "(", ")", "return", "self", ".", "as...
[ 147, 4 ]
[ 162, 9 ]
python
en
['en', 'sm', 'en']
False