Skip to content

Commit aa83e47

Browse files
committed
device_class & state_class first try
1 parent 4c47385 commit aa83e47

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

nibe_mqtt/mqtt.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,17 @@ def publish_discovery(self, coil: Coil, device_info: dict):
106106
uom = coil.unit
107107
if uom is not None:
108108
config["unit_of_measurement"] = uom
109-
109+
if uom == "°C":
110+
config["device_class"] = "temperature"
111+
config["state_class"] = "measurement"
112+
elif uom in ["h", "min"]:
113+
config["device_class"] = "duration"
114+
elif uom in ["kW", "W"]:
115+
config["device_class"] = "power"
116+
elif uom == "kWh":
117+
config["device_class"] = "energy"
118+
elif uom == "Hz":
119+
config["device_class"] = "frequency"
110120
if coil.is_boolean:
111121
if coil.is_writable: # switch
112122
component = "switch"

0 commit comments

Comments
 (0)