mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
Use ENERGY_KILO_WATT_HOUR constant (#33962)
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user