Skip to content

Commit

Permalink
sml-mqtt-bridge.py: Add properties for energy dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
mtdcr committed Oct 22, 2021
1 parent f4449d2 commit 21c6bcb
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions examples/sml-mqtt-bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,12 @@ async def _publish_hass_config(self, mqtt) -> None:
config["unit_of_measurement"] = unit
if unit == "W":
config["device_class"] = "power"
config["state_class"] = "measurement"
elif unit == "Wh":
config["device_class"] = "energy"
config["last_reset_topic"] = config["state_topic"]
config["last_reset_value_template"] = "1970-01-01T00:00:00+00:00"
config["state_class"] = "total_increasing"

topic = self._hass_topic("sensor", object_id)
await self._publish(mqtt, topic, config, retain=True)
Expand Down

0 comments on commit 21c6bcb

Please sign in to comment.