@ashscott wrote:
I want to trigger an automation when a binary sensor changes state but only if it is with 5 seconds of another binary sensor changing state.
I’ve been trying something like this, without success:
- alias: trigger_from_switch_2 trigger: platform: state entity_id: binary_sensor.switch_2 condition: condition: template value_template: "{{ (as_timestamp(now()) - as_timestamp(state_attr('binary_sensor.switch_1', 'last_changed'))) | int < 5 }}" action: - service: script.notifications data_template: message: 'switch 2 triggered' speaker: 'media_player.kitchen_speaker' title: 'Test switches'
I can’t get the template to render in Dev Tools so don’t yet know if it will work as an automation trigger.
Would somebody please point me in the right direction?
Posts: 1
Participants: 1