mirror of
https://github.com/elisspace/core.git
synced 2026-10-01 06:49:55 +00:00
Tellduslive refactoring (#18780)
* move component to a package * move TelldusLiveEntry to separate file * refactor * move entities from a shared container * using the dispatch helper instead for communication between component and platforms * updated covereagerc and codeowners * suggestions from MartinHjelmare * don't make update async * "Strip is good!"
This commit is contained in:
committed by
Martin Hjelmare
parent
a6511fc0b9
commit
d6a4e106a9
@@ -6,7 +6,8 @@ https://home-assistant.io/components/sensor.tellduslive/
|
||||
"""
|
||||
import logging
|
||||
|
||||
from homeassistant.components.tellduslive import TelldusLiveEntity
|
||||
from homeassistant.components import tellduslive
|
||||
from homeassistant.components.tellduslive.entry import TelldusLiveEntity
|
||||
from homeassistant.const import (
|
||||
DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_ILLUMINANCE, DEVICE_CLASS_TEMPERATURE,
|
||||
TEMP_CELSIUS)
|
||||
@@ -27,8 +28,8 @@ SENSOR_TYPE_DEW_POINT = 'dewp'
|
||||
SENSOR_TYPE_BAROMETRIC_PRESSURE = 'barpress'
|
||||
|
||||
SENSOR_TYPES = {
|
||||
SENSOR_TYPE_TEMPERATURE: ['Temperature', TEMP_CELSIUS, None,
|
||||
DEVICE_CLASS_TEMPERATURE],
|
||||
SENSOR_TYPE_TEMPERATURE:
|
||||
['Temperature', TEMP_CELSIUS, None, DEVICE_CLASS_TEMPERATURE],
|
||||
SENSOR_TYPE_HUMIDITY: ['Humidity', '%', None, DEVICE_CLASS_HUMIDITY],
|
||||
SENSOR_TYPE_RAINRATE: ['Rain rate', 'mm/h', 'mdi:water', None],
|
||||
SENSOR_TYPE_RAINTOTAL: ['Rain total', 'mm', 'mdi:water', None],
|
||||
@@ -39,7 +40,7 @@ SENSOR_TYPES = {
|
||||
SENSOR_TYPE_WATT: ['Power', 'W', '', None],
|
||||
SENSOR_TYPE_LUMINANCE: ['Luminance', 'lx', None, DEVICE_CLASS_ILLUMINANCE],
|
||||
SENSOR_TYPE_DEW_POINT:
|
||||
['Dew Point', TEMP_CELSIUS, None, DEVICE_CLASS_TEMPERATURE],
|
||||
['Dew Point', TEMP_CELSIUS, None, DEVICE_CLASS_TEMPERATURE],
|
||||
SENSOR_TYPE_BAROMETRIC_PRESSURE: ['Barometric Pressure', 'kPa', '', None],
|
||||
}
|
||||
|
||||
@@ -48,7 +49,9 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the Tellstick sensors."""
|
||||
if discovery_info is None:
|
||||
return
|
||||
add_entities(TelldusLiveSensor(hass, sensor) for sensor in discovery_info)
|
||||
client = hass.data[tellduslive.DOMAIN]
|
||||
add_entities(
|
||||
TelldusLiveSensor(client, sensor) for sensor in discovery_info)
|
||||
|
||||
|
||||
class TelldusLiveSensor(TelldusLiveEntity):
|
||||
@@ -87,9 +90,7 @@ class TelldusLiveSensor(TelldusLiveEntity):
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of the sensor."""
|
||||
return '{} {}'.format(
|
||||
super().name,
|
||||
self.quantity_name or '')
|
||||
return '{} {}'.format(super().name, self.quantity_name or '').strip()
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
|
||||
Reference in New Issue
Block a user