Murphy's Law

I noticed this morning that my energy costs were a lot higher than usual. Unfortunately I had to go out for the day and could not investigate.

After arriving back home I discovered that the automation that changes my energy tariff from peak to off-peak failed to run yesterday evening. Why?

Because I restarted home assistant at a few seconds before 9pm - the time my tariff changes to off-peak for the whole weekend.
:man_facepalming:

It was relatively easy to re-calibrate my grid import energy utility meters that updated my daily costs back to normal.

I also copied all the 5 minute LTS from the peak sensor to a spreadsheet ready to set them to 0 and update the off-peak sensor. However actually making the change causes the statistic editor to go back to the current time. I realised that to make the hundreds of changes I need to would take far too long.

I might come back to it in a week when it has been down sampled from 5 minute data to hourly data. Less than 24 changes that way.

What a bonehead move.

Ever done anything similar?

Lucky for you it was just data. I had a reboot that skipped turning my 600W dehumidifier off. I noticed the next day. That was actual money. The good news: I learned from HA statistics that the 300W setting the dehumidifier worked just as well and I also realized that I should put a safeguard in the automation.

Good point about making automations more tolerant to this. I’ve done things like this in automations which I want to run once a day, but only once:

  trigger:
  - platform: time
    at: 01:00:00
  - platform: time
    at: 02:00:00
  - platform: time
    at: '14:00:00'
  - platform: time
    at: '22:00:00'
  condition:
  - condition: template
    value_template: '{{ now().strftime(''%x'') != as_timestamp(states.automation.[this automation name].attributes.last_triggered)
      | timestamp_custom(''%D'') }}'

Unfortunately that won’t work in this particular case. Peak to off-peak and vice-versa happen at strictly defined times & days.

Good point; my example isn’t exactly right for this use case. But I was thinking maybe shorten the times to just a few minutes apart, to cover brief outages like an update. You would lose a little data during that time HA was down anyway, but at least once things come back up the tariff change would be applied.

It wouldn’t be easy. This is the trigger:

  trigger:
  - platform: state
    entity_id: binary_sensor.peak_rate
    not_to:
      - unknown
      - unavailable

As it triggers on a binary template sensor changing to on or off.

- name: "Peak Rate"
  unique_id: de98f85a-61be-46e7-92fd-d34320b80e4e
  icon: "mdi:power-plug"
  state: >
    {% if states('binary_sensor.is_dst')|bool(0) %}
      {{ (now().weekday() < 5) and ( (7 < now().hour < 11) or (16 < now().hour < 22) ) }}
    {% else %}
      {{ (now().weekday() < 5) and ( (6 < now().hour < 10) or (15 < now().hour < 21) ) }}
    {% endif %}