Hello,
I made the following automation to trigger a boolean switch when the date is between two input_datetime. So it turns on the switch when we are bewteen and turns off when not.
The switch is turned off when the date is not in the interval so it works for the turn off part.
But when the conditions are met in the turn on part, the switch keeps going for on to off to on to off, etc… every seconds.
I think the problem come from the conditions in the turn_off part but I’m unable to resolve it.
thanks
- id: '1557859466358'
alias: Chauffage spécial ON
trigger:
- platform: time_pattern
seconds: '/10'
condition:
condition: and
conditions:
- condition: template
value_template: '{{ states("sensor.date_time") > (states.input_datetime.date_debut.attributes.timestamp | int | timestamp_custom("%Y-%m-%d, %H:%M", True)) }}'
- condition: template
value_template: '{{ states("sensor.date_time") < (states.input_datetime.date_fin.attributes.timestamp | int | timestamp_custom("%Y-%m-%d, %H:%M", True)) }}'
- condition: template
value_template: '{{ is_state("input_boolean.chauffedate", "off") }}'
action:
- alias: 'ON'
service: input_boolean.turn_on
entity_id: input_boolean.chauffedate
- id: '1557859716841'
alias: Chauffage spécial OFF
trigger:
- platform: time_pattern
seconds: '/10'
condition:
condition: and
conditions:
- condition: template
value_template: '{{ is_state("input_boolean.chauffedate", "on") }}'
- condition: or
conditions:
- condition: template
value_template: '{{ states("sensor.date_time") < (states.input_datetime.date_debut.attributes.timestamp | int | timestamp_custom("%Y-%m-%d, %H:%M", True)) }}'
- condition: template
value_template: '{{ states("sensor.date_time") > (states.input_datetime.date_fin.attributes.timestamp | int | timestamp_custom("%Y-%m-%d, %H:%M", True)) }}'
action:
- alias: 'OFF'
service: input_boolean.turn_off
entity_id: input_boolean.chauffedate