Set device_class on temperature sensors A-E (#49524)
Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
parent
0099b54489
commit
9b8a776001
12 changed files with 593 additions and 258 deletions
|
@ -7,6 +7,7 @@ import voluptuous as vol
|
||||||
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_RESOURCES,
|
CONF_RESOURCES,
|
||||||
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
ELECTRICAL_CURRENT_AMPERE,
|
ELECTRICAL_CURRENT_AMPERE,
|
||||||
ELECTRICAL_VOLT_AMPERE,
|
ELECTRICAL_VOLT_AMPERE,
|
||||||
FREQUENCY_HERTZ,
|
FREQUENCY_HERTZ,
|
||||||
|
@ -25,72 +26,72 @@ _LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
SENSOR_PREFIX = "UPS "
|
SENSOR_PREFIX = "UPS "
|
||||||
SENSOR_TYPES = {
|
SENSOR_TYPES = {
|
||||||
"alarmdel": ["Alarm Delay", "", "mdi:alarm"],
|
"alarmdel": ["Alarm Delay", "", "mdi:alarm", None],
|
||||||
"ambtemp": ["Ambient Temperature", "", "mdi:thermometer"],
|
"ambtemp": ["Ambient Temperature", "", "mdi:thermometer", None],
|
||||||
"apc": ["Status Data", "", "mdi:information-outline"],
|
"apc": ["Status Data", "", "mdi:information-outline", None],
|
||||||
"apcmodel": ["Model", "", "mdi:information-outline"],
|
"apcmodel": ["Model", "", "mdi:information-outline", None],
|
||||||
"badbatts": ["Bad Batteries", "", "mdi:information-outline"],
|
"badbatts": ["Bad Batteries", "", "mdi:information-outline", None],
|
||||||
"battdate": ["Battery Replaced", "", "mdi:calendar-clock"],
|
"battdate": ["Battery Replaced", "", "mdi:calendar-clock", None],
|
||||||
"battstat": ["Battery Status", "", "mdi:information-outline"],
|
"battstat": ["Battery Status", "", "mdi:information-outline", None],
|
||||||
"battv": ["Battery Voltage", VOLT, "mdi:flash"],
|
"battv": ["Battery Voltage", VOLT, "mdi:flash", None],
|
||||||
"bcharge": ["Battery", PERCENTAGE, "mdi:battery"],
|
"bcharge": ["Battery", PERCENTAGE, "mdi:battery", None],
|
||||||
"cable": ["Cable Type", "", "mdi:ethernet-cable"],
|
"cable": ["Cable Type", "", "mdi:ethernet-cable", None],
|
||||||
"cumonbatt": ["Total Time on Battery", "", "mdi:timer-outline"],
|
"cumonbatt": ["Total Time on Battery", "", "mdi:timer-outline", None],
|
||||||
"date": ["Status Date", "", "mdi:calendar-clock"],
|
"date": ["Status Date", "", "mdi:calendar-clock", None],
|
||||||
"dipsw": ["Dip Switch Settings", "", "mdi:information-outline"],
|
"dipsw": ["Dip Switch Settings", "", "mdi:information-outline", None],
|
||||||
"dlowbatt": ["Low Battery Signal", "", "mdi:clock-alert"],
|
"dlowbatt": ["Low Battery Signal", "", "mdi:clock-alert", None],
|
||||||
"driver": ["Driver", "", "mdi:information-outline"],
|
"driver": ["Driver", "", "mdi:information-outline", None],
|
||||||
"dshutd": ["Shutdown Delay", "", "mdi:timer-outline"],
|
"dshutd": ["Shutdown Delay", "", "mdi:timer-outline", None],
|
||||||
"dwake": ["Wake Delay", "", "mdi:timer-outline"],
|
"dwake": ["Wake Delay", "", "mdi:timer-outline", None],
|
||||||
"endapc": ["Date and Time", "", "mdi:calendar-clock"],
|
"endapc": ["Date and Time", "", "mdi:calendar-clock", None],
|
||||||
"extbatts": ["External Batteries", "", "mdi:information-outline"],
|
"extbatts": ["External Batteries", "", "mdi:information-outline", None],
|
||||||
"firmware": ["Firmware Version", "", "mdi:information-outline"],
|
"firmware": ["Firmware Version", "", "mdi:information-outline", None],
|
||||||
"hitrans": ["Transfer High", VOLT, "mdi:flash"],
|
"hitrans": ["Transfer High", VOLT, "mdi:flash", None],
|
||||||
"hostname": ["Hostname", "", "mdi:information-outline"],
|
"hostname": ["Hostname", "", "mdi:information-outline", None],
|
||||||
"humidity": ["Ambient Humidity", PERCENTAGE, "mdi:water-percent"],
|
"humidity": ["Ambient Humidity", PERCENTAGE, "mdi:water-percent", None],
|
||||||
"itemp": ["Internal Temperature", TEMP_CELSIUS, "mdi:thermometer"],
|
"itemp": ["Internal Temperature", TEMP_CELSIUS, None, DEVICE_CLASS_TEMPERATURE],
|
||||||
"lastxfer": ["Last Transfer", "", "mdi:transfer"],
|
"lastxfer": ["Last Transfer", "", "mdi:transfer", None],
|
||||||
"linefail": ["Input Voltage Status", "", "mdi:information-outline"],
|
"linefail": ["Input Voltage Status", "", "mdi:information-outline", None],
|
||||||
"linefreq": ["Line Frequency", FREQUENCY_HERTZ, "mdi:information-outline"],
|
"linefreq": ["Line Frequency", FREQUENCY_HERTZ, "mdi:information-outline", None],
|
||||||
"linev": ["Input Voltage", VOLT, "mdi:flash"],
|
"linev": ["Input Voltage", VOLT, "mdi:flash", None],
|
||||||
"loadpct": ["Load", PERCENTAGE, "mdi:gauge"],
|
"loadpct": ["Load", PERCENTAGE, "mdi:gauge", None],
|
||||||
"loadapnt": ["Load Apparent Power", PERCENTAGE, "mdi:gauge"],
|
"loadapnt": ["Load Apparent Power", PERCENTAGE, "mdi:gauge", None],
|
||||||
"lotrans": ["Transfer Low", VOLT, "mdi:flash"],
|
"lotrans": ["Transfer Low", VOLT, "mdi:flash", None],
|
||||||
"mandate": ["Manufacture Date", "", "mdi:calendar"],
|
"mandate": ["Manufacture Date", "", "mdi:calendar", None],
|
||||||
"masterupd": ["Master Update", "", "mdi:information-outline"],
|
"masterupd": ["Master Update", "", "mdi:information-outline", None],
|
||||||
"maxlinev": ["Input Voltage High", VOLT, "mdi:flash"],
|
"maxlinev": ["Input Voltage High", VOLT, "mdi:flash", None],
|
||||||
"maxtime": ["Battery Timeout", "", "mdi:timer-off-outline"],
|
"maxtime": ["Battery Timeout", "", "mdi:timer-off-outline", None],
|
||||||
"mbattchg": ["Battery Shutdown", PERCENTAGE, "mdi:battery-alert"],
|
"mbattchg": ["Battery Shutdown", PERCENTAGE, "mdi:battery-alert", None],
|
||||||
"minlinev": ["Input Voltage Low", VOLT, "mdi:flash"],
|
"minlinev": ["Input Voltage Low", VOLT, "mdi:flash", None],
|
||||||
"mintimel": ["Shutdown Time", "", "mdi:timer-outline"],
|
"mintimel": ["Shutdown Time", "", "mdi:timer-outline", None],
|
||||||
"model": ["Model", "", "mdi:information-outline"],
|
"model": ["Model", "", "mdi:information-outline", None],
|
||||||
"nombattv": ["Battery Nominal Voltage", VOLT, "mdi:flash"],
|
"nombattv": ["Battery Nominal Voltage", VOLT, "mdi:flash", None],
|
||||||
"nominv": ["Nominal Input Voltage", VOLT, "mdi:flash"],
|
"nominv": ["Nominal Input Voltage", VOLT, "mdi:flash", None],
|
||||||
"nomoutv": ["Nominal Output Voltage", VOLT, "mdi:flash"],
|
"nomoutv": ["Nominal Output Voltage", VOLT, "mdi:flash", None],
|
||||||
"nompower": ["Nominal Output Power", POWER_WATT, "mdi:flash"],
|
"nompower": ["Nominal Output Power", POWER_WATT, "mdi:flash", None],
|
||||||
"nomapnt": ["Nominal Apparent Power", ELECTRICAL_VOLT_AMPERE, "mdi:flash"],
|
"nomapnt": ["Nominal Apparent Power", ELECTRICAL_VOLT_AMPERE, "mdi:flash", None],
|
||||||
"numxfers": ["Transfer Count", "", "mdi:counter"],
|
"numxfers": ["Transfer Count", "", "mdi:counter", None],
|
||||||
"outcurnt": ["Output Current", ELECTRICAL_CURRENT_AMPERE, "mdi:flash"],
|
"outcurnt": ["Output Current", ELECTRICAL_CURRENT_AMPERE, "mdi:flash", None],
|
||||||
"outputv": ["Output Voltage", VOLT, "mdi:flash"],
|
"outputv": ["Output Voltage", VOLT, "mdi:flash", None],
|
||||||
"reg1": ["Register 1 Fault", "", "mdi:information-outline"],
|
"reg1": ["Register 1 Fault", "", "mdi:information-outline", None],
|
||||||
"reg2": ["Register 2 Fault", "", "mdi:information-outline"],
|
"reg2": ["Register 2 Fault", "", "mdi:information-outline", None],
|
||||||
"reg3": ["Register 3 Fault", "", "mdi:information-outline"],
|
"reg3": ["Register 3 Fault", "", "mdi:information-outline", None],
|
||||||
"retpct": ["Restore Requirement", PERCENTAGE, "mdi:battery-alert"],
|
"retpct": ["Restore Requirement", PERCENTAGE, "mdi:battery-alert", None],
|
||||||
"selftest": ["Last Self Test", "", "mdi:calendar-clock"],
|
"selftest": ["Last Self Test", "", "mdi:calendar-clock", None],
|
||||||
"sense": ["Sensitivity", "", "mdi:information-outline"],
|
"sense": ["Sensitivity", "", "mdi:information-outline", None],
|
||||||
"serialno": ["Serial Number", "", "mdi:information-outline"],
|
"serialno": ["Serial Number", "", "mdi:information-outline", None],
|
||||||
"starttime": ["Startup Time", "", "mdi:calendar-clock"],
|
"starttime": ["Startup Time", "", "mdi:calendar-clock", None],
|
||||||
"statflag": ["Status Flag", "", "mdi:information-outline"],
|
"statflag": ["Status Flag", "", "mdi:information-outline", None],
|
||||||
"status": ["Status", "", "mdi:information-outline"],
|
"status": ["Status", "", "mdi:information-outline", None],
|
||||||
"stesti": ["Self Test Interval", "", "mdi:information-outline"],
|
"stesti": ["Self Test Interval", "", "mdi:information-outline", None],
|
||||||
"timeleft": ["Time Left", "", "mdi:clock-alert"],
|
"timeleft": ["Time Left", "", "mdi:clock-alert", None],
|
||||||
"tonbatt": ["Time on Battery", "", "mdi:timer-outline"],
|
"tonbatt": ["Time on Battery", "", "mdi:timer-outline", None],
|
||||||
"upsmode": ["Mode", "", "mdi:information-outline"],
|
"upsmode": ["Mode", "", "mdi:information-outline", None],
|
||||||
"upsname": ["Name", "", "mdi:information-outline"],
|
"upsname": ["Name", "", "mdi:information-outline", None],
|
||||||
"version": ["Daemon Info", "", "mdi:information-outline"],
|
"version": ["Daemon Info", "", "mdi:information-outline", None],
|
||||||
"xoffbat": ["Transfer from Battery", "", "mdi:transfer"],
|
"xoffbat": ["Transfer from Battery", "", "mdi:transfer", None],
|
||||||
"xoffbatt": ["Transfer from Battery", "", "mdi:transfer"],
|
"xoffbatt": ["Transfer from Battery", "", "mdi:transfer", None],
|
||||||
"xonbatt": ["Transfer to Battery", "", "mdi:transfer"],
|
"xonbatt": ["Transfer to Battery", "", "mdi:transfer", None],
|
||||||
}
|
}
|
||||||
|
|
||||||
SPECIFIC_UNITS = {"ITEMP": TEMP_CELSIUS}
|
SPECIFIC_UNITS = {"ITEMP": TEMP_CELSIUS}
|
||||||
|
@ -166,6 +167,7 @@ class APCUPSdSensor(SensorEntity):
|
||||||
self._attr_icon = SENSOR_TYPES[self.type][2]
|
self._attr_icon = SENSOR_TYPES[self.type][2]
|
||||||
if SENSOR_TYPES[sensor_type][1]:
|
if SENSOR_TYPES[sensor_type][1]:
|
||||||
self._attr_unit_of_measurement = SENSOR_TYPES[sensor_type][1]
|
self._attr_unit_of_measurement = SENSOR_TYPES[sensor_type][1]
|
||||||
|
self._attr_device_class = SENSOR_TYPES[sensor_type][3]
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
"""Get the latest status and use it to update our sensor state."""
|
"""Get the latest status and use it to update our sensor state."""
|
||||||
|
|
|
@ -5,6 +5,7 @@ import voluptuous as vol
|
||||||
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_MONITORED_CONDITIONS,
|
CONF_MONITORED_CONDITIONS,
|
||||||
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
PERCENTAGE,
|
PERCENTAGE,
|
||||||
POWER_WATT,
|
POWER_WATT,
|
||||||
TEMP_CELSIUS,
|
TEMP_CELSIUS,
|
||||||
|
@ -21,18 +22,28 @@ SALT_UNITS = ["g/L", "PPM"]
|
||||||
WATT_UNITS = [POWER_WATT, POWER_WATT]
|
WATT_UNITS = [POWER_WATT, POWER_WATT]
|
||||||
NO_UNITS = [None, None]
|
NO_UNITS = [None, None]
|
||||||
|
|
||||||
# sensor_type [ description, unit, icon ]
|
# sensor_type [ description, unit, icon, device_class ]
|
||||||
# sensor_type corresponds to property names in aqualogic.core.AquaLogic
|
# sensor_type corresponds to property names in aqualogic.core.AquaLogic
|
||||||
SENSOR_TYPES = {
|
SENSOR_TYPES = {
|
||||||
"air_temp": ["Air Temperature", TEMP_UNITS, "mdi:thermometer"],
|
"air_temp": ["Air Temperature", TEMP_UNITS, None, DEVICE_CLASS_TEMPERATURE],
|
||||||
"pool_temp": ["Pool Temperature", TEMP_UNITS, "mdi:oil-temperature"],
|
"pool_temp": [
|
||||||
"spa_temp": ["Spa Temperature", TEMP_UNITS, "mdi:oil-temperature"],
|
"Pool Temperature",
|
||||||
"pool_chlorinator": ["Pool Chlorinator", PERCENT_UNITS, "mdi:gauge"],
|
TEMP_UNITS,
|
||||||
"spa_chlorinator": ["Spa Chlorinator", PERCENT_UNITS, "mdi:gauge"],
|
"mdi:oil-temperature",
|
||||||
"salt_level": ["Salt Level", SALT_UNITS, "mdi:gauge"],
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
"pump_speed": ["Pump Speed", PERCENT_UNITS, "mdi:speedometer"],
|
],
|
||||||
"pump_power": ["Pump Power", WATT_UNITS, "mdi:gauge"],
|
"spa_temp": [
|
||||||
"status": ["Status", NO_UNITS, "mdi:alert"],
|
"Spa Temperature",
|
||||||
|
TEMP_UNITS,
|
||||||
|
"mdi:oil-temperature",
|
||||||
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
|
],
|
||||||
|
"pool_chlorinator": ["Pool Chlorinator", PERCENT_UNITS, "mdi:gauge", None],
|
||||||
|
"spa_chlorinator": ["Spa Chlorinator", PERCENT_UNITS, "mdi:gauge", None],
|
||||||
|
"salt_level": ["Salt Level", SALT_UNITS, "mdi:gauge", None],
|
||||||
|
"pump_speed": ["Pump Speed", PERCENT_UNITS, "mdi:speedometer", None],
|
||||||
|
"pump_power": ["Pump Power", WATT_UNITS, "mdi:gauge", None],
|
||||||
|
"status": ["Status", NO_UNITS, "mdi:alert", None],
|
||||||
}
|
}
|
||||||
|
|
||||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||||
|
@ -89,6 +100,11 @@ class AquaLogicSensor(SensorEntity):
|
||||||
"""Return the polling state."""
|
"""Return the polling state."""
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@property
|
||||||
|
def device_class(self):
|
||||||
|
"""Return the class of this device, from component DEVICE_CLASSES."""
|
||||||
|
return SENSOR_TYPES[self._type][3]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def icon(self):
|
def icon(self):
|
||||||
"""Icon to use in the frontend, if any."""
|
"""Icon to use in the frontend, if any."""
|
||||||
|
|
|
@ -4,7 +4,12 @@ import logging
|
||||||
|
|
||||||
from homeassistant.components import mqtt
|
from homeassistant.components import mqtt
|
||||||
from homeassistant.components.sensor import SensorEntity
|
from homeassistant.components.sensor import SensorEntity
|
||||||
from homeassistant.const import DEGREE, TEMP_CELSIUS, TEMP_FAHRENHEIT
|
from homeassistant.const import (
|
||||||
|
DEGREE,
|
||||||
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
|
TEMP_CELSIUS,
|
||||||
|
TEMP_FAHRENHEIT,
|
||||||
|
)
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.util import slugify
|
from homeassistant.util import slugify
|
||||||
|
|
||||||
|
@ -30,7 +35,9 @@ def discover_sensors(topic, payload):
|
||||||
unit = TEMP_FAHRENHEIT
|
unit = TEMP_FAHRENHEIT
|
||||||
else:
|
else:
|
||||||
unit = TEMP_CELSIUS
|
unit = TEMP_CELSIUS
|
||||||
return ArwnSensor(topic, name, "temp", unit)
|
return ArwnSensor(
|
||||||
|
topic, name, "temp", unit, device_class=DEVICE_CLASS_TEMPERATURE
|
||||||
|
)
|
||||||
if domain == "moisture":
|
if domain == "moisture":
|
||||||
name = f"{parts[2]} Moisture"
|
name = f"{parts[2]} Moisture"
|
||||||
return ArwnSensor(topic, name, "moisture", unit, "mdi:water-percent")
|
return ArwnSensor(topic, name, "moisture", unit, "mdi:water-percent")
|
||||||
|
@ -117,7 +124,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
||||||
class ArwnSensor(SensorEntity):
|
class ArwnSensor(SensorEntity):
|
||||||
"""Representation of an ARWN sensor."""
|
"""Representation of an ARWN sensor."""
|
||||||
|
|
||||||
def __init__(self, topic, name, state_key, units, icon=None):
|
def __init__(self, topic, name, state_key, units, icon=None, device_class=None):
|
||||||
"""Initialize the sensor."""
|
"""Initialize the sensor."""
|
||||||
self.hass = None
|
self.hass = None
|
||||||
self.entity_id = _slug(name)
|
self.entity_id = _slug(name)
|
||||||
|
@ -128,6 +135,7 @@ class ArwnSensor(SensorEntity):
|
||||||
self.event = {}
|
self.event = {}
|
||||||
self._unit_of_measurement = units
|
self._unit_of_measurement = units
|
||||||
self._icon = icon
|
self._icon = icon
|
||||||
|
self._device_class = device_class
|
||||||
|
|
||||||
def set_event(self, event):
|
def set_event(self, event):
|
||||||
"""Update the sensor with the most recent event."""
|
"""Update the sensor with the most recent event."""
|
||||||
|
@ -168,6 +176,11 @@ class ArwnSensor(SensorEntity):
|
||||||
"""Return the polling state."""
|
"""Return the polling state."""
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@property
|
||||||
|
def device_class(self):
|
||||||
|
"""Return the class of this device, from component DEVICE_CLASSES."""
|
||||||
|
return self._device_class
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def icon(self):
|
def icon(self):
|
||||||
"""Return the icon of device based on its type."""
|
"""Return the icon of device based on its type."""
|
||||||
|
|
|
@ -5,6 +5,7 @@ from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
AREA_SQUARE_METERS,
|
AREA_SQUARE_METERS,
|
||||||
CONF_MONITORED_CONDITIONS,
|
CONF_MONITORED_CONDITIONS,
|
||||||
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
PERCENTAGE,
|
PERCENTAGE,
|
||||||
PRESSURE_INHG,
|
PRESSURE_INHG,
|
||||||
PRESSURE_MBAR,
|
PRESSURE_MBAR,
|
||||||
|
@ -43,6 +44,11 @@ SENSOR_UNITS_METRIC = {
|
||||||
"Voltage": "mV",
|
"Voltage": "mV",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Device class
|
||||||
|
SENSOR_DEVICE_CLASS = {
|
||||||
|
"Temperature": DEVICE_CLASS_TEMPERATURE,
|
||||||
|
}
|
||||||
|
|
||||||
# Which sensors to format numerically
|
# Which sensors to format numerically
|
||||||
FORMAT_NUMBERS = ["Temperature", "Pressure", "Voltage"]
|
FORMAT_NUMBERS = ["Temperature", "Pressure", "Voltage"]
|
||||||
|
|
||||||
|
@ -103,6 +109,11 @@ class BloomSkySensor(SensorEntity):
|
||||||
return SENSOR_UNITS_METRIC.get(self._sensor_name, None)
|
return SENSOR_UNITS_METRIC.get(self._sensor_name, None)
|
||||||
return SENSOR_UNITS_IMPERIAL.get(self._sensor_name, None)
|
return SENSOR_UNITS_IMPERIAL.get(self._sensor_name, None)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def device_class(self):
|
||||||
|
"""Return the class of this device, from component DEVICE_CLASSES."""
|
||||||
|
return SENSOR_DEVICE_CLASS.get(self._sensor_name)
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
"""Request an update from the BloomSky API."""
|
"""Request an update from the BloomSky API."""
|
||||||
self._bloomsky.refresh_devices()
|
self._bloomsky.refresh_devices()
|
||||||
|
|
|
@ -29,6 +29,7 @@ from homeassistant.const import (
|
||||||
CONF_MONITORED_CONDITIONS,
|
CONF_MONITORED_CONDITIONS,
|
||||||
CONF_NAME,
|
CONF_NAME,
|
||||||
DEGREE,
|
DEGREE,
|
||||||
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
IRRADIATION_WATTS_PER_SQUARE_METER,
|
IRRADIATION_WATTS_PER_SQUARE_METER,
|
||||||
LENGTH_KILOMETERS,
|
LENGTH_KILOMETERS,
|
||||||
LENGTH_MILLIMETERS,
|
LENGTH_MILLIMETERS,
|
||||||
|
@ -60,132 +61,260 @@ SCHEDULE_NOK = 2
|
||||||
# Supported sensor types:
|
# Supported sensor types:
|
||||||
# Key: ['label', unit, icon]
|
# Key: ['label', unit, icon]
|
||||||
SENSOR_TYPES = {
|
SENSOR_TYPES = {
|
||||||
"stationname": ["Stationname", None, None],
|
"stationname": ["Stationname", None, None, None],
|
||||||
# new in json api (>1.0.0):
|
# new in json api (>1.0.0):
|
||||||
"barometerfc": ["Barometer value", None, "mdi:gauge"],
|
"barometerfc": ["Barometer value", None, "mdi:gauge", None],
|
||||||
# new in json api (>1.0.0):
|
# new in json api (>1.0.0):
|
||||||
"barometerfcname": ["Barometer", None, "mdi:gauge"],
|
"barometerfcname": ["Barometer", None, "mdi:gauge", None],
|
||||||
# new in json api (>1.0.0):
|
# new in json api (>1.0.0):
|
||||||
"barometerfcnamenl": ["Barometer", None, "mdi:gauge"],
|
"barometerfcnamenl": ["Barometer", None, "mdi:gauge", None],
|
||||||
"condition": ["Condition", None, None],
|
"condition": ["Condition", None, None, None],
|
||||||
"conditioncode": ["Condition code", None, None],
|
"conditioncode": ["Condition code", None, None, None],
|
||||||
"conditiondetailed": ["Detailed condition", None, None],
|
"conditiondetailed": ["Detailed condition", None, None, None],
|
||||||
"conditionexact": ["Full condition", None, None],
|
"conditionexact": ["Full condition", None, None, None],
|
||||||
"symbol": ["Symbol", None, None],
|
"symbol": ["Symbol", None, None, None],
|
||||||
# new in json api (>1.0.0):
|
# new in json api (>1.0.0):
|
||||||
"feeltemperature": ["Feel temperature", TEMP_CELSIUS, "mdi:thermometer"],
|
"feeltemperature": [
|
||||||
"humidity": ["Humidity", PERCENTAGE, "mdi:water-percent"],
|
"Feel temperature",
|
||||||
"temperature": ["Temperature", TEMP_CELSIUS, "mdi:thermometer"],
|
TEMP_CELSIUS,
|
||||||
"groundtemperature": ["Ground temperature", TEMP_CELSIUS, "mdi:thermometer"],
|
None,
|
||||||
"windspeed": ["Wind speed", SPEED_KILOMETERS_PER_HOUR, "mdi:weather-windy"],
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
"windforce": ["Wind force", "Bft", "mdi:weather-windy"],
|
],
|
||||||
"winddirection": ["Wind direction", None, "mdi:compass-outline"],
|
"humidity": ["Humidity", PERCENTAGE, "mdi:water-percent", None],
|
||||||
"windazimuth": ["Wind direction azimuth", DEGREE, "mdi:compass-outline"],
|
"temperature": [
|
||||||
"pressure": ["Pressure", PRESSURE_HPA, "mdi:gauge"],
|
"Temperature",
|
||||||
"visibility": ["Visibility", LENGTH_KILOMETERS, None],
|
TEMP_CELSIUS,
|
||||||
"windgust": ["Wind gust", SPEED_KILOMETERS_PER_HOUR, "mdi:weather-windy"],
|
None,
|
||||||
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
|
],
|
||||||
|
"groundtemperature": [
|
||||||
|
"Ground temperature",
|
||||||
|
TEMP_CELSIUS,
|
||||||
|
None,
|
||||||
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
|
],
|
||||||
|
"windspeed": ["Wind speed", SPEED_KILOMETERS_PER_HOUR, "mdi:weather-windy", None],
|
||||||
|
"windforce": ["Wind force", "Bft", "mdi:weather-windy", None],
|
||||||
|
"winddirection": ["Wind direction", None, "mdi:compass-outline", None],
|
||||||
|
"windazimuth": ["Wind direction azimuth", DEGREE, "mdi:compass-outline", None],
|
||||||
|
"pressure": ["Pressure", PRESSURE_HPA, "mdi:gauge", None],
|
||||||
|
"visibility": ["Visibility", LENGTH_KILOMETERS, None, None],
|
||||||
|
"windgust": ["Wind gust", SPEED_KILOMETERS_PER_HOUR, "mdi:weather-windy", None],
|
||||||
"precipitation": [
|
"precipitation": [
|
||||||
"Precipitation",
|
"Precipitation",
|
||||||
PRECIPITATION_MILLIMETERS_PER_HOUR,
|
PRECIPITATION_MILLIMETERS_PER_HOUR,
|
||||||
"mdi:weather-pouring",
|
"mdi:weather-pouring",
|
||||||
|
None,
|
||||||
|
],
|
||||||
|
"irradiance": [
|
||||||
|
"Irradiance",
|
||||||
|
IRRADIATION_WATTS_PER_SQUARE_METER,
|
||||||
|
"mdi:sunglasses",
|
||||||
|
None,
|
||||||
],
|
],
|
||||||
"irradiance": ["Irradiance", IRRADIATION_WATTS_PER_SQUARE_METER, "mdi:sunglasses"],
|
|
||||||
"precipitation_forecast_average": [
|
"precipitation_forecast_average": [
|
||||||
"Precipitation forecast average",
|
"Precipitation forecast average",
|
||||||
PRECIPITATION_MILLIMETERS_PER_HOUR,
|
PRECIPITATION_MILLIMETERS_PER_HOUR,
|
||||||
"mdi:weather-pouring",
|
"mdi:weather-pouring",
|
||||||
|
None,
|
||||||
],
|
],
|
||||||
"precipitation_forecast_total": [
|
"precipitation_forecast_total": [
|
||||||
"Precipitation forecast total",
|
"Precipitation forecast total",
|
||||||
LENGTH_MILLIMETERS,
|
LENGTH_MILLIMETERS,
|
||||||
"mdi:weather-pouring",
|
"mdi:weather-pouring",
|
||||||
|
None,
|
||||||
],
|
],
|
||||||
# new in json api (>1.0.0):
|
# new in json api (>1.0.0):
|
||||||
"rainlast24hour": ["Rain last 24h", LENGTH_MILLIMETERS, "mdi:weather-pouring"],
|
"rainlast24hour": [
|
||||||
|
"Rain last 24h",
|
||||||
|
LENGTH_MILLIMETERS,
|
||||||
|
"mdi:weather-pouring",
|
||||||
|
None,
|
||||||
|
],
|
||||||
# new in json api (>1.0.0):
|
# new in json api (>1.0.0):
|
||||||
"rainlasthour": ["Rain last hour", LENGTH_MILLIMETERS, "mdi:weather-pouring"],
|
"rainlasthour": ["Rain last hour", LENGTH_MILLIMETERS, "mdi:weather-pouring", None],
|
||||||
"temperature_1d": ["Temperature 1d", TEMP_CELSIUS, "mdi:thermometer"],
|
"temperature_1d": [
|
||||||
"temperature_2d": ["Temperature 2d", TEMP_CELSIUS, "mdi:thermometer"],
|
"Temperature 1d",
|
||||||
"temperature_3d": ["Temperature 3d", TEMP_CELSIUS, "mdi:thermometer"],
|
TEMP_CELSIUS,
|
||||||
"temperature_4d": ["Temperature 4d", TEMP_CELSIUS, "mdi:thermometer"],
|
None,
|
||||||
"temperature_5d": ["Temperature 5d", TEMP_CELSIUS, "mdi:thermometer"],
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
"mintemp_1d": ["Minimum temperature 1d", TEMP_CELSIUS, "mdi:thermometer"],
|
],
|
||||||
"mintemp_2d": ["Minimum temperature 2d", TEMP_CELSIUS, "mdi:thermometer"],
|
"temperature_2d": [
|
||||||
"mintemp_3d": ["Minimum temperature 3d", TEMP_CELSIUS, "mdi:thermometer"],
|
"Temperature 2d",
|
||||||
"mintemp_4d": ["Minimum temperature 4d", TEMP_CELSIUS, "mdi:thermometer"],
|
TEMP_CELSIUS,
|
||||||
"mintemp_5d": ["Minimum temperature 5d", TEMP_CELSIUS, "mdi:thermometer"],
|
None,
|
||||||
"rain_1d": ["Rain 1d", LENGTH_MILLIMETERS, "mdi:weather-pouring"],
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
"rain_2d": ["Rain 2d", LENGTH_MILLIMETERS, "mdi:weather-pouring"],
|
],
|
||||||
"rain_3d": ["Rain 3d", LENGTH_MILLIMETERS, "mdi:weather-pouring"],
|
"temperature_3d": [
|
||||||
"rain_4d": ["Rain 4d", LENGTH_MILLIMETERS, "mdi:weather-pouring"],
|
"Temperature 3d",
|
||||||
"rain_5d": ["Rain 5d", LENGTH_MILLIMETERS, "mdi:weather-pouring"],
|
TEMP_CELSIUS,
|
||||||
|
None,
|
||||||
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
|
],
|
||||||
|
"temperature_4d": [
|
||||||
|
"Temperature 4d",
|
||||||
|
TEMP_CELSIUS,
|
||||||
|
None,
|
||||||
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
|
],
|
||||||
|
"temperature_5d": [
|
||||||
|
"Temperature 5d",
|
||||||
|
TEMP_CELSIUS,
|
||||||
|
None,
|
||||||
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
|
],
|
||||||
|
"mintemp_1d": [
|
||||||
|
"Minimum temperature 1d",
|
||||||
|
TEMP_CELSIUS,
|
||||||
|
None,
|
||||||
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
|
],
|
||||||
|
"mintemp_2d": [
|
||||||
|
"Minimum temperature 2d",
|
||||||
|
TEMP_CELSIUS,
|
||||||
|
None,
|
||||||
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
|
],
|
||||||
|
"mintemp_3d": [
|
||||||
|
"Minimum temperature 3d",
|
||||||
|
TEMP_CELSIUS,
|
||||||
|
None,
|
||||||
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
|
],
|
||||||
|
"mintemp_4d": [
|
||||||
|
"Minimum temperature 4d",
|
||||||
|
TEMP_CELSIUS,
|
||||||
|
None,
|
||||||
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
|
],
|
||||||
|
"mintemp_5d": [
|
||||||
|
"Minimum temperature 5d",
|
||||||
|
TEMP_CELSIUS,
|
||||||
|
None,
|
||||||
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
|
],
|
||||||
|
"rain_1d": ["Rain 1d", LENGTH_MILLIMETERS, "mdi:weather-pouring", None],
|
||||||
|
"rain_2d": ["Rain 2d", LENGTH_MILLIMETERS, "mdi:weather-pouring", None],
|
||||||
|
"rain_3d": ["Rain 3d", LENGTH_MILLIMETERS, "mdi:weather-pouring", None],
|
||||||
|
"rain_4d": ["Rain 4d", LENGTH_MILLIMETERS, "mdi:weather-pouring", None],
|
||||||
|
"rain_5d": ["Rain 5d", LENGTH_MILLIMETERS, "mdi:weather-pouring", None],
|
||||||
# new in json api (>1.0.0):
|
# new in json api (>1.0.0):
|
||||||
"minrain_1d": ["Minimum rain 1d", LENGTH_MILLIMETERS, "mdi:weather-pouring"],
|
"minrain_1d": ["Minimum rain 1d", LENGTH_MILLIMETERS, "mdi:weather-pouring", None],
|
||||||
"minrain_2d": ["Minimum rain 2d", LENGTH_MILLIMETERS, "mdi:weather-pouring"],
|
"minrain_2d": ["Minimum rain 2d", LENGTH_MILLIMETERS, "mdi:weather-pouring", None],
|
||||||
"minrain_3d": ["Minimum rain 3d", LENGTH_MILLIMETERS, "mdi:weather-pouring"],
|
"minrain_3d": ["Minimum rain 3d", LENGTH_MILLIMETERS, "mdi:weather-pouring", None],
|
||||||
"minrain_4d": ["Minimum rain 4d", LENGTH_MILLIMETERS, "mdi:weather-pouring"],
|
"minrain_4d": ["Minimum rain 4d", LENGTH_MILLIMETERS, "mdi:weather-pouring", None],
|
||||||
"minrain_5d": ["Minimum rain 5d", LENGTH_MILLIMETERS, "mdi:weather-pouring"],
|
"minrain_5d": ["Minimum rain 5d", LENGTH_MILLIMETERS, "mdi:weather-pouring", None],
|
||||||
# new in json api (>1.0.0):
|
# new in json api (>1.0.0):
|
||||||
"maxrain_1d": ["Maximum rain 1d", LENGTH_MILLIMETERS, "mdi:weather-pouring"],
|
"maxrain_1d": ["Maximum rain 1d", LENGTH_MILLIMETERS, "mdi:weather-pouring", None],
|
||||||
"maxrain_2d": ["Maximum rain 2d", LENGTH_MILLIMETERS, "mdi:weather-pouring"],
|
"maxrain_2d": ["Maximum rain 2d", LENGTH_MILLIMETERS, "mdi:weather-pouring", None],
|
||||||
"maxrain_3d": ["Maximum rain 3d", LENGTH_MILLIMETERS, "mdi:weather-pouring"],
|
"maxrain_3d": ["Maximum rain 3d", LENGTH_MILLIMETERS, "mdi:weather-pouring", None],
|
||||||
"maxrain_4d": ["Maximum rain 4d", LENGTH_MILLIMETERS, "mdi:weather-pouring"],
|
"maxrain_4d": ["Maximum rain 4d", LENGTH_MILLIMETERS, "mdi:weather-pouring", None],
|
||||||
"maxrain_5d": ["Maximum rain 5d", LENGTH_MILLIMETERS, "mdi:weather-pouring"],
|
"maxrain_5d": ["Maximum rain 5d", LENGTH_MILLIMETERS, "mdi:weather-pouring", None],
|
||||||
"rainchance_1d": ["Rainchance 1d", PERCENTAGE, "mdi:weather-pouring"],
|
"rainchance_1d": ["Rainchance 1d", PERCENTAGE, "mdi:weather-pouring", None],
|
||||||
"rainchance_2d": ["Rainchance 2d", PERCENTAGE, "mdi:weather-pouring"],
|
"rainchance_2d": ["Rainchance 2d", PERCENTAGE, "mdi:weather-pouring", None],
|
||||||
"rainchance_3d": ["Rainchance 3d", PERCENTAGE, "mdi:weather-pouring"],
|
"rainchance_3d": ["Rainchance 3d", PERCENTAGE, "mdi:weather-pouring", None],
|
||||||
"rainchance_4d": ["Rainchance 4d", PERCENTAGE, "mdi:weather-pouring"],
|
"rainchance_4d": ["Rainchance 4d", PERCENTAGE, "mdi:weather-pouring", None],
|
||||||
"rainchance_5d": ["Rainchance 5d", PERCENTAGE, "mdi:weather-pouring"],
|
"rainchance_5d": ["Rainchance 5d", PERCENTAGE, "mdi:weather-pouring", None],
|
||||||
"sunchance_1d": ["Sunchance 1d", PERCENTAGE, "mdi:weather-partly-cloudy"],
|
"sunchance_1d": ["Sunchance 1d", PERCENTAGE, "mdi:weather-partly-cloudy", None],
|
||||||
"sunchance_2d": ["Sunchance 2d", PERCENTAGE, "mdi:weather-partly-cloudy"],
|
"sunchance_2d": ["Sunchance 2d", PERCENTAGE, "mdi:weather-partly-cloudy", None],
|
||||||
"sunchance_3d": ["Sunchance 3d", PERCENTAGE, "mdi:weather-partly-cloudy"],
|
"sunchance_3d": ["Sunchance 3d", PERCENTAGE, "mdi:weather-partly-cloudy", None],
|
||||||
"sunchance_4d": ["Sunchance 4d", PERCENTAGE, "mdi:weather-partly-cloudy"],
|
"sunchance_4d": ["Sunchance 4d", PERCENTAGE, "mdi:weather-partly-cloudy", None],
|
||||||
"sunchance_5d": ["Sunchance 5d", PERCENTAGE, "mdi:weather-partly-cloudy"],
|
"sunchance_5d": ["Sunchance 5d", PERCENTAGE, "mdi:weather-partly-cloudy", None],
|
||||||
"windforce_1d": ["Wind force 1d", "Bft", "mdi:weather-windy"],
|
"windforce_1d": ["Wind force 1d", "Bft", "mdi:weather-windy", None],
|
||||||
"windforce_2d": ["Wind force 2d", "Bft", "mdi:weather-windy"],
|
"windforce_2d": ["Wind force 2d", "Bft", "mdi:weather-windy", None],
|
||||||
"windforce_3d": ["Wind force 3d", "Bft", "mdi:weather-windy"],
|
"windforce_3d": ["Wind force 3d", "Bft", "mdi:weather-windy", None],
|
||||||
"windforce_4d": ["Wind force 4d", "Bft", "mdi:weather-windy"],
|
"windforce_4d": ["Wind force 4d", "Bft", "mdi:weather-windy", None],
|
||||||
"windforce_5d": ["Wind force 5d", "Bft", "mdi:weather-windy"],
|
"windforce_5d": ["Wind force 5d", "Bft", "mdi:weather-windy", None],
|
||||||
"windspeed_1d": ["Wind speed 1d", SPEED_KILOMETERS_PER_HOUR, "mdi:weather-windy"],
|
"windspeed_1d": [
|
||||||
"windspeed_2d": ["Wind speed 2d", SPEED_KILOMETERS_PER_HOUR, "mdi:weather-windy"],
|
"Wind speed 1d",
|
||||||
"windspeed_3d": ["Wind speed 3d", SPEED_KILOMETERS_PER_HOUR, "mdi:weather-windy"],
|
SPEED_KILOMETERS_PER_HOUR,
|
||||||
"windspeed_4d": ["Wind speed 4d", SPEED_KILOMETERS_PER_HOUR, "mdi:weather-windy"],
|
"mdi:weather-windy",
|
||||||
"windspeed_5d": ["Wind speed 5d", SPEED_KILOMETERS_PER_HOUR, "mdi:weather-windy"],
|
None,
|
||||||
"winddirection_1d": ["Wind direction 1d", None, "mdi:compass-outline"],
|
],
|
||||||
"winddirection_2d": ["Wind direction 2d", None, "mdi:compass-outline"],
|
"windspeed_2d": [
|
||||||
"winddirection_3d": ["Wind direction 3d", None, "mdi:compass-outline"],
|
"Wind speed 2d",
|
||||||
"winddirection_4d": ["Wind direction 4d", None, "mdi:compass-outline"],
|
SPEED_KILOMETERS_PER_HOUR,
|
||||||
"winddirection_5d": ["Wind direction 5d", None, "mdi:compass-outline"],
|
"mdi:weather-windy",
|
||||||
"windazimuth_1d": ["Wind direction azimuth 1d", DEGREE, "mdi:compass-outline"],
|
None,
|
||||||
"windazimuth_2d": ["Wind direction azimuth 2d", DEGREE, "mdi:compass-outline"],
|
],
|
||||||
"windazimuth_3d": ["Wind direction azimuth 3d", DEGREE, "mdi:compass-outline"],
|
"windspeed_3d": [
|
||||||
"windazimuth_4d": ["Wind direction azimuth 4d", DEGREE, "mdi:compass-outline"],
|
"Wind speed 3d",
|
||||||
"windazimuth_5d": ["Wind direction azimuth 5d", DEGREE, "mdi:compass-outline"],
|
SPEED_KILOMETERS_PER_HOUR,
|
||||||
"condition_1d": ["Condition 1d", None, None],
|
"mdi:weather-windy",
|
||||||
"condition_2d": ["Condition 2d", None, None],
|
None,
|
||||||
"condition_3d": ["Condition 3d", None, None],
|
],
|
||||||
"condition_4d": ["Condition 4d", None, None],
|
"windspeed_4d": [
|
||||||
"condition_5d": ["Condition 5d", None, None],
|
"Wind speed 4d",
|
||||||
"conditioncode_1d": ["Condition code 1d", None, None],
|
SPEED_KILOMETERS_PER_HOUR,
|
||||||
"conditioncode_2d": ["Condition code 2d", None, None],
|
"mdi:weather-windy",
|
||||||
"conditioncode_3d": ["Condition code 3d", None, None],
|
None,
|
||||||
"conditioncode_4d": ["Condition code 4d", None, None],
|
],
|
||||||
"conditioncode_5d": ["Condition code 5d", None, None],
|
"windspeed_5d": [
|
||||||
"conditiondetailed_1d": ["Detailed condition 1d", None, None],
|
"Wind speed 5d",
|
||||||
"conditiondetailed_2d": ["Detailed condition 2d", None, None],
|
SPEED_KILOMETERS_PER_HOUR,
|
||||||
"conditiondetailed_3d": ["Detailed condition 3d", None, None],
|
"mdi:weather-windy",
|
||||||
"conditiondetailed_4d": ["Detailed condition 4d", None, None],
|
None,
|
||||||
"conditiondetailed_5d": ["Detailed condition 5d", None, None],
|
],
|
||||||
"conditionexact_1d": ["Full condition 1d", None, None],
|
"winddirection_1d": ["Wind direction 1d", None, "mdi:compass-outline", None],
|
||||||
"conditionexact_2d": ["Full condition 2d", None, None],
|
"winddirection_2d": ["Wind direction 2d", None, "mdi:compass-outline", None],
|
||||||
"conditionexact_3d": ["Full condition 3d", None, None],
|
"winddirection_3d": ["Wind direction 3d", None, "mdi:compass-outline", None],
|
||||||
"conditionexact_4d": ["Full condition 4d", None, None],
|
"winddirection_4d": ["Wind direction 4d", None, "mdi:compass-outline", None],
|
||||||
"conditionexact_5d": ["Full condition 5d", None, None],
|
"winddirection_5d": ["Wind direction 5d", None, "mdi:compass-outline", None],
|
||||||
"symbol_1d": ["Symbol 1d", None, None],
|
"windazimuth_1d": [
|
||||||
"symbol_2d": ["Symbol 2d", None, None],
|
"Wind direction azimuth 1d",
|
||||||
"symbol_3d": ["Symbol 3d", None, None],
|
DEGREE,
|
||||||
"symbol_4d": ["Symbol 4d", None, None],
|
"mdi:compass-outline",
|
||||||
"symbol_5d": ["Symbol 5d", None, None],
|
None,
|
||||||
|
],
|
||||||
|
"windazimuth_2d": [
|
||||||
|
"Wind direction azimuth 2d",
|
||||||
|
DEGREE,
|
||||||
|
"mdi:compass-outline",
|
||||||
|
None,
|
||||||
|
],
|
||||||
|
"windazimuth_3d": [
|
||||||
|
"Wind direction azimuth 3d",
|
||||||
|
DEGREE,
|
||||||
|
"mdi:compass-outline",
|
||||||
|
None,
|
||||||
|
],
|
||||||
|
"windazimuth_4d": [
|
||||||
|
"Wind direction azimuth 4d",
|
||||||
|
DEGREE,
|
||||||
|
"mdi:compass-outline",
|
||||||
|
None,
|
||||||
|
],
|
||||||
|
"windazimuth_5d": [
|
||||||
|
"Wind direction azimuth 5d",
|
||||||
|
DEGREE,
|
||||||
|
"mdi:compass-outline",
|
||||||
|
None,
|
||||||
|
],
|
||||||
|
"condition_1d": ["Condition 1d", None, None, None],
|
||||||
|
"condition_2d": ["Condition 2d", None, None, None],
|
||||||
|
"condition_3d": ["Condition 3d", None, None, None],
|
||||||
|
"condition_4d": ["Condition 4d", None, None, None],
|
||||||
|
"condition_5d": ["Condition 5d", None, None, None],
|
||||||
|
"conditioncode_1d": ["Condition code 1d", None, None, None],
|
||||||
|
"conditioncode_2d": ["Condition code 2d", None, None, None],
|
||||||
|
"conditioncode_3d": ["Condition code 3d", None, None, None],
|
||||||
|
"conditioncode_4d": ["Condition code 4d", None, None, None],
|
||||||
|
"conditioncode_5d": ["Condition code 5d", None, None, None],
|
||||||
|
"conditiondetailed_1d": ["Detailed condition 1d", None, None, None],
|
||||||
|
"conditiondetailed_2d": ["Detailed condition 2d", None, None, None],
|
||||||
|
"conditiondetailed_3d": ["Detailed condition 3d", None, None, None],
|
||||||
|
"conditiondetailed_4d": ["Detailed condition 4d", None, None, None],
|
||||||
|
"conditiondetailed_5d": ["Detailed condition 5d", None, None, None],
|
||||||
|
"conditionexact_1d": ["Full condition 1d", None, None, None],
|
||||||
|
"conditionexact_2d": ["Full condition 2d", None, None, None],
|
||||||
|
"conditionexact_3d": ["Full condition 3d", None, None, None],
|
||||||
|
"conditionexact_4d": ["Full condition 4d", None, None, None],
|
||||||
|
"conditionexact_5d": ["Full condition 5d", None, None, None],
|
||||||
|
"symbol_1d": ["Symbol 1d", None, None, None],
|
||||||
|
"symbol_2d": ["Symbol 2d", None, None, None],
|
||||||
|
"symbol_3d": ["Symbol 3d", None, None, None],
|
||||||
|
"symbol_4d": ["Symbol 4d", None, None, None],
|
||||||
|
"symbol_5d": ["Symbol 5d", None, None, None],
|
||||||
}
|
}
|
||||||
|
|
||||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||||
|
@ -471,6 +600,11 @@ class BrSensor(SensorEntity):
|
||||||
"""Return the unit of measurement of this entity, if any."""
|
"""Return the unit of measurement of this entity, if any."""
|
||||||
return self._unit_of_measurement
|
return self._unit_of_measurement
|
||||||
|
|
||||||
|
@property
|
||||||
|
def device_class(self):
|
||||||
|
"""Return the class of this device, from component DEVICE_CLASSES."""
|
||||||
|
return SENSOR_TYPES[self.type][3]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def icon(self):
|
def icon(self):
|
||||||
"""Return possible sensor specific icon."""
|
"""Return possible sensor specific icon."""
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
"""Constants for ebus component."""
|
"""Constants for ebus component."""
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
ENERGY_KILO_WATT_HOUR,
|
ENERGY_KILO_WATT_HOUR,
|
||||||
PERCENTAGE,
|
PERCENTAGE,
|
||||||
PRESSURE_BAR,
|
PRESSURE_BAR,
|
||||||
|
@ -17,127 +18,243 @@ SENSOR_TYPES = {
|
||||||
"ActualFlowTemperatureDesired": [
|
"ActualFlowTemperatureDesired": [
|
||||||
"Hc1ActualFlowTempDesired",
|
"Hc1ActualFlowTempDesired",
|
||||||
TEMP_CELSIUS,
|
TEMP_CELSIUS,
|
||||||
"mdi:thermometer",
|
None,
|
||||||
0,
|
0,
|
||||||
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
],
|
],
|
||||||
"MaxFlowTemperatureDesired": [
|
"MaxFlowTemperatureDesired": [
|
||||||
"Hc1MaxFlowTempDesired",
|
"Hc1MaxFlowTempDesired",
|
||||||
TEMP_CELSIUS,
|
TEMP_CELSIUS,
|
||||||
"mdi:thermometer",
|
None,
|
||||||
0,
|
0,
|
||||||
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
],
|
],
|
||||||
"MinFlowTemperatureDesired": [
|
"MinFlowTemperatureDesired": [
|
||||||
"Hc1MinFlowTempDesired",
|
"Hc1MinFlowTempDesired",
|
||||||
TEMP_CELSIUS,
|
TEMP_CELSIUS,
|
||||||
"mdi:thermometer",
|
None,
|
||||||
0,
|
0,
|
||||||
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
],
|
],
|
||||||
"PumpStatus": ["Hc1PumpStatus", None, "mdi:toggle-switch", 2],
|
"PumpStatus": ["Hc1PumpStatus", None, "mdi:toggle-switch", 2, None],
|
||||||
"HCSummerTemperatureLimit": [
|
"HCSummerTemperatureLimit": [
|
||||||
"Hc1SummerTempLimit",
|
"Hc1SummerTempLimit",
|
||||||
TEMP_CELSIUS,
|
TEMP_CELSIUS,
|
||||||
"mdi:weather-sunny",
|
"mdi:weather-sunny",
|
||||||
0,
|
0,
|
||||||
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
|
],
|
||||||
|
"HolidayTemperature": [
|
||||||
|
"HolidayTemp",
|
||||||
|
TEMP_CELSIUS,
|
||||||
|
None,
|
||||||
|
0,
|
||||||
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
|
],
|
||||||
|
"HWTemperatureDesired": [
|
||||||
|
"HwcTempDesired",
|
||||||
|
TEMP_CELSIUS,
|
||||||
|
None,
|
||||||
|
0,
|
||||||
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
|
],
|
||||||
|
"HWActualTemperature": [
|
||||||
|
"HwcStorageTemp",
|
||||||
|
TEMP_CELSIUS,
|
||||||
|
None,
|
||||||
|
0,
|
||||||
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
|
],
|
||||||
|
"HWTimerMonday": ["hwcTimer.Monday", None, "mdi:timer-outline", 1, None],
|
||||||
|
"HWTimerTuesday": ["hwcTimer.Tuesday", None, "mdi:timer-outline", 1, None],
|
||||||
|
"HWTimerWednesday": ["hwcTimer.Wednesday", None, "mdi:timer-outline", 1, None],
|
||||||
|
"HWTimerThursday": ["hwcTimer.Thursday", None, "mdi:timer-outline", 1, None],
|
||||||
|
"HWTimerFriday": ["hwcTimer.Friday", None, "mdi:timer-outline", 1, None],
|
||||||
|
"HWTimerSaturday": ["hwcTimer.Saturday", None, "mdi:timer-outline", 1, None],
|
||||||
|
"HWTimerSunday": ["hwcTimer.Sunday", None, "mdi:timer-outline", 1, None],
|
||||||
|
"HWOperativeMode": ["HwcOpMode", None, "mdi:math-compass", 3, None],
|
||||||
|
"WaterPressure": ["WaterPressure", PRESSURE_BAR, "mdi:water-pump", 0, None],
|
||||||
|
"Zone1RoomZoneMapping": ["z1RoomZoneMapping", None, "mdi:label", 0, None],
|
||||||
|
"Zone1NightTemperature": [
|
||||||
|
"z1NightTemp",
|
||||||
|
TEMP_CELSIUS,
|
||||||
|
"mdi:weather-night",
|
||||||
|
0,
|
||||||
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
|
],
|
||||||
|
"Zone1DayTemperature": [
|
||||||
|
"z1DayTemp",
|
||||||
|
TEMP_CELSIUS,
|
||||||
|
"mdi:weather-sunny",
|
||||||
|
0,
|
||||||
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
],
|
],
|
||||||
"HolidayTemperature": ["HolidayTemp", TEMP_CELSIUS, "mdi:thermometer", 0],
|
|
||||||
"HWTemperatureDesired": ["HwcTempDesired", TEMP_CELSIUS, "mdi:thermometer", 0],
|
|
||||||
"HWActualTemperature": ["HwcStorageTemp", TEMP_CELSIUS, "mdi:thermometer", 0],
|
|
||||||
"HWTimerMonday": ["hwcTimer.Monday", None, "mdi:timer-outline", 1],
|
|
||||||
"HWTimerTuesday": ["hwcTimer.Tuesday", None, "mdi:timer-outline", 1],
|
|
||||||
"HWTimerWednesday": ["hwcTimer.Wednesday", None, "mdi:timer-outline", 1],
|
|
||||||
"HWTimerThursday": ["hwcTimer.Thursday", None, "mdi:timer-outline", 1],
|
|
||||||
"HWTimerFriday": ["hwcTimer.Friday", None, "mdi:timer-outline", 1],
|
|
||||||
"HWTimerSaturday": ["hwcTimer.Saturday", None, "mdi:timer-outline", 1],
|
|
||||||
"HWTimerSunday": ["hwcTimer.Sunday", None, "mdi:timer-outline", 1],
|
|
||||||
"HWOperativeMode": ["HwcOpMode", None, "mdi:math-compass", 3],
|
|
||||||
"WaterPressure": ["WaterPressure", PRESSURE_BAR, "mdi:water-pump", 0],
|
|
||||||
"Zone1RoomZoneMapping": ["z1RoomZoneMapping", None, "mdi:label", 0],
|
|
||||||
"Zone1NightTemperature": ["z1NightTemp", TEMP_CELSIUS, "mdi:weather-night", 0],
|
|
||||||
"Zone1DayTemperature": ["z1DayTemp", TEMP_CELSIUS, "mdi:weather-sunny", 0],
|
|
||||||
"Zone1HolidayTemperature": [
|
"Zone1HolidayTemperature": [
|
||||||
"z1HolidayTemp",
|
"z1HolidayTemp",
|
||||||
TEMP_CELSIUS,
|
TEMP_CELSIUS,
|
||||||
"mdi:thermometer",
|
None,
|
||||||
0,
|
0,
|
||||||
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
|
],
|
||||||
|
"Zone1RoomTemperature": [
|
||||||
|
"z1RoomTemp",
|
||||||
|
TEMP_CELSIUS,
|
||||||
|
None,
|
||||||
|
0,
|
||||||
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
],
|
],
|
||||||
"Zone1RoomTemperature": ["z1RoomTemp", TEMP_CELSIUS, "mdi:thermometer", 0],
|
|
||||||
"Zone1ActualRoomTemperatureDesired": [
|
"Zone1ActualRoomTemperatureDesired": [
|
||||||
"z1ActualRoomTempDesired",
|
"z1ActualRoomTempDesired",
|
||||||
TEMP_CELSIUS,
|
TEMP_CELSIUS,
|
||||||
"mdi:thermometer",
|
None,
|
||||||
0,
|
0,
|
||||||
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
|
],
|
||||||
|
"Zone1TimerMonday": ["z1Timer.Monday", None, "mdi:timer-outline", 1, None],
|
||||||
|
"Zone1TimerTuesday": ["z1Timer.Tuesday", None, "mdi:timer-outline", 1, None],
|
||||||
|
"Zone1TimerWednesday": [
|
||||||
|
"z1Timer.Wednesday",
|
||||||
|
None,
|
||||||
|
"mdi:timer-outline",
|
||||||
|
1,
|
||||||
|
None,
|
||||||
|
],
|
||||||
|
"Zone1TimerThursday": ["z1Timer.Thursday", None, "mdi:timer-outline", 1, None],
|
||||||
|
"Zone1TimerFriday": ["z1Timer.Friday", None, "mdi:timer-outline", 1, None],
|
||||||
|
"Zone1TimerSaturday": ["z1Timer.Saturday", None, "mdi:timer-outline", 1, None],
|
||||||
|
"Zone1TimerSunday": ["z1Timer.Sunday", None, "mdi:timer-outline", 1, None],
|
||||||
|
"Zone1OperativeMode": ["z1OpMode", None, "mdi:math-compass", 3, None],
|
||||||
|
"ContinuosHeating": [
|
||||||
|
"ContinuosHeating",
|
||||||
|
TEMP_CELSIUS,
|
||||||
|
"mdi:weather-snowy",
|
||||||
|
0,
|
||||||
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
],
|
],
|
||||||
"Zone1TimerMonday": ["z1Timer.Monday", None, "mdi:timer-outline", 1],
|
|
||||||
"Zone1TimerTuesday": ["z1Timer.Tuesday", None, "mdi:timer-outline", 1],
|
|
||||||
"Zone1TimerWednesday": ["z1Timer.Wednesday", None, "mdi:timer-outline", 1],
|
|
||||||
"Zone1TimerThursday": ["z1Timer.Thursday", None, "mdi:timer-outline", 1],
|
|
||||||
"Zone1TimerFriday": ["z1Timer.Friday", None, "mdi:timer-outline", 1],
|
|
||||||
"Zone1TimerSaturday": ["z1Timer.Saturday", None, "mdi:timer-outline", 1],
|
|
||||||
"Zone1TimerSunday": ["z1Timer.Sunday", None, "mdi:timer-outline", 1],
|
|
||||||
"Zone1OperativeMode": ["z1OpMode", None, "mdi:math-compass", 3],
|
|
||||||
"ContinuosHeating": ["ContinuosHeating", TEMP_CELSIUS, "mdi:weather-snowy", 0],
|
|
||||||
"PowerEnergyConsumptionLastMonth": [
|
"PowerEnergyConsumptionLastMonth": [
|
||||||
"PrEnergySumHcLastMonth",
|
"PrEnergySumHcLastMonth",
|
||||||
ENERGY_KILO_WATT_HOUR,
|
ENERGY_KILO_WATT_HOUR,
|
||||||
"mdi:flash",
|
"mdi:flash",
|
||||||
0,
|
0,
|
||||||
|
None,
|
||||||
],
|
],
|
||||||
"PowerEnergyConsumptionThisMonth": [
|
"PowerEnergyConsumptionThisMonth": [
|
||||||
"PrEnergySumHcThisMonth",
|
"PrEnergySumHcThisMonth",
|
||||||
ENERGY_KILO_WATT_HOUR,
|
ENERGY_KILO_WATT_HOUR,
|
||||||
"mdi:flash",
|
"mdi:flash",
|
||||||
0,
|
0,
|
||||||
|
None,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
"ehp": {
|
"ehp": {
|
||||||
"HWTemperature": ["HwcTemp", TEMP_CELSIUS, "mdi:thermometer", 4],
|
"HWTemperature": ["HwcTemp", TEMP_CELSIUS, None, 4, DEVICE_CLASS_TEMPERATURE],
|
||||||
"OutsideTemp": ["OutsideTemp", TEMP_CELSIUS, "mdi:thermometer", 4],
|
"OutsideTemp": ["OutsideTemp", TEMP_CELSIUS, None, 4, DEVICE_CLASS_TEMPERATURE],
|
||||||
},
|
},
|
||||||
"bai": {
|
"bai": {
|
||||||
"HotWaterTemperature": ["HwcTemp", TEMP_CELSIUS, "mdi:thermometer", 4],
|
"HotWaterTemperature": [
|
||||||
"StorageTemperature": ["StorageTemp", TEMP_CELSIUS, "mdi:thermometer", 4],
|
"HwcTemp",
|
||||||
|
TEMP_CELSIUS,
|
||||||
|
None,
|
||||||
|
4,
|
||||||
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
|
],
|
||||||
|
"StorageTemperature": [
|
||||||
|
"StorageTemp",
|
||||||
|
TEMP_CELSIUS,
|
||||||
|
None,
|
||||||
|
4,
|
||||||
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
|
],
|
||||||
"DesiredStorageTemperature": [
|
"DesiredStorageTemperature": [
|
||||||
"StorageTempDesired",
|
"StorageTempDesired",
|
||||||
TEMP_CELSIUS,
|
TEMP_CELSIUS,
|
||||||
"mdi:thermometer",
|
None,
|
||||||
0,
|
0,
|
||||||
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
],
|
],
|
||||||
"OutdoorsTemperature": [
|
"OutdoorsTemperature": [
|
||||||
"OutdoorstempSensor",
|
"OutdoorstempSensor",
|
||||||
TEMP_CELSIUS,
|
TEMP_CELSIUS,
|
||||||
"mdi:thermometer",
|
None,
|
||||||
4,
|
4,
|
||||||
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
],
|
],
|
||||||
"WaterPreasure": ["WaterPressure", PRESSURE_BAR, "mdi:pipe", 4],
|
"WaterPreasure": ["WaterPressure", PRESSURE_BAR, "mdi:pipe", 4, None],
|
||||||
"AverageIgnitionTime": ["averageIgnitiontime", TIME_SECONDS, "mdi:av-timer", 0],
|
"AverageIgnitionTime": [
|
||||||
"MaximumIgnitionTime": ["maxIgnitiontime", TIME_SECONDS, "mdi:av-timer", 0],
|
"averageIgnitiontime",
|
||||||
"MinimumIgnitionTime": ["minIgnitiontime", TIME_SECONDS, "mdi:av-timer", 0],
|
TIME_SECONDS,
|
||||||
"ReturnTemperature": ["ReturnTemp", TEMP_CELSIUS, "mdi:thermometer", 4],
|
"mdi:av-timer",
|
||||||
"CentralHeatingPump": ["WP", None, "mdi:toggle-switch", 2],
|
0,
|
||||||
"HeatingSwitch": ["HeatingSwitch", None, "mdi:toggle-switch", 2],
|
None,
|
||||||
|
],
|
||||||
|
"MaximumIgnitionTime": [
|
||||||
|
"maxIgnitiontime",
|
||||||
|
TIME_SECONDS,
|
||||||
|
"mdi:av-timer",
|
||||||
|
0,
|
||||||
|
None,
|
||||||
|
],
|
||||||
|
"MinimumIgnitionTime": [
|
||||||
|
"minIgnitiontime",
|
||||||
|
TIME_SECONDS,
|
||||||
|
"mdi:av-timer",
|
||||||
|
0,
|
||||||
|
None,
|
||||||
|
],
|
||||||
|
"ReturnTemperature": [
|
||||||
|
"ReturnTemp",
|
||||||
|
TEMP_CELSIUS,
|
||||||
|
None,
|
||||||
|
4,
|
||||||
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
|
],
|
||||||
|
"CentralHeatingPump": ["WP", None, "mdi:toggle-switch", 2, None],
|
||||||
|
"HeatingSwitch": ["HeatingSwitch", None, "mdi:toggle-switch", 2, None],
|
||||||
"DesiredFlowTemperature": [
|
"DesiredFlowTemperature": [
|
||||||
"FlowTempDesired",
|
"FlowTempDesired",
|
||||||
TEMP_CELSIUS,
|
TEMP_CELSIUS,
|
||||||
"mdi:thermometer",
|
None,
|
||||||
0,
|
0,
|
||||||
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
],
|
],
|
||||||
"FlowTemperature": ["FlowTemp", TEMP_CELSIUS, "mdi:thermometer", 4],
|
"FlowTemperature": [
|
||||||
"Flame": ["Flame", None, "mdi:toggle-switch", 2],
|
"FlowTemp",
|
||||||
|
TEMP_CELSIUS,
|
||||||
|
None,
|
||||||
|
4,
|
||||||
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
|
None,
|
||||||
|
],
|
||||||
|
"Flame": ["Flame", None, "mdi:toggle-switch", 2, None],
|
||||||
"PowerEnergyConsumptionHeatingCircuit": [
|
"PowerEnergyConsumptionHeatingCircuit": [
|
||||||
"PrEnergySumHc1",
|
"PrEnergySumHc1",
|
||||||
ENERGY_KILO_WATT_HOUR,
|
ENERGY_KILO_WATT_HOUR,
|
||||||
"mdi:flash",
|
"mdi:flash",
|
||||||
0,
|
0,
|
||||||
|
None,
|
||||||
],
|
],
|
||||||
"PowerEnergyConsumptionHotWaterCircuit": [
|
"PowerEnergyConsumptionHotWaterCircuit": [
|
||||||
"PrEnergySumHwc1",
|
"PrEnergySumHwc1",
|
||||||
ENERGY_KILO_WATT_HOUR,
|
ENERGY_KILO_WATT_HOUR,
|
||||||
"mdi:flash",
|
"mdi:flash",
|
||||||
0,
|
0,
|
||||||
|
None,
|
||||||
|
],
|
||||||
|
"RoomThermostat": ["DCRoomthermostat", None, "mdi:toggle-switch", 2, None],
|
||||||
|
"HeatingPartLoad": [
|
||||||
|
"PartloadHcKW",
|
||||||
|
ENERGY_KILO_WATT_HOUR,
|
||||||
|
"mdi:flash",
|
||||||
|
0,
|
||||||
|
None,
|
||||||
|
],
|
||||||
|
"StateNumber": ["StateNumber", None, "mdi:fire", 3, None],
|
||||||
|
"ModulationPercentage": [
|
||||||
|
"ModulationTempDesired",
|
||||||
|
PERCENTAGE,
|
||||||
|
"mdi:percent",
|
||||||
|
0,
|
||||||
|
None,
|
||||||
],
|
],
|
||||||
"RoomThermostat": ["DCRoomthermostat", None, "mdi:toggle-switch", 2],
|
|
||||||
"HeatingPartLoad": ["PartloadHcKW", ENERGY_KILO_WATT_HOUR, "mdi:flash", 0],
|
|
||||||
"StateNumber": ["StateNumber", None, "mdi:fire", 3],
|
|
||||||
"ModulationPercentage": ["ModulationTempDesired", PERCENTAGE, "mdi:percent", 0],
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,13 @@ class EbusdSensor(SensorEntity):
|
||||||
"""Initialize the sensor."""
|
"""Initialize the sensor."""
|
||||||
self._state = None
|
self._state = None
|
||||||
self._client_name = name
|
self._client_name = name
|
||||||
self._name, self._unit_of_measurement, self._icon, self._type = sensor
|
(
|
||||||
|
self._name,
|
||||||
|
self._unit_of_measurement,
|
||||||
|
self._icon,
|
||||||
|
self._type,
|
||||||
|
self._device_class,
|
||||||
|
) = sensor
|
||||||
self.data = data
|
self.data = data
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -77,6 +83,11 @@ class EbusdSensor(SensorEntity):
|
||||||
return schedule
|
return schedule
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def device_class(self):
|
||||||
|
"""Return the class of this device, from component DEVICE_CLASSES."""
|
||||||
|
return self._device_class
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def icon(self):
|
def icon(self):
|
||||||
"""Icon to use in the frontend, if any."""
|
"""Icon to use in the frontend, if any."""
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""Allows reading temperatures from ecoal/esterownik.pl controller."""
|
"""Allows reading temperatures from ecoal/esterownik.pl controller."""
|
||||||
from homeassistant.components.sensor import SensorEntity
|
from homeassistant.components.sensor import SensorEntity
|
||||||
from homeassistant.const import TEMP_CELSIUS
|
from homeassistant.const import DEVICE_CLASS_TEMPERATURE, TEMP_CELSIUS
|
||||||
|
|
||||||
from . import AVAILABLE_SENSORS, DATA_ECOAL_BOILER
|
from . import AVAILABLE_SENSORS, DATA_ECOAL_BOILER
|
||||||
|
|
||||||
|
@ -37,6 +37,11 @@ class EcoalTempSensor(SensorEntity):
|
||||||
"""Return the state of the sensor."""
|
"""Return the state of the sensor."""
|
||||||
return self._state
|
return self._state
|
||||||
|
|
||||||
|
@property
|
||||||
|
def device_class(self):
|
||||||
|
"""Return the class of this device, from component DEVICE_CLASSES."""
|
||||||
|
return DEVICE_CLASS_TEMPERATURE
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unit_of_measurement(self):
|
def unit_of_measurement(self):
|
||||||
"""Return the unit of measurement."""
|
"""Return the unit of measurement."""
|
||||||
|
|
|
@ -13,6 +13,7 @@ import voluptuous as vol
|
||||||
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_NAME,
|
CONF_NAME,
|
||||||
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
EVENT_HOMEASSISTANT_START,
|
EVENT_HOMEASSISTANT_START,
|
||||||
EVENT_HOMEASSISTANT_STOP,
|
EVENT_HOMEASSISTANT_STOP,
|
||||||
STATE_UNKNOWN,
|
STATE_UNKNOWN,
|
||||||
|
@ -117,6 +118,11 @@ class EddystoneTemp(SensorEntity):
|
||||||
"""Return the state of the device."""
|
"""Return the state of the device."""
|
||||||
return self.temperature
|
return self.temperature
|
||||||
|
|
||||||
|
@property
|
||||||
|
def device_class(self):
|
||||||
|
"""Return the class of this device, from component DEVICE_CLASSES."""
|
||||||
|
return DEVICE_CLASS_TEMPERATURE
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unit_of_measurement(self):
|
def unit_of_measurement(self):
|
||||||
"""Return the unit the value is expressed in."""
|
"""Return the unit the value is expressed in."""
|
||||||
|
|
|
@ -2,7 +2,12 @@
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.components.sensor import SensorEntity
|
from homeassistant.components.sensor import SensorEntity
|
||||||
from homeassistant.const import PERCENTAGE, TEMP_CELSIUS, TEMP_FAHRENHEIT
|
from homeassistant.const import (
|
||||||
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
|
PERCENTAGE,
|
||||||
|
TEMP_CELSIUS,
|
||||||
|
TEMP_FAHRENHEIT,
|
||||||
|
)
|
||||||
|
|
||||||
from . import (
|
from . import (
|
||||||
CONF_SENSORS,
|
CONF_SENSORS,
|
||||||
|
@ -172,10 +177,11 @@ class EightUserSensor(EightSleepUserEntity, SensorEntity):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def icon(self):
|
def device_class(self):
|
||||||
"""Icon to use in the frontend, if any."""
|
"""Return the class of this device, from component DEVICE_CLASSES."""
|
||||||
if "bed_temp" in self._sensor:
|
if "bed_temp" in self._sensor:
|
||||||
return "mdi:thermometer"
|
return DEVICE_CLASS_TEMPERATURE
|
||||||
|
return None
|
||||||
|
|
||||||
async def async_update(self):
|
async def async_update(self):
|
||||||
"""Retrieve latest state."""
|
"""Retrieve latest state."""
|
||||||
|
@ -334,6 +340,6 @@ class EightRoomSensor(EightSleepUserEntity, SensorEntity):
|
||||||
return TEMP_FAHRENHEIT
|
return TEMP_FAHRENHEIT
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def icon(self):
|
def device_class(self):
|
||||||
"""Icon to use in the frontend, if any."""
|
"""Return the class of this device, from component DEVICE_CLASSES."""
|
||||||
return "mdi:thermometer"
|
return DEVICE_CLASS_TEMPERATURE
|
||||||
|
|
|
@ -12,6 +12,7 @@ from homeassistant.const import (
|
||||||
ATTR_LOCATION,
|
ATTR_LOCATION,
|
||||||
CONF_LATITUDE,
|
CONF_LATITUDE,
|
||||||
CONF_LONGITUDE,
|
CONF_LONGITUDE,
|
||||||
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
TEMP_CELSIUS,
|
TEMP_CELSIUS,
|
||||||
)
|
)
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
@ -77,6 +78,7 @@ class ECSensor(SensorEntity):
|
||||||
self._state = None
|
self._state = None
|
||||||
self._attr = None
|
self._attr = None
|
||||||
self._unit = None
|
self._unit = None
|
||||||
|
self._device_class = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self) -> str:
|
def unique_id(self) -> str:
|
||||||
|
@ -103,6 +105,11 @@ class ECSensor(SensorEntity):
|
||||||
"""Return the units of measurement."""
|
"""Return the units of measurement."""
|
||||||
return self._unit
|
return self._unit
|
||||||
|
|
||||||
|
@property
|
||||||
|
def device_class(self):
|
||||||
|
"""Return the class of this device, from component DEVICE_CLASSES."""
|
||||||
|
return self._device_class
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
"""Update current conditions."""
|
"""Update current conditions."""
|
||||||
self.ec_data.update()
|
self.ec_data.update()
|
||||||
|
@ -135,6 +142,7 @@ class ECSensor(SensorEntity):
|
||||||
"humidex",
|
"humidex",
|
||||||
]:
|
]:
|
||||||
self._unit = TEMP_CELSIUS
|
self._unit = TEMP_CELSIUS
|
||||||
|
self._device_class = DEVICE_CLASS_TEMPERATURE
|
||||||
else:
|
else:
|
||||||
self._unit = sensor_data.get("unit")
|
self._unit = sensor_data.get("unit")
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_DISPLAY_OPTIONS,
|
CONF_DISPLAY_OPTIONS,
|
||||||
CONF_NAME,
|
CONF_NAME,
|
||||||
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
PRESSURE_HPA,
|
PRESSURE_HPA,
|
||||||
TEMP_CELSIUS,
|
TEMP_CELSIUS,
|
||||||
VOLT,
|
VOLT,
|
||||||
|
@ -24,22 +25,22 @@ CONF_USE_LEDS = "use_leds"
|
||||||
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=60)
|
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=60)
|
||||||
|
|
||||||
SENSOR_TYPES = {
|
SENSOR_TYPES = {
|
||||||
"light": ["light", " ", "mdi:weather-sunny"],
|
"light": ["light", " ", "mdi:weather-sunny", None],
|
||||||
"light_red": ["light_red", " ", "mdi:invert-colors"],
|
"light_red": ["light_red", " ", "mdi:invert-colors", None],
|
||||||
"light_green": ["light_green", " ", "mdi:invert-colors"],
|
"light_green": ["light_green", " ", "mdi:invert-colors", None],
|
||||||
"light_blue": ["light_blue", " ", "mdi:invert-colors"],
|
"light_blue": ["light_blue", " ", "mdi:invert-colors", None],
|
||||||
"accelerometer_x": ["accelerometer_x", "G", "mdi:earth"],
|
"accelerometer_x": ["accelerometer_x", "G", "mdi:earth", None],
|
||||||
"accelerometer_y": ["accelerometer_y", "G", "mdi:earth"],
|
"accelerometer_y": ["accelerometer_y", "G", "mdi:earth", None],
|
||||||
"accelerometer_z": ["accelerometer_z", "G", "mdi:earth"],
|
"accelerometer_z": ["accelerometer_z", "G", "mdi:earth", None],
|
||||||
"magnetometer_x": ["magnetometer_x", " ", "mdi:magnet"],
|
"magnetometer_x": ["magnetometer_x", " ", "mdi:magnet", None],
|
||||||
"magnetometer_y": ["magnetometer_y", " ", "mdi:magnet"],
|
"magnetometer_y": ["magnetometer_y", " ", "mdi:magnet", None],
|
||||||
"magnetometer_z": ["magnetometer_z", " ", "mdi:magnet"],
|
"magnetometer_z": ["magnetometer_z", " ", "mdi:magnet", None],
|
||||||
"temperature": ["temperature", TEMP_CELSIUS, "mdi:thermometer"],
|
"temperature": ["temperature", TEMP_CELSIUS, None, DEVICE_CLASS_TEMPERATURE],
|
||||||
"pressure": ["pressure", PRESSURE_HPA, "mdi:gauge"],
|
"pressure": ["pressure", PRESSURE_HPA, "mdi:gauge", None],
|
||||||
"voltage_0": ["voltage_0", VOLT, "mdi:flash"],
|
"voltage_0": ["voltage_0", VOLT, "mdi:flash", None],
|
||||||
"voltage_1": ["voltage_1", VOLT, "mdi:flash"],
|
"voltage_1": ["voltage_1", VOLT, "mdi:flash", None],
|
||||||
"voltage_2": ["voltage_2", VOLT, "mdi:flash"],
|
"voltage_2": ["voltage_2", VOLT, "mdi:flash", None],
|
||||||
"voltage_3": ["voltage_3", VOLT, "mdi:flash"],
|
"voltage_3": ["voltage_3", VOLT, "mdi:flash", None],
|
||||||
}
|
}
|
||||||
|
|
||||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||||
|
@ -91,6 +92,11 @@ class EnvirophatSensor(SensorEntity):
|
||||||
"""Return the state of the sensor."""
|
"""Return the state of the sensor."""
|
||||||
return self._state
|
return self._state
|
||||||
|
|
||||||
|
@property
|
||||||
|
def device_class(self):
|
||||||
|
"""Return the class of this device, from component DEVICE_CLASSES."""
|
||||||
|
return SENSOR_TYPES[self.type][3]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def icon(self):
|
def icon(self):
|
||||||
"""Icon to use in the frontend, if any."""
|
"""Icon to use in the frontend, if any."""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue