Is there a way to know if a device is connected via AirPlay? #1397
Replies: 3 comments 12 replies
-
I would look at the sessioncontrol section of shairport-sync.conf. You will see a bunch of events that can trigger scripts. You could use these events to accomplish what you want to do. One of my shairport-sync instances uses these events to turn on an AVR and then when playback ends I call a script that starts a 10 minute timer and if the timer isn't interrupted by another event before it times out, it turns off the AVR. You could also use shairport-sync's MQTT integration to capture playback start/stop events. The tools are there, you just have to get creative. |
Beta Was this translation helpful? Give feedback.
-
If you have HA running, it should be super easy to get an mqtt (mosquito) host running - there is an add-on in the HA Addon Store. For a new user, this should be mush easier than using scripts. |
Beta Was this translation helpful? Give feedback.
-
You could use play_start and play_end if you want to. Download MQTTfx and play around, watching the messages come in. I didn't want the speaker power to toggle on and off every time I paused and then resumed play, so I went with active_start and active_end. The "play" messages get sent on any play/pause action. The active_start message is sent when a "session" starts (i.e. you connect to the source and start streaming to it - you dont get the message just by connecting, you have to also start streaming). Active end is sent when disconnected from the source, after a delay as specific in the SPS config file (see active_state_timeout). I like the media player in HA just for aesthetics. Cool to have a card that shows metadata and album art, especially on a wall-mounted tablet. SPS has a beta version that has been super stable for me and implements AP2, it rules, but yeah - doesn't matter if you already use a multichannel relay for whole house. Use That is a good question. I may be wrong, but i think you can still run homebridge, and have use iOS Home locally with no AppleTV/iPad acting as a Home Hub. But unsure. Yes, siri shortcuts can be triggered by HA: https://companion.home-assistant.io/docs/integrations/siri-shortcuts/ As for not seeing SPS in iOS Home, what version of SPS are you running (run Example of a shortcut that connects to a specific AirPlay Source, opens the Apple Music app, and starts playing is here, you should be able to play around and tailor it to your needs: https://www.icloud.com/shortcuts/99fb471146f342daab8992ebb09f9441 |
Beta Was this translation helpful? Give feedback.
-
I currently use Home Assistant and Node-Red to start a timer when I turn on my HTD whole-house audio system and alert me if the system has been on for longer than a given amount of time. I have my RaspberryPi running Shairport-sync hooked up to the whole-house audio system, and then AirPlay to the pi to get the audio from my iPhone to the whole-house audio system.
Sometimes people forget to turn the system off, and it just gets left on overnight. I want to avoid that, hence the timer.
A better method to make sure it doesn't get left on would be for Home Assistant/Node-Red to be able to check and see if there is a device connected to Shairport-Sync via AirPlay. If there is no device connected and the system is on, it can trigger an alert to let me know. But to do this, I need for Home Assistant/Node-Red to be able to check and see if someone is connected.
Anyone know if this is possible?
Beta Was this translation helpful? Give feedback.
All reactions