Skip to content

Commit a22cd5d

Browse files
authored
Merge pull request #97 from RogerSelwyn/patch-1
Add required device class and UOM to last meter reading
2 parents de5ed80 + 993bbf1 commit a22cd5d

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

custom_components/monta/sensor.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
SensorEntityDescription,
1616
)
1717
from homeassistant.config_entries import ConfigEntry
18+
from homeassistant.const import (
19+
UnitOfEnergy,
20+
)
1821
from homeassistant.core import HomeAssistant
1922
from homeassistant.helpers.entity import generate_entity_id
2023
from homeassistant.helpers.entity_platform import AddEntitiesCallback
@@ -143,6 +146,8 @@ def _parse_date(chargedate: str):
143146
key="charger_lastMeterReadingKwh",
144147
name="Last meter reading",
145148
icon="mdi:wallet",
149+
device_class=SensorDeviceClass.ENERGY,
150+
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
146151
value_fn=lambda data: data["lastMeterReadingKwh"],
147152
extra_state_attributes_fn=None,
148153
),

0 commit comments

Comments
 (0)