I am trying to configure the energy dashboard to correctly show my electricity charges. I have an economy 7 style tariff. I have tried to setup a template I copied from another post but I am getting errors.
template:
# Home Energy sensors for HAEnergy
- name: Octopus GO
unit_of_measurement: GBP
state: >
{% set e7_normal = 0.3443 %}
{% set e7_cheap = 0.0750 %}
{% if states('sensor.time_utc') >= ('04:30' | timestamp_custom('%H:%M', False)) %}
{{( e7_normal ) | float}} {% else %}
{% if states('sensor.time_utc') >= ('00:30' | timestamp_custom('%H:%M', False)) %}
{{( e7_cheap ) | float}} {% else %}
{{( e7_normal ) | float}} {% endif %} {% endif %}
I want to then add on the standing daily charge but not sure how to do this.
Any help would be greatly appreciated
Your original sensor simply displays the current price at that moment but you need to use the static values (or multiple static sensors) as you have done in your latest post to actually calculate the totals.
My tarrifs are far more complex so i have to set them specifically. i’ve not used the next tariff service myself as i needed to use the select tariff service. Check your tarrif is actually changing
yes, the tariff seems to change. When I setup a sensor manually it all seems to work. However if I try to input this into the energy dashboard as an entity tracking total cost I cannot select my sensor. I have tried rounding to 2 decimal places, but that doesnt fix it
Hmmm. You’ve moved to the legacy template sensor config. Try the newer method again how you originally started. It may not work in sensors.yaml though so if there are issues just test it in configuration.yaml.
Moving something in config files won’t break it if you move it around down the track so nothing to fear there.
template:
- sensor:
- name: Octopus GO
unit_of_measurement: GBP
state_class: total_increasing
device_class: monetary
state: >
{% set e7_normal = 0.3443 %}
{% set e7_cheap = 0.0750 %}
{% set t = (utcnow().time()|string)[:5] %}
{% if t >= '04:30' %} {{ e7_normal }}
{% elif t >= '00:30' %} {{e7_cheap }}
{% else %} {{ e7_normal }}
{% endif %}
One issue I see is the double quotes of the spend sensor are being passed as part of the state. Remove those from the start and end of the sensors state.