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
OneWireProxyEntity.update
(self)
Get the latest data from the device.
Get the latest data from the device.
def update(self): """Get the latest data from the device.""" value = None try: self._value_raw = float(self._read_value_ownet()) except protocol.Error as exc: _LOGGER.error("Owserver failure in read(), got: %s", exc) else: if self._entity_type ...
[ "def", "update", "(", "self", ")", ":", "value", "=", "None", "try", ":", "self", ".", "_value_raw", "=", "float", "(", "self", ".", "_read_value_ownet", "(", ")", ")", "except", "protocol", ".", "Error", "as", "exc", ":", "_LOGGER", ".", "error", "(...
[ 105, 4 ]
[ 124, 27 ]
python
en
['en', 'en', 'en']
True
test_reproducing_states
(hass, caplog)
Test reproducing Water heater states.
Test reproducing Water heater states.
async def test_reproducing_states(hass, caplog): """Test reproducing Water heater states.""" hass.states.async_set("water_heater.entity_off", STATE_OFF, {}) hass.states.async_set("water_heater.entity_on", STATE_ON, {ATTR_TEMPERATURE: 45}) hass.states.async_set("water_heater.entity_away", STATE_ON, {ATTR...
[ "async", "def", "test_reproducing_states", "(", "hass", ",", "caplog", ")", ":", "hass", ".", "states", ".", "async_set", "(", "\"water_heater.entity_off\"", ",", "STATE_OFF", ",", "{", "}", ")", "hass", ".", "states", ".", "async_set", "(", "\"water_heater.en...
[ 17, 0 ]
[ 121, 42 ]
python
en
['da', 'en', 'en']
True
async_setup_entry
(hass, config_entry, async_add_entities)
Set up the Xiaomi light from a config entry.
Set up the Xiaomi light from a config entry.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up the Xiaomi light from a config entry.""" entities = [] if config_entry.data[CONF_FLOW_TYPE] == CONF_GATEWAY: gateway = hass.data[DOMAIN][config_entry.entry_id] # Gateway light if gateway.model not in [ ...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "entities", "=", "[", "]", "if", "config_entry", ".", "data", "[", "CONF_FLOW_TYPE", "]", "==", "CONF_GATEWAY", ":", "gateway", "=", "hass", ".", "dat...
[ 132, 0 ]
[ 148, 56 ]
python
en
['en', 'en', 'en']
True
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Set up the light from config.
Set up the light from config.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the light from config.""" if DATA_KEY not in hass.data: hass.data[DATA_KEY] = {} host = config[CONF_HOST] token = config[CONF_TOKEN] name = config[CONF_NAME] model = config.get(CONF_MODEL) ...
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "if", "DATA_KEY", "not", "in", "hass", ".", "data", ":", "hass", ".", "data", "[", "DATA_KEY", "]", "=", "{", "}"...
[ 151, 0 ]
[ 261, 9 ]
python
en
['en', 'en', 'en']
True
XiaomiPhilipsAbstractLight.__init__
(self, name, light, model, unique_id)
Initialize the light device.
Initialize the light device.
def __init__(self, name, light, model, unique_id): """Initialize the light device.""" self._name = name self._light = light self._model = model self._unique_id = unique_id self._brightness = None self._available = False self._state = None self._s...
[ "def", "__init__", "(", "self", ",", "name", ",", "light", ",", "model", ",", "unique_id", ")", ":", "self", ".", "_name", "=", "name", "self", ".", "_light", "=", "light", "self", ".", "_model", "=", "model", "self", ".", "_unique_id", "=", "unique_...
[ 267, 4 ]
[ 278, 53 ]
python
en
['en', 'en', 'en']
True
XiaomiPhilipsAbstractLight.unique_id
(self)
Return an unique ID.
Return an unique ID.
def unique_id(self): """Return an unique ID.""" return self._unique_id
[ "def", "unique_id", "(", "self", ")", ":", "return", "self", ".", "_unique_id" ]
[ 281, 4 ]
[ 283, 30 ]
python
fr
['fr', 'fr', 'en']
True
XiaomiPhilipsAbstractLight.name
(self)
Return the name of the device if any.
Return the name of the device if any.
def name(self): """Return the name of the device if any.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 286, 4 ]
[ 288, 25 ]
python
en
['en', 'en', 'en']
True
XiaomiPhilipsAbstractLight.available
(self)
Return true when state is known.
Return true when state is known.
def available(self): """Return true when state is known.""" return self._available
[ "def", "available", "(", "self", ")", ":", "return", "self", ".", "_available" ]
[ 291, 4 ]
[ 293, 30 ]
python
en
['en', 'de', 'en']
True
XiaomiPhilipsAbstractLight.device_state_attributes
(self)
Return the state attributes of the device.
Return the state attributes of the device.
def device_state_attributes(self): """Return the state attributes of the device.""" return self._state_attrs
[ "def", "device_state_attributes", "(", "self", ")", ":", "return", "self", ".", "_state_attrs" ]
[ 296, 4 ]
[ 298, 32 ]
python
en
['en', 'en', 'en']
True
XiaomiPhilipsAbstractLight.is_on
(self)
Return true if light is on.
Return true if light is on.
def is_on(self): """Return true if light is on.""" return self._state
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 301, 4 ]
[ 303, 26 ]
python
en
['en', 'et', 'en']
True
XiaomiPhilipsAbstractLight.brightness
(self)
Return the brightness of this light between 0..255.
Return the brightness of this light between 0..255.
def brightness(self): """Return the brightness of this light between 0..255.""" return self._brightness
[ "def", "brightness", "(", "self", ")", ":", "return", "self", ".", "_brightness" ]
[ 306, 4 ]
[ 308, 31 ]
python
en
['en', 'en', 'en']
True
XiaomiPhilipsAbstractLight.supported_features
(self)
Return the supported features.
Return the supported features.
def supported_features(self): """Return the supported features.""" return SUPPORT_BRIGHTNESS
[ "def", "supported_features", "(", "self", ")", ":", "return", "SUPPORT_BRIGHTNESS" ]
[ 311, 4 ]
[ 313, 33 ]
python
en
['en', 'en', 'en']
True
XiaomiPhilipsAbstractLight._try_command
(self, mask_error, func, *args, **kwargs)
Call a light command handling error messages.
Call a light command handling error messages.
async def _try_command(self, mask_error, func, *args, **kwargs): """Call a light command handling error messages.""" try: result = await self.hass.async_add_executor_job( partial(func, *args, **kwargs) ) _LOGGER.debug("Response received from light: %s...
[ "async", "def", "_try_command", "(", "self", ",", "mask_error", ",", "func", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "result", "=", "await", "self", ".", "hass", ".", "async_add_executor_job", "(", "partial", "(", "func", ",", ...
[ 315, 4 ]
[ 330, 24 ]
python
en
['en', 'lb', 'en']
True
XiaomiPhilipsAbstractLight.async_turn_on
(self, **kwargs)
Turn the light on.
Turn the light on.
async def async_turn_on(self, **kwargs): """Turn the light on.""" if ATTR_BRIGHTNESS in kwargs: brightness = kwargs[ATTR_BRIGHTNESS] percent_brightness = ceil(100 * brightness / 255.0) _LOGGER.debug("Setting brightness: %s %s%%", brightness, percent_brightness) ...
[ "async", "def", "async_turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "ATTR_BRIGHTNESS", "in", "kwargs", ":", "brightness", "=", "kwargs", "[", "ATTR_BRIGHTNESS", "]", "percent_brightness", "=", "ceil", "(", "100", "*", "brightness", "/", ...
[ 332, 4 ]
[ 349, 83 ]
python
en
['en', 'et', 'en']
True
XiaomiPhilipsAbstractLight.async_turn_off
(self, **kwargs)
Turn the light off.
Turn the light off.
async def async_turn_off(self, **kwargs): """Turn the light off.""" await self._try_command("Turning the light off failed.", self._light.off)
[ "async", "def", "async_turn_off", "(", "self", ",", "*", "*", "kwargs", ")", ":", "await", "self", ".", "_try_command", "(", "\"Turning the light off failed.\"", ",", "self", ".", "_light", ".", "off", ")" ]
[ 351, 4 ]
[ 353, 81 ]
python
en
['en', 'zh', 'en']
True
XiaomiPhilipsAbstractLight.async_update
(self)
Fetch state from the device.
Fetch state from the device.
async def async_update(self): """Fetch state from the device.""" try: state = await self.hass.async_add_executor_job(self._light.status) except DeviceException as ex: if self._available: self._available = False _LOGGER.error("Got exception ...
[ "async", "def", "async_update", "(", "self", ")", ":", "try", ":", "state", "=", "await", "self", ".", "hass", ".", "async_add_executor_job", "(", "self", ".", "_light", ".", "status", ")", "except", "DeviceException", "as", "ex", ":", "if", "self", ".",...
[ 355, 4 ]
[ 369, 65 ]
python
en
['en', 'en', 'en']
True
XiaomiPhilipsGenericLight.__init__
(self, name, light, model, unique_id)
Initialize the light device.
Initialize the light device.
def __init__(self, name, light, model, unique_id): """Initialize the light device.""" super().__init__(name, light, model, unique_id) self._state_attrs.update({ATTR_SCENE: None, ATTR_DELAYED_TURN_OFF: None})
[ "def", "__init__", "(", "self", ",", "name", ",", "light", ",", "model", ",", "unique_id", ")", ":", "super", "(", ")", ".", "__init__", "(", "name", ",", "light", ",", "model", ",", "unique_id", ")", "self", ".", "_state_attrs", ".", "update", "(", ...
[ 375, 4 ]
[ 379, 81 ]
python
en
['en', 'en', 'en']
True
XiaomiPhilipsGenericLight.async_update
(self)
Fetch state from the device.
Fetch state from the device.
async def async_update(self): """Fetch state from the device.""" try: state = await self.hass.async_add_executor_job(self._light.status) except DeviceException as ex: if self._available: self._available = False _LOGGER.error("Got exception ...
[ "async", "def", "async_update", "(", "self", ")", ":", "try", ":", "state", "=", "await", "self", ".", "hass", ".", "async_add_executor_job", "(", "self", ".", "_light", ".", "status", ")", "except", "DeviceException", "as", "ex", ":", "if", "self", ".",...
[ 381, 4 ]
[ 405, 9 ]
python
en
['en', 'en', 'en']
True
XiaomiPhilipsGenericLight.async_set_scene
(self, scene: int = 1)
Set the fixed scene.
Set the fixed scene.
async def async_set_scene(self, scene: int = 1): """Set the fixed scene.""" await self._try_command( "Setting a fixed scene failed.", self._light.set_scene, scene )
[ "async", "def", "async_set_scene", "(", "self", ",", "scene", ":", "int", "=", "1", ")", ":", "await", "self", ".", "_try_command", "(", "\"Setting a fixed scene failed.\"", ",", "self", ".", "_light", ".", "set_scene", ",", "scene", ")" ]
[ 407, 4 ]
[ 411, 9 ]
python
en
['en', 'sr', 'en']
True
XiaomiPhilipsGenericLight.async_set_delayed_turn_off
(self, time_period: timedelta)
Set delayed turn off.
Set delayed turn off.
async def async_set_delayed_turn_off(self, time_period: timedelta): """Set delayed turn off.""" await self._try_command( "Setting the turn off delay failed.", self._light.delay_off, time_period.total_seconds(), )
[ "async", "def", "async_set_delayed_turn_off", "(", "self", ",", "time_period", ":", "timedelta", ")", ":", "await", "self", ".", "_try_command", "(", "\"Setting the turn off delay failed.\"", ",", "self", ".", "_light", ".", "delay_off", ",", "time_period", ".", "...
[ 413, 4 ]
[ 419, 9 ]
python
en
['en', 'da', 'en']
True
XiaomiPhilipsGenericLight.delayed_turn_off_timestamp
( countdown: int, current: datetime, previous: datetime )
Update the turn off timestamp only if necessary.
Update the turn off timestamp only if necessary.
def delayed_turn_off_timestamp( countdown: int, current: datetime, previous: datetime ): """Update the turn off timestamp only if necessary.""" if countdown is not None and countdown > 0: new = current.replace(microsecond=0) + timedelta(seconds=countdown) if previous...
[ "def", "delayed_turn_off_timestamp", "(", "countdown", ":", "int", ",", "current", ":", "datetime", ",", "previous", ":", "datetime", ")", ":", "if", "countdown", "is", "not", "None", "and", "countdown", ">", "0", ":", "new", "=", "current", ".", "replace"...
[ 422, 4 ]
[ 440, 19 ]
python
en
['en', 'en', 'en']
True
XiaomiPhilipsBulb.__init__
(self, name, light, model, unique_id)
Initialize the light device.
Initialize the light device.
def __init__(self, name, light, model, unique_id): """Initialize the light device.""" super().__init__(name, light, model, unique_id) self._color_temp = None
[ "def", "__init__", "(", "self", ",", "name", ",", "light", ",", "model", ",", "unique_id", ")", ":", "super", "(", ")", ".", "__init__", "(", "name", ",", "light", ",", "model", ",", "unique_id", ")", "self", ".", "_color_temp", "=", "None" ]
[ 446, 4 ]
[ 450, 31 ]
python
en
['en', 'en', 'en']
True
XiaomiPhilipsBulb.color_temp
(self)
Return the color temperature.
Return the color temperature.
def color_temp(self): """Return the color temperature.""" return self._color_temp
[ "def", "color_temp", "(", "self", ")", ":", "return", "self", ".", "_color_temp" ]
[ 453, 4 ]
[ 455, 31 ]
python
en
['en', 'la', 'en']
True
XiaomiPhilipsBulb.min_mireds
(self)
Return the coldest color_temp that this light supports.
Return the coldest color_temp that this light supports.
def min_mireds(self): """Return the coldest color_temp that this light supports.""" return 175
[ "def", "min_mireds", "(", "self", ")", ":", "return", "175" ]
[ 458, 4 ]
[ 460, 18 ]
python
en
['en', 'en', 'en']
True
XiaomiPhilipsBulb.max_mireds
(self)
Return the warmest color_temp that this light supports.
Return the warmest color_temp that this light supports.
def max_mireds(self): """Return the warmest color_temp that this light supports.""" return 333
[ "def", "max_mireds", "(", "self", ")", ":", "return", "333" ]
[ 463, 4 ]
[ 465, 18 ]
python
en
['en', 'en', 'en']
True
XiaomiPhilipsBulb.supported_features
(self)
Return the supported features.
Return the supported features.
def supported_features(self): """Return the supported features.""" return SUPPORT_BRIGHTNESS | SUPPORT_COLOR_TEMP
[ "def", "supported_features", "(", "self", ")", ":", "return", "SUPPORT_BRIGHTNESS", "|", "SUPPORT_COLOR_TEMP" ]
[ 468, 4 ]
[ 470, 54 ]
python
en
['en', 'en', 'en']
True
XiaomiPhilipsBulb.async_turn_on
(self, **kwargs)
Turn the light on.
Turn the light on.
async def async_turn_on(self, **kwargs): """Turn the light on.""" if ATTR_COLOR_TEMP in kwargs: color_temp = kwargs[ATTR_COLOR_TEMP] percent_color_temp = self.translate( color_temp, self.max_mireds, self.min_mireds, CCT_MIN, CCT_MAX ) if ATTR_...
[ "async", "def", "async_turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "ATTR_COLOR_TEMP", "in", "kwargs", ":", "color_temp", "=", "kwargs", "[", "ATTR_COLOR_TEMP", "]", "percent_color_temp", "=", "self", ".", "translate", "(", "color_temp", "...
[ 472, 4 ]
[ 537, 83 ]
python
en
['en', 'et', 'en']
True
XiaomiPhilipsBulb.async_update
(self)
Fetch state from the device.
Fetch state from the device.
async def async_update(self): """Fetch state from the device.""" try: state = await self.hass.async_add_executor_job(self._light.status) except DeviceException as ex: if self._available: self._available = False _LOGGER.error("Got exception ...
[ "async", "def", "async_update", "(", "self", ")", ":", "try", ":", "state", "=", "await", "self", ".", "hass", ".", "async_add_executor_job", "(", "self", ".", "_light", ".", "status", ")", "except", "DeviceException", "as", "ex", ":", "if", "self", ".",...
[ 539, 4 ]
[ 566, 9 ]
python
en
['en', 'en', 'en']
True
XiaomiPhilipsBulb.translate
(value, left_min, left_max, right_min, right_max)
Map a value from left span to right span.
Map a value from left span to right span.
def translate(value, left_min, left_max, right_min, right_max): """Map a value from left span to right span.""" left_span = left_max - left_min right_span = right_max - right_min value_scaled = float(value - left_min) / float(left_span) return int(right_min + (value_scaled * righ...
[ "def", "translate", "(", "value", ",", "left_min", ",", "left_max", ",", "right_min", ",", "right_max", ")", ":", "left_span", "=", "left_max", "-", "left_min", "right_span", "=", "right_max", "-", "right_min", "value_scaled", "=", "float", "(", "value", "-"...
[ 569, 4 ]
[ 574, 59 ]
python
en
['en', 'en', 'en']
True
XiaomiPhilipsCeilingLamp.__init__
(self, name, light, model, unique_id)
Initialize the light device.
Initialize the light device.
def __init__(self, name, light, model, unique_id): """Initialize the light device.""" super().__init__(name, light, model, unique_id) self._state_attrs.update( {ATTR_NIGHT_LIGHT_MODE: None, ATTR_AUTOMATIC_COLOR_TEMPERATURE: None} )
[ "def", "__init__", "(", "self", ",", "name", ",", "light", ",", "model", ",", "unique_id", ")", ":", "super", "(", ")", ".", "__init__", "(", "name", ",", "light", ",", "model", ",", "unique_id", ")", "self", ".", "_state_attrs", ".", "update", "(", ...
[ 580, 4 ]
[ 586, 9 ]
python
en
['en', 'en', 'en']
True
XiaomiPhilipsCeilingLamp.min_mireds
(self)
Return the coldest color_temp that this light supports.
Return the coldest color_temp that this light supports.
def min_mireds(self): """Return the coldest color_temp that this light supports.""" return 175
[ "def", "min_mireds", "(", "self", ")", ":", "return", "175" ]
[ 589, 4 ]
[ 591, 18 ]
python
en
['en', 'en', 'en']
True
XiaomiPhilipsCeilingLamp.max_mireds
(self)
Return the warmest color_temp that this light supports.
Return the warmest color_temp that this light supports.
def max_mireds(self): """Return the warmest color_temp that this light supports.""" return 370
[ "def", "max_mireds", "(", "self", ")", ":", "return", "370" ]
[ 594, 4 ]
[ 596, 18 ]
python
en
['en', 'en', 'en']
True
XiaomiPhilipsCeilingLamp.async_update
(self)
Fetch state from the device.
Fetch state from the device.
async def async_update(self): """Fetch state from the device.""" try: state = await self.hass.async_add_executor_job(self._light.status) except DeviceException as ex: if self._available: self._available = False _LOGGER.error("Got exception ...
[ "async", "def", "async_update", "(", "self", ")", ":", "try", ":", "state", "=", "await", "self", ".", "hass", ".", "async_add_executor_job", "(", "self", ".", "_light", ".", "status", ")", "except", "DeviceException", "as", "ex", ":", "if", "self", ".",...
[ 598, 4 ]
[ 630, 9 ]
python
en
['en', 'en', 'en']
True
XiaomiPhilipsEyecareLamp.__init__
(self, name, light, model, unique_id)
Initialize the light device.
Initialize the light device.
def __init__(self, name, light, model, unique_id): """Initialize the light device.""" super().__init__(name, light, model, unique_id) self._state_attrs.update( {ATTR_REMINDER: None, ATTR_NIGHT_LIGHT_MODE: None, ATTR_EYECARE_MODE: None} )
[ "def", "__init__", "(", "self", ",", "name", ",", "light", ",", "model", ",", "unique_id", ")", ":", "super", "(", ")", ".", "__init__", "(", "name", ",", "light", ",", "model", ",", "unique_id", ")", "self", ".", "_state_attrs", ".", "update", "(", ...
[ 636, 4 ]
[ 642, 9 ]
python
en
['en', 'en', 'en']
True
XiaomiPhilipsEyecareLamp.async_update
(self)
Fetch state from the device.
Fetch state from the device.
async def async_update(self): """Fetch state from the device.""" try: state = await self.hass.async_add_executor_job(self._light.status) except DeviceException as ex: if self._available: self._available = False _LOGGER.error("Got exception ...
[ "async", "def", "async_update", "(", "self", ")", ":", "try", ":", "state", "=", "await", "self", ".", "hass", ".", "async_add_executor_job", "(", "self", ".", "_light", ".", "status", ")", "except", "DeviceException", "as", "ex", ":", "if", "self", ".",...
[ 644, 4 ]
[ 674, 9 ]
python
en
['en', 'en', 'en']
True
XiaomiPhilipsEyecareLamp.async_set_delayed_turn_off
(self, time_period: timedelta)
Set delayed turn off.
Set delayed turn off.
async def async_set_delayed_turn_off(self, time_period: timedelta): """Set delayed turn off.""" await self._try_command( "Setting the turn off delay failed.", self._light.delay_off, round(time_period.total_seconds() / 60), )
[ "async", "def", "async_set_delayed_turn_off", "(", "self", ",", "time_period", ":", "timedelta", ")", ":", "await", "self", ".", "_try_command", "(", "\"Setting the turn off delay failed.\"", ",", "self", ".", "_light", ".", "delay_off", ",", "round", "(", "time_p...
[ 676, 4 ]
[ 682, 9 ]
python
en
['en', 'da', 'en']
True
XiaomiPhilipsEyecareLamp.async_reminder_on
(self)
Enable the eye fatigue notification.
Enable the eye fatigue notification.
async def async_reminder_on(self): """Enable the eye fatigue notification.""" await self._try_command( "Turning on the reminder failed.", self._light.reminder_on )
[ "async", "def", "async_reminder_on", "(", "self", ")", ":", "await", "self", ".", "_try_command", "(", "\"Turning on the reminder failed.\"", ",", "self", ".", "_light", ".", "reminder_on", ")" ]
[ 684, 4 ]
[ 688, 9 ]
python
en
['en', 'en', 'en']
True
XiaomiPhilipsEyecareLamp.async_reminder_off
(self)
Disable the eye fatigue notification.
Disable the eye fatigue notification.
async def async_reminder_off(self): """Disable the eye fatigue notification.""" await self._try_command( "Turning off the reminder failed.", self._light.reminder_off )
[ "async", "def", "async_reminder_off", "(", "self", ")", ":", "await", "self", ".", "_try_command", "(", "\"Turning off the reminder failed.\"", ",", "self", ".", "_light", ".", "reminder_off", ")" ]
[ 690, 4 ]
[ 694, 9 ]
python
en
['en', 'gl', 'en']
True
XiaomiPhilipsEyecareLamp.async_night_light_mode_on
(self)
Turn the smart night light mode on.
Turn the smart night light mode on.
async def async_night_light_mode_on(self): """Turn the smart night light mode on.""" await self._try_command( "Turning on the smart night light mode failed.", self._light.smart_night_light_on, )
[ "async", "def", "async_night_light_mode_on", "(", "self", ")", ":", "await", "self", ".", "_try_command", "(", "\"Turning on the smart night light mode failed.\"", ",", "self", ".", "_light", ".", "smart_night_light_on", ",", ")" ]
[ 696, 4 ]
[ 701, 9 ]
python
en
['en', 'zh', 'en']
True
XiaomiPhilipsEyecareLamp.async_night_light_mode_off
(self)
Turn the smart night light mode off.
Turn the smart night light mode off.
async def async_night_light_mode_off(self): """Turn the smart night light mode off.""" await self._try_command( "Turning off the smart night light mode failed.", self._light.smart_night_light_off, )
[ "async", "def", "async_night_light_mode_off", "(", "self", ")", ":", "await", "self", ".", "_try_command", "(", "\"Turning off the smart night light mode failed.\"", ",", "self", ".", "_light", ".", "smart_night_light_off", ",", ")" ]
[ 703, 4 ]
[ 708, 9 ]
python
en
['en', 'ky', 'en']
True
XiaomiPhilipsEyecareLamp.async_eyecare_mode_on
(self)
Turn the eyecare mode on.
Turn the eyecare mode on.
async def async_eyecare_mode_on(self): """Turn the eyecare mode on.""" await self._try_command( "Turning on the eyecare mode failed.", self._light.eyecare_on )
[ "async", "def", "async_eyecare_mode_on", "(", "self", ")", ":", "await", "self", ".", "_try_command", "(", "\"Turning on the eyecare mode failed.\"", ",", "self", ".", "_light", ".", "eyecare_on", ")" ]
[ 710, 4 ]
[ 714, 9 ]
python
en
['en', 'en', 'en']
True
XiaomiPhilipsEyecareLamp.async_eyecare_mode_off
(self)
Turn the eyecare mode off.
Turn the eyecare mode off.
async def async_eyecare_mode_off(self): """Turn the eyecare mode off.""" await self._try_command( "Turning off the eyecare mode failed.", self._light.eyecare_off )
[ "async", "def", "async_eyecare_mode_off", "(", "self", ")", ":", "await", "self", ".", "_try_command", "(", "\"Turning off the eyecare mode failed.\"", ",", "self", ".", "_light", ".", "eyecare_off", ")" ]
[ 716, 4 ]
[ 720, 9 ]
python
en
['en', 'en', 'en']
True
XiaomiPhilipsEyecareLamp.delayed_turn_off_timestamp
( countdown: int, current: datetime, previous: datetime )
Update the turn off timestamp only if necessary.
Update the turn off timestamp only if necessary.
def delayed_turn_off_timestamp( countdown: int, current: datetime, previous: datetime ): """Update the turn off timestamp only if necessary.""" if countdown is not None and countdown > 0: new = current.replace(second=0, microsecond=0) + timedelta( minutes=countdow...
[ "def", "delayed_turn_off_timestamp", "(", "countdown", ":", "int", ",", "current", ":", "datetime", ",", "previous", ":", "datetime", ")", ":", "if", "countdown", "is", "not", "None", "and", "countdown", ">", "0", ":", "new", "=", "current", ".", "replace"...
[ 723, 4 ]
[ 743, 19 ]
python
en
['en', 'en', 'en']
True
XiaomiPhilipsEyecareLampAmbientLight.__init__
(self, name, light, model, unique_id)
Initialize the light device.
Initialize the light device.
def __init__(self, name, light, model, unique_id): """Initialize the light device.""" name = f"{name} Ambient Light" if unique_id is not None: unique_id = f"{unique_id}-ambient" super().__init__(name, light, model, unique_id)
[ "def", "__init__", "(", "self", ",", "name", ",", "light", ",", "model", ",", "unique_id", ")", ":", "name", "=", "f\"{name} Ambient Light\"", "if", "unique_id", "is", "not", "None", ":", "unique_id", "=", "f\"{unique_id}-ambient\"", "super", "(", ")", ".", ...
[ 749, 4 ]
[ 754, 55 ]
python
en
['en', 'en', 'en']
True
XiaomiPhilipsEyecareLampAmbientLight.async_turn_on
(self, **kwargs)
Turn the light on.
Turn the light on.
async def async_turn_on(self, **kwargs): """Turn the light on.""" if ATTR_BRIGHTNESS in kwargs: brightness = kwargs[ATTR_BRIGHTNESS] percent_brightness = ceil(100 * brightness / 255.0) _LOGGER.debug( "Setting brightness of the ambient light: %s %s%%",...
[ "async", "def", "async_turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "ATTR_BRIGHTNESS", "in", "kwargs", ":", "brightness", "=", "kwargs", "[", "ATTR_BRIGHTNESS", "]", "percent_brightness", "=", "ceil", "(", "100", "*", "brightness", "/", ...
[ 756, 4 ]
[ 779, 13 ]
python
en
['en', 'et', 'en']
True
XiaomiPhilipsEyecareLampAmbientLight.async_turn_off
(self, **kwargs)
Turn the light off.
Turn the light off.
async def async_turn_off(self, **kwargs): """Turn the light off.""" await self._try_command( "Turning the ambient light off failed.", self._light.ambient_off )
[ "async", "def", "async_turn_off", "(", "self", ",", "*", "*", "kwargs", ")", ":", "await", "self", ".", "_try_command", "(", "\"Turning the ambient light off failed.\"", ",", "self", ".", "_light", ".", "ambient_off", ")" ]
[ 781, 4 ]
[ 785, 9 ]
python
en
['en', 'zh', 'en']
True
XiaomiPhilipsEyecareLampAmbientLight.async_update
(self)
Fetch state from the device.
Fetch state from the device.
async def async_update(self): """Fetch state from the device.""" try: state = await self.hass.async_add_executor_job(self._light.status) except DeviceException as ex: if self._available: self._available = False _LOGGER.error("Got exception ...
[ "async", "def", "async_update", "(", "self", ")", ":", "try", ":", "state", "=", "await", "self", ".", "hass", ".", "async_add_executor_job", "(", "self", ".", "_light", ".", "status", ")", "except", "DeviceException", "as", "ex", ":", "if", "self", ".",...
[ 787, 4 ]
[ 801, 73 ]
python
en
['en', 'en', 'en']
True
XiaomiPhilipsMoonlightLamp.__init__
(self, name, light, model, unique_id)
Initialize the light device.
Initialize the light device.
def __init__(self, name, light, model, unique_id): """Initialize the light device.""" super().__init__(name, light, model, unique_id) self._hs_color = None self._state_attrs.pop(ATTR_DELAYED_TURN_OFF) self._state_attrs.update( { ATTR_SLEEP_ASSISTANT: ...
[ "def", "__init__", "(", "self", ",", "name", ",", "light", ",", "model", ",", "unique_id", ")", ":", "super", "(", ")", ".", "__init__", "(", "name", ",", "light", ",", "model", ",", "unique_id", ")", "self", ".", "_hs_color", "=", "None", "self", ...
[ 807, 4 ]
[ 821, 9 ]
python
en
['en', 'en', 'en']
True
XiaomiPhilipsMoonlightLamp.min_mireds
(self)
Return the coldest color_temp that this light supports.
Return the coldest color_temp that this light supports.
def min_mireds(self): """Return the coldest color_temp that this light supports.""" return 153
[ "def", "min_mireds", "(", "self", ")", ":", "return", "153" ]
[ 824, 4 ]
[ 826, 18 ]
python
en
['en', 'en', 'en']
True
XiaomiPhilipsMoonlightLamp.max_mireds
(self)
Return the warmest color_temp that this light supports.
Return the warmest color_temp that this light supports.
def max_mireds(self): """Return the warmest color_temp that this light supports.""" return 588
[ "def", "max_mireds", "(", "self", ")", ":", "return", "588" ]
[ 829, 4 ]
[ 831, 18 ]
python
en
['en', 'en', 'en']
True
XiaomiPhilipsMoonlightLamp.hs_color
(self)
Return the hs color value.
Return the hs color value.
def hs_color(self) -> tuple: """Return the hs color value.""" return self._hs_color
[ "def", "hs_color", "(", "self", ")", "->", "tuple", ":", "return", "self", ".", "_hs_color" ]
[ 834, 4 ]
[ 836, 29 ]
python
en
['en', 'en', 'en']
True
XiaomiPhilipsMoonlightLamp.supported_features
(self)
Return the supported features.
Return the supported features.
def supported_features(self): """Return the supported features.""" return SUPPORT_BRIGHTNESS | SUPPORT_COLOR | SUPPORT_COLOR_TEMP
[ "def", "supported_features", "(", "self", ")", ":", "return", "SUPPORT_BRIGHTNESS", "|", "SUPPORT_COLOR", "|", "SUPPORT_COLOR_TEMP" ]
[ 839, 4 ]
[ 841, 70 ]
python
en
['en', 'en', 'en']
True
XiaomiPhilipsMoonlightLamp.async_turn_on
(self, **kwargs)
Turn the light on.
Turn the light on.
async def async_turn_on(self, **kwargs): """Turn the light on.""" if ATTR_COLOR_TEMP in kwargs: color_temp = kwargs[ATTR_COLOR_TEMP] percent_color_temp = self.translate( color_temp, self.max_mireds, self.min_mireds, CCT_MIN, CCT_MAX ) if ATTR_...
[ "async", "def", "async_turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "ATTR_COLOR_TEMP", "in", "kwargs", ":", "color_temp", "=", "kwargs", "[", "ATTR_COLOR_TEMP", "]", "percent_color_temp", "=", "self", ".", "translate", "(", "color_temp", "...
[ 843, 4 ]
[ 941, 83 ]
python
en
['en', 'et', 'en']
True
XiaomiPhilipsMoonlightLamp.async_update
(self)
Fetch state from the device.
Fetch state from the device.
async def async_update(self): """Fetch state from the device.""" try: state = await self.hass.async_add_executor_job(self._light.status) except DeviceException as ex: if self._available: self._available = False _LOGGER.error("Got exception ...
[ "async", "def", "async_update", "(", "self", ")", ":", "try", ":", "state", "=", "await", "self", ".", "hass", ".", "async_add_executor_job", "(", "self", ".", "_light", ".", "status", ")", "except", "DeviceException", "as", "ex", ":", "if", "self", ".",...
[ 943, 4 ]
[ 972, 9 ]
python
en
['en', 'en', 'en']
True
XiaomiPhilipsMoonlightLamp.async_set_delayed_turn_off
(self, time_period: timedelta)
Set delayed turn off. Unsupported.
Set delayed turn off. Unsupported.
async def async_set_delayed_turn_off(self, time_period: timedelta): """Set delayed turn off. Unsupported.""" return
[ "async", "def", "async_set_delayed_turn_off", "(", "self", ",", "time_period", ":", "timedelta", ")", ":", "return" ]
[ 974, 4 ]
[ 976, 14 ]
python
en
['en', 'en', 'en']
True
XiaomiGatewayLight.__init__
(self, gateway_device, gateway_name, gateway_device_id)
Initialize the XiaomiGatewayLight.
Initialize the XiaomiGatewayLight.
def __init__(self, gateway_device, gateway_name, gateway_device_id): """Initialize the XiaomiGatewayLight.""" self._gateway = gateway_device self._name = f"{gateway_name} Light" self._gateway_device_id = gateway_device_id self._unique_id = gateway_device_id self._availabl...
[ "def", "__init__", "(", "self", ",", "gateway_device", ",", "gateway_name", ",", "gateway_device_id", ")", ":", "self", ".", "_gateway", "=", "gateway_device", "self", ".", "_name", "=", "f\"{gateway_name} Light\"", "self", ".", "_gateway_device_id", "=", "gateway...
[ 982, 4 ]
[ 992, 25 ]
python
en
['en', 'pl', 'en']
True
XiaomiGatewayLight.unique_id
(self)
Return an unique ID.
Return an unique ID.
def unique_id(self): """Return an unique ID.""" return self._unique_id
[ "def", "unique_id", "(", "self", ")", ":", "return", "self", ".", "_unique_id" ]
[ 995, 4 ]
[ 997, 30 ]
python
fr
['fr', 'fr', 'en']
True
XiaomiGatewayLight.device_info
(self)
Return the device info of the gateway.
Return the device info of the gateway.
def device_info(self): """Return the device info of the gateway.""" return { "identifiers": {(DOMAIN, self._gateway_device_id)}, }
[ "def", "device_info", "(", "self", ")", ":", "return", "{", "\"identifiers\"", ":", "{", "(", "DOMAIN", ",", "self", ".", "_gateway_device_id", ")", "}", ",", "}" ]
[ 1000, 4 ]
[ 1004, 9 ]
python
en
['en', 'en', 'en']
True
XiaomiGatewayLight.name
(self)
Return the name of this entity, if any.
Return the name of this entity, if any.
def name(self): """Return the name of this entity, if any.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 1007, 4 ]
[ 1009, 25 ]
python
en
['en', 'en', 'en']
True
XiaomiGatewayLight.available
(self)
Return true when state is known.
Return true when state is known.
def available(self): """Return true when state is known.""" return self._available
[ "def", "available", "(", "self", ")", ":", "return", "self", ".", "_available" ]
[ 1012, 4 ]
[ 1014, 30 ]
python
en
['en', 'de', 'en']
True
XiaomiGatewayLight.is_on
(self)
Return true if it is on.
Return true if it is on.
def is_on(self): """Return true if it is on.""" return self._is_on
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_is_on" ]
[ 1017, 4 ]
[ 1019, 26 ]
python
en
['en', 'fy', 'en']
True
XiaomiGatewayLight.brightness
(self)
Return the brightness of this light between 0..255.
Return the brightness of this light between 0..255.
def brightness(self): """Return the brightness of this light between 0..255.""" return int(255 * self._brightness_pct / 100)
[ "def", "brightness", "(", "self", ")", ":", "return", "int", "(", "255", "*", "self", ".", "_brightness_pct", "/", "100", ")" ]
[ 1022, 4 ]
[ 1024, 52 ]
python
en
['en', 'en', 'en']
True
XiaomiGatewayLight.hs_color
(self)
Return the hs color value.
Return the hs color value.
def hs_color(self): """Return the hs color value.""" return self._hs
[ "def", "hs_color", "(", "self", ")", ":", "return", "self", ".", "_hs" ]
[ 1027, 4 ]
[ 1029, 23 ]
python
en
['en', 'en', 'en']
True
XiaomiGatewayLight.supported_features
(self)
Return the supported features.
Return the supported features.
def supported_features(self): """Return the supported features.""" return SUPPORT_BRIGHTNESS | SUPPORT_COLOR
[ "def", "supported_features", "(", "self", ")", ":", "return", "SUPPORT_BRIGHTNESS", "|", "SUPPORT_COLOR" ]
[ 1032, 4 ]
[ 1034, 49 ]
python
en
['en', 'en', 'en']
True
XiaomiGatewayLight.turn_on
(self, **kwargs)
Turn the light on.
Turn the light on.
def turn_on(self, **kwargs): """Turn the light on.""" if ATTR_HS_COLOR in kwargs: rgb = color.color_hs_to_RGB(*kwargs[ATTR_HS_COLOR]) else: rgb = self._rgb if ATTR_BRIGHTNESS in kwargs: brightness_pct = int(100 * kwargs[ATTR_BRIGHTNESS] / 255) ...
[ "def", "turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "ATTR_HS_COLOR", "in", "kwargs", ":", "rgb", "=", "color", ".", "color_hs_to_RGB", "(", "*", "kwargs", "[", "ATTR_HS_COLOR", "]", ")", "else", ":", "rgb", "=", "self", ".", "_rgb...
[ 1036, 4 ]
[ 1050, 39 ]
python
en
['en', 'et', 'en']
True
XiaomiGatewayLight.turn_off
(self, **kwargs)
Turn the light off.
Turn the light off.
def turn_off(self, **kwargs): """Turn the light off.""" self._gateway.light.set_rgb(0, self._rgb) self.schedule_update_ha_state()
[ "def", "turn_off", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_gateway", ".", "light", ".", "set_rgb", "(", "0", ",", "self", ".", "_rgb", ")", "self", ".", "schedule_update_ha_state", "(", ")" ]
[ 1052, 4 ]
[ 1055, 39 ]
python
en
['en', 'zh', 'en']
True
XiaomiGatewayLight.async_update
(self)
Fetch state from the device.
Fetch state from the device.
async def async_update(self): """Fetch state from the device.""" try: state_dict = await self.hass.async_add_executor_job( self._gateway.light.rgb_status ) except GatewayException as ex: if self._available: self._available = Fal...
[ "async", "def", "async_update", "(", "self", ")", ":", "try", ":", "state_dict", "=", "await", "self", ".", "hass", ".", "async_add_executor_job", "(", "self", ".", "_gateway", ".", "light", ".", "rgb_status", ")", "except", "GatewayException", "as", "ex", ...
[ 1057, 4 ]
[ 1077, 56 ]
python
en
['en', 'en', 'en']
True
async_setup
(hass: HomeAssistant, config: ConfigType)
Set up the Toon components.
Set up the Toon components.
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the Toon components.""" if DOMAIN not in config: return True register_oauth2_implementations( hass, config[DOMAIN][CONF_CLIENT_ID], config[DOMAIN][CONF_CLIENT_SECRET] ) hass.async_create_task( ...
[ "async", "def", "async_setup", "(", "hass", ":", "HomeAssistant", ",", "config", ":", "ConfigType", ")", "->", "bool", ":", "if", "DOMAIN", "not", "in", "config", ":", "return", "True", "register_oauth2_implementations", "(", "hass", ",", "config", "[", "DOM...
[ 56, 0 ]
[ 69, 15 ]
python
en
['en', 'en', 'en']
True
async_migrate_entry
(hass: HomeAssistant, entry: ConfigEntry)
Handle migration of a previous version config entry.
Handle migration of a previous version config entry.
async def async_migrate_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Handle migration of a previous version config entry.""" if entry.version == 1: # There is no usable data in version 1 anymore. # The integration switched to OAuth and because of this, uses # different uniq...
[ "async", "def", "async_migrate_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ")", "->", "bool", ":", "if", "entry", ".", "version", "==", "1", ":", "# There is no usable data in version 1 anymore.", "# The integration switched to OAuth and...
[ 72, 0 ]
[ 88, 15 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass: HomeAssistant, entry: ConfigEntry)
Set up Toon from a config entry.
Set up Toon from a config entry.
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Set up Toon from a config entry.""" implementation = await async_get_config_entry_implementation(hass, entry) session = OAuth2Session(hass, entry, implementation) coordinator = ToonDataUpdateCoordinator(hass, entry=entry, ...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ")", "->", "bool", ":", "implementation", "=", "await", "async_get_config_entry_implementation", "(", "hass", ",", "entry", ")", "session", "=", "OAuth2Sessio...
[ 91, 0 ]
[ 135, 15 ]
python
en
['en', 'en', 'en']
True
async_unload_entry
(hass: HomeAssistant, entry: ConfigEntry)
Unload Toon config entry.
Unload Toon config entry.
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Unload Toon config entry.""" # Remove webhooks registration await hass.data[DOMAIN][entry.entry_id].unregister_webhook() # Unload entities for this entry/device. unload_ok = all( await asyncio.gather( ...
[ "async", "def", "async_unload_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ")", "->", "bool", ":", "# Remove webhooks registration", "await", "hass", ".", "data", "[", "DOMAIN", "]", "[", "entry", ".", "entry_id", "]", ".", "u...
[ 138, 0 ]
[ 158, 20 ]
python
en
['nl', 'en', 'en']
True
get_data_update_coordinator
( hass: HomeAssistant, config_entry: ConfigEntry )
Get an update coordinator.
Get an update coordinator.
def get_data_update_coordinator( hass: HomeAssistant, config_entry: ConfigEntry ) -> DeviceDataUpdateCoordinator: """Get an update coordinator.""" hass.data.setdefault(DOMAIN, {}) hass.data[DOMAIN].setdefault(config_entry.entry_id, {}) config_entry_data = hass.data[DOMAIN][config_entry.entry_id] ...
[ "def", "get_data_update_coordinator", "(", "hass", ":", "HomeAssistant", ",", "config_entry", ":", "ConfigEntry", ")", "->", "DeviceDataUpdateCoordinator", ":", "hass", ".", "data", ".", "setdefault", "(", "DOMAIN", ",", "{", "}", ")", "hass", ".", "data", "["...
[ 59, 0 ]
[ 89, 53 ]
python
en
['en', 'lb', 'en']
True
cover_unique_id
(config_entry: ConfigEntry, door: AbstractDoor)
Generate a cover entity unique id.
Generate a cover entity unique id.
def cover_unique_id(config_entry: ConfigEntry, door: AbstractDoor) -> str: """Generate a cover entity unique id.""" return f"{config_entry.unique_id}_{door.door_id}"
[ "def", "cover_unique_id", "(", "config_entry", ":", "ConfigEntry", ",", "door", ":", "AbstractDoor", ")", "->", "str", ":", "return", "f\"{config_entry.unique_id}_{door.door_id}\"" ]
[ 92, 0 ]
[ 94, 53 ]
python
en
['fr', 'it', 'en']
False
get_api
(config_data: dict)
Get an api object for config data.
Get an api object for config data.
def get_api(config_data: dict) -> AbstractGateApi: """Get an api object for config data.""" gate_class = GogoGate2Api if config_data[CONF_DEVICE] == DEVICE_TYPE_ISMARTGATE: gate_class = ISmartGateApi return gate_class( config_data[CONF_IP_ADDRESS], config_data[CONF_USERNAME], ...
[ "def", "get_api", "(", "config_data", ":", "dict", ")", "->", "AbstractGateApi", ":", "gate_class", "=", "GogoGate2Api", "if", "config_data", "[", "CONF_DEVICE", "]", "==", "DEVICE_TYPE_ISMARTGATE", ":", "gate_class", "=", "ISmartGateApi", "return", "gate_class", ...
[ 97, 0 ]
[ 108, 5 ]
python
en
['en', 'en', 'en']
True
DeviceDataUpdateCoordinator.__init__
( self, hass: HomeAssistant, logger: logging.Logger, api: AbstractGateApi, *, name: str, update_interval: timedelta, update_method: Optional[Callable[[], Awaitable]] = None, request_refresh_debouncer: Optional[Debouncer] = None, )
Initialize the data update coordinator.
Initialize the data update coordinator.
def __init__( self, hass: HomeAssistant, logger: logging.Logger, api: AbstractGateApi, *, name: str, update_interval: timedelta, update_method: Optional[Callable[[], Awaitable]] = None, request_refresh_debouncer: Optional[Debouncer] = None, ): ...
[ "def", "__init__", "(", "self", ",", "hass", ":", "HomeAssistant", ",", "logger", ":", "logging", ".", "Logger", ",", "api", ":", "AbstractGateApi", ",", "*", ",", "name", ":", "str", ",", "update_interval", ":", "timedelta", ",", "update_method", ":", "...
[ 35, 4 ]
[ 56, 22 ]
python
en
['en', 'co', 'en']
True
test_default_setup
(hass, monkeypatch)
Test all basic functionality of the rflink sensor component.
Test all basic functionality of the rflink sensor component.
async def test_default_setup(hass, monkeypatch): """Test all basic functionality of the rflink sensor component.""" # setup mocking rflink module event_callback, create, _, _ = await mock_rflink(hass, CONFIG, DOMAIN, monkeypatch) # make sure arguments are passed assert create.call_args_list[0][1]["...
[ "async", "def", "test_default_setup", "(", "hass", ",", "monkeypatch", ")", ":", "# setup mocking rflink module", "event_callback", ",", "create", ",", "_", ",", "_", "=", "await", "mock_rflink", "(", "hass", ",", "CONFIG", ",", "DOMAIN", ",", "monkeypatch", "...
[ 37, 0 ]
[ 70, 61 ]
python
en
['en', 'en', 'en']
True
test_disable_automatic_add
(hass, monkeypatch)
If disabled new devices should not be automatically added.
If disabled new devices should not be automatically added.
async def test_disable_automatic_add(hass, monkeypatch): """If disabled new devices should not be automatically added.""" config = { "rflink": {"port": "/dev/ttyABC0"}, DOMAIN: {"platform": "rflink", "automatic_add": False}, } # setup mocking rflink module event_callback, _, _, _ = ...
[ "async", "def", "test_disable_automatic_add", "(", "hass", ",", "monkeypatch", ")", ":", "config", "=", "{", "\"rflink\"", ":", "{", "\"port\"", ":", "\"/dev/ttyABC0\"", "}", ",", "DOMAIN", ":", "{", "\"platform\"", ":", "\"rflink\"", ",", "\"automatic_add\"", ...
[ 73, 0 ]
[ 90, 46 ]
python
en
['en', 'en', 'en']
True
test_entity_availability
(hass, monkeypatch)
If Rflink device is disconnected, entities should become unavailable.
If Rflink device is disconnected, entities should become unavailable.
async def test_entity_availability(hass, monkeypatch): """If Rflink device is disconnected, entities should become unavailable.""" # Make sure Rflink mock does not 'recover' to quickly from the # disconnect or else the unavailability cannot be measured config = CONFIG failures = [True, True] con...
[ "async", "def", "test_entity_availability", "(", "hass", ",", "monkeypatch", ")", ":", "# Make sure Rflink mock does not 'recover' to quickly from the", "# disconnect or else the unavailability cannot be measured", "config", "=", "CONFIG", "failures", "=", "[", "True", ",", "Tr...
[ 93, 0 ]
[ 125, 64 ]
python
en
['en', 'en', 'en']
True
test_aliases
(hass, monkeypatch)
Validate the response to sensor's alias (with aliases).
Validate the response to sensor's alias (with aliases).
async def test_aliases(hass, monkeypatch): """Validate the response to sensor's alias (with aliases).""" config = { "rflink": {"port": "/dev/ttyABC0"}, DOMAIN: { "platform": "rflink", "devices": { "test_02": { "name": "test_02", ...
[ "async", "def", "test_aliases", "(", "hass", ",", "monkeypatch", ")", ":", "config", "=", "{", "\"rflink\"", ":", "{", "\"port\"", ":", "\"/dev/ttyABC0\"", "}", ",", "DOMAIN", ":", "{", "\"platform\"", ":", "\"rflink\"", ",", "\"devices\"", ":", "{", "\"te...
[ 128, 0 ]
[ 167, 76 ]
python
en
['en', 'lt', 'en']
True
test_race_condition
(hass, monkeypatch)
Test race condition for unknown components.
Test race condition for unknown components.
async def test_race_condition(hass, monkeypatch): """Test race condition for unknown components.""" config = {"rflink": {"port": "/dev/ttyABC0"}, DOMAIN: {"platform": "rflink"}} tmp_entity = TMP_ENTITY.format("test3") # setup mocking rflink module event_callback, _, _, _ = await mock_rflink(hass, c...
[ "async", "def", "test_race_condition", "(", "hass", ",", "monkeypatch", ")", ":", "config", "=", "{", "\"rflink\"", ":", "{", "\"port\"", ":", "\"/dev/ttyABC0\"", "}", ",", "DOMAIN", ":", "{", "\"platform\"", ":", "\"rflink\"", "}", "}", "tmp_entity", "=", ...
[ 170, 0 ]
[ 206, 35 ]
python
en
['en', 'en', 'en']
True
async_setup
(hass: HomeAssistantType, config: ConfigType)
Initialize the SmartThings platform.
Initialize the SmartThings platform.
async def async_setup(hass: HomeAssistantType, config: ConfigType): """Initialize the SmartThings platform.""" await setup_smartapp_endpoint(hass) return True
[ "async", "def", "async_setup", "(", "hass", ":", "HomeAssistantType", ",", "config", ":", "ConfigType", ")", ":", "await", "setup_smartapp_endpoint", "(", "hass", ")", "return", "True" ]
[ 55, 0 ]
[ 58, 15 ]
python
en
['en', 'en', 'en']
True
async_migrate_entry
(hass: HomeAssistantType, entry: ConfigEntry)
Handle migration of a previous version config entry. A config entry created under a previous version must go through the integration setup again so we can properly retrieve the needed data elements. Force this by removing the entry and triggering a new flow.
Handle migration of a previous version config entry.
async def async_migrate_entry(hass: HomeAssistantType, entry: ConfigEntry): """Handle migration of a previous version config entry. A config entry created under a previous version must go through the integration setup again so we can properly retrieve the needed data elements. Force this by removing th...
[ "async", "def", "async_migrate_entry", "(", "hass", ":", "HomeAssistantType", ",", "entry", ":", "ConfigEntry", ")", ":", "# Remove the entry which will invoke the callback to delete the app.", "hass", ".", "async_create_task", "(", "hass", ".", "config_entries", ".", "as...
[ 61, 0 ]
[ 78, 16 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass: HomeAssistantType, entry: ConfigEntry)
Initialize config entry which represents an installed SmartApp.
Initialize config entry which represents an installed SmartApp.
async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry): """Initialize config entry which represents an installed SmartApp.""" # For backwards compat if entry.unique_id is None: hass.config_entries.async_update_entry( entry, unique_id=format_unique_id( ...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistantType", ",", "entry", ":", "ConfigEntry", ")", ":", "# For backwards compat", "if", "entry", ".", "unique_id", "is", "None", ":", "hass", ".", "config_entries", ".", "async_update_entry", "(", "...
[ 81, 0 ]
[ 190, 15 ]
python
en
['en', 'en', 'en']
True
async_get_entry_scenes
(entry: ConfigEntry, api)
Get the scenes within an integration.
Get the scenes within an integration.
async def async_get_entry_scenes(entry: ConfigEntry, api): """Get the scenes within an integration.""" try: return await api.scenes(location_id=entry.data[CONF_LOCATION_ID]) except ClientResponseError as ex: if ex.status == HTTP_FORBIDDEN: _LOGGER.exception( "Unab...
[ "async", "def", "async_get_entry_scenes", "(", "entry", ":", "ConfigEntry", ",", "api", ")", ":", "try", ":", "return", "await", "api", ".", "scenes", "(", "location_id", "=", "entry", ".", "data", "[", "CONF_LOCATION_ID", "]", ")", "except", "ClientResponse...
[ 193, 0 ]
[ 205, 13 ]
python
en
['en', 'en', 'en']
True
async_unload_entry
(hass: HomeAssistantType, entry: ConfigEntry)
Unload a config entry.
Unload a config entry.
async def async_unload_entry(hass: HomeAssistantType, entry: ConfigEntry): """Unload a config entry.""" broker = hass.data[DOMAIN][DATA_BROKERS].pop(entry.entry_id, None) if broker: broker.disconnect() tasks = [ hass.config_entries.async_forward_entry_unload(entry, component) fo...
[ "async", "def", "async_unload_entry", "(", "hass", ":", "HomeAssistantType", ",", "entry", ":", "ConfigEntry", ")", ":", "broker", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "DATA_BROKERS", "]", ".", "pop", "(", "entry", ".", "entry_id", ",", "No...
[ 208, 0 ]
[ 218, 44 ]
python
en
['en', 'es', 'en']
True
async_remove_entry
(hass: HomeAssistantType, entry: ConfigEntry)
Perform clean-up when entry is being removed.
Perform clean-up when entry is being removed.
async def async_remove_entry(hass: HomeAssistantType, entry: ConfigEntry) -> None: """Perform clean-up when entry is being removed.""" api = SmartThings(async_get_clientsession(hass), entry.data[CONF_ACCESS_TOKEN]) # Remove the installed_app, which if already removed raises a HTTP_FORBIDDEN error. inst...
[ "async", "def", "async_remove_entry", "(", "hass", ":", "HomeAssistantType", ",", "entry", ":", "ConfigEntry", ")", "->", "None", ":", "api", "=", "SmartThings", "(", "async_get_clientsession", "(", "hass", ")", ",", "entry", ".", "data", "[", "CONF_ACCESS_TOK...
[ 221, 0 ]
[ 262, 44 ]
python
en
['en', 'en', 'en']
True
DeviceBroker.__init__
( self, hass: HomeAssistantType, entry: ConfigEntry, token, smart_app, devices: Iterable, scenes: Iterable, )
Create a new instance of the DeviceBroker.
Create a new instance of the DeviceBroker.
def __init__( self, hass: HomeAssistantType, entry: ConfigEntry, token, smart_app, devices: Iterable, scenes: Iterable, ): """Create a new instance of the DeviceBroker.""" self._hass = hass self._entry = entry self._installed_ap...
[ "def", "__init__", "(", "self", ",", "hass", ":", "HomeAssistantType", ",", "entry", ":", "ConfigEntry", ",", "token", ",", "smart_app", ",", "devices", ":", "Iterable", ",", "scenes", ":", "Iterable", ",", ")", ":", "self", ".", "_hass", "=", "hass", ...
[ 268, 4 ]
[ 287, 65 ]
python
en
['en', 'en', 'en']
True
DeviceBroker._assign_capabilities
(self, devices: Iterable)
Assign platforms to capabilities.
Assign platforms to capabilities.
def _assign_capabilities(self, devices: Iterable): """Assign platforms to capabilities.""" assignments = {} for device in devices: capabilities = device.capabilities.copy() slots = {} for platform_name in SUPPORTED_PLATFORMS: platform = importl...
[ "def", "_assign_capabilities", "(", "self", ",", "devices", ":", "Iterable", ")", ":", "assignments", "=", "{", "}", "for", "device", "in", "devices", ":", "capabilities", "=", "device", ".", "capabilities", ".", "copy", "(", ")", "slots", "=", "{", "}",...
[ 289, 4 ]
[ 309, 26 ]
python
en
['en', 'en', 'en']
True
DeviceBroker.connect
(self)
Connect handlers/listeners for device/lifecycle events.
Connect handlers/listeners for device/lifecycle events.
def connect(self): """Connect handlers/listeners for device/lifecycle events.""" # Setup interval to regenerate the refresh token on a periodic basis. # Tokens expire in 30 days and once expired, cannot be recovered. async def regenerate_refresh_token(now): """Generate a new ...
[ "def", "connect", "(", "self", ")", ":", "# Setup interval to regenerate the refresh token on a periodic basis.", "# Tokens expire in 30 days and once expired, cannot be recovered.", "async", "def", "regenerate_refresh_token", "(", "now", ")", ":", "\"\"\"Generate a new refresh token a...
[ 311, 4 ]
[ 338, 83 ]
python
en
['da', 'en', 'en']
True
DeviceBroker.disconnect
(self)
Disconnects handlers/listeners for device/lifecycle events.
Disconnects handlers/listeners for device/lifecycle events.
def disconnect(self): """Disconnects handlers/listeners for device/lifecycle events.""" if self._regenerate_token_remove: self._regenerate_token_remove() if self._event_disconnect: self._event_disconnect()
[ "def", "disconnect", "(", "self", ")", ":", "if", "self", ".", "_regenerate_token_remove", ":", "self", ".", "_regenerate_token_remove", "(", ")", "if", "self", ".", "_event_disconnect", ":", "self", ".", "_event_disconnect", "(", ")" ]
[ 340, 4 ]
[ 345, 36 ]
python
en
['da', 'en', 'en']
True
DeviceBroker.get_assigned
(self, device_id: str, platform: str)
Get the capabilities assigned to the platform.
Get the capabilities assigned to the platform.
def get_assigned(self, device_id: str, platform: str): """Get the capabilities assigned to the platform.""" slots = self._assignments.get(device_id, {}) return [key for key, value in slots.items() if value == platform]
[ "def", "get_assigned", "(", "self", ",", "device_id", ":", "str", ",", "platform", ":", "str", ")", ":", "slots", "=", "self", ".", "_assignments", ".", "get", "(", "device_id", ",", "{", "}", ")", "return", "[", "key", "for", "key", ",", "value", ...
[ 347, 4 ]
[ 350, 73 ]
python
en
['en', 'en', 'en']
True
DeviceBroker.any_assigned
(self, device_id: str, platform: str)
Return True if the platform has any assigned capabilities.
Return True if the platform has any assigned capabilities.
def any_assigned(self, device_id: str, platform: str): """Return True if the platform has any assigned capabilities.""" slots = self._assignments.get(device_id, {}) return any(value for value in slots.values() if value == platform)
[ "def", "any_assigned", "(", "self", ",", "device_id", ":", "str", ",", "platform", ":", "str", ")", ":", "slots", "=", "self", ".", "_assignments", ".", "get", "(", "device_id", ",", "{", "}", ")", "return", "any", "(", "value", "for", "value", "in",...
[ 352, 4 ]
[ 355, 74 ]
python
en
['en', 'en', 'en']
True
DeviceBroker._event_handler
(self, req, resp, app)
Broker for incoming events.
Broker for incoming events.
async def _event_handler(self, req, resp, app): """Broker for incoming events.""" # Do not process events received from a different installed app # under the same parent SmartApp (valid use-scenario) if req.installed_app_id != self._installed_app_id: return updated_d...
[ "async", "def", "_event_handler", "(", "self", ",", "req", ",", "resp", ",", "app", ")", ":", "# Do not process events received from a different installed app", "# under the same parent SmartApp (valid use-scenario)", "if", "req", ".", "installed_app_id", "!=", "self", ".",...
[ 357, 4 ]
[ 408, 85 ]
python
en
['da', 'en', 'en']
True
SmartThingsEntity.__init__
(self, device)
Initialize the instance.
Initialize the instance.
def __init__(self, device): """Initialize the instance.""" self._device = device self._dispatcher_remove = None
[ "def", "__init__", "(", "self", ",", "device", ")", ":", "self", ".", "_device", "=", "device", "self", ".", "_dispatcher_remove", "=", "None" ]
[ 414, 4 ]
[ 417, 38 ]
python
en
['en', 'en', 'en']
True
SmartThingsEntity.async_added_to_hass
(self)
Device added to hass.
Device added to hass.
async def async_added_to_hass(self): """Device added to hass.""" async def async_update_state(devices): """Update device state.""" if self._device.device_id in devices: await self.async_update_ha_state(True) self._dispatcher_remove = async_dispatcher_con...
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "async", "def", "async_update_state", "(", "devices", ")", ":", "\"\"\"Update device state.\"\"\"", "if", "self", ".", "_device", ".", "device_id", "in", "devices", ":", "await", "self", ".", "async_u...
[ 419, 4 ]
[ 429, 9 ]
python
en
['en', 'en', 'en']
True
SmartThingsEntity.async_will_remove_from_hass
(self)
Disconnect the device when removed.
Disconnect the device when removed.
async def async_will_remove_from_hass(self) -> None: """Disconnect the device when removed.""" if self._dispatcher_remove: self._dispatcher_remove()
[ "async", "def", "async_will_remove_from_hass", "(", "self", ")", "->", "None", ":", "if", "self", ".", "_dispatcher_remove", ":", "self", ".", "_dispatcher_remove", "(", ")" ]
[ 431, 4 ]
[ 434, 37 ]
python
en
['en', 'en', 'en']
True
SmartThingsEntity.device_info
(self)
Get attributes about the device.
Get attributes about the device.
def device_info(self): """Get attributes about the device.""" return { "identifiers": {(DOMAIN, self._device.device_id)}, "name": self._device.label, "model": self._device.device_type_name, "manufacturer": "Unavailable", }
[ "def", "device_info", "(", "self", ")", ":", "return", "{", "\"identifiers\"", ":", "{", "(", "DOMAIN", ",", "self", ".", "_device", ".", "device_id", ")", "}", ",", "\"name\"", ":", "self", ".", "_device", ".", "label", ",", "\"model\"", ":", "self", ...
[ 437, 4 ]
[ 444, 9 ]
python
en
['en', 'en', 'en']
True
SmartThingsEntity.name
(self)
Return the name of the device.
Return the name of the device.
def name(self) -> str: """Return the name of the device.""" return self._device.label
[ "def", "name", "(", "self", ")", "->", "str", ":", "return", "self", ".", "_device", ".", "label" ]
[ 447, 4 ]
[ 449, 33 ]
python
en
['en', 'en', 'en']
True
SmartThingsEntity.should_poll
(self)
No polling needed for this device.
No polling needed for this device.
def should_poll(self) -> bool: """No polling needed for this device.""" return False
[ "def", "should_poll", "(", "self", ")", "->", "bool", ":", "return", "False" ]
[ 452, 4 ]
[ 454, 20 ]
python
en
['en', 'en', 'en']
True
SmartThingsEntity.unique_id
(self)
Return a unique ID.
Return a unique ID.
def unique_id(self) -> str: """Return a unique ID.""" return self._device.device_id
[ "def", "unique_id", "(", "self", ")", "->", "str", ":", "return", "self", ".", "_device", ".", "device_id" ]
[ 457, 4 ]
[ 459, 37 ]
python
ca
['fr', 'ca', 'en']
False