SgtBatten,
Could you assist, trying to update your code to below to have an action that caters for:
- Peak - 7-9am and 5-8pm (weekdays)
- Shoulder - 9am - 5pm and 8pm - 10pm (weekdays)
- Off Peak - 10pm - 7am (weekdays) and ‘all weekend’
Your original code is:
alias: Set Electricity Tariff
description: ''
trigger:
- platform: time
at: '07:00:00'
- platform: time
at: '14:00:00'
- platform: time
at: '20:00:00'
- platform: time
at: '22:00:00'
- platform: homeassistant
event: start
condition: []
action:
- service: select.select_option
data:
option: >-
{% set t = now() %} {%- if t.hour >=14 and t.hour <20 and
is_state('binary_sensor.workday_sensor', 'on') %}
peak
{%- elif t.hour >= 22 or t.hour < 7 -%}
off-peak
{%- else -%}
shoulder
{%- endif -%}
target:
entity_id:
- select.electricity_imported_power_daily
mode: single
Trying the following and can’t seem to workout the syntax / format to use, to amend the action data option section. Trying the following and failing:
action:
- service: select.select_option
data:
option: >-
{% set t = now() %} {%- if t.hour >=07 and t.hour <09 and
is_state('binary_sensor.workday_sensor', 'on') %}
peak
{%- elif t.hour >= 17 or t.hour < 20 -%}
peak
{%- elif t.hour >= 22 or t.hour < 7 -%}
off-peak
{%- else -%}
shoulder
{%- endif -%}
target:
entity_id:
- select.electricity_imported_power_daily
or
action:
- service: select.select_option
data:
option: >-
{% set t = now() %} {%- if ( t.hour >=07 and t.hour <09 ) or ( t.hour >=17 and t.hour <20 ) and
is_state('binary_sensor.workday_sensor', 'on') %}
peak
{%- elif t.hour >= 22 or t.hour < 7 -%}
off-peak
{%- else -%}
shoulder
{%- endif -%}
target:
entity_id:
- select.electricity_imported_power_daily
Any assistance appreciated. BTW the gas coding works great, seems like there’s a bug in the Energy Dashboard since an update going back a few months. Entities have the correct figures, but dashboard displays something else.