I’m trying to implement a mechanism, so that the sensors in the Energy Dashboard use the current energy price.
From roaming through the forums here, I found the following configuration snippet:
- platform: template
sensors:
current_electricity_rate:
friendly_name: Current Electricity Rate
value_template: >-
{% set t = strptime(states('sensor.time'), '%H:%M') %}
{%- if t.hour >=6 and t.hour <22 -%}0.2648
{%- else -%}0.2124
{%- endif -%}
unit_of_measurement: €/kWh
Unfortunately, when I try to use this newly created sensor in the energy dashboard, I get the following error message:
I’m fairly new to Home Assistant, so bear with me
Any help here is appreciated!
Further information:
I tried to see what this virtual (?) sensor is actually returning.
It seems it doesnt return anything at all.
When I add a card to my dashboard to show the entity “Current Electricity Rate” it shows as “unavailable”.
Sorry I can’t add a screenshot here because of being a new user.
You can only add entities (sensors) that provide energy (i.e. Wh or kWh) to the energy dashboard.
You can provide tariffs to the utility meter and perhaps visualise some of that data with your own charts. If you add a state class to a sensor, you’ll get long-term stats.
Nevertheless, my tariffs change base upon time of day.
So for example, from 6-22h, the energy cost is higher than from 22-6h.
The energy dashboard needs to take this into account somehow.
Right, I see. Unfortunately, I’m not familiar with that part of the functionality (in my country we only have a flat rate). Perhaps someone else can chime in, but I think my previous point still holds: Create a utility meter and I think you can then select that in the dialogue. See Frequently Asked Questions about home energy management.