Day and night meter electricity consumption in energy dashboard

Currently I have my energy dashboard configured to track a 24 hour electricity tariff like so:

daily_energy:
  source: sensor.shellyem_5e26f6_channel_1_energy
  cycle: daily
  tariffs:
    - peak

But have recently moved to a day/night tariff where I pay one price for kwh from 9am-12am, and another price between 12am-9am.
How do I setup the utility meter to track both tariffs?
I know I can do this:

daily_energy:
  source: sensor.shellyem_5e26f6_channel_1_energy
  cycle: daily
  tariffs:
    - peak
    - offpeak

But I am not seeing how that knows the times when to track consumption for each tariff?

It does not. You have to change the tariff with an automation.

See: https://www.home-assistant.io/integrations/utility_meter/#advanced-configuration

Ok so I have done that as well, however the offpeak tariff doesn’t seem to work at all:

daily_energy:
  source: sensor.shellyem_5e26f6_channel_1_energy
  cycle: daily
  tariffs:
    - peak
    - offpeak

The automation:

- id: '1652831843092'
  alias: Energy - Switch tariff
  description: ''
  trigger:
  - platform: time
    at: 09:00:00
    variables:
      tariff: peak
  - platform: time
    at: 00:00:00
    variables:
      tariff: offpeak
  condition: []
  action:
  - service: select.select_option
    target:
      entity_id: select.daily_energy
    data:
      option: '{{ tariff }}'
  - service: select.select_option
    target:
      entity_id: select.monthly_energy
    data:
      option: '{{ tariff }}'
  mode: single

The “peak” works ok

But not the offpeak, it is still unknown value


The automation does trigger correctly too
image

Any ideas?

That’s because you just copied the example without changing the tariff select that your utility meter uses.

  action:
  - service: select.select_option 
    target:
      entity_id: select.daily_energy # This is not your tariff select entity id.
    data:
      option: '{{ tariff }}'
  - service: select.select_option # You don't even have or need this one. 
    target:
      entity_id: select.monthly_energy 
    data:
      option: '{{ tariff }}'

I have the monthly one too, I just didn’t paste in here, same as the daily one but with monthly cycle.
But I still don’t follow I have select.daily_energy and monthly entitiy ids which are called the same?



Not sure if these are set up correctly either:

Ok scrap that then, also I got confused with your sensor name and the utility meter name. So that is ok too.

Is it past midnight yet?

That’s when it switches to using your offpeak tariff:

It’s usually wise to quote times, : can do funny things to yaml parsing:

  trigger:
  - platform: time
    at: "09:00:00"
    variables:
      tariff: peak
  - platform: time
    at: "00:00:00"
    variables:
      tariff: offpeak

Also, did your automation trigger?

Check the trace:

So I manually ran the automation last night but it looks like it didn’t execute correctly so maybe that’s why it’s still stuck at unknown


But today it did work so I think it might be ok later on perhaps:

If you run the automation manually there will be no trigger, and therefore no variable to select which tariff to use.

  trigger:
  - platform: time
    at: 09:00:00
    variables:
      tariff: peak    # only set at 9am, not with a manual trigger
  - platform: time
    at: 00:00:00
    variables:
      tariff: offpeak  # only set at midnight, not with a manual trigger
.
.
.
  - service: select.select_option
    target:
      entity_id: select.daily_energy
    data:
      option: '{{ tariff }}'  # so this is not defined when run manually.

Ok so that is exactly what happened then :slight_smile:

Yup that was it @tom_l , values are working now with one exception, it doesn’t seem to let me add the off peak value to the energy dashboard, it’s simply not on the list while the peak one is and can be selected, but I can’t see a difference between them?

Any idea what that usually means?

That’s odd. It has all the required attributes.

Try refreshing your web browser cache.

Found it


Fix issue, well fixed the issue :smiley:

1 Like

Hello guys, there is my config of 2 automations in case if someone will need.
I got a sensor sensor.energy_meter with 2 parameters sensor.energy_meter_day and sensor.energy_meter_night As result automation config for first period looks like below. You can make different automations for different periods as many as you need.

alias: 2 zone energy tariff Day
description: ""
trigger:
  - platform: time
    at: "07:00:00"
condition: []
action:
  - service: select.select_option
    data:
      option: Day
    target:
      entity_id: select.energy_meter
mode: single