I’m new to home assistant and so far am overwhelmed by the possibilities
I got a few use cases working but becoming desperate with one seemingly easy thing: I’d like to trigger an automation when I shut down a PC.
My thought was to use network connectivity for this. I can see the PC as device via my router and it’s correctly switching home/away, so I’ve tried to put that in a trigger:
This will create a binary sensor and the change from on to off when the PC shuts down will trigger an automation.
- id: 'xxxxx'
alias: PC shutdown
description: 'Does something when a PC shuts down'
trigger:
- platform: state
to: 'off'
entity_id: binary_sensor.your_pc
condition: []
action:
- something...
Your PC isn’t leaving/entering a zone, it’s state is changing from “home” <> “not_home”, so you should use the state trigger instead.
- id: 'xxxxx'
alias: PC shutdown
description: ''Do whatever when your PC goes offline"
trigger:
- platform: state
to: 'not_home'
entity_id: device_tracker.your_pc
condition: []
action:
- whatever you want
Or if you want to get really fancy you could send a MQTT packet or general API call from the PC to Home Assistant on shutdown, with a ping sensor as a redundant backup (in case you don’t properly shut down and fire the MQTT).
I do something similar with my Mac’s, but since Mac is already unix it’s easy to just use SSH to pass things around.