2020-05-13 20:59:54 ERROR (MainThread) [homeassistant.config] Invalid config for [automation]: Invalid time specified: {{ states('input_datetime.mower_timer1_stop_time') }} for dictionary value @ data['condition'][0]['conditions'][2]['before']. Got None
Invalid time specified: {{states.input_datetime.mower_timer1_start_time.state}} for dictionary value @ data['condition'][0]['conditions'][2]['after']. Got None. (See ?, line ?).
template editor {{states.input_datetime.mower_timer1_start_time.state}}
returns 08:00:00
this works
- condition: time
after: "08:00:00"
before: "15:00:00"
I have speakers with 2 ‘ON’ slots each one checks for midnight.
They also turn off if the house is unoccupied (to come back on if I come back) and also cater for a sleep mode and manual on.
They are run by a binary sensor which concentrates all the evaluations in one spot rather than the 5+ otherwise
Pick the bones out of this one : -
binary_sensor:
- platform: template
sensors:
bs_pifi01_result_on:
entity_id: switch.switch_fibaro_f01
value_template: "{{ is_state('switch.switch_fibaro_f01', 'on') }}"
friendly_name: Pi-Fi-01 On
icon_template: "{{ 'mdi:music' if is_state('switch.switch_fibaro_f01', 'on') else 'mdi:volume-off' }}"
bs_pifi01_timeslot_on:
entity_id: binary_sensor.bs_occupied, sensor.time, input_boolean.ib_switch_pifi01_result_on, input_boolean.ib_switch_pifi01_timer_enable, input_boolean.ib_switch_pifi01_timeslot1_enable, input_boolean.ib_switch_pifi01_timeslot2_enable
value_template: >
{% set time = states('sensor.time') %}
{% set slt1en = is_state('input_boolean.ib_switch_pifi01_timeslot1_enable', 'on') %}
{% set slt1start = states('input_datetime.id_switch_pifi01_tmeslt1_on') [0:5] %}
{% set slt1stop = states('input_datetime.id_switch_pifi01_tmeslt1_off') [0:5] %}
{% set slt2en = is_state('input_boolean.ib_switch_pifi01_timeslot2_enable', 'on') %}
{% set slt2start = states('input_datetime.id_switch_pifi01_tmeslt2_on') [0:5] %}
{% set slt2stop = states('input_datetime.id_switch_pifi01_tmeslt2_off') [0:5] %}
{% set slt1on = (slt1start <= time < slt1stop) if (slt1start < slt1stop) else (slt1start <= time or time < slt1stop) %}
{% set slt2on = (slt2start <= time < slt2stop) if (slt2start < slt2stop) else (slt2start <= time or time < slt2stop) %}
{{ (slt1on and slt1en) or (slt2on and slt2en) }}
friendly_name: Pi-Fi-01 Time Slot On