Use ENERGY_KILO_WATT_HOUR constant (#33962)
This commit is contained in:
parent
c3c4752fa5
commit
02c9e47db8
13 changed files with 132 additions and 60 deletions
|
@ -16,7 +16,7 @@ import pytest
|
|||
|
||||
from homeassistant.bootstrap import async_setup_component
|
||||
from homeassistant.components.dsmr.sensor import DerivativeDSMREntity
|
||||
from homeassistant.const import TIME_HOURS, VOLUME_CUBIC_METERS
|
||||
from homeassistant.const import ENERGY_KILO_WATT_HOUR, TIME_HOURS, VOLUME_CUBIC_METERS
|
||||
|
||||
from tests.common import assert_setup_component
|
||||
|
||||
|
@ -62,7 +62,7 @@ async def test_default_setup(hass, mock_connection_factory):
|
|||
|
||||
telegram = {
|
||||
CURRENT_ELECTRICITY_USAGE: CosemObject(
|
||||
[{"value": Decimal("0.0"), "unit": "kWh"}]
|
||||
[{"value": Decimal("0.0"), "unit": ENERGY_KILO_WATT_HOUR}]
|
||||
),
|
||||
ELECTRICITY_ACTIVE_TARIFF: CosemObject([{"value": "0001", "unit": ""}]),
|
||||
GAS_METER_READING: MBusObject(
|
||||
|
@ -92,7 +92,9 @@ async def test_default_setup(hass, mock_connection_factory):
|
|||
# ensure entities have new state value after incoming telegram
|
||||
power_consumption = hass.states.get("sensor.power_consumption")
|
||||
assert power_consumption.state == "0.0"
|
||||
assert power_consumption.attributes.get("unit_of_measurement") == "kWh"
|
||||
assert (
|
||||
power_consumption.attributes.get("unit_of_measurement") == ENERGY_KILO_WATT_HOUR
|
||||
)
|
||||
|
||||
# tariff should be translated in human readable and have no unit
|
||||
power_tariff = hass.states.get("sensor.power_tariff")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue