Add enum device class and translations to DSMR Active tariff sensor (#84253)
parent
a6217ca9b9
commit
298ea3ff46
|
@ -97,6 +97,9 @@ SENSORS: tuple[DSMRSensorEntityDescription, ...] = (
|
|||
name="Active tariff",
|
||||
obis_reference=obis_references.ELECTRICITY_ACTIVE_TARIFF,
|
||||
dsmr_versions={"2.2", "4", "5", "5B", "5L"},
|
||||
device_class=SensorDeviceClass.ENUM,
|
||||
options=["low", "normal"],
|
||||
translation_key="electricity_tariff",
|
||||
icon="mdi:flash",
|
||||
),
|
||||
DSMRSensorEntityDescription(
|
||||
|
|
|
@ -40,6 +40,16 @@
|
|||
"cannot_communicate": "Failed to communicate"
|
||||
}
|
||||
},
|
||||
"entity": {
|
||||
"sensor": {
|
||||
"electricity_tariff": {
|
||||
"state": {
|
||||
"low": "Low",
|
||||
"normal": "Normal"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"options": {
|
||||
"step": {
|
||||
"init": {
|
||||
|
|
|
@ -40,6 +40,16 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"entity": {
|
||||
"sensor": {
|
||||
"electricity_tariff": {
|
||||
"state": {
|
||||
"low": "Low",
|
||||
"normal": "Normal"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"options": {
|
||||
"step": {
|
||||
"init": {
|
||||
|
|
|
@ -13,6 +13,7 @@ from unittest.mock import DEFAULT, MagicMock
|
|||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.sensor import (
|
||||
ATTR_OPTIONS,
|
||||
ATTR_STATE_CLASS,
|
||||
SensorDeviceClass,
|
||||
SensorStateClass,
|
||||
|
@ -116,8 +117,9 @@ async def test_default_setup(hass, dsmr_connection_fixture):
|
|||
# tariff should be translated in human readable and have no unit
|
||||
active_tariff = hass.states.get("sensor.electricity_meter_active_tariff")
|
||||
assert active_tariff.state == "low"
|
||||
assert active_tariff.attributes.get(ATTR_DEVICE_CLASS) is None
|
||||
assert active_tariff.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.ENUM
|
||||
assert active_tariff.attributes.get(ATTR_ICON) == "mdi:flash"
|
||||
assert active_tariff.attributes.get(ATTR_OPTIONS) == ["low", "normal"]
|
||||
assert active_tariff.attributes.get(ATTR_STATE_CLASS) is None
|
||||
assert active_tariff.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == ""
|
||||
|
||||
|
@ -215,8 +217,9 @@ async def test_v4_meter(hass, dsmr_connection_fixture):
|
|||
# tariff should be translated in human readable and have no unit
|
||||
active_tariff = hass.states.get("sensor.electricity_meter_active_tariff")
|
||||
assert active_tariff.state == "low"
|
||||
assert active_tariff.attributes.get(ATTR_DEVICE_CLASS) is None
|
||||
assert active_tariff.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.ENUM
|
||||
assert active_tariff.attributes.get(ATTR_ICON) == "mdi:flash"
|
||||
assert active_tariff.attributes.get(ATTR_OPTIONS) == ["low", "normal"]
|
||||
assert active_tariff.attributes.get(ATTR_STATE_CLASS) is None
|
||||
assert active_tariff.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == ""
|
||||
|
||||
|
@ -286,8 +289,9 @@ async def test_v5_meter(hass, dsmr_connection_fixture):
|
|||
# tariff should be translated in human readable and have no unit
|
||||
active_tariff = hass.states.get("sensor.electricity_meter_active_tariff")
|
||||
assert active_tariff.state == "low"
|
||||
assert active_tariff.attributes.get(ATTR_DEVICE_CLASS) is None
|
||||
assert active_tariff.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.ENUM
|
||||
assert active_tariff.attributes.get(ATTR_ICON) == "mdi:flash"
|
||||
assert active_tariff.attributes.get(ATTR_OPTIONS) == ["low", "normal"]
|
||||
assert active_tariff.attributes.get(ATTR_STATE_CLASS) is None
|
||||
assert active_tariff.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == ""
|
||||
|
||||
|
@ -440,8 +444,9 @@ async def test_belgian_meter(hass, dsmr_connection_fixture):
|
|||
# tariff should be translated in human readable and have no unit
|
||||
active_tariff = hass.states.get("sensor.electricity_meter_active_tariff")
|
||||
assert active_tariff.state == "normal"
|
||||
assert active_tariff.attributes.get(ATTR_DEVICE_CLASS) is None
|
||||
assert active_tariff.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.ENUM
|
||||
assert active_tariff.attributes.get(ATTR_ICON) == "mdi:flash"
|
||||
assert active_tariff.attributes.get(ATTR_OPTIONS) == ["low", "normal"]
|
||||
assert active_tariff.attributes.get(ATTR_STATE_CLASS) is None
|
||||
assert active_tariff.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == ""
|
||||
|
||||
|
@ -499,8 +504,9 @@ async def test_belgian_meter_low(hass, dsmr_connection_fixture):
|
|||
# tariff should be translated in human readable and have no unit
|
||||
active_tariff = hass.states.get("sensor.electricity_meter_active_tariff")
|
||||
assert active_tariff.state == "low"
|
||||
assert active_tariff.attributes.get(ATTR_DEVICE_CLASS) is None
|
||||
assert active_tariff.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.ENUM
|
||||
assert active_tariff.attributes.get(ATTR_ICON) == "mdi:flash"
|
||||
assert active_tariff.attributes.get(ATTR_OPTIONS) == ["low", "normal"]
|
||||
assert active_tariff.attributes.get(ATTR_STATE_CLASS) is None
|
||||
assert active_tariff.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == ""
|
||||
|
||||
|
|
Loading…
Reference in New Issue