Skip to main content

SlashLogs

Integrate a energy sensor in Home Assistant energy production dashboard.

Home Assistant Energy dashboard

In the last post i showed you how do i get data in Home Assistant from a Sonoff Pow R2 using MQTT now we going to use that data to feed the energy dashboard. Because just like i said my sonoff is measuring my single solar panel production and we can use that to integrate with the beautiful dashboard that Hass as gifted us.

How do i measure my house energy consumption?

I've done a good post explaining what is KiloWatt / hour and how to measure it if you don't understand those concepts and don't have a clue how to measure it you should read it before continuing.

Identify the sources

Now i will explain my setup to make it easy to understand, for this post we will be talking about two sensors that i have in my home a shelly em two way sensor measuring my home energy consumption or the energy that i feed to the grid when my solar panel produces more that i can use. And right with my solar panel i have an Sonoff PowR2 measuring what my solar panel is producing this Sonoff is integrated to home assistant in a MQTT Server.

Integrating with home assistant

The shelly is pretty straight forward you just need to go to your energy dashboard and select that the shelly is giving the "consumption" and "return to grid" information.

Shelly integrated in home assistant

For the Tasmotized Sonoff I've got to do something else. Before it show up in my energy dash board i have to go to the configuration.yaml file and typed the following:

sensor:
  #pow_panel
  - platform: mqtt
    name: "PowR2Panel Power"
    state_topic: "pow_panel/tele/SENSOR"
    value_template: '{{ value_json.ENERGY.Power }}'
    device_class: "power"
    unit_of_measurement: "W"
  - platform: mqtt
    name: "PowR2Panel Energy Today"
    state_topic: "pow_panel/tele/SENSOR"
    value_template: '{{ value_json.ENERGY.Today }}'
    device_class: "energy"
    unit_of_measurement: "kWh"
  - platform: mqtt
    name: "PowR2Panel Voltage"
    state_topic: "pow_panel/tele/SENSOR"
    value_template: '{{ value_json.ENERGY.Voltage }}'
    device_class: "voltage"

If you are struggling check my post on MQTT integation for the tasmotized sonoff.

After that i restarted the Home Assistant and it showed up as an Energy Production just like i wanted.

Sonoff as energy source in home assistant

Conclusion

Home Assistant is perfect for integrating devices from different manufactures and making them work together. Putting a little more effort in the integration allow us to buy devices in our conditions without being locked to a vendor and their conditions. Took me a while to figure this out, hope it helps someone.

comments powered by Disqus