The output of above is “Unknown”. I think {{(states('input_number.summer/winter_offpeak/peak'))}} is not getting created.
The sensors sensor.current_electricity_season and sensor.current_electricity_rate_type is working and I see the correct output.I am looking to feed the value from offpeak/peak to go into those four sensors input_number.summer_offpeakinput_number.summer_peakinput_number.winter_offpeakinput_number.winter_peak
My utility meter has tarriffs as peak, offpeak
and switching the tarriff using this code
current_electricity_rate_type:
friendly_name: Current Electricity Rate Type
value_template: >-
{% if now() >= today_at("14:00:00") and now() < today_at("18:59:59")%}
peak
{% else %}
offpeak
{% endif %}
Once you have your helper entities set up, you can simplify that template a lot:
{% set season = 'summer' if
is_state('sensor.current_electricity_season', 'summer') else 'winter' %}
{% set type = states('sensor.current_electricity_rate_type') %}
{% set ent = 'input_number.'~season~'_'~type %}
{{ states(ent) }}
I need another favor if you can please. I’m not sure how to write this. I am trying to set(automate) the Utility daily_enegy based on current summer_peak, summer_offpeak, winter_peak and winter_offpeak.
Set -> daily_energy
Condition so that this is if season = Summer and time >=14:00:00 < 18:59:59
then daily_energy_summer_peak
else if season = Summer and time >=19:00:00 < 13:59:59
then daily_energy_summer_offpeak)
{% else %}
Condition so that this is if season = Winter and time >=14:00:00 < 18:59:59
then daily_energy_Winter_peak
else if season = Winter and time >=19:00:00 < 13:59:59
then daily_energy_Winter_offpeak)
{% endif %}
Reset Daily_Energy: End of each month at 12:00 AM
It’s basically the same as the other one, just a little shorter:
current_electricity_rate_type:
friendly_name: Current Electricity Rate Type
value_template: >-
{% set season = 'summer' if is_state('sensor.current_electricity_season', 'summer') else 'winter' %}
{% set type = 'peak' if today_at('14:00:00') <= now() < today_at('18:59:59') else 'offpeak' %}
{{ season~'_'~type }}
If I’m understanding the rest of your question correctly, the next step would be an automation to switch the tariffs via the select entities:
In this case, using not_to prevents the automation running if/when the sensor goes into a fail state or during start up when the state briefly goes from unknown to unavailable.
It would probably be fine to leave it out, since there won’t be a a matching option that the select could be changed to that would be a problem, but adding it doesn’t hurt anything and may prevent a couple error messages showing up in the logs.