I’m trying to set up an automation which will trigger when a device is detected as being offline. I’m using ping for the detection and that functions ok, for that I’m using this code:
binary_sensor:
- platform: ping
name: "UPS Supply"
host: 192.168.1.155
The status goes from ‘on’ when it is online to ‘off’ when it is not (unplugged)
I want to use this in an automation and in the example below I’m trying to get it to turn on a light if the binary sensor above has gone to ‘off’ for more than 30 seconds but cancel the automation if the binary sensor comes back on. For this I have tis automation, but it doesn’t trigger. Any ideas why?
- id: '1578149229611'
alias: UPS
description: ''
trigger:
- entity_id: binary_sensor.ups_supply
for: 00:00:30
platform: state
to: 'off'
condition:
- condition: state
entity_id: binary_sensor.ups_supply
state: 'on'
action:
- alias: ''
data: {}
entity_id: switch.living_room_main_light
service: switch.turn_on