Openenergymonitor and Octopus Go "Energy dashboard" integration

I have an emonpi from https://openenergymonitor.org/ for tracking solar PV + home energy usage, and I’m on Octopus Go variable rate tariff, neither of which were entirely straight forward to add to the Energy dashboard, and as no one else appears to have done so I thought I’d share my config here

the EmonPi connects via MQTT and has CT1 on the main grid meter tails (positive power = import), and CT2 on the Solar PV inverter.

The power has to be integrated to get the ‘energy’ using the Riemann sum sensor. This means the any HA downtime will yield lost data / dead spots in the feed, it would be better to have emonpi publish the kWh energy fields on MQTT but I couldn’t figure out how to do that! (New emonpi firmware accumulates the energy field on the ATmega328p chip in real time which would give even better results, except it does not accumulate “import” and “export” separately so is fairly useless!)

Octopus Go has fixed “cheap rate” at 00:30 - 04:30 each morning, so a simple template sensor provides this for me as a “import price” entiry.

Any questions let me know.

configuration.yaml

sensor:
  - platform: mqtt
    name: "Grid Import Power"
    state_topic: "emon/emonpi/power1"
    device_class: power
    state_class: measurement
    unit_of_measurement: "W"
    value_template: |-
        {{ [value|int, 0] | max }}
  - platform: mqtt
    name: "Grid Export Power"
    state_topic: "emon/emonpi/power1"
    device_class: power
    state_class: measurement
    unit_of_measurement: "W"
    value_template: |-
        {{ [0-(value|int), 0] | max }}
  - platform: mqtt
    name: "Solar PV Production Power"
    state_topic: "emon/emonpi/power2"
    device_class: power
    state_class: measurement
    unit_of_measurement: "W"
  - platform: mqtt
    name: "House Consumption Power"
    state_topic: "emon/emonpi/power1pluspower2"
    device_class: power
    state_class: measurement
    unit_of_measurement: "W"
  - platform: integration
    name: "Grid Import Energy"
    source: sensor.grid_import_power
    unit_prefix: k
    round: 2
  - platform: integration
    name: "Grid Export Energy"
    source: sensor.grid_export_power
    unit_prefix: k
    round: 2
  - platform: integration
    name: "Solar PV Production Energy"
    source: sensor.solar_pv_production_power
    unit_prefix: k
    round: 2
  - platform: template
    sensors:   
      octopus_go_tarif:
        friendly_name: "Octopus Go Import Tariff"
        unit_of_measurement: GBP/kWh
        value_template:  "
            {% if  (now().hour == 0 and now().minute > 30) or
         (now().hour >= 1 and now().hour) < 4 or
        (now().hour == 4 and now().minute < 30) %} 0.05
            {% else %} 0.2425
            {% endif %}"

1 Like

Thanks Joth - this is exactly the setup I have with PV panels, Octopus Go and the need for an energy monitor that handles both. I’ve been looking at Emonpi and have just set up a Home Assistant hence still a newbie. Can you confirm if you just have the PV bundle from Emonpi and sorry, idiot question but does the config yaml go on the Home Assistant or the Emon? Obviously, I need to do some more reading in all of this! Anyway, appreciate the post.

Welcome to Home Assistant!

Can you confirm if you just have the PV bundle from Emonpi

Yes that’s correct.

sorry, idiot question but does the config yaml go on the Home Assistant or the Emon?

Haha no problem, yes configuration.yaml is very much a Home Assistant thing.

There were a few tricks to getting the emonpi to actually do anything useful out of the box, however I set that up over a year ago so I’m afraid I don’t actually remember what they were off the top of my head - sorry!
Since posting the article here I did stop using the ‘platform: integration’ to calculate Energy readings from the Power, and instead have emonpi broadcast energy readings on their own topics. Relevant udpated HA config below.

One thing that proved a real PITA is whenever the emonpi is reset the meter readings reset to zero, and this seems to make HA Energy dashboard think there’s been a massive negative usage of power on that day, and trying to “clean” the HA database up to remove these negative reads involves a lot of splunking about in the SQL add on. The docs say that energy meters going backward should be autodetected as a meter reset and in essence ignored, but my experience so far is that is not so good!

Final note: Octopus increased the SEG outgoing rate to 7.5p yesterday, so I better update the dashboard to use that now! Outgoing Octopus | Octopus Energy (Maybe one day I’ll actually pull this via their API…)

  - platform: mqtt
    name: "Grid Import Energy"
    unique_id: sensor.grid_import_energy
    state_topic: "emon/emonpi/import_kwh"
    device_class: energy
    state_class: measurement
    unit_of_measurement: "kWh"
  - platform: mqtt
    name: "Grid Export Energy"
    unique_id: sensor.grid_export_energy
    state_topic: "emon/emonpi/export_kwh"
    device_class: energy
    state_class: measurement
    unit_of_measurement: "kWh"
  - platform: mqtt
    name: "Solar PV Production Energy"
    unique_id: sensor.solar_pv_production_energy
    state_topic: "emon/emonpi/solar_kwh"
    device_class: energy
    state_class: measurement
    unit_of_measurement: "kWh"

thanks Joth, this really got me started. question regarding your export feed. how are you doing this? did find this example, that seems to be giving me what i need to create an export feed.

Allow positive
Log to feed: → emonpi: import
Power to kWh  → emonpi: import_kWh
Reset to ZERO
-input →  [whatever this input is called]
Allow positive
Log to feed: → emonpi: export
Power to kWh  → emonpi: export_kWh

also see that you exporting kwh and not the W. Would this not give you the total KWh generated instead of the W that is currently being used?

any new so just getting my head around it all