Skip to content

Commit

Permalink
Correct reactive power device class (#1417)
Browse files Browse the repository at this point in the history
* reactive power

* fix

* exclude energy reactive
  • Loading branch information
N3rdix authored Dec 1, 2024
1 parent a55913c commit 51bc142
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion custom_components/ocpp/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,19 @@ def device_class(self):
device_class = SensorDeviceClass.CURRENT
elif self.metric.lower().startswith("voltage"):
device_class = SensorDeviceClass.VOLTAGE
elif self.metric.lower().startswith("energy.r"):
device_class = None
elif self.metric.lower().startswith("energy."):
device_class = SensorDeviceClass.ENERGY
elif self.metric in [
Measurand.frequency,
Measurand.rpm,
] or self.metric.lower().startswith("frequency"):
device_class = SensorDeviceClass.FREQUENCY
elif self.metric.lower().startswith(("power.a", "power.o", "power.r")):
elif self.metric.lower().startswith(("power.a", "power.o")):
device_class = SensorDeviceClass.POWER
elif self.metric.lower().startswith("power.r"):
device_class = SensorDeviceClass.REACTIVE_POWER
elif self.metric.lower().startswith("temperature."):
device_class = SensorDeviceClass.TEMPERATURE
elif self.metric.lower().startswith("timestamp.") or self.metric in [
Expand Down

0 comments on commit 51bc142

Please sign in to comment.