I was reviewing the DACP protocol trying to find a way to detect when the Apple TV was turned off (so I could add play, pause and off lights) however the closest I got was detecting when the app is closed (or turned off). It works really well, is this something you would be happy for me to PR?
If not, and for anyone interested in setting this up for automation (I have only tested this on the alternate-playpause-switch) there's a few simple changes you need to make.
The first is to change the switch type to Outlet which enables on/off (playing/paused) and in use (on when playing / paused, off when app is closed).
I was reviewing the DACP protocol trying to find a way to detect when the Apple TV was turned off (so I could add play, pause and off lights) however the closest I got was detecting when the app is closed (or turned off). It works really well, is this something you would be happy for me to PR?
If not, and for anyone interested in setting this up for automation (I have only tested this on the
alternate-playpause-switch
) there's a few simple changes you need to make.The first is to change the switch type to
Outlet
which enables on/off (playing/paused) and in use (on when playing / paused, off when app is closed).https://github.com/grover/homebridge-dacp/blob/8a8f472f72eab24eb9b0c7ce0e9c599a7be723f3/src/DacpAccessory.js#L95-L108
This needs to change to:
And then the controls service needs to change too:
https://github.com/grover/homebridge-dacp/blob/8a8f472f72eab24eb9b0c7ce0e9c599a7be723f3/src/PlayerControlsService.js#L3
The constructor needs to support the new parameter
The service needs to use the new characteristic
The update needs to track the new characteristic and determine the on state
And finally we need to add some state monitors for logging
Once that is done, you should be able to listen to the power state going off to determine the Apple TV is off (or close enough at least).