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
test_color_rgb_to_int
()
Test RGB to integer conversion.
Test RGB to integer conversion.
def test_color_rgb_to_int(): """Test RGB to integer conversion.""" assert everlights.color_rgb_to_int(0x00, 0x00, 0x00) == 0x000000 assert everlights.color_rgb_to_int(0xFF, 0xFF, 0xFF) == 0xFFFFFF assert everlights.color_rgb_to_int(0x12, 0x34, 0x56) == 0x123456
[ "def", "test_color_rgb_to_int", "(", ")", ":", "assert", "everlights", ".", "color_rgb_to_int", "(", "0x00", ",", "0x00", ",", "0x00", ")", "==", "0x000000", "assert", "everlights", ".", "color_rgb_to_int", "(", "0xFF", ",", "0xFF", ",", "0xFF", ")", "==", ...
[ 4, 0 ]
[ 8, 68 ]
python
en
['en', 'en', 'en']
True
test_int_to_rgb
()
Test integer to RGB conversion.
Test integer to RGB conversion.
def test_int_to_rgb(): """Test integer to RGB conversion.""" assert everlights.color_int_to_rgb(0x000000) == (0x00, 0x00, 0x00) assert everlights.color_int_to_rgb(0xFFFFFF) == (0xFF, 0xFF, 0xFF) assert everlights.color_int_to_rgb(0x123456) == (0x12, 0x34, 0x56)
[ "def", "test_int_to_rgb", "(", ")", ":", "assert", "everlights", ".", "color_int_to_rgb", "(", "0x000000", ")", "==", "(", "0x00", ",", "0x00", ",", "0x00", ")", "assert", "everlights", ".", "color_int_to_rgb", "(", "0xFFFFFF", ")", "==", "(", "0xFF", ",",...
[ 11, 0 ]
[ 15, 70 ]
python
en
['en', 'en', 'en']
True
setup
(hass, config)
Set up the Nextcloud integration.
Set up the Nextcloud integration.
def setup(hass, config): """Set up the Nextcloud integration.""" # Fetch Nextcloud Monitor api data conf = config[DOMAIN] try: ncm = NextcloudMonitor(conf[CONF_URL], conf[CONF_USERNAME], conf[CONF_PASSWORD]) except NextcloudMonitorError: _LOGGER.error("Nextcloud setup failed - Check...
[ "def", "setup", "(", "hass", ",", "config", ")", ":", "# Fetch Nextcloud Monitor api data", "conf", "=", "config", "[", "DOMAIN", "]", "try", ":", "ncm", "=", "NextcloudMonitor", "(", "conf", "[", "CONF_URL", "]", ",", "conf", "[", "CONF_USERNAME", "]", ",...
[ 91, 0 ]
[ 121, 15 ]
python
en
['en', 'su', 'en']
True
get_data_points
(api_data, key_path="", leaf=False)
Use Recursion to discover data-points and values. Get dictionary of data-points by recursing through dict returned by api until the dictionary value does not contain another dictionary and use the resulting path of dictionary keys and resulting value as the name/value for the data-point. returns: ...
Use Recursion to discover data-points and values.
def get_data_points(api_data, key_path="", leaf=False): """Use Recursion to discover data-points and values. Get dictionary of data-points by recursing through dict returned by api until the dictionary value does not contain another dictionary and use the resulting path of dictionary keys and resulting...
[ "def", "get_data_points", "(", "api_data", ",", "key_path", "=", "\"\"", ",", "leaf", "=", "False", ")", ":", "result", "=", "{", "}", "for", "key", ",", "value", "in", "api_data", ".", "items", "(", ")", ":", "if", "isinstance", "(", "value", ",", ...
[ 125, 0 ]
[ 147, 17 ]
python
en
['en', 'en', 'en']
True
SPOSSupernetTrainingMutator.sample_search
(self)
Sample a candidate for training. When `flops_func` is not None, candidates will be sampled uniformly relative to flops. Returns ------- dict
Sample a candidate for training. When `flops_func` is not None, candidates will be sampled uniformly relative to flops.
def sample_search(self): """ Sample a candidate for training. When `flops_func` is not None, candidates will be sampled uniformly relative to flops. Returns ------- dict """ if self._flops_func is not None: for times in range(self._flops_sampl...
[ "def", "sample_search", "(", "self", ")", ":", "if", "self", ".", "_flops_func", "is", "not", "None", ":", "for", "times", "in", "range", "(", "self", ".", "_flops_sample_timeout", ")", ":", "idx", "=", "np", ".", "random", ".", "randint", "(", "self",...
[ 42, 4 ]
[ 59, 38 ]
python
en
['en', 'error', 'th']
False
SPOSSupernetTrainingMutator.sample_final
(self)
Implement only to suffice the interface of Mutator.
Implement only to suffice the interface of Mutator.
def sample_final(self): """ Implement only to suffice the interface of Mutator. """ return self.sample_search()
[ "def", "sample_final", "(", "self", ")", ":", "return", "self", ".", "sample_search", "(", ")" ]
[ 61, 4 ]
[ 65, 35 ]
python
en
['en', 'error', 'th']
False
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the Atome sensor.
Set up the Atome sensor.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Atome sensor.""" username = config[CONF_USERNAME] password = config[CONF_PASSWORD] try: atome_client = AtomeClient(username, password) atome_client.login() except PyAtomeError as exp: _LOGGER....
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "username", "=", "config", "[", "CONF_USERNAME", "]", "password", "=", "config", "[", "CONF_PASSWORD", "]", "try", ":", "atome_client", "=...
[ 53, 0 ]
[ 74, 31 ]
python
en
['en', 'pt', 'en']
True
AtomeData.__init__
(self, client: AtomeClient)
Initialize the data.
Initialize the data.
def __init__(self, client: AtomeClient): """Initialize the data.""" self.atome_client = client self._live_power = None self._subscribed_power = None self._is_connected = None self._day_usage = None self._day_price = None self._week_usage = None sel...
[ "def", "__init__", "(", "self", ",", "client", ":", "AtomeClient", ")", ":", "self", ".", "atome_client", "=", "client", "self", ".", "_live_power", "=", "None", "self", ".", "_subscribed_power", "=", "None", "self", ".", "_is_connected", "=", "None", "sel...
[ 80, 4 ]
[ 93, 31 ]
python
en
['en', 'en', 'en']
True
AtomeData.live_power
(self)
Return latest active power value.
Return latest active power value.
def live_power(self): """Return latest active power value.""" return self._live_power
[ "def", "live_power", "(", "self", ")", ":", "return", "self", ".", "_live_power" ]
[ 96, 4 ]
[ 98, 31 ]
python
en
['en', 'en', 'en']
True
AtomeData.subscribed_power
(self)
Return latest active power value.
Return latest active power value.
def subscribed_power(self): """Return latest active power value.""" return self._subscribed_power
[ "def", "subscribed_power", "(", "self", ")", ":", "return", "self", ".", "_subscribed_power" ]
[ 101, 4 ]
[ 103, 37 ]
python
en
['en', 'en', 'en']
True
AtomeData.is_connected
(self)
Return latest active power value.
Return latest active power value.
def is_connected(self): """Return latest active power value.""" return self._is_connected
[ "def", "is_connected", "(", "self", ")", ":", "return", "self", ".", "_is_connected" ]
[ 106, 4 ]
[ 108, 33 ]
python
en
['en', 'en', 'en']
True
AtomeData.update_live_usage
(self)
Return current power value.
Return current power value.
def update_live_usage(self): """Return current power value.""" try: values = self.atome_client.get_live() self._live_power = values["last"] self._subscribed_power = values["subscribed"] self._is_connected = values["isConnected"] _LOGGER.debug( ...
[ "def", "update_live_usage", "(", "self", ")", ":", "try", ":", "values", "=", "self", ".", "atome_client", ".", "get_live", "(", ")", "self", ".", "_live_power", "=", "values", "[", "\"last\"", "]", "self", ".", "_subscribed_power", "=", "values", "[", "...
[ 111, 4 ]
[ 126, 80 ]
python
en
['en', 'la', 'en']
True
AtomeData.day_usage
(self)
Return latest daily usage value.
Return latest daily usage value.
def day_usage(self): """Return latest daily usage value.""" return self._day_usage
[ "def", "day_usage", "(", "self", ")", ":", "return", "self", ".", "_day_usage" ]
[ 129, 4 ]
[ 131, 30 ]
python
en
['en', 'en', 'en']
True
AtomeData.day_price
(self)
Return latest daily usage value.
Return latest daily usage value.
def day_price(self): """Return latest daily usage value.""" return self._day_price
[ "def", "day_price", "(", "self", ")", ":", "return", "self", ".", "_day_price" ]
[ 134, 4 ]
[ 136, 30 ]
python
en
['en', 'en', 'en']
True
AtomeData.update_day_usage
(self)
Return current daily power usage.
Return current daily power usage.
def update_day_usage(self): """Return current daily power usage.""" try: values = self.atome_client.get_consumption(DAILY_TYPE) self._day_usage = values["total"] / 1000 self._day_price = values["price"] _LOGGER.debug("Updating Atome daily data. Got: %d", s...
[ "def", "update_day_usage", "(", "self", ")", ":", "try", ":", "values", "=", "self", ".", "atome_client", ".", "get_consumption", "(", "DAILY_TYPE", ")", "self", ".", "_day_usage", "=", "values", "[", "\"total\"", "]", "/", "1000", "self", ".", "_day_price...
[ 139, 4 ]
[ 148, 80 ]
python
en
['en', 'en', 'en']
True
AtomeData.week_usage
(self)
Return latest weekly usage value.
Return latest weekly usage value.
def week_usage(self): """Return latest weekly usage value.""" return self._week_usage
[ "def", "week_usage", "(", "self", ")", ":", "return", "self", ".", "_week_usage" ]
[ 151, 4 ]
[ 153, 31 ]
python
en
['en', 'et', 'en']
True
AtomeData.week_price
(self)
Return latest weekly usage value.
Return latest weekly usage value.
def week_price(self): """Return latest weekly usage value.""" return self._week_price
[ "def", "week_price", "(", "self", ")", ":", "return", "self", ".", "_week_price" ]
[ 156, 4 ]
[ 158, 31 ]
python
en
['en', 'et', 'en']
True
AtomeData.update_week_usage
(self)
Return current weekly power usage.
Return current weekly power usage.
def update_week_usage(self): """Return current weekly power usage.""" try: values = self.atome_client.get_consumption(WEEKLY_TYPE) self._week_usage = values["total"] / 1000 self._week_price = values["price"] _LOGGER.debug("Updating Atome weekly data. Got: ...
[ "def", "update_week_usage", "(", "self", ")", ":", "try", ":", "values", "=", "self", ".", "atome_client", ".", "get_consumption", "(", "WEEKLY_TYPE", ")", "self", ".", "_week_usage", "=", "values", "[", "\"total\"", "]", "/", "1000", "self", ".", "_week_p...
[ 161, 4 ]
[ 170, 80 ]
python
en
['en', 'en', 'en']
True
AtomeData.month_usage
(self)
Return latest monthly usage value.
Return latest monthly usage value.
def month_usage(self): """Return latest monthly usage value.""" return self._month_usage
[ "def", "month_usage", "(", "self", ")", ":", "return", "self", ".", "_month_usage" ]
[ 173, 4 ]
[ 175, 32 ]
python
en
['en', 'en', 'en']
True
AtomeData.month_price
(self)
Return latest monthly usage value.
Return latest monthly usage value.
def month_price(self): """Return latest monthly usage value.""" return self._month_price
[ "def", "month_price", "(", "self", ")", ":", "return", "self", ".", "_month_price" ]
[ 178, 4 ]
[ 180, 32 ]
python
en
['en', 'en', 'en']
True
AtomeData.update_month_usage
(self)
Return current monthly power usage.
Return current monthly power usage.
def update_month_usage(self): """Return current monthly power usage.""" try: values = self.atome_client.get_consumption(MONTHLY_TYPE) self._month_usage = values["total"] / 1000 self._month_price = values["price"] _LOGGER.debug("Updating Atome monthly data....
[ "def", "update_month_usage", "(", "self", ")", ":", "try", ":", "values", "=", "self", ".", "atome_client", ".", "get_consumption", "(", "MONTHLY_TYPE", ")", "self", ".", "_month_usage", "=", "values", "[", "\"total\"", "]", "/", "1000", "self", ".", "_mon...
[ 183, 4 ]
[ 192, 80 ]
python
en
['en', 'en', 'en']
True
AtomeData.year_usage
(self)
Return latest yearly usage value.
Return latest yearly usage value.
def year_usage(self): """Return latest yearly usage value.""" return self._year_usage
[ "def", "year_usage", "(", "self", ")", ":", "return", "self", ".", "_year_usage" ]
[ 195, 4 ]
[ 197, 31 ]
python
en
['en', 'en', 'en']
True
AtomeData.year_price
(self)
Return latest yearly usage value.
Return latest yearly usage value.
def year_price(self): """Return latest yearly usage value.""" return self._year_price
[ "def", "year_price", "(", "self", ")", ":", "return", "self", ".", "_year_price" ]
[ 200, 4 ]
[ 202, 31 ]
python
en
['en', 'en', 'en']
True
AtomeData.update_year_usage
(self)
Return current yearly power usage.
Return current yearly power usage.
def update_year_usage(self): """Return current yearly power usage.""" try: values = self.atome_client.get_consumption(YEARLY_TYPE) self._year_usage = values["total"] / 1000 self._year_price = values["price"] _LOGGER.debug("Updating Atome yearly data. Got: ...
[ "def", "update_year_usage", "(", "self", ")", ":", "try", ":", "values", "=", "self", ".", "atome_client", ".", "get_consumption", "(", "YEARLY_TYPE", ")", "self", ".", "_year_usage", "=", "values", "[", "\"total\"", "]", "/", "1000", "self", ".", "_year_p...
[ 205, 4 ]
[ 214, 80 ]
python
en
['en', 'en', 'en']
True
AtomeSensor.__init__
(self, data, name, sensor_type)
Initialize the sensor.
Initialize the sensor.
def __init__(self, data, name, sensor_type): """Initialize the sensor.""" self._name = name self._data = data self._state = None self._attributes = {} self._sensor_type = sensor_type if sensor_type == LIVE_TYPE: self._unit_of_measurement = POWER_WATT...
[ "def", "__init__", "(", "self", ",", "data", ",", "name", ",", "sensor_type", ")", ":", "self", ".", "_name", "=", "name", "self", ".", "_data", "=", "data", "self", ".", "_state", "=", "None", "self", ".", "_attributes", "=", "{", "}", "self", "."...
[ 220, 4 ]
[ 232, 61 ]
python
en
['en', 'en', 'en']
True
AtomeSensor.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" ]
[ 235, 4 ]
[ 237, 25 ]
python
en
['en', 'mi', 'en']
True
AtomeSensor.state
(self)
Return the state of the sensor.
Return the state of the sensor.
def state(self): """Return the state of the sensor.""" return self._state
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 240, 4 ]
[ 242, 26 ]
python
en
['en', 'en', 'en']
True
AtomeSensor.device_state_attributes
(self)
Return the state attributes.
Return the state attributes.
def device_state_attributes(self): """Return the state attributes.""" return self._attributes
[ "def", "device_state_attributes", "(", "self", ")", ":", "return", "self", ".", "_attributes" ]
[ 245, 4 ]
[ 247, 31 ]
python
en
['en', 'en', 'en']
True
AtomeSensor.unit_of_measurement
(self)
Return the unit of measurement.
Return the unit of measurement.
def unit_of_measurement(self): """Return the unit of measurement.""" return self._unit_of_measurement
[ "def", "unit_of_measurement", "(", "self", ")", ":", "return", "self", ".", "_unit_of_measurement" ]
[ 250, 4 ]
[ 252, 40 ]
python
en
['en', 'la', 'en']
True
AtomeSensor.icon
(self)
Icon to use in the frontend, if any.
Icon to use in the frontend, if any.
def icon(self): """Icon to use in the frontend, if any.""" return ICON
[ "def", "icon", "(", "self", ")", ":", "return", "ICON" ]
[ 255, 4 ]
[ 257, 19 ]
python
en
['en', 'en', 'en']
True
AtomeSensor.device_class
(self)
Return the device class.
Return the device class.
def device_class(self): """Return the device class.""" return DEVICE_CLASS_POWER
[ "def", "device_class", "(", "self", ")", ":", "return", "DEVICE_CLASS_POWER" ]
[ 260, 4 ]
[ 262, 33 ]
python
en
['en', 'en', 'en']
True
AtomeSensor.update
(self)
Update device state.
Update device state.
def update(self): """Update device state.""" update_function = getattr(self._data, f"update_{self._sensor_type}_usage") update_function() if self._sensor_type == LIVE_TYPE: self._state = self._data.live_power self._attributes["subscribed_power"] = self._data.subs...
[ "def", "update", "(", "self", ")", ":", "update_function", "=", "getattr", "(", "self", ".", "_data", ",", "f\"update_{self._sensor_type}_usage\"", ")", "update_function", "(", ")", "if", "self", ".", "_sensor_type", "==", "LIVE_TYPE", ":", "self", ".", "_stat...
[ 264, 4 ]
[ 277, 13 ]
python
en
['fr', 'en', 'en']
True
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Set up a MJPEG IP Camera.
Set up a MJPEG IP Camera.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up a MJPEG IP Camera.""" filter_urllib3_logging() if discovery_info: config = PLATFORM_SCHEMA(discovery_info) async_add_entities([MjpegCamera(config)])
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "filter_urllib3_logging", "(", ")", "if", "discovery_info", ":", "config", "=", "PLATFORM_SCHEMA", "(", "discovery_info", "...
[ 51, 0 ]
[ 57, 45 ]
python
en
['en', 'cs', 'en']
True
filter_urllib3_logging
()
Filter header errors from urllib3 due to a urllib3 bug.
Filter header errors from urllib3 due to a urllib3 bug.
def filter_urllib3_logging(): """Filter header errors from urllib3 due to a urllib3 bug.""" urllib3_logger = logging.getLogger("urllib3.connectionpool") if not any(isinstance(x, NoHeaderErrorFilter) for x in urllib3_logger.filters): urllib3_logger.addFilter(NoHeaderErrorFilter())
[ "def", "filter_urllib3_logging", "(", ")", ":", "urllib3_logger", "=", "logging", ".", "getLogger", "(", "\"urllib3.connectionpool\"", ")", "if", "not", "any", "(", "isinstance", "(", "x", ",", "NoHeaderErrorFilter", ")", "for", "x", "in", "urllib3_logger", ".",...
[ 60, 0 ]
[ 64, 55 ]
python
en
['en', 'sv', 'en']
True
extract_image_from_mjpeg
(stream)
Take in a MJPEG stream object, return the jpg from it.
Take in a MJPEG stream object, return the jpg from it.
def extract_image_from_mjpeg(stream): """Take in a MJPEG stream object, return the jpg from it.""" data = b"" for chunk in stream: data += chunk jpg_end = data.find(b"\xff\xd9") if jpg_end == -1: continue jpg_start = data.find(b"\xff\xd8") if jpg_start...
[ "def", "extract_image_from_mjpeg", "(", "stream", ")", ":", "data", "=", "b\"\"", "for", "chunk", "in", "stream", ":", "data", "+=", "chunk", "jpg_end", "=", "data", ".", "find", "(", "b\"\\xff\\xd9\"", ")", "if", "jpg_end", "==", "-", "1", ":", "continu...
[ 67, 0 ]
[ 83, 44 ]
python
en
['en', 'fy', 'en']
True
MjpegCamera.__init__
(self, device_info)
Initialize a MJPEG camera.
Initialize a MJPEG camera.
def __init__(self, device_info): """Initialize a MJPEG camera.""" super().__init__() self._name = device_info.get(CONF_NAME) self._authentication = device_info.get(CONF_AUTHENTICATION) self._username = device_info.get(CONF_USERNAME) self._password = device_info.get(CONF_P...
[ "def", "__init__", "(", "self", ",", "device_info", ")", ":", "super", "(", ")", ".", "__init__", "(", ")", "self", ".", "_name", "=", "device_info", ".", "get", "(", "CONF_NAME", ")", "self", ".", "_authentication", "=", "device_info", ".", "get", "("...
[ 89, 4 ]
[ 103, 59 ]
python
cs
['en', 'cs', 'it']
False
MjpegCamera.async_camera_image
(self)
Return a still image response from the camera.
Return a still image response from the camera.
async def async_camera_image(self): """Return a still image response from the camera.""" # DigestAuth is not supported if ( self._authentication == HTTP_DIGEST_AUTHENTICATION or self._still_image_url is None ): image = await self.hass.async_add_executo...
[ "async", "def", "async_camera_image", "(", "self", ")", ":", "# DigestAuth is not supported", "if", "(", "self", ".", "_authentication", "==", "HTTP_DIGEST_AUTHENTICATION", "or", "self", ".", "_still_image_url", "is", "None", ")", ":", "image", "=", "await", "self...
[ 105, 4 ]
[ 127, 88 ]
python
en
['en', 'en', 'en']
True
MjpegCamera.camera_image
(self)
Return a still image response from the camera.
Return a still image response from the camera.
def camera_image(self): """Return a still image response from the camera.""" if self._username and self._password: if self._authentication == HTTP_DIGEST_AUTHENTICATION: auth = HTTPDigestAuth(self._username, self._password) else: auth = HTTPBasicAu...
[ "def", "camera_image", "(", "self", ")", ":", "if", "self", ".", "_username", "and", "self", ".", "_password", ":", "if", "self", ".", "_authentication", "==", "HTTP_DIGEST_AUTHENTICATION", ":", "auth", "=", "HTTPDigestAuth", "(", "self", ".", "_username", "...
[ 129, 4 ]
[ 149, 74 ]
python
en
['en', 'en', 'en']
True
MjpegCamera.handle_async_mjpeg_stream
(self, request)
Generate an HTTP MJPEG stream from the camera.
Generate an HTTP MJPEG stream from the camera.
async def handle_async_mjpeg_stream(self, request): """Generate an HTTP MJPEG stream from the camera.""" # aiohttp don't support DigestAuth -> Fallback if self._authentication == HTTP_DIGEST_AUTHENTICATION: return await super().handle_async_mjpeg_stream(request) # connect to...
[ "async", "def", "handle_async_mjpeg_stream", "(", "self", ",", "request", ")", ":", "# aiohttp don't support DigestAuth -> Fallback", "if", "self", ".", "_authentication", "==", "HTTP_DIGEST_AUTHENTICATION", ":", "return", "await", "super", "(", ")", ".", "handle_async_...
[ 151, 4 ]
[ 161, 77 ]
python
en
['en', 'en', 'en']
True
MjpegCamera.name
(self)
Return the name of this camera.
Return the name of this camera.
def name(self): """Return the name of this camera.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 164, 4 ]
[ 166, 25 ]
python
en
['en', 'en', 'en']
True
NoHeaderErrorFilter.filter
(self, record)
Filter out Header Parsing Errors.
Filter out Header Parsing Errors.
def filter(self, record): """Filter out Header Parsing Errors.""" return "Failed to parse headers" not in record.getMessage()
[ "def", "filter", "(", "self", ",", "record", ")", ":", "return", "\"Failed to parse headers\"", "not", "in", "record", ".", "getMessage", "(", ")" ]
[ 172, 4 ]
[ 174, 67 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
( hass: HomeAssistant, entry: ConfigEntry, async_add_entities )
Set up the Tado water heater platform.
Set up the Tado water heater platform.
async def async_setup_entry( hass: HomeAssistant, entry: ConfigEntry, async_add_entities ): """Set up the Tado water heater platform.""" tado = hass.data[DOMAIN][entry.entry_id][DATA] entities = await hass.async_add_executor_job(_generate_entities, tado) platform = entity_platform.current_platform...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ",", "async_add_entities", ")", ":", "tado", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "entry", ".", "entry_id", "]", "[", "DATA", "]", "en...
[ 62, 0 ]
[ 79, 42 ]
python
en
['en', 'lv', 'en']
True
_generate_entities
(tado)
Create all water heater entities.
Create all water heater entities.
def _generate_entities(tado): """Create all water heater entities.""" entities = [] for zone in tado.zones: if zone["type"] == TYPE_HOT_WATER: entity = create_water_heater_entity(tado, zone["name"], zone["id"], zone) entities.append(entity) return entities
[ "def", "_generate_entities", "(", "tado", ")", ":", "entities", "=", "[", "]", "for", "zone", "in", "tado", ".", "zones", ":", "if", "zone", "[", "\"type\"", "]", "==", "TYPE_HOT_WATER", ":", "entity", "=", "create_water_heater_entity", "(", "tado", ",", ...
[ 82, 0 ]
[ 91, 19 ]
python
en
['en', 'en', 'en']
True
create_water_heater_entity
(tado, name: str, zone_id: int, zone: str)
Create a Tado water heater device.
Create a Tado water heater device.
def create_water_heater_entity(tado, name: str, zone_id: int, zone: str): """Create a Tado water heater device.""" capabilities = tado.get_capabilities(zone_id) supports_temperature_control = capabilities["canSetTemperature"] if supports_temperature_control and "temperatures" in capabilities: ...
[ "def", "create_water_heater_entity", "(", "tado", ",", "name", ":", "str", ",", "zone_id", ":", "int", ",", "zone", ":", "str", ")", ":", "capabilities", "=", "tado", ".", "get_capabilities", "(", "zone_id", ")", "supports_temperature_control", "=", "capabilit...
[ 94, 0 ]
[ 118, 17 ]
python
en
['es', 'ro', 'en']
False
TadoWaterHeater.__init__
( self, tado, zone_name, zone_id, supports_temperature_control, min_temp, max_temp, device_info, )
Initialize of Tado water heater entity.
Initialize of Tado water heater entity.
def __init__( self, tado, zone_name, zone_id, supports_temperature_control, min_temp, max_temp, device_info, ): """Initialize of Tado water heater entity.""" self._tado = tado super().__init__(zone_name, device_info, tado.devic...
[ "def", "__init__", "(", "self", ",", "tado", ",", "zone_name", ",", "zone_id", ",", "supports_temperature_control", ",", "min_temp", ",", "max_temp", ",", "device_info", ",", ")", ":", "self", ".", "_tado", "=", "tado", "super", "(", ")", ".", "__init__", ...
[ 124, 4 ]
[ 156, 35 ]
python
en
['en', 'en', 'en']
True
TadoWaterHeater.async_added_to_hass
(self)
Register for sensor updates.
Register for sensor updates.
async def async_added_to_hass(self): """Register for sensor updates.""" self.async_on_remove( async_dispatcher_connect( self.hass, SIGNAL_TADO_UPDATE_RECEIVED.format( self._tado.device_id, "zone", self.zone_id ), ...
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "self", ".", "async_on_remove", "(", "async_dispatcher_connect", "(", "self", ".", "hass", ",", "SIGNAL_TADO_UPDATE_RECEIVED", ".", "format", "(", "self", ".", "_tado", ".", "device_id", ",", "\"zone\...
[ 158, 4 ]
[ 170, 33 ]
python
da
['da', 'no', 'en']
False
TadoWaterHeater.supported_features
(self)
Return the list of supported features.
Return the list of supported features.
def supported_features(self): """Return the list of supported features.""" return self._supported_features
[ "def", "supported_features", "(", "self", ")", ":", "return", "self", ".", "_supported_features" ]
[ 173, 4 ]
[ 175, 39 ]
python
en
['en', 'en', 'en']
True
TadoWaterHeater.name
(self)
Return the name of the entity.
Return the name of the entity.
def name(self): """Return the name of the entity.""" return self.zone_name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "zone_name" ]
[ 178, 4 ]
[ 180, 29 ]
python
en
['en', 'en', 'en']
True
TadoWaterHeater.unique_id
(self)
Return the unique id.
Return the unique id.
def unique_id(self): """Return the unique id.""" return self._unique_id
[ "def", "unique_id", "(", "self", ")", ":", "return", "self", ".", "_unique_id" ]
[ 183, 4 ]
[ 185, 30 ]
python
en
['en', 'la', 'en']
True
TadoWaterHeater.current_operation
(self)
Return current readable operation mode.
Return current readable operation mode.
def current_operation(self): """Return current readable operation mode.""" return WATER_HEATER_MAP_TADO.get(self._current_tado_hvac_mode)
[ "def", "current_operation", "(", "self", ")", ":", "return", "WATER_HEATER_MAP_TADO", ".", "get", "(", "self", ".", "_current_tado_hvac_mode", ")" ]
[ 188, 4 ]
[ 190, 70 ]
python
en
['vo', 'en', 'en']
True
TadoWaterHeater.target_temperature
(self)
Return the temperature we try to reach.
Return the temperature we try to reach.
def target_temperature(self): """Return the temperature we try to reach.""" return self._tado_zone_data.target_temp
[ "def", "target_temperature", "(", "self", ")", ":", "return", "self", ".", "_tado_zone_data", ".", "target_temp" ]
[ 193, 4 ]
[ 195, 47 ]
python
en
['en', 'en', 'en']
True
TadoWaterHeater.is_away_mode_on
(self)
Return true if away mode is on.
Return true if away mode is on.
def is_away_mode_on(self): """Return true if away mode is on.""" return self._tado_zone_data.is_away
[ "def", "is_away_mode_on", "(", "self", ")", ":", "return", "self", ".", "_tado_zone_data", ".", "is_away" ]
[ 198, 4 ]
[ 200, 43 ]
python
en
['en', 'fy', 'en']
True
TadoWaterHeater.operation_list
(self)
Return the list of available operation modes (readable).
Return the list of available operation modes (readable).
def operation_list(self): """Return the list of available operation modes (readable).""" return OPERATION_MODES
[ "def", "operation_list", "(", "self", ")", ":", "return", "OPERATION_MODES" ]
[ 203, 4 ]
[ 205, 30 ]
python
en
['en', 'en', 'en']
True
TadoWaterHeater.temperature_unit
(self)
Return the unit of measurement used by the platform.
Return the unit of measurement used by the platform.
def temperature_unit(self): """Return the unit of measurement used by the platform.""" return TEMP_CELSIUS
[ "def", "temperature_unit", "(", "self", ")", ":", "return", "TEMP_CELSIUS" ]
[ 208, 4 ]
[ 210, 27 ]
python
en
['en', 'en', 'en']
True
TadoWaterHeater.min_temp
(self)
Return the minimum temperature.
Return the minimum temperature.
def min_temp(self): """Return the minimum temperature.""" return self._min_temperature
[ "def", "min_temp", "(", "self", ")", ":", "return", "self", ".", "_min_temperature" ]
[ 213, 4 ]
[ 215, 36 ]
python
en
['en', 'la', 'en']
True
TadoWaterHeater.max_temp
(self)
Return the maximum temperature.
Return the maximum temperature.
def max_temp(self): """Return the maximum temperature.""" return self._max_temperature
[ "def", "max_temp", "(", "self", ")", ":", "return", "self", ".", "_max_temperature" ]
[ 218, 4 ]
[ 220, 36 ]
python
en
['en', 'la', 'en']
True
TadoWaterHeater.set_operation_mode
(self, operation_mode)
Set new operation mode.
Set new operation mode.
def set_operation_mode(self, operation_mode): """Set new operation mode.""" mode = None if operation_mode == MODE_OFF: mode = CONST_MODE_OFF elif operation_mode == MODE_AUTO: mode = CONST_MODE_SMART_SCHEDULE elif operation_mode == MODE_HEAT: m...
[ "def", "set_operation_mode", "(", "self", ",", "operation_mode", ")", ":", "mode", "=", "None", "if", "operation_mode", "==", "MODE_OFF", ":", "mode", "=", "CONST_MODE_OFF", "elif", "operation_mode", "==", "MODE_AUTO", ":", "mode", "=", "CONST_MODE_SMART_SCHEDULE"...
[ 222, 4 ]
[ 233, 44 ]
python
en
['en', 'ny', 'en']
True
TadoWaterHeater.set_timer
(self, time_period, temperature=None)
Set the timer on the entity, and temperature if supported.
Set the timer on the entity, and temperature if supported.
def set_timer(self, time_period, temperature=None): """Set the timer on the entity, and temperature if supported.""" if not self._supports_temperature_control and temperature is not None: temperature = None self._control_heater( hvac_mode=CONST_MODE_HEAT, target_temp=tem...
[ "def", "set_timer", "(", "self", ",", "time_period", ",", "temperature", "=", "None", ")", ":", "if", "not", "self", ".", "_supports_temperature_control", "and", "temperature", "is", "not", "None", ":", "temperature", "=", "None", "self", ".", "_control_heater...
[ 235, 4 ]
[ 242, 9 ]
python
en
['en', 'en', 'en']
True
TadoWaterHeater.set_temperature
(self, **kwargs)
Set new target temperature.
Set new target temperature.
def set_temperature(self, **kwargs): """Set new target temperature.""" temperature = kwargs.get(ATTR_TEMPERATURE) if not self._supports_temperature_control or temperature is None: return if self._current_tado_hvac_mode not in ( CONST_MODE_OFF, CONST_M...
[ "def", "set_temperature", "(", "self", ",", "*", "*", "kwargs", ")", ":", "temperature", "=", "kwargs", ".", "get", "(", "ATTR_TEMPERATURE", ")", "if", "not", "self", ".", "_supports_temperature_control", "or", "temperature", "is", "None", ":", "return", "if...
[ 244, 4 ]
[ 258, 80 ]
python
en
['en', 'ca', 'en']
True
TadoWaterHeater._async_update_callback
(self)
Load tado data and update state.
Load tado data and update state.
def _async_update_callback(self): """Load tado data and update state.""" self._async_update_data() self.async_write_ha_state()
[ "def", "_async_update_callback", "(", "self", ")", ":", "self", ".", "_async_update_data", "(", ")", "self", ".", "async_write_ha_state", "(", ")" ]
[ 261, 4 ]
[ 264, 35 ]
python
en
['pt', 'en', 'en']
True
TadoWaterHeater._async_update_data
(self)
Load tado data.
Load tado data.
def _async_update_data(self): """Load tado data.""" _LOGGER.debug("Updating water_heater platform for zone %d", self.zone_id) self._tado_zone_data = self._tado.data["zone"][self.zone_id] self._current_tado_hvac_mode = self._tado_zone_data.current_hvac_mode
[ "def", "_async_update_data", "(", "self", ")", ":", "_LOGGER", ".", "debug", "(", "\"Updating water_heater platform for zone %d\"", ",", "self", ".", "zone_id", ")", "self", ".", "_tado_zone_data", "=", "self", ".", "_tado", ".", "data", "[", "\"zone\"", "]", ...
[ 267, 4 ]
[ 271, 77 ]
python
pt
['pt', 'mg', 'pt']
True
TadoWaterHeater._control_heater
(self, hvac_mode=None, target_temp=None, duration=None)
Send new target temperature.
Send new target temperature.
def _control_heater(self, hvac_mode=None, target_temp=None, duration=None): """Send new target temperature.""" if hvac_mode: self._current_tado_hvac_mode = hvac_mode if target_temp: self._target_temp = target_temp # Set a target temperature if we don't have any...
[ "def", "_control_heater", "(", "self", ",", "hvac_mode", "=", "None", ",", "target_temp", "=", "None", ",", "duration", "=", "None", ")", ":", "if", "hvac_mode", ":", "self", ".", "_current_tado_hvac_mode", "=", "hvac_mode", "if", "target_temp", ":", "self",...
[ 273, 4 ]
[ 323, 57 ]
python
en
['en', 'la', 'en']
True
check_required_arg
(value)
Validate that the required "arg" for the sensor types that need it are set.
Validate that the required "arg" for the sensor types that need it are set.
def check_required_arg(value): """Validate that the required "arg" for the sensor types that need it are set.""" for sensor in value: sensor_type = sensor[CONF_TYPE] sensor_arg = sensor.get(CONF_ARG) if sensor_arg is None and SENSOR_TYPES[sensor_type][4]: raise vol.RequiredF...
[ "def", "check_required_arg", "(", "value", ")", ":", "for", "sensor", "in", "value", ":", "sensor_type", "=", "sensor", "[", "CONF_TYPE", "]", "sensor_arg", "=", "sensor", ".", "get", "(", "CONF_ARG", ")", "if", "sensor_arg", "is", "None", "and", "SENSOR_T...
[ 95, 0 ]
[ 106, 16 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the system monitor sensors.
Set up the system monitor sensors.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the system monitor sensors.""" dev = [] for resource in config[CONF_RESOURCES]: # Initialize the sensor argument if none was provided. # For disk monitoring default to "/" (root) to prevent runtime errors, if argu...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "dev", "=", "[", "]", "for", "resource", "in", "config", "[", "CONF_RESOURCES", "]", ":", "# Initialize the sensor argument if none was provided...
[ 160, 0 ]
[ 181, 27 ]
python
en
['en', 'en', 'en']
True
SystemMonitorSensor.__init__
(self, sensor_type, argument="")
Initialize the sensor.
Initialize the sensor.
def __init__(self, sensor_type, argument=""): """Initialize the sensor.""" self._name = "{} {}".format(SENSOR_TYPES[sensor_type][0], argument) self._unique_id = slugify(f"{sensor_type}_{argument}") self.argument = argument self.type = sensor_type self._state = None ...
[ "def", "__init__", "(", "self", ",", "sensor_type", ",", "argument", "=", "\"\"", ")", ":", "self", ".", "_name", "=", "\"{} {}\"", ".", "format", "(", "SENSOR_TYPES", "[", "sensor_type", "]", "[", "0", "]", ",", "argument", ")", "self", ".", "_unique_...
[ 187, 4 ]
[ 198, 41 ]
python
en
['en', 'en', 'en']
True
SystemMonitorSensor.name
(self)
Return the name of the sensor.
Return the name of the sensor.
def name(self): """Return the name of the sensor.""" return self._name.rstrip()
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name", ".", "rstrip", "(", ")" ]
[ 201, 4 ]
[ 203, 34 ]
python
en
['en', 'mi', 'en']
True
SystemMonitorSensor.unique_id
(self)
Return the unique ID.
Return the unique ID.
def unique_id(self): """Return the unique ID.""" return self._unique_id
[ "def", "unique_id", "(", "self", ")", ":", "return", "self", ".", "_unique_id" ]
[ 206, 4 ]
[ 208, 30 ]
python
en
['en', 'la', 'en']
True
SystemMonitorSensor.device_class
(self)
Return the class of this sensor.
Return the class of this sensor.
def device_class(self): """Return the class of this sensor.""" return SENSOR_TYPES[self.type][3]
[ "def", "device_class", "(", "self", ")", ":", "return", "SENSOR_TYPES", "[", "self", ".", "type", "]", "[", "3", "]" ]
[ 211, 4 ]
[ 213, 41 ]
python
en
['en', 'en', 'en']
True
SystemMonitorSensor.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 SENSOR_TYPES[self.type][2]
[ "def", "icon", "(", "self", ")", ":", "return", "SENSOR_TYPES", "[", "self", ".", "type", "]", "[", "2", "]" ]
[ 216, 4 ]
[ 218, 41 ]
python
en
['en', 'en', 'en']
True
SystemMonitorSensor.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" ]
[ 221, 4 ]
[ 223, 26 ]
python
en
['en', 'en', 'en']
True
SystemMonitorSensor.unit_of_measurement
(self)
Return the unit of measurement of this entity, if any.
Return the unit of measurement of this entity, if any.
def unit_of_measurement(self): """Return the unit of measurement of this entity, if any.""" return self._unit_of_measurement
[ "def", "unit_of_measurement", "(", "self", ")", ":", "return", "self", ".", "_unit_of_measurement" ]
[ 226, 4 ]
[ 228, 40 ]
python
en
['en', 'en', 'en']
True
SystemMonitorSensor.available
(self)
Return True if entity is available.
Return True if entity is available.
def available(self): """Return True if entity is available.""" return self._available
[ "def", "available", "(", "self", ")", ":", "return", "self", ".", "_available" ]
[ 231, 4 ]
[ 233, 30 ]
python
en
['en', 'en', 'en']
True
SystemMonitorSensor.update
(self)
Get the latest system information.
Get the latest system information.
def update(self): """Get the latest system information.""" if self.type == "disk_use_percent": self._state = psutil.disk_usage(self.argument).percent elif self.type == "disk_use": self._state = round(psutil.disk_usage(self.argument).used / 1024 ** 3, 1) elif self....
[ "def", "update", "(", "self", ")", ":", "if", "self", ".", "type", "==", "\"disk_use_percent\"", ":", "self", ".", "_state", "=", "psutil", ".", "disk_usage", "(", "self", ".", "argument", ")", ".", "percent", "elif", "self", ".", "type", "==", "\"disk...
[ 235, 4 ]
[ 326, 54 ]
python
en
['en', 'en', 'en']
True
SystemMonitorSensor.read_cpu_temperature
()
Attempt to read CPU / processor temperature.
Attempt to read CPU / processor temperature.
def read_cpu_temperature(): """Attempt to read CPU / processor temperature.""" temps = psutil.sensors_temperatures() for name, entries in temps.items(): i = 1 for entry in entries: # In case the label is empty (e.g. on Raspberry PI 4), # c...
[ "def", "read_cpu_temperature", "(", ")", ":", "temps", "=", "psutil", ".", "sensors_temperatures", "(", ")", "for", "name", ",", "entries", "in", "temps", ".", "items", "(", ")", ":", "i", "=", "1", "for", "entry", "in", "entries", ":", "# In case the la...
[ 329, 4 ]
[ 346, 22 ]
python
en
['en', 'it', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the Pilight platform.
Set up the Pilight platform.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Pilight platform.""" switches = config.get(CONF_LIGHTS) devices = [] for dev_name, dev_config in switches.items(): devices.append(PilightLight(hass, dev_name, dev_config)) add_entities(devices)
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "switches", "=", "config", ".", "get", "(", "CONF_LIGHTS", ")", "devices", "=", "[", "]", "for", "dev_name", ",", "dev_config", "in", ...
[ 27, 0 ]
[ 35, 25 ]
python
en
['en', 'lv', 'en']
True
PilightLight.__init__
(self, hass, name, config)
Initialize a switch.
Initialize a switch.
def __init__(self, hass, name, config): """Initialize a switch.""" super().__init__(hass, name, config) self._dimlevel_min = config.get(CONF_DIMLEVEL_MIN) self._dimlevel_max = config.get(CONF_DIMLEVEL_MAX)
[ "def", "__init__", "(", "self", ",", "hass", ",", "name", ",", "config", ")", ":", "super", "(", ")", ".", "__init__", "(", "hass", ",", "name", ",", "config", ")", "self", ".", "_dimlevel_min", "=", "config", ".", "get", "(", "CONF_DIMLEVEL_MIN", ")...
[ 41, 4 ]
[ 45, 58 ]
python
en
['en', 'pl', 'en']
True
PilightLight.brightness
(self)
Return the brightness.
Return the brightness.
def brightness(self): """Return the brightness.""" return self._brightness
[ "def", "brightness", "(", "self", ")", ":", "return", "self", ".", "_brightness" ]
[ 48, 4 ]
[ 50, 31 ]
python
en
['en', 'sn', 'en']
True
PilightLight.supported_features
(self)
Flag supported features.
Flag supported features.
def supported_features(self): """Flag supported features.""" return SUPPORT_BRIGHTNESS
[ "def", "supported_features", "(", "self", ")", ":", "return", "SUPPORT_BRIGHTNESS" ]
[ 53, 4 ]
[ 55, 33 ]
python
en
['da', 'en', 'en']
True
PilightLight.turn_on
(self, **kwargs)
Turn the switch on by calling pilight.send service with on code.
Turn the switch on by calling pilight.send service with on code.
def turn_on(self, **kwargs): """Turn the switch on by calling pilight.send service with on code.""" # Update brightness only if provided as an argument. # This will allow the switch to keep its previous brightness level. dimlevel = None if ATTR_BRIGHTNESS in kwargs: ...
[ "def", "turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "# Update brightness only if provided as an argument.", "# This will allow the switch to keep its previous brightness level.", "dimlevel", "=", "None", "if", "ATTR_BRIGHTNESS", "in", "kwargs", ":", "self", "....
[ 57, 4 ]
[ 75, 55 ]
python
en
['en', 'en', 'en']
True
train
(args, train_dataset, model, tokenizer)
Train the model
Train the model
def train(args, train_dataset, model, tokenizer): """ Train the model """ if args.local_rank in [-1, 0]: tb_writer = SummaryWriter() args.train_batch_size = args.per_gpu_train_batch_size * max(1, args.n_gpu) train_sampler = RandomSampler(train_dataset) if args.local_rank == -1 else DistributedS...
[ "def", "train", "(", "args", ",", "train_dataset", ",", "model", ",", "tokenizer", ")", ":", "if", "args", ".", "local_rank", "in", "[", "-", "1", ",", "0", "]", ":", "tb_writer", "=", "SummaryWriter", "(", ")", "args", ".", "train_batch_size", "=", ...
[ 72, 0 ]
[ 260, 45 ]
python
en
['en', 'it', 'en']
True
async_get_discoverable_devices
(hass)
Return if there are devices that can be discovered.
Return if there are devices that can be discovered.
async def async_get_discoverable_devices(hass): """Return if there are devices that can be discovered.""" def discover(): devs = Discover.discover() return devs return await hass.async_add_executor_job(discover)
[ "async", "def", "async_get_discoverable_devices", "(", "hass", ")", ":", "def", "discover", "(", ")", ":", "devs", "=", "Discover", ".", "discover", "(", ")", "return", "devs", "return", "await", "hass", ".", "async_add_executor_job", "(", "discover", ")" ]
[ 57, 0 ]
[ 64, 54 ]
python
en
['en', 'en', 'en']
True
async_discover_devices
( hass: HomeAssistantType, existing_devices: SmartDevices )
Get devices through discovery.
Get devices through discovery.
async def async_discover_devices( hass: HomeAssistantType, existing_devices: SmartDevices ) -> SmartDevices: """Get devices through discovery.""" _LOGGER.debug("Discovering devices") devices = await async_get_discoverable_devices(hass) _LOGGER.info("Discovered %s TP-Link smart home device(s)", len(d...
[ "async", "def", "async_discover_devices", "(", "hass", ":", "HomeAssistantType", ",", "existing_devices", ":", "SmartDevices", ")", "->", "SmartDevices", ":", "_LOGGER", ".", "debug", "(", "\"Discovering devices\"", ")", "devices", "=", "await", "async_get_discoverabl...
[ 67, 0 ]
[ 103, 41 ]
python
en
['en', 'en', 'en']
True
get_static_devices
(config_data)
Get statically defined devices in the config.
Get statically defined devices in the config.
def get_static_devices(config_data) -> SmartDevices: """Get statically defined devices in the config.""" _LOGGER.debug("Getting static devices") lights = [] switches = [] for type_ in [CONF_LIGHT, CONF_SWITCH, CONF_STRIP, CONF_DIMMER]: for entry in config_data[type_]: host = ent...
[ "def", "get_static_devices", "(", "config_data", ")", "->", "SmartDevices", ":", "_LOGGER", ".", "debug", "(", "\"Getting static devices\"", ")", "lights", "=", "[", "]", "switches", "=", "[", "]", "for", "type_", "in", "[", "CONF_LIGHT", ",", "CONF_SWITCH", ...
[ 106, 0 ]
[ 130, 41 ]
python
en
['en', 'en', 'en']
True
add_available_devices
(hass, device_type, device_class)
Get sysinfo for all devices.
Get sysinfo for all devices.
def add_available_devices(hass, device_type, device_class): """Get sysinfo for all devices.""" devices = hass.data[TPLINK_DOMAIN][device_type] if f"{device_type}_remaining" in hass.data[TPLINK_DOMAIN]: devices = hass.data[TPLINK_DOMAIN][f"{device_type}_remaining"] entities_ready = [] devi...
[ "def", "add_available_devices", "(", "hass", ",", "device_type", ",", "device_class", ")", ":", "devices", "=", "hass", ".", "data", "[", "TPLINK_DOMAIN", "]", "[", "device_type", "]", "if", "f\"{device_type}_remaining\"", "in", "hass", ".", "data", "[", "TPLI...
[ 133, 0 ]
[ 156, 25 ]
python
en
['en', 'en', 'en']
True
SmartDevices.__init__
( self, lights: List[SmartDevice] = None, switches: List[SmartDevice] = None )
Initialize device holder.
Initialize device holder.
def __init__( self, lights: List[SmartDevice] = None, switches: List[SmartDevice] = None ): """Initialize device holder.""" self._lights = lights or [] self._switches = switches or []
[ "def", "__init__", "(", "self", ",", "lights", ":", "List", "[", "SmartDevice", "]", "=", "None", ",", "switches", ":", "List", "[", "SmartDevice", "]", "=", "None", ")", ":", "self", ".", "_lights", "=", "lights", "or", "[", "]", "self", ".", "_sw...
[ 31, 4 ]
[ 36, 39 ]
python
en
['fr', 'en', 'en']
True
SmartDevices.lights
(self)
Get the lights.
Get the lights.
def lights(self): """Get the lights.""" return self._lights
[ "def", "lights", "(", "self", ")", ":", "return", "self", ".", "_lights" ]
[ 39, 4 ]
[ 41, 27 ]
python
en
['en', 'en', 'en']
True
SmartDevices.switches
(self)
Get the switches.
Get the switches.
def switches(self): """Get the switches.""" return self._switches
[ "def", "switches", "(", "self", ")", ":", "return", "self", ".", "_switches" ]
[ 44, 4 ]
[ 46, 29 ]
python
en
['en', 'en', 'en']
True
SmartDevices.has_device_with_host
(self, host)
Check if a devices exists with a specific host.
Check if a devices exists with a specific host.
def has_device_with_host(self, host): """Check if a devices exists with a specific host.""" for device in self.lights + self.switches: if device.host == host: return True return False
[ "def", "has_device_with_host", "(", "self", ",", "host", ")", ":", "for", "device", "in", "self", ".", "lights", "+", "self", ".", "switches", ":", "if", "device", ".", "host", "==", "host", ":", "return", "True", "return", "False" ]
[ 48, 4 ]
[ 54, 20 ]
python
en
['en', 'en', '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 switch_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", "switch_type", "in", "co...
[ 27, 0 ]
[ 36, 31 ]
python
en
['en', 'en', 'en']
True
SkybellSwitch.__init__
(self, device, switch_type)
Initialize a light for a Skybell device.
Initialize a light for a Skybell device.
def __init__(self, device, switch_type): """Initialize a light for a Skybell device.""" super().__init__(device) self._switch_type = switch_type self._name = "{} {}".format( self._device.name, SWITCH_TYPES[self._switch_type][0] )
[ "def", "__init__", "(", "self", ",", "device", ",", "switch_type", ")", ":", "super", "(", ")", ".", "__init__", "(", "device", ")", "self", ".", "_switch_type", "=", "switch_type", "self", ".", "_name", "=", "\"{} {}\"", ".", "format", "(", "self", "....
[ 42, 4 ]
[ 48, 9 ]
python
en
['en', 'en', 'en']
True
SkybellSwitch.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" ]
[ 51, 4 ]
[ 53, 25 ]
python
en
['en', 'mi', 'en']
True
SkybellSwitch.turn_on
(self, **kwargs)
Turn on the switch.
Turn on the switch.
def turn_on(self, **kwargs): """Turn on the switch.""" setattr(self._device, self._switch_type, True)
[ "def", "turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "setattr", "(", "self", ".", "_device", ",", "self", ".", "_switch_type", ",", "True", ")" ]
[ 55, 4 ]
[ 57, 54 ]
python
en
['en', 'en', 'en']
True
SkybellSwitch.turn_off
(self, **kwargs)
Turn off the switch.
Turn off the switch.
def turn_off(self, **kwargs): """Turn off the switch.""" setattr(self._device, self._switch_type, False)
[ "def", "turn_off", "(", "self", ",", "*", "*", "kwargs", ")", ":", "setattr", "(", "self", ".", "_device", ",", "self", ".", "_switch_type", ",", "False", ")" ]
[ 59, 4 ]
[ 61, 55 ]
python
en
['en', 'en', 'en']
True
SkybellSwitch.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 getattr(self._device, self._switch_type)
[ "def", "is_on", "(", "self", ")", ":", "return", "getattr", "(", "self", ".", "_device", ",", "self", ".", "_switch_type", ")" ]
[ 64, 4 ]
[ 66, 55 ]
python
en
['en', 'fy', 'en']
True
ceiling_fan
(name: str)
Create a ceiling fan with given name.
Create a ceiling fan with given name.
def ceiling_fan(name: str): """Create a ceiling fan with given name.""" return { "name": name, "type": DeviceType.CEILING_FAN, "actions": ["SetSpeed", "SetDirection"], }
[ "def", "ceiling_fan", "(", "name", ":", "str", ")", ":", "return", "{", "\"name\"", ":", "name", ",", "\"type\"", ":", "DeviceType", ".", "CEILING_FAN", ",", "\"actions\"", ":", "[", "\"SetSpeed\"", ",", "\"SetDirection\"", "]", ",", "}" ]
[ 33, 0 ]
[ 39, 5 ]
python
en
['en', 'en', 'en']
True
turn_fan_on
( hass: core.HomeAssistant, fan_id: str, speed: Optional[str] = None )
Turn the fan on at the specified speed.
Turn the fan on at the specified speed.
async def turn_fan_on( hass: core.HomeAssistant, fan_id: str, speed: Optional[str] = None ) -> None: """Turn the fan on at the specified speed.""" service_data = {ATTR_ENTITY_ID: fan_id} if speed: service_data[fan.ATTR_SPEED] = speed await hass.services.async_call( FAN_DOMAIN, ...
[ "async", "def", "turn_fan_on", "(", "hass", ":", "core", ".", "HomeAssistant", ",", "fan_id", ":", "str", ",", "speed", ":", "Optional", "[", "str", "]", "=", "None", ")", "->", "None", ":", "service_data", "=", "{", "ATTR_ENTITY_ID", ":", "fan_id", "}...
[ 42, 0 ]
[ 55, 38 ]
python
en
['en', 'en', 'en']
True
test_entity_registry
(hass: core.HomeAssistant)
Tests that the devices are registered in the entity registry.
Tests that the devices are registered in the entity registry.
async def test_entity_registry(hass: core.HomeAssistant): """Tests that the devices are registered in the entity registry.""" await setup_platform( hass, FAN_DOMAIN, ceiling_fan("name-1"), bond_version={"bondid": "test-hub-id"}, bond_device_id="test-device-id", ) ...
[ "async", "def", "test_entity_registry", "(", "hass", ":", "core", ".", "HomeAssistant", ")", ":", "await", "setup_platform", "(", "hass", ",", "FAN_DOMAIN", ",", "ceiling_fan", "(", "\"name-1\"", ")", ",", "bond_version", "=", "{", "\"bondid\"", ":", "\"test-h...
[ 58, 0 ]
[ 70, 59 ]
python
en
['en', 'en', 'en']
True
test_non_standard_speed_list
(hass: core.HomeAssistant)
Tests that the device is registered with custom speed list if number of supported speeds differs form 3.
Tests that the device is registered with custom speed list if number of supported speeds differs form 3.
async def test_non_standard_speed_list(hass: core.HomeAssistant): """Tests that the device is registered with custom speed list if number of supported speeds differs form 3.""" await setup_platform( hass, FAN_DOMAIN, ceiling_fan("name-1"), bond_device_id="test-device-id", ...
[ "async", "def", "test_non_standard_speed_list", "(", "hass", ":", "core", ".", "HomeAssistant", ")", ":", "await", "setup_platform", "(", "hass", ",", "FAN_DOMAIN", ",", "ceiling_fan", "(", "\"name-1\"", ")", ",", "bond_device_id", "=", "\"test-device-id\"", ",", ...
[ 73, 0 ]
[ 108, 9 ]
python
en
['en', 'en', 'en']
True
test_fan_speed_with_no_max_seed
(hass: core.HomeAssistant)
Tests that fans without max speed (increase/decrease controls) map speed to HA standard.
Tests that fans without max speed (increase/decrease controls) map speed to HA standard.
async def test_fan_speed_with_no_max_seed(hass: core.HomeAssistant): """Tests that fans without max speed (increase/decrease controls) map speed to HA standard.""" await setup_platform( hass, FAN_DOMAIN, ceiling_fan("name-1"), bond_device_id="test-device-id", props={"no":...
[ "async", "def", "test_fan_speed_with_no_max_seed", "(", "hass", ":", "core", ".", "HomeAssistant", ")", ":", "await", "setup_platform", "(", "hass", ",", "FAN_DOMAIN", ",", "ceiling_fan", "(", "\"name-1\"", ")", ",", "bond_device_id", "=", "\"test-device-id\"", ",...
[ 111, 0 ]
[ 122, 78 ]
python
en
['en', 'en', 'en']
True
test_turn_on_fan_with_speed
(hass: core.HomeAssistant)
Tests that turn on command delegates to set speed API.
Tests that turn on command delegates to set speed API.
async def test_turn_on_fan_with_speed(hass: core.HomeAssistant): """Tests that turn on command delegates to set speed API.""" await setup_platform( hass, FAN_DOMAIN, ceiling_fan("name-1"), bond_device_id="test-device-id" ) with patch_bond_action() as mock_set_speed, patch_bond_device_state(): ...
[ "async", "def", "test_turn_on_fan_with_speed", "(", "hass", ":", "core", ".", "HomeAssistant", ")", ":", "await", "setup_platform", "(", "hass", ",", "FAN_DOMAIN", ",", "ceiling_fan", "(", "\"name-1\"", ")", ",", "bond_device_id", "=", "\"test-device-id\"", ")", ...
[ 125, 0 ]
[ 134, 76 ]
python
en
['en', 'en', 'en']
True