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
MyStromLight.hs_color
(self)
Return the color of the light.
Return the color of the light.
def hs_color(self): """Return the color of the light.""" return self._color_h, self._color_s
[ "def", "hs_color", "(", "self", ")", ":", "return", "self", ".", "_color_h", ",", "self", ".", "_color_s" ]
[ 96, 4 ]
[ 98, 43 ]
python
en
['en', 'en', 'en']
True
MyStromLight.available
(self)
Return True if entity is available.
Return True if entity is available.
def available(self) -> bool: """Return True if entity is available.""" return self._available
[ "def", "available", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "_available" ]
[ 101, 4 ]
[ 103, 30 ]
python
en
['en', 'en', 'en']
True
MyStromLight.effect_list
(self)
Return the list of supported effects.
Return the list of supported effects.
def effect_list(self): """Return the list of supported effects.""" return MYSTROM_EFFECT_LIST
[ "def", "effect_list", "(", "self", ")", ":", "return", "MYSTROM_EFFECT_LIST" ]
[ 106, 4 ]
[ 108, 34 ]
python
en
['en', 'en', 'en']
True
MyStromLight.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" ]
[ 111, 4 ]
[ 113, 26 ]
python
en
['en', 'et', 'en']
True
MyStromLight.async_turn_on
(self, **kwargs)
Turn on the light.
Turn on the light.
async def async_turn_on(self, **kwargs): """Turn on the light.""" brightness = kwargs.get(ATTR_BRIGHTNESS, 255) effect = kwargs.get(ATTR_EFFECT) if ATTR_HS_COLOR in kwargs: color_h, color_s = kwargs[ATTR_HS_COLOR] elif ATTR_BRIGHTNESS in kwargs: # Brightn...
[ "async", "def", "async_turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "brightness", "=", "kwargs", ".", "get", "(", "ATTR_BRIGHTNESS", ",", "255", ")", "effect", "=", "kwargs", ".", "get", "(", "ATTR_EFFECT", ")", "if", "ATTR_HS_COLOR", "in", ...
[ 115, 4 ]
[ 140, 55 ]
python
en
['en', 'et', 'en']
True
MyStromLight.async_turn_off
(self, **kwargs)
Turn off the bulb.
Turn off the bulb.
async def async_turn_off(self, **kwargs): """Turn off the bulb.""" try: await self._bulb.set_off() except MyStromConnectionError: _LOGGER.warning("myStrom bulb not online")
[ "async", "def", "async_turn_off", "(", "self", ",", "*", "*", "kwargs", ")", ":", "try", ":", "await", "self", ".", "_bulb", ".", "set_off", "(", ")", "except", "MyStromConnectionError", ":", "_LOGGER", ".", "warning", "(", "\"myStrom bulb not online\"", ")"...
[ 142, 4 ]
[ 147, 54 ]
python
en
['en', 'ig', 'en']
True
MyStromLight.async_update
(self)
Fetch new state data for this light.
Fetch new state data for this light.
async def async_update(self): """Fetch new state data for this light.""" try: await self._bulb.get_state() self._state = self._bulb.state colors = self._bulb.color try: color_h, color_s, color_v = colors.split(";") except Value...
[ "async", "def", "async_update", "(", "self", ")", ":", "try", ":", "await", "self", ".", "_bulb", ".", "get_state", "(", ")", "self", ".", "_state", "=", "self", ".", "_bulb", ".", "state", "colors", "=", "self", ".", "_bulb", ".", "color", "try", ...
[ 149, 4 ]
[ 169, 35 ]
python
en
['en', 'en', 'en']
True
test_temperature_not_a_number
(hass)
Test that temperature is a number.
Test that temperature is a number.
def test_temperature_not_a_number(hass): """Test that temperature is a number.""" temp = "Temperature" with pytest.raises(Exception) as exception: display_temp(hass, temp, TEMP_CELSIUS, PRECISION_HALVES) assert f"Temperature is not a number: {temp}" in str(exception.value)
[ "def", "test_temperature_not_a_number", "(", "hass", ")", ":", "temp", "=", "\"Temperature\"", "with", "pytest", ".", "raises", "(", "Exception", ")", "as", "exception", ":", "display_temp", "(", "hass", ",", "temp", ",", "TEMP_CELSIUS", ",", "PRECISION_HALVES",...
[ 15, 0 ]
[ 21, 73 ]
python
en
['en', 'en', 'en']
True
test_celsius_halves
(hass)
Test temperature to celsius rounding to halves.
Test temperature to celsius rounding to halves.
def test_celsius_halves(hass): """Test temperature to celsius rounding to halves.""" assert display_temp(hass, TEMP, TEMP_CELSIUS, PRECISION_HALVES) == 24.5
[ "def", "test_celsius_halves", "(", "hass", ")", ":", "assert", "display_temp", "(", "hass", ",", "TEMP", ",", "TEMP_CELSIUS", ",", "PRECISION_HALVES", ")", "==", "24.5" ]
[ 24, 0 ]
[ 26, 75 ]
python
en
['en', 'en', 'en']
True
test_celsius_tenths
(hass)
Test temperature to celsius rounding to tenths.
Test temperature to celsius rounding to tenths.
def test_celsius_tenths(hass): """Test temperature to celsius rounding to tenths.""" assert display_temp(hass, TEMP, TEMP_CELSIUS, PRECISION_TENTHS) == 24.6
[ "def", "test_celsius_tenths", "(", "hass", ")", ":", "assert", "display_temp", "(", "hass", ",", "TEMP", ",", "TEMP_CELSIUS", ",", "PRECISION_TENTHS", ")", "==", "24.6" ]
[ 29, 0 ]
[ 31, 75 ]
python
en
['en', 'en', 'en']
True
test_fahrenheit_wholes
(hass)
Test temperature to fahrenheit rounding to wholes.
Test temperature to fahrenheit rounding to wholes.
def test_fahrenheit_wholes(hass): """Test temperature to fahrenheit rounding to wholes.""" assert display_temp(hass, TEMP, TEMP_FAHRENHEIT, PRECISION_WHOLE) == -4
[ "def", "test_fahrenheit_wholes", "(", "hass", ")", ":", "assert", "display_temp", "(", "hass", ",", "TEMP", ",", "TEMP_FAHRENHEIT", ",", "PRECISION_WHOLE", ")", "==", "-", "4" ]
[ 34, 0 ]
[ 36, 75 ]
python
en
['en', 'el-Latn', 'en']
True
async_setup
(hass, base_config)
Set up of Tesla component.
Set up of Tesla component.
async def async_setup(hass, base_config): """Set up of Tesla component.""" def _update_entry(email, data=None, options=None): data = data or {} options = options or { CONF_SCAN_INTERVAL: DEFAULT_SCAN_INTERVAL, CONF_WAKE_ON_START: DEFAULT_WAKE_ON_START, } ...
[ "async", "def", "async_setup", "(", "hass", ",", "base_config", ")", ":", "def", "_update_entry", "(", "email", ",", "data", "=", "None", ",", "options", "=", "None", ")", ":", "data", "=", "data", "or", "{", "}", "options", "=", "options", "or", "{"...
[ 77, 0 ]
[ 120, 15 ]
python
en
['en', 'da', 'en']
True
async_setup_entry
(hass, config_entry)
Set up Tesla as config entry.
Set up Tesla as config entry.
async def async_setup_entry(hass, config_entry): """Set up Tesla as config entry.""" hass.data.setdefault(DOMAIN, {}) config = config_entry.data websession = aiohttp_client.async_get_clientsession(hass) email = config_entry.title if email in hass.data[DOMAIN] and CONF_SCAN_INTERVAL in hass.data[...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ")", ":", "hass", ".", "data", ".", "setdefault", "(", "DOMAIN", ",", "{", "}", ")", "config", "=", "config_entry", ".", "data", "websession", "=", "aiohttp_client", ".", "async_get_clien...
[ 123, 0 ]
[ 181, 15 ]
python
en
['en', 'en', 'en']
True
async_unload_entry
(hass, config_entry)
Unload a config entry.
Unload a config entry.
async def async_unload_entry(hass, config_entry) -> bool: """Unload a config entry.""" unload_ok = all( await asyncio.gather( *[ hass.config_entries.async_forward_entry_unload(config_entry, component) for component in TESLA_COMPONENTS ] ) ...
[ "async", "def", "async_unload_entry", "(", "hass", ",", "config_entry", ")", "->", "bool", ":", "unload_ok", "=", "all", "(", "await", "asyncio", ".", "gather", "(", "*", "[", "hass", ".", "config_entries", ".", "async_forward_entry_unload", "(", "config_entry...
[ 184, 0 ]
[ 201, 16 ]
python
en
['en', 'es', 'en']
True
update_listener
(hass, config_entry)
Update when config_entry options update.
Update when config_entry options update.
async def update_listener(hass, config_entry): """Update when config_entry options update.""" controller = hass.data[DOMAIN][config_entry.entry_id]["coordinator"].controller old_update_interval = controller.update_interval controller.update_interval = config_entry.options.get(CONF_SCAN_INTERVAL) if ...
[ "async", "def", "update_listener", "(", "hass", ",", "config_entry", ")", ":", "controller", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "config_entry", ".", "entry_id", "]", "[", "\"coordinator\"", "]", ".", "controller", "old_update_interval", "=", ...
[ 204, 0 ]
[ 214, 9 ]
python
en
['en', 'en', 'en']
True
TeslaDataUpdateCoordinator.__init__
(self, hass, *, config_entry, controller)
Initialize global Tesla data updater.
Initialize global Tesla data updater.
def __init__(self, hass, *, config_entry, controller): """Initialize global Tesla data updater.""" self.controller = controller self.config_entry = config_entry update_interval = timedelta(seconds=MIN_SCAN_INTERVAL) super().__init__( hass, _LOGGER, ...
[ "def", "__init__", "(", "self", ",", "hass", ",", "*", ",", "config_entry", ",", "controller", ")", ":", "self", ".", "controller", "=", "controller", "self", ".", "config_entry", "=", "config_entry", "update_interval", "=", "timedelta", "(", "seconds", "=",...
[ 220, 4 ]
[ 232, 9 ]
python
en
['en', 'en', 'it']
True
TeslaDataUpdateCoordinator._async_update_data
(self)
Fetch data from API endpoint.
Fetch data from API endpoint.
async def _async_update_data(self): """Fetch data from API endpoint.""" if self.controller.is_token_refreshed(): (refresh_token, access_token) = self.controller.get_tokens() _async_save_tokens( self.hass, self.config_entry, access_token, refresh_token ...
[ "async", "def", "_async_update_data", "(", "self", ")", ":", "if", "self", ".", "controller", ".", "is_token_refreshed", "(", ")", ":", "(", "refresh_token", ",", "access_token", ")", "=", "self", ".", "controller", ".", "get_tokens", "(", ")", "_async_save_...
[ 234, 4 ]
[ 249, 79 ]
python
en
['en', 'en', 'en']
True
TeslaDevice.__init__
(self, tesla_device, coordinator)
Initialise the Tesla device.
Initialise the Tesla device.
def __init__(self, tesla_device, coordinator): """Initialise the Tesla device.""" super().__init__(coordinator) self.tesla_device = tesla_device self._name = self.tesla_device.name self._unique_id = slugify(self.tesla_device.uniq_name) self._attributes = self.tesla_device...
[ "def", "__init__", "(", "self", ",", "tesla_device", ",", "coordinator", ")", ":", "super", "(", ")", ".", "__init__", "(", "coordinator", ")", "self", ".", "tesla_device", "=", "tesla_device", "self", ".", "_name", "=", "self", ".", "tesla_device", ".", ...
[ 255, 4 ]
[ 261, 57 ]
python
en
['en', 'zu', 'en']
True
TeslaDevice.name
(self)
Return the name of the device.
Return the name of the device.
def name(self): """Return the name of the device.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 264, 4 ]
[ 266, 25 ]
python
en
['en', 'en', 'en']
True
TeslaDevice.unique_id
(self)
Return a unique ID.
Return a unique ID.
def unique_id(self) -> str: """Return a unique ID.""" return self._unique_id
[ "def", "unique_id", "(", "self", ")", "->", "str", ":", "return", "self", ".", "_unique_id" ]
[ 269, 4 ]
[ 271, 30 ]
python
ca
['fr', 'ca', 'en']
False
TeslaDevice.icon
(self)
Return the icon of the sensor.
Return the icon of the sensor.
def icon(self): """Return the icon of the sensor.""" if self.device_class: return None return ICONS.get(self.tesla_device.type)
[ "def", "icon", "(", "self", ")", ":", "if", "self", ".", "device_class", ":", "return", "None", "return", "ICONS", ".", "get", "(", "self", ".", "tesla_device", ".", "type", ")" ]
[ 274, 4 ]
[ 279, 48 ]
python
en
['en', 'en', 'en']
True
TeslaDevice.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.""" attr = self._attributes if self.tesla_device.has_battery(): attr[ATTR_BATTERY_LEVEL] = self.tesla_device.battery_level() attr[ATTR_BATTERY_CHARGING] = self.tesla_device.battery_charging() ...
[ "def", "device_state_attributes", "(", "self", ")", ":", "attr", "=", "self", ".", "_attributes", "if", "self", ".", "tesla_device", ".", "has_battery", "(", ")", ":", "attr", "[", "ATTR_BATTERY_LEVEL", "]", "=", "self", ".", "tesla_device", ".", "battery_le...
[ 282, 4 ]
[ 288, 19 ]
python
en
['en', 'en', 'en']
True
TeslaDevice.device_info
(self)
Return the device_info of the device.
Return the device_info of the device.
def device_info(self): """Return the device_info of the device.""" return { "identifiers": {(DOMAIN, self.tesla_device.id())}, "name": self.tesla_device.car_name(), "manufacturer": "Tesla", "model": self.tesla_device.car_type, "sw_version": sel...
[ "def", "device_info", "(", "self", ")", ":", "return", "{", "\"identifiers\"", ":", "{", "(", "DOMAIN", ",", "self", ".", "tesla_device", ".", "id", "(", ")", ")", "}", ",", "\"name\"", ":", "self", ".", "tesla_device", ".", "car_name", "(", ")", ","...
[ 291, 4 ]
[ 299, 9 ]
python
en
['en', 'en', 'en']
True
TeslaDevice.async_added_to_hass
(self)
Register state update callback.
Register state update callback.
async def async_added_to_hass(self): """Register state update callback.""" self.async_on_remove(self.coordinator.async_add_listener(self.refresh))
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "self", ".", "async_on_remove", "(", "self", ".", "coordinator", ".", "async_add_listener", "(", "self", ".", "refresh", ")", ")" ]
[ 301, 4 ]
[ 303, 79 ]
python
en
['en', 'co', 'en']
True
TeslaDevice.refresh
(self)
Refresh the state of the device. This assumes the coordinator has updated the controller.
Refresh the state of the device.
def refresh(self) -> None: """Refresh the state of the device. This assumes the coordinator has updated the controller. """ self.tesla_device.refresh() self._attributes = self.tesla_device.attrs.copy() self.async_write_ha_state()
[ "def", "refresh", "(", "self", ")", "->", "None", ":", "self", ".", "tesla_device", ".", "refresh", "(", ")", "self", ".", "_attributes", "=", "self", ".", "tesla_device", ".", "attrs", ".", "copy", "(", ")", "self", ".", "async_write_ha_state", "(", "...
[ 306, 4 ]
[ 313, 35 ]
python
en
['en', 'en', 'en']
True
test_capped_setup
(hass, aioclient_mock)
Test the default setup.
Test the default setup.
async def test_capped_setup(hass, aioclient_mock): """Test the default setup.""" config = { "platform": "startca", "api_key": "NOTAKEY", "total_bandwidth": 400, "monitored_variables": [ "usage", "usage_gb", "limit", "used_download",...
[ "async", "def", "test_capped_setup", "(", "hass", ",", "aioclient_mock", ")", ":", "config", "=", "{", "\"platform\"", ":", "\"startca\"", ",", "\"api_key\"", ":", "\"NOTAKEY\"", ",", "\"total_bandwidth\"", ":", "400", ",", "\"monitored_variables\"", ":", "[", "...
[ 12, 0 ]
[ 105, 33 ]
python
en
['en', 'da', 'en']
True
test_unlimited_setup
(hass, aioclient_mock)
Test the default setup.
Test the default setup.
async def test_unlimited_setup(hass, aioclient_mock): """Test the default setup.""" config = { "platform": "startca", "api_key": "NOTAKEY", "total_bandwidth": 0, "monitored_variables": [ "usage", "usage_gb", "limit", "used_download"...
[ "async", "def", "test_unlimited_setup", "(", "hass", ",", "aioclient_mock", ")", ":", "config", "=", "{", "\"platform\"", ":", "\"startca\"", ",", "\"api_key\"", ":", "\"NOTAKEY\"", ",", "\"total_bandwidth\"", ":", "0", ",", "\"monitored_variables\"", ":", "[", ...
[ 108, 0 ]
[ 201, 31 ]
python
en
['en', 'da', 'en']
True
test_bad_return_code
(hass, aioclient_mock)
Test handling a return code that isn't HTTP OK.
Test handling a return code that isn't HTTP OK.
async def test_bad_return_code(hass, aioclient_mock): """Test handling a return code that isn't HTTP OK.""" aioclient_mock.get( "https://www.start.ca/support/usage/api?key=NOTAKEY", status=HTTP_NOT_FOUND ) scd = StartcaData(hass.loop, async_get_clientsession(hass), "NOTAKEY", 400) result =...
[ "async", "def", "test_bad_return_code", "(", "hass", ",", "aioclient_mock", ")", ":", "aioclient_mock", ".", "get", "(", "\"https://www.start.ca/support/usage/api?key=NOTAKEY\"", ",", "status", "=", "HTTP_NOT_FOUND", ")", "scd", "=", "StartcaData", "(", "hass", ".", ...
[ 204, 0 ]
[ 213, 26 ]
python
en
['en', 'lb', 'en']
True
test_bad_json_decode
(hass, aioclient_mock)
Test decoding invalid json result.
Test decoding invalid json result.
async def test_bad_json_decode(hass, aioclient_mock): """Test decoding invalid json result.""" aioclient_mock.get( "https://www.start.ca/support/usage/api?key=NOTAKEY", text="this is not xml" ) scd = StartcaData(hass.loop, async_get_clientsession(hass), "NOTAKEY", 400) result = await scd.a...
[ "async", "def", "test_bad_json_decode", "(", "hass", ",", "aioclient_mock", ")", ":", "aioclient_mock", ".", "get", "(", "\"https://www.start.ca/support/usage/api?key=NOTAKEY\"", ",", "text", "=", "\"this is not xml\"", ")", "scd", "=", "StartcaData", "(", "hass", "."...
[ 216, 0 ]
[ 225, 26 ]
python
da
['fr', 'da', 'en']
False
_async_create_entities
(hass, config)
Create the Template switches.
Create the Template switches.
async def _async_create_entities(hass, config): """Create the Template switches.""" switches = [] for device, device_config in config[CONF_SWITCHES].items(): friendly_name = device_config.get(ATTR_FRIENDLY_NAME, device) state_template = device_config.get(CONF_VALUE_TEMPLATE) icon_te...
[ "async", "def", "_async_create_entities", "(", "hass", ",", "config", ")", ":", "switches", "=", "[", "]", "for", "device", ",", "device_config", "in", "config", "[", "CONF_SWITCHES", "]", ".", "items", "(", ")", ":", "friendly_name", "=", "device_config", ...
[ 58, 0 ]
[ 87, 19 ]
python
en
['en', 'en', 'en']
True
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Set up the template switches.
Set up the template switches.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the template switches.""" await async_setup_reload_service(hass, DOMAIN, PLATFORMS) async_add_entities(await _async_create_entities(hass, config))
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "await", "async_setup_reload_service", "(", "hass", ",", "DOMAIN", ",", "PLATFORMS", ")", "async_add_entities", "(", "await...
[ 90, 0 ]
[ 94, 66 ]
python
en
['en', 'en', 'en']
True
SwitchTemplate.__init__
( self, hass, device_id, friendly_name, state_template, icon_template, entity_picture_template, availability_template, on_action, off_action, unique_id, )
Initialize the Template switch.
Initialize the Template switch.
def __init__( self, hass, device_id, friendly_name, state_template, icon_template, entity_picture_template, availability_template, on_action, off_action, unique_id, ): """Initialize the Template switch.""" super(...
[ "def", "__init__", "(", "self", ",", "hass", ",", "device_id", ",", "friendly_name", ",", "state_template", ",", "icon_template", ",", "entity_picture_template", ",", "availability_template", ",", "on_action", ",", "off_action", ",", "unique_id", ",", ")", ":", ...
[ 100, 4 ]
[ 128, 35 ]
python
en
['en', 'en', 'en']
True
SwitchTemplate.async_added_to_hass
(self)
Register callbacks.
Register callbacks.
async def async_added_to_hass(self): """Register callbacks.""" if self._template is None: # restore state after startup await super().async_added_to_hass() state = await self.async_get_last_state() if state: self._state = state.state == S...
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "if", "self", ".", "_template", "is", "None", ":", "# restore state after startup", "await", "super", "(", ")", ".", "async_added_to_hass", "(", ")", "state", "=", "await", "self", ".", "async_get_l...
[ 147, 4 ]
[ 164, 43 ]
python
en
['en', 'no', 'en']
False
SwitchTemplate.name
(self)
Return the name of the switch.
Return the name of the switch.
def name(self): """Return the name of the switch.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 167, 4 ]
[ 169, 25 ]
python
en
['en', 'en', 'en']
True
SwitchTemplate.unique_id
(self)
Return the unique id of this switch.
Return the unique id of this switch.
def unique_id(self): """Return the unique id of this switch.""" return self._unique_id
[ "def", "unique_id", "(", "self", ")", ":", "return", "self", ".", "_unique_id" ]
[ 172, 4 ]
[ 174, 30 ]
python
en
['en', 'en', 'en']
True
SwitchTemplate.is_on
(self)
Return true if device is on.
Return true if device is on.
def is_on(self): """Return true if device is on.""" return self._state
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 177, 4 ]
[ 179, 26 ]
python
en
['en', 'fy', 'en']
True
SwitchTemplate.should_poll
(self)
Return the polling state.
Return the polling state.
def should_poll(self): """Return the polling state.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 182, 4 ]
[ 184, 20 ]
python
en
['en', 'en', 'en']
True
SwitchTemplate.async_turn_on
(self, **kwargs)
Fire the on action.
Fire the on action.
async def async_turn_on(self, **kwargs): """Fire the on action.""" await self._on_script.async_run(context=self._context) if self._template is None: self._state = True self.async_write_ha_state()
[ "async", "def", "async_turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "await", "self", ".", "_on_script", ".", "async_run", "(", "context", "=", "self", ".", "_context", ")", "if", "self", ".", "_template", "is", "None", ":", "self", ".", ...
[ 186, 4 ]
[ 191, 39 ]
python
en
['en', 'en', 'en']
True
SwitchTemplate.async_turn_off
(self, **kwargs)
Fire the off action.
Fire the off action.
async def async_turn_off(self, **kwargs): """Fire the off action.""" await self._off_script.async_run(context=self._context) if self._template is None: self._state = False self.async_write_ha_state()
[ "async", "def", "async_turn_off", "(", "self", ",", "*", "*", "kwargs", ")", ":", "await", "self", ".", "_off_script", ".", "async_run", "(", "context", "=", "self", ".", "_context", ")", "if", "self", ".", "_template", "is", "None", ":", "self", ".", ...
[ 193, 4 ]
[ 198, 39 ]
python
en
['en', 'en', 'en']
True
SwitchTemplate.assumed_state
(self)
State is assumed, if no template given.
State is assumed, if no template given.
def assumed_state(self): """State is assumed, if no template given.""" return self._template is None
[ "def", "assumed_state", "(", "self", ")", ":", "return", "self", ".", "_template", "is", "None" ]
[ 201, 4 ]
[ 203, 37 ]
python
en
['en', 'en', 'en']
True
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Set up the Zodiac sensor platform.
Set up the Zodiac sensor platform.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the Zodiac sensor platform.""" if discovery_info is None: return async_add_entities([ZodiacSensor()], True)
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "if", "discovery_info", "is", "None", ":", "return", "async_add_entities", "(", "[", "ZodiacSensor", "(", ")", "]", ","...
[ 156, 0 ]
[ 161, 46 ]
python
en
['en', 'pt', 'en']
True
ZodiacSensor.__init__
(self)
Initialize the zodiac sensor.
Initialize the zodiac sensor.
def __init__(self): """Initialize the zodiac sensor.""" self._attrs = None self._state = None
[ "def", "__init__", "(", "self", ")", ":", "self", ".", "_attrs", "=", "None", "self", ".", "_state", "=", "None" ]
[ 167, 4 ]
[ 170, 26 ]
python
en
['en', 'pl', 'en']
True
ZodiacSensor.unique_id
(self)
Return a unique ID.
Return a unique ID.
def unique_id(self): """Return a unique ID.""" return DOMAIN
[ "def", "unique_id", "(", "self", ")", ":", "return", "DOMAIN" ]
[ 173, 4 ]
[ 175, 21 ]
python
ca
['fr', 'ca', 'en']
False
ZodiacSensor.name
(self)
Return the name of the entity.
Return the name of the entity.
def name(self): """Return the name of the entity.""" return "Zodiac"
[ "def", "name", "(", "self", ")", ":", "return", "\"Zodiac\"" ]
[ 178, 4 ]
[ 180, 23 ]
python
en
['en', 'en', 'en']
True
ZodiacSensor.device_class
(self)
Return the device class of the entity.
Return the device class of the entity.
def device_class(self): """Return the device class of the entity.""" return "zodiac__sign"
[ "def", "device_class", "(", "self", ")", ":", "return", "\"zodiac__sign\"" ]
[ 183, 4 ]
[ 185, 29 ]
python
en
['en', 'en', 'en']
True
ZodiacSensor.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" ]
[ 188, 4 ]
[ 190, 26 ]
python
en
['en', 'en', 'en']
True
ZodiacSensor.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 ZODIAC_ICONS.get(self._state)
[ "def", "icon", "(", "self", ")", ":", "return", "ZODIAC_ICONS", ".", "get", "(", "self", ".", "_state", ")" ]
[ 193, 4 ]
[ 195, 44 ]
python
en
['en', 'en', 'en']
True
ZodiacSensor.device_state_attributes
(self)
Return the state attributes.
Return the state attributes.
def device_state_attributes(self): """Return the state attributes.""" return self._attrs
[ "def", "device_state_attributes", "(", "self", ")", ":", "return", "self", ".", "_attrs" ]
[ 198, 4 ]
[ 200, 26 ]
python
en
['en', 'en', 'en']
True
ZodiacSensor.async_update
(self)
Get the time and updates the state.
Get the time and updates the state.
async def async_update(self): """Get the time and updates the state.""" today = as_local(utcnow()).date() month = int(today.month) day = int(today.day) for sign in ZODIAC_BY_DATE: if (month == sign[0][1] and day >= sign[0][0]) or ( month == sign[1][1...
[ "async", "def", "async_update", "(", "self", ")", ":", "today", "=", "as_local", "(", "utcnow", "(", ")", ")", ".", "date", "(", ")", "month", "=", "int", "(", "today", ".", "month", ")", "day", "=", "int", "(", "today", ".", "day", ")", "for", ...
[ 202, 4 ]
[ 215, 21 ]
python
en
['en', 'en', 'en']
True
test_sonos_playback
(hass, mock_plex_server)
Test playing media on a Sonos speaker.
Test playing media on a Sonos speaker.
async def test_sonos_playback(hass, mock_plex_server): """Test playing media on a Sonos speaker.""" server_id = mock_plex_server.machineIdentifier loaded_server = hass.data[DOMAIN][SERVERS][server_id] # Test Sonos integration lookup failure with patch.object( hass.components.sonos, "get_coo...
[ "async", "def", "test_sonos_playback", "(", "hass", ",", "mock_plex_server", ")", ":", "server_id", "=", "mock_plex_server", ".", "machineIdentifier", "loaded_server", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "SERVERS", "]", "[", "server_id", "]", "#...
[ 23, 0 ]
[ 130, 9 ]
python
en
['en', 'en', 'en']
True
test_playback_multiple_servers
(hass, mock_websocket, setup_plex_server)
Test playing media when multiple servers available.
Test playing media when multiple servers available.
async def test_playback_multiple_servers(hass, mock_websocket, setup_plex_server): """Test playing media when multiple servers available.""" secondary_entry = MockConfigEntry( domain=DOMAIN, data=SECONDARY_DATA, options=DEFAULT_OPTIONS, unique_id=SECONDARY_DATA["server_id"], ...
[ "async", "def", "test_playback_multiple_servers", "(", "hass", ",", "mock_websocket", ",", "setup_plex_server", ")", ":", "secondary_entry", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", "data", "=", "SECONDARY_DATA", ",", "options", "=", "DEFAULT_OPTIO...
[ 133, 0 ]
[ 159, 9 ]
python
en
['en', 'en', 'en']
True
init_integration
( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, skip_setup: bool = False, )
Set up the BSBLan integration in Home Assistant.
Set up the BSBLan integration in Home Assistant.
async def init_integration( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, skip_setup: bool = False, ) -> MockConfigEntry: """Set up the BSBLan integration in Home Assistant.""" aioclient_mock.post( "http://example.local:80/1234/JQ?Parameter=6224,6225,6226", params={"Para...
[ "async", "def", "init_integration", "(", "hass", ":", "HomeAssistant", ",", "aioclient_mock", ":", "AiohttpClientMocker", ",", "skip_setup", ":", "bool", "=", "False", ",", ")", "->", "MockConfigEntry", ":", "aioclient_mock", ".", "post", "(", "\"http://example.lo...
[ 14, 0 ]
[ 45, 16 ]
python
en
['en', 'en', 'en']
True
device_reg
(hass)
Return an empty, loaded, registry.
Return an empty, loaded, registry.
def device_reg(hass): """Return an empty, loaded, registry.""" return mock_device_registry(hass)
[ "def", "device_reg", "(", "hass", ")", ":", "return", "mock_device_registry", "(", "hass", ")" ]
[ 27, 0 ]
[ 29, 37 ]
python
en
['en', 'fy', 'en']
True
entity_reg
(hass)
Return an empty, loaded, registry.
Return an empty, loaded, registry.
def entity_reg(hass): """Return an empty, loaded, registry.""" return mock_registry(hass)
[ "def", "entity_reg", "(", "hass", ")", ":", "return", "mock_registry", "(", "hass", ")" ]
[ 33, 0 ]
[ 35, 30 ]
python
en
['en', 'fy', 'en']
True
calls
(hass)
Track calls to a mock service.
Track calls to a mock service.
def calls(hass): """Track calls to a mock service.""" return async_mock_service(hass, "test", "automation")
[ "def", "calls", "(", "hass", ")", ":", "return", "async_mock_service", "(", "hass", ",", "\"test\"", ",", "\"automation\"", ")" ]
[ 39, 0 ]
[ 41, 57 ]
python
en
['en', 'en', 'en']
True
test_get_conditions
(hass, device_reg, entity_reg)
Test we get the expected conditions from a cover.
Test we get the expected conditions from a cover.
async def test_get_conditions(hass, device_reg, entity_reg): """Test we get the expected conditions from a cover.""" platform = getattr(hass.components, f"test.{DOMAIN}") platform.init() ent = platform.ENTITIES[0] config_entry = MockConfigEntry(domain="test", data={}) config_entry.add_to_hass(h...
[ "async", "def", "test_get_conditions", "(", "hass", ",", "device_reg", ",", "entity_reg", ")", ":", "platform", "=", "getattr", "(", "hass", ".", "components", ",", "f\"test.{DOMAIN}\"", ")", "platform", ".", "init", "(", ")", "ent", "=", "platform", ".", ...
[ 44, 0 ]
[ 92, 54 ]
python
en
['en', 'en', 'en']
True
test_get_conditions_set_pos
(hass, device_reg, entity_reg)
Test we get the expected conditions from a cover.
Test we get the expected conditions from a cover.
async def test_get_conditions_set_pos(hass, device_reg, entity_reg): """Test we get the expected conditions from a cover.""" platform = getattr(hass.components, f"test.{DOMAIN}") platform.init() ent = platform.ENTITIES[1] config_entry = MockConfigEntry(domain="test", data={}) config_entry.add_t...
[ "async", "def", "test_get_conditions_set_pos", "(", "hass", ",", "device_reg", ",", "entity_reg", ")", ":", "platform", "=", "getattr", "(", "hass", ".", "components", ",", "f\"test.{DOMAIN}\"", ")", "platform", ".", "init", "(", ")", "ent", "=", "platform", ...
[ 95, 0 ]
[ 150, 54 ]
python
en
['en', 'en', 'en']
True
test_get_conditions_set_tilt_pos
(hass, device_reg, entity_reg)
Test we get the expected conditions from a cover.
Test we get the expected conditions from a cover.
async def test_get_conditions_set_tilt_pos(hass, device_reg, entity_reg): """Test we get the expected conditions from a cover.""" platform = getattr(hass.components, f"test.{DOMAIN}") platform.init() ent = platform.ENTITIES[2] config_entry = MockConfigEntry(domain="test", data={}) config_entry....
[ "async", "def", "test_get_conditions_set_tilt_pos", "(", "hass", ",", "device_reg", ",", "entity_reg", ")", ":", "platform", "=", "getattr", "(", "hass", ".", "components", ",", "f\"test.{DOMAIN}\"", ")", "platform", ".", "init", "(", ")", "ent", "=", "platfor...
[ 153, 0 ]
[ 208, 54 ]
python
en
['en', 'en', 'en']
True
test_get_condition_capabilities
(hass, device_reg, entity_reg)
Test we get the expected capabilities from a cover condition.
Test we get the expected capabilities from a cover condition.
async def test_get_condition_capabilities(hass, device_reg, entity_reg): """Test we get the expected capabilities from a cover condition.""" platform = getattr(hass.components, f"test.{DOMAIN}") platform.init() ent = platform.ENTITIES[0] config_entry = MockConfigEntry(domain="test", data={}) co...
[ "async", "def", "test_get_condition_capabilities", "(", "hass", ",", "device_reg", ",", "entity_reg", ")", ":", "platform", "=", "getattr", "(", "hass", ".", "components", ",", "f\"test.{DOMAIN}\"", ")", "platform", ".", "init", "(", ")", "ent", "=", "platform...
[ 211, 0 ]
[ 235, 51 ]
python
en
['en', 'en', 'en']
True
test_get_condition_capabilities_set_pos
(hass, device_reg, entity_reg)
Test we get the expected capabilities from a cover condition.
Test we get the expected capabilities from a cover condition.
async def test_get_condition_capabilities_set_pos(hass, device_reg, entity_reg): """Test we get the expected capabilities from a cover condition.""" platform = getattr(hass.components, f"test.{DOMAIN}") platform.init() ent = platform.ENTITIES[1] config_entry = MockConfigEntry(domain="test", data={}...
[ "async", "def", "test_get_condition_capabilities_set_pos", "(", "hass", ",", "device_reg", ",", "entity_reg", ")", ":", "platform", "=", "getattr", "(", "hass", ".", "components", ",", "f\"test.{DOMAIN}\"", ")", "platform", ".", "init", "(", ")", "ent", "=", "...
[ 238, 0 ]
[ 285, 55 ]
python
en
['en', 'en', 'en']
True
test_get_condition_capabilities_set_tilt_pos
(hass, device_reg, entity_reg)
Test we get the expected capabilities from a cover condition.
Test we get the expected capabilities from a cover condition.
async def test_get_condition_capabilities_set_tilt_pos(hass, device_reg, entity_reg): """Test we get the expected capabilities from a cover condition.""" platform = getattr(hass.components, f"test.{DOMAIN}") platform.init() ent = platform.ENTITIES[2] config_entry = MockConfigEntry(domain="test", da...
[ "async", "def", "test_get_condition_capabilities_set_tilt_pos", "(", "hass", ",", "device_reg", ",", "entity_reg", ")", ":", "platform", "=", "getattr", "(", "hass", ".", "components", ",", "f\"test.{DOMAIN}\"", ")", "platform", ".", "init", "(", ")", "ent", "="...
[ 288, 0 ]
[ 335, 55 ]
python
en
['en', 'en', 'en']
True
test_if_state
(hass, calls)
Test for turn_on and turn_off conditions.
Test for turn_on and turn_off conditions.
async def test_if_state(hass, calls): """Test for turn_on and turn_off conditions.""" hass.states.async_set("cover.entity", STATE_OPEN) assert await async_setup_component( hass, automation.DOMAIN, { automation.DOMAIN: [ { "trigger": {"...
[ "async", "def", "test_if_state", "(", "hass", ",", "calls", ")", ":", "hass", ".", "states", ".", "async_set", "(", "\"cover.entity\"", ",", "STATE_OPEN", ")", "assert", "await", "async_setup_component", "(", "hass", ",", "automation", ".", "DOMAIN", ",", "{...
[ 338, 0 ]
[ 447, 70 ]
python
en
['en', 'en', 'en']
True
test_if_position
(hass, calls)
Test for position conditions.
Test for position conditions.
async def test_if_position(hass, calls): """Test for position conditions.""" platform = getattr(hass.components, f"test.{DOMAIN}") platform.init() ent = platform.ENTITIES[1] assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "test"}}) await hass.async_block_till_done() ...
[ "async", "def", "test_if_position", "(", "hass", ",", "calls", ")", ":", "platform", "=", "getattr", "(", "hass", ".", "components", ",", "f\"test.{DOMAIN}\"", ")", "platform", ".", "init", "(", ")", "ent", "=", "platform", ".", "ENTITIES", "[", "1", "]"...
[ 450, 0 ]
[ 551, 72 ]
python
en
['en', 'en', 'en']
True
test_if_tilt_position
(hass, calls)
Test for tilt position conditions.
Test for tilt position conditions.
async def test_if_tilt_position(hass, calls): """Test for tilt position conditions.""" platform = getattr(hass.components, f"test.{DOMAIN}") platform.init() ent = platform.ENTITIES[2] assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "test"}}) await hass.async_block_till_...
[ "async", "def", "test_if_tilt_position", "(", "hass", ",", "calls", ")", ":", "platform", "=", "getattr", "(", "hass", ".", "components", ",", "f\"test.{DOMAIN}\"", ")", "platform", ".", "init", "(", ")", "ent", "=", "platform", ".", "ENTITIES", "[", "2", ...
[ 554, 0 ]
[ 655, 72 ]
python
en
['da', 'en', 'en']
True
load_data
()
Load dataset, use boston dataset
Load dataset, use boston dataset
def load_data(): '''Load dataset, use boston dataset''' boston = load_boston() X_train, X_test, y_train, y_test = train_test_split( boston.data, boston.target, random_state=99, test_size=0.25) #normalize data ss_X = StandardScaler() ss_y = StandardScaler() X_train = ss_X.fit_transfo...
[ "def", "load_data", "(", ")", ":", "boston", "=", "load_boston", "(", ")", "X_train", ",", "X_test", ",", "y_train", ",", "y_test", "=", "train_test_split", "(", "boston", ".", "data", ",", "boston", ".", "target", ",", "random_state", "=", "99", ",", ...
[ 32, 0 ]
[ 46, 43 ]
python
en
['es', 'zu', 'en']
False
get_default_parameters
()
get default parameters
get default parameters
def get_default_parameters(): '''get default parameters''' params = {'model_name': 'LinearRegression'} return params
[ "def", "get_default_parameters", "(", ")", ":", "params", "=", "{", "'model_name'", ":", "'LinearRegression'", "}", "return", "params" ]
[ 48, 0 ]
[ 51, 17 ]
python
fr
['fr', 'fr', 'en']
True
get_model
(PARAMS)
Get model according to parameters
Get model according to parameters
def get_model(PARAMS): '''Get model according to parameters''' model_dict = { 'LinearRegression': LinearRegression(), 'Ridge': Ridge(), 'Lars': Lars(), 'ARDRegression': ARDRegression() } if not model_dict.get(PARAMS['model_name']): LOG.exception('Not supported mo...
[ "def", "get_model", "(", "PARAMS", ")", ":", "model_dict", "=", "{", "'LinearRegression'", ":", "LinearRegression", "(", ")", ",", "'Ridge'", ":", "Ridge", "(", ")", ",", "'Lars'", ":", "Lars", "(", ")", ",", "'ARDRegression'", ":", "ARDRegression", "(", ...
[ 53, 0 ]
[ 69, 16 ]
python
en
['en', 'en', 'en']
True
run
(X_train, X_test, y_train, y_test, model)
Train model and predict result
Train model and predict result
def run(X_train, X_test, y_train, y_test, model): '''Train model and predict result''' model.fit(X_train, y_train) predict_y = model.predict(X_test) score = r2_score(y_test, predict_y) LOG.debug('r2 score: %s', score) nni.report_final_result(score)
[ "def", "run", "(", "X_train", ",", "X_test", ",", "y_train", ",", "y_test", ",", "model", ")", ":", "model", ".", "fit", "(", "X_train", ",", "y_train", ")", "predict_y", "=", "model", ".", "predict", "(", "X_test", ")", "score", "=", "r2_score", "("...
[ 71, 0 ]
[ 77, 34 ]
python
en
['en', 'it', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the platform for a Skybell device.
Set up the platform for a Skybell device.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the platform for a Skybell device.""" skybell = hass.data.get(SKYBELL_DOMAIN) sensors = [] for sensor_type in config.get(CONF_MONITORED_CONDITIONS): for device in skybell.get_devices(): sensors.append(Sky...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "skybell", "=", "hass", ".", "data", ".", "get", "(", "SKYBELL_DOMAIN", ")", "sensors", "=", "[", "]", "for", "sensor_type", "in", "co...
[ 36, 0 ]
[ 45, 31 ]
python
en
['en', 'en', 'en']
True
SkybellBinarySensor.__init__
(self, device, sensor_type)
Initialize a binary sensor for a Skybell device.
Initialize a binary sensor for a Skybell device.
def __init__(self, device, sensor_type): """Initialize a binary sensor for a Skybell device.""" super().__init__(device) self._sensor_type = sensor_type self._name = "{} {}".format( self._device.name, SENSOR_TYPES[self._sensor_type][0] ) self._device_class = S...
[ "def", "__init__", "(", "self", ",", "device", ",", "sensor_type", ")", ":", "super", "(", ")", ".", "__init__", "(", "device", ")", "self", ".", "_sensor_type", "=", "sensor_type", "self", ".", "_name", "=", "\"{} {}\"", ".", "format", "(", "self", "....
[ 51, 4 ]
[ 60, 26 ]
python
en
['en', 'en', 'en']
True
SkybellBinarySensor.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" ]
[ 63, 4 ]
[ 65, 25 ]
python
en
['en', 'mi', 'en']
True
SkybellBinarySensor.is_on
(self)
Return True if the binary sensor is on.
Return True if the binary sensor is on.
def is_on(self): """Return True if the binary sensor is on.""" return self._state
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 68, 4 ]
[ 70, 26 ]
python
en
['en', 'fy', 'en']
True
SkybellBinarySensor.device_class
(self)
Return the class of the binary sensor.
Return the class of the binary sensor.
def device_class(self): """Return the class of the binary sensor.""" return self._device_class
[ "def", "device_class", "(", "self", ")", ":", "return", "self", ".", "_device_class" ]
[ 73, 4 ]
[ 75, 33 ]
python
en
['en', 'tg', 'en']
True
SkybellBinarySensor.device_state_attributes
(self)
Return the state attributes.
Return the state attributes.
def device_state_attributes(self): """Return the state attributes.""" attrs = super().device_state_attributes attrs["event_date"] = self._event.get("createdAt") return attrs
[ "def", "device_state_attributes", "(", "self", ")", ":", "attrs", "=", "super", "(", ")", ".", "device_state_attributes", "attrs", "[", "\"event_date\"", "]", "=", "self", ".", "_event", ".", "get", "(", "\"createdAt\"", ")", "return", "attrs" ]
[ 78, 4 ]
[ 84, 20 ]
python
en
['en', 'en', 'en']
True
SkybellBinarySensor.update
(self)
Get the latest data and updates the state.
Get the latest data and updates the state.
def update(self): """Get the latest data and updates the state.""" super().update() event = self._device.latest(SENSOR_TYPES[self._sensor_type][2]) self._state = bool(event and event.get("id") != self._event.get("id")) self._event = event or {}
[ "def", "update", "(", "self", ")", ":", "super", "(", ")", ".", "update", "(", ")", "event", "=", "self", ".", "_device", ".", "latest", "(", "SENSOR_TYPES", "[", "self", ".", "_sensor_type", "]", "[", "2", "]", ")", "self", ".", "_state", "=", "...
[ 86, 4 ]
[ 94, 33 ]
python
en
['en', 'en', 'en']
True
async_setup_platform
( hass: HomeAssistantType, config: ConfigType, async_add_entities: Callable[[Sequence[Entity], bool], None], discovery_info: Optional[DiscoveryInfoType] = None, )
Initialize Light Switch platform.
Initialize Light Switch platform.
async def async_setup_platform( hass: HomeAssistantType, config: ConfigType, async_add_entities: Callable[[Sequence[Entity], bool], None], discovery_info: Optional[DiscoveryInfoType] = None, ) -> None: """Initialize Light Switch platform.""" registry = await hass.helpers.entity_registry.async_g...
[ "async", "def", "async_setup_platform", "(", "hass", ":", "HomeAssistantType", ",", "config", ":", "ConfigType", ",", "async_add_entities", ":", "Callable", "[", "[", "Sequence", "[", "Entity", "]", ",", "bool", "]", ",", "None", "]", ",", "discovery_info", ...
[ 36, 0 ]
[ 57, 5 ]
python
en
['en', 'pl', 'en']
True
LightSwitch.__init__
(self, name: str, switch_entity_id: str, unique_id: str)
Initialize Light Switch.
Initialize Light Switch.
def __init__(self, name: str, switch_entity_id: str, unique_id: str) -> None: """Initialize Light Switch.""" self._name = name self._switch_entity_id = switch_entity_id self._unique_id = unique_id self._is_on = False self._available = False self._async_unsub_state...
[ "def", "__init__", "(", "self", ",", "name", ":", "str", ",", "switch_entity_id", ":", "str", ",", "unique_id", ":", "str", ")", "->", "None", ":", "self", ".", "_name", "=", "name", "self", ".", "_switch_entity_id", "=", "switch_entity_id", "self", ".",...
[ 63, 4 ]
[ 70, 71 ]
python
en
['en', 'pl', 'en']
True
LightSwitch.name
(self)
Return the name of the entity.
Return the name of the entity.
def name(self) -> str: """Return the name of the entity.""" return self._name
[ "def", "name", "(", "self", ")", "->", "str", ":", "return", "self", ".", "_name" ]
[ 73, 4 ]
[ 75, 25 ]
python
en
['en', 'en', 'en']
True
LightSwitch.is_on
(self)
Return true if light switch is on.
Return true if light switch is on.
def is_on(self) -> bool: """Return true if light switch is on.""" return self._is_on
[ "def", "is_on", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "_is_on" ]
[ 78, 4 ]
[ 80, 26 ]
python
en
['en', 'fy', 'en']
True
LightSwitch.available
(self)
Return true if light switch is on.
Return true if light switch is on.
def available(self) -> bool: """Return true if light switch is on.""" return self._available
[ "def", "available", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "_available" ]
[ 83, 4 ]
[ 85, 30 ]
python
en
['en', 'fy', 'en']
True
LightSwitch.should_poll
(self)
No polling needed for a light switch.
No polling needed for a light switch.
def should_poll(self) -> bool: """No polling needed for a light switch.""" return False
[ "def", "should_poll", "(", "self", ")", "->", "bool", ":", "return", "False" ]
[ 88, 4 ]
[ 90, 20 ]
python
en
['en', 'en', 'en']
True
LightSwitch.unique_id
(self)
Return the unique id of the light switch.
Return the unique id of the light switch.
def unique_id(self): """Return the unique id of the light switch.""" return self._unique_id
[ "def", "unique_id", "(", "self", ")", ":", "return", "self", ".", "_unique_id" ]
[ 93, 4 ]
[ 95, 30 ]
python
en
['en', 'en', 'en']
True
LightSwitch.async_turn_on
(self, **kwargs)
Forward the turn_on command to the switch in this light switch.
Forward the turn_on command to the switch in this light switch.
async def async_turn_on(self, **kwargs): """Forward the turn_on command to the switch in this light switch.""" data = {ATTR_ENTITY_ID: self._switch_entity_id} await self.hass.services.async_call( switch.DOMAIN, switch.SERVICE_TURN_ON, data, blockin...
[ "async", "def", "async_turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "data", "=", "{", "ATTR_ENTITY_ID", ":", "self", ".", "_switch_entity_id", "}", "await", "self", ".", "hass", ".", "services", ".", "async_call", "(", "switch", ".", "DOMAIN...
[ 97, 4 ]
[ 106, 9 ]
python
en
['en', 'en', 'en']
True
LightSwitch.async_turn_off
(self, **kwargs)
Forward the turn_off command to the switch in this light switch.
Forward the turn_off command to the switch in this light switch.
async def async_turn_off(self, **kwargs): """Forward the turn_off command to the switch in this light switch.""" data = {ATTR_ENTITY_ID: self._switch_entity_id} await self.hass.services.async_call( switch.DOMAIN, switch.SERVICE_TURN_OFF, data, bloc...
[ "async", "def", "async_turn_off", "(", "self", ",", "*", "*", "kwargs", ")", ":", "data", "=", "{", "ATTR_ENTITY_ID", ":", "self", ".", "_switch_entity_id", "}", "await", "self", ".", "hass", ".", "services", ".", "async_call", "(", "switch", ".", "DOMAI...
[ 108, 4 ]
[ 117, 9 ]
python
en
['en', 'en', 'en']
True
LightSwitch.async_update
(self)
Query the switch in this light switch and determine the state.
Query the switch in this light switch and determine the state.
async def async_update(self): """Query the switch in this light switch and determine the state.""" switch_state = self.hass.states.get(self._switch_entity_id) if switch_state is None: self._available = False return self._is_on = switch_state.state == STATE_ON ...
[ "async", "def", "async_update", "(", "self", ")", ":", "switch_state", "=", "self", ".", "hass", ".", "states", ".", "get", "(", "self", ".", "_switch_entity_id", ")", "if", "switch_state", "is", "None", ":", "self", ".", "_available", "=", "False", "ret...
[ 119, 4 ]
[ 128, 65 ]
python
en
['en', 'en', 'en']
True
LightSwitch.async_added_to_hass
(self)
Register callbacks.
Register callbacks.
async def async_added_to_hass(self) -> None: """Register callbacks.""" @callback def async_state_changed_listener(*_: Any) -> None: """Handle child updates.""" self.async_schedule_update_ha_state(True) assert self.hass is not None self._async_unsub_state...
[ "async", "def", "async_added_to_hass", "(", "self", ")", "->", "None", ":", "@", "callback", "def", "async_state_changed_listener", "(", "*", "_", ":", "Any", ")", "->", "None", ":", "\"\"\"Handle child updates.\"\"\"", "self", ".", "async_schedule_update_ha_state",...
[ 130, 4 ]
[ 141, 9 ]
python
en
['en', 'no', 'en']
False
LightSwitch.async_will_remove_from_hass
(self)
Handle removal from Home Assistant.
Handle removal from Home Assistant.
async def async_will_remove_from_hass(self): """Handle removal from Home Assistant.""" if self._async_unsub_state_changed is not None: self._async_unsub_state_changed() self._async_unsub_state_changed = None self._available = False
[ "async", "def", "async_will_remove_from_hass", "(", "self", ")", ":", "if", "self", ".", "_async_unsub_state_changed", "is", "not", "None", ":", "self", ".", "_async_unsub_state_changed", "(", ")", "self", ".", "_async_unsub_state_changed", "=", "None", "self", "....
[ 143, 4 ]
[ 148, 35 ]
python
en
['en', 'en', 'en']
True
device_reg
(hass)
Return an empty, loaded, registry.
Return an empty, loaded, registry.
def device_reg(hass): """Return an empty, loaded, registry.""" return mock_device_registry(hass)
[ "def", "device_reg", "(", "hass", ")", ":", "return", "mock_device_registry", "(", "hass", ")" ]
[ 24, 0 ]
[ 26, 37 ]
python
en
['en', 'fy', 'en']
True
entity_reg
(hass)
Return an empty, loaded, registry.
Return an empty, loaded, registry.
def entity_reg(hass): """Return an empty, loaded, registry.""" return mock_registry(hass)
[ "def", "entity_reg", "(", "hass", ")", ":", "return", "mock_registry", "(", "hass", ")" ]
[ 30, 0 ]
[ 32, 30 ]
python
en
['en', 'fy', 'en']
True
calls
(hass)
Track calls to a mock service.
Track calls to a mock service.
def calls(hass): """Track calls to a mock service.""" return async_mock_service(hass, "test", "automation")
[ "def", "calls", "(", "hass", ")", ":", "return", "async_mock_service", "(", "hass", ",", "\"test\"", ",", "\"automation\"", ")" ]
[ 36, 0 ]
[ 38, 57 ]
python
en
['en', 'en', 'en']
True
test_get_triggers
(hass, device_reg, entity_reg)
Test we get the expected triggers from a switch.
Test we get the expected triggers from a switch.
async def test_get_triggers(hass, device_reg, entity_reg): """Test we get the expected triggers from a switch.""" config_entry = MockConfigEntry(domain="test", data={}) config_entry.add_to_hass(hass) device_entry = device_reg.async_get_or_create( config_entry_id=config_entry.entry_id, co...
[ "async", "def", "test_get_triggers", "(", "hass", ",", "device_reg", ",", "entity_reg", ")", ":", "config_entry", "=", "MockConfigEntry", "(", "domain", "=", "\"test\"", ",", "data", "=", "{", "}", ")", "config_entry", ".", "add_to_hass", "(", "hass", ")", ...
[ 41, 0 ]
[ 67, 40 ]
python
en
['en', 'en', 'en']
True
test_get_trigger_capabilities
(hass, device_reg, entity_reg)
Test we get the expected capabilities from a switch trigger.
Test we get the expected capabilities from a switch trigger.
async def test_get_trigger_capabilities(hass, device_reg, entity_reg): """Test we get the expected capabilities from a switch trigger.""" config_entry = MockConfigEntry(domain="test", data={}) config_entry.add_to_hass(hass) device_entry = device_reg.async_get_or_create( config_entry_id=config_en...
[ "async", "def", "test_get_trigger_capabilities", "(", "hass", ",", "device_reg", ",", "entity_reg", ")", ":", "config_entry", "=", "MockConfigEntry", "(", "domain", "=", "\"test\"", ",", "data", "=", "{", "}", ")", "config_entry", ".", "add_to_hass", "(", "has...
[ 70, 0 ]
[ 89, 52 ]
python
en
['en', 'en', 'en']
True
test_if_fires_on_state_change
(hass, calls)
Test for turn_on and turn_off triggers firing.
Test for turn_on and turn_off triggers firing.
async def test_if_fires_on_state_change(hass, calls): """Test for turn_on and turn_off triggers firing.""" platform = getattr(hass.components, f"test.{DOMAIN}") platform.init() assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "test"}}) await hass.async_block_till_done() ...
[ "async", "def", "test_if_fires_on_state_change", "(", "hass", ",", "calls", ")", ":", "platform", "=", "getattr", "(", "hass", ".", "components", ",", "f\"test.{DOMAIN}\"", ")", "platform", ".", "init", "(", ")", "assert", "await", "async_setup_component", "(", ...
[ 92, 0 ]
[ 174, 5 ]
python
en
['en', 'en', 'en']
True
test_if_fires_on_state_change_with_for
(hass, calls)
Test for triggers firing with delay.
Test for triggers firing with delay.
async def test_if_fires_on_state_change_with_for(hass, calls): """Test for triggers firing with delay.""" platform = getattr(hass.components, f"test.{DOMAIN}") platform.init() assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "test"}}) await hass.async_block_till_done() ...
[ "async", "def", "test_if_fires_on_state_change_with_for", "(", "hass", ",", "calls", ")", ":", "platform", "=", "getattr", "(", "hass", ".", "components", ",", "f\"test.{DOMAIN}\"", ")", "platform", ".", "init", "(", ")", "assert", "await", "async_setup_component"...
[ 177, 0 ]
[ 233, 5 ]
python
en
['en', 'en', 'en']
True
async_setup_platform
( hass, hass_config, async_add_entities, discovery_info=None )
Setups the LCN cover platform.
Setups the LCN cover platform.
async def async_setup_platform( hass, hass_config, async_add_entities, discovery_info=None ): """Setups the LCN cover platform.""" if discovery_info is None: return devices = [] for config in discovery_info: address, connection_id = config[CONF_ADDRESS] addr = pypck.lcn_addr...
[ "async", "def", "async_setup_platform", "(", "hass", ",", "hass_config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "if", "discovery_info", "is", "None", ":", "return", "devices", "=", "[", "]", "for", "config", "in", "discovery_i...
[ 11, 0 ]
[ 31, 31 ]
python
en
['en', 'da', 'en']
True
LcnOutputsCover.__init__
(self, config, address_connection)
Initialize the LCN cover.
Initialize the LCN cover.
def __init__(self, config, address_connection): """Initialize the LCN cover.""" super().__init__(config, address_connection) self.output_ids = [ pypck.lcn_defs.OutputPort["OUTPUTUP"].value, pypck.lcn_defs.OutputPort["OUTPUTDOWN"].value, ] if CONF_REVERSE_...
[ "def", "__init__", "(", "self", ",", "config", ",", "address_connection", ")", ":", "super", "(", ")", ".", "__init__", "(", "config", ",", "address_connection", ")", "self", ".", "output_ids", "=", "[", "pypck", ".", "lcn_defs", ".", "OutputPort", "[", ...
[ 37, 4 ]
[ 54, 32 ]
python
en
['en', 'en', 'en']
True
LcnOutputsCover.async_added_to_hass
(self)
Run when entity about to be added to hass.
Run when entity about to be added to hass.
async def async_added_to_hass(self): """Run when entity about to be added to hass.""" await super().async_added_to_hass() await self.address_connection.activate_status_request_handler( pypck.lcn_defs.OutputPort["OUTPUTUP"] ) await self.address_connection.activate_stat...
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "await", "super", "(", ")", ".", "async_added_to_hass", "(", ")", "await", "self", ".", "address_connection", ".", "activate_status_request_handler", "(", "pypck", ".", "lcn_defs", ".", "OutputPort", ...
[ 56, 4 ]
[ 64, 9 ]
python
en
['en', 'en', 'en']
True
LcnOutputsCover.is_closed
(self)
Return if the cover is closed.
Return if the cover is closed.
def is_closed(self): """Return if the cover is closed.""" return self._is_closed
[ "def", "is_closed", "(", "self", ")", ":", "return", "self", ".", "_is_closed" ]
[ 67, 4 ]
[ 69, 30 ]
python
en
['en', 'en', 'en']
True
LcnOutputsCover.is_opening
(self)
Return if the cover is opening or not.
Return if the cover is opening or not.
def is_opening(self): """Return if the cover is opening or not.""" return self._is_opening
[ "def", "is_opening", "(", "self", ")", ":", "return", "self", ".", "_is_opening" ]
[ 72, 4 ]
[ 74, 31 ]
python
en
['en', 'en', 'en']
True
LcnOutputsCover.is_closing
(self)
Return if the cover is closing or not.
Return if the cover is closing or not.
def is_closing(self): """Return if the cover is closing or not.""" return self._is_closing
[ "def", "is_closing", "(", "self", ")", ":", "return", "self", ".", "_is_closing" ]
[ 77, 4 ]
[ 79, 31 ]
python
en
['en', 'en', 'en']
True