Glow / Hildebrand Display - Local MQTT Access - Template Help

I’ve managed to calculate costs for my peak/off-peak Intelligent Octopus electricity supply, with the help of this guide: https://community.home-assistant.io/t/simulating-different-tou-electricity-plans-with-utility-meter-automations-and-templates/494374.

First I created a daily utility meter with named “peak” and “off-peak” tariffs based on today’s import from MQTT, named “Electricity Used”.

Then, I created an automation to set the tariff to either “peak” or “off-peak”, using the binary sensor from the IO HACS integration (alternatively, I could have based it on the time):

alias: Update Octopus Tariffs
description: ""
trigger:
  - type: turned_on
    platform: device
    device_id: XXX
    entity_id: binary_sensor.octopus_intelligent_slot
    domain: binary_sensor
    variables:
      tariff: off-peak
  - type: turned_off
    platform: device
    device_id: XXX
    entity_id: binary_sensor.octopus_intelligent_slot
    domain: binary_sensor
    variables:
      tariff: peak
condition: []
action:
  - service: select.select_option
    data:
      option: "{{ tariff }}"
    target:
      entity_id: select.electricity_used
mode: single

This creates and fills two daily “buckets” for peak and off-peak energy used.

Finally, I used a template sensor to calculate the daily cost:

template:
  - sensor:
      - name: Daily Electricity cost
        state_class: total_increasing
        device_class: monetary
        unit_of_measurement: GBP
        icon: mdi:currency-gbp
        state: >
          {% set peak_cost = states('sensor.electricity_used_peak')|float * 0.429 %}
          {% set off_peak_cost = states('sensor.electricity_used_off_peak')|float * 0.10 %}
          {{ (peak_cost + off_peak_cost + 0.5109) | round(2) }}

I could have fetched the current rates and daily charge from the octo API, but they’re just hardcoded for the moment.

Hopefully this is useful to someone else.
Tim

1 Like