Fix unit of measurement for P1 Montior (#57495)
This commit is contained in:
parent
a3b3c4ebad
commit
efbe8a8689
2 changed files with 20 additions and 16 deletions
|
@ -19,7 +19,6 @@ from homeassistant.const import (
|
|||
DEVICE_CLASS_CURRENT,
|
||||
DEVICE_CLASS_ENERGY,
|
||||
DEVICE_CLASS_GAS,
|
||||
DEVICE_CLASS_MONETARY,
|
||||
DEVICE_CLASS_POWER,
|
||||
DEVICE_CLASS_VOLTAGE,
|
||||
ELECTRIC_CURRENT_AMPERE,
|
||||
|
@ -195,32 +194,32 @@ SENSORS: dict[
|
|||
key="gas_consumption_price",
|
||||
name="Gas Consumption Price",
|
||||
entity_registry_enabled_default=False,
|
||||
device_class=DEVICE_CLASS_MONETARY,
|
||||
native_unit_of_measurement=CURRENCY_EURO,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
native_unit_of_measurement=f"{CURRENCY_EURO}/{VOLUME_CUBIC_METERS}",
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="energy_consumption_price_low",
|
||||
name="Energy Consumption Price - Low",
|
||||
device_class=DEVICE_CLASS_MONETARY,
|
||||
native_unit_of_measurement=CURRENCY_EURO,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
native_unit_of_measurement=f"{CURRENCY_EURO}/{ENERGY_KILO_WATT_HOUR}",
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="energy_consumption_price_high",
|
||||
name="Energy Consumption Price - High",
|
||||
device_class=DEVICE_CLASS_MONETARY,
|
||||
native_unit_of_measurement=CURRENCY_EURO,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
native_unit_of_measurement=f"{CURRENCY_EURO}/{ENERGY_KILO_WATT_HOUR}",
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="energy_production_price_low",
|
||||
name="Energy Production Price - Low",
|
||||
device_class=DEVICE_CLASS_MONETARY,
|
||||
native_unit_of_measurement=CURRENCY_EURO,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
native_unit_of_measurement=f"{CURRENCY_EURO}/{ENERGY_KILO_WATT_HOUR}",
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="energy_production_price_high",
|
||||
name="Energy Production Price - High",
|
||||
device_class=DEVICE_CLASS_MONETARY,
|
||||
native_unit_of_measurement=CURRENCY_EURO,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
native_unit_of_measurement=f"{CURRENCY_EURO}/{ENERGY_KILO_WATT_HOUR}",
|
||||
),
|
||||
),
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@ from homeassistant.const import (
|
|||
CURRENCY_EURO,
|
||||
DEVICE_CLASS_CURRENT,
|
||||
DEVICE_CLASS_ENERGY,
|
||||
DEVICE_CLASS_MONETARY,
|
||||
DEVICE_CLASS_POWER,
|
||||
DEVICE_CLASS_VOLTAGE,
|
||||
ELECTRIC_CURRENT_AMPERE,
|
||||
|
@ -158,8 +157,11 @@ async def test_settings(
|
|||
assert entry.unique_id == f"{entry_id}_settings_energy_consumption_price_low"
|
||||
assert state.state == "0.20522"
|
||||
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "Energy Consumption Price - Low"
|
||||
assert state.attributes.get(ATTR_DEVICE_CLASS) == DEVICE_CLASS_MONETARY
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == CURRENCY_EURO
|
||||
assert state.attributes.get(ATTR_STATE_CLASS) == STATE_CLASS_MEASUREMENT
|
||||
assert (
|
||||
state.attributes.get(ATTR_UNIT_OF_MEASUREMENT)
|
||||
== f"{CURRENCY_EURO}/{ENERGY_KILO_WATT_HOUR}"
|
||||
)
|
||||
|
||||
state = hass.states.get("sensor.monitor_energy_production_price_low")
|
||||
entry = entity_registry.async_get("sensor.monitor_energy_production_price_low")
|
||||
|
@ -168,8 +170,11 @@ async def test_settings(
|
|||
assert entry.unique_id == f"{entry_id}_settings_energy_production_price_low"
|
||||
assert state.state == "0.20522"
|
||||
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "Energy Production Price - Low"
|
||||
assert state.attributes.get(ATTR_DEVICE_CLASS) == DEVICE_CLASS_MONETARY
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == CURRENCY_EURO
|
||||
assert state.attributes.get(ATTR_STATE_CLASS) == STATE_CLASS_MEASUREMENT
|
||||
assert (
|
||||
state.attributes.get(ATTR_UNIT_OF_MEASUREMENT)
|
||||
== f"{CURRENCY_EURO}/{ENERGY_KILO_WATT_HOUR}"
|
||||
)
|
||||
|
||||
assert entry.device_id
|
||||
device_entry = device_registry.async_get(entry.device_id)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue