WIP
Requirements
- plistutil (libplist-util if you are using docker)
- platform: command_line
name: 'Airplay Status'
command: curl -s -X GET <airport-ip>:7000/info | plistutil | grep "<key>statusFlags</key>" -A1 | grep -Eo '[0-9]{1,4}'
scan_interval: 10
Which will give you a sensor of the current statusFlags (no idea what they mean). It seems like there are some different statusFlags, but from what I’ve seen they always have 2048 between each other and the status for not connected is between 1 and 2000. So from that I’ve just created a binary sensor to test if the status minus 2048 is positive (someone is connected to airplay) or negative (not in use).
- platform: template
sensors:
airplay:
friendly_name: "Airplay"
device_class: sound
value_template: "{{ states.sensor.bose_airplay_status.state | int -2048 > 0 }}"
So far so good.
Edit: statusflags, 0x4XX… off, 0xXXX04 on
https://openairplay.github.io/airplay-spec/status_flags.html
Edit2: All in one
- platform: command_line
name: 'Airplay 2'
command: expr $(echo "obase=16;" `curl -s -X GET <airport-ip>:7000/info | plistutil | grep "<key>statusFlags</key>" -A1 | grep -Eo '[0-9]{1,4}'` | bc | cut -c1) - 4 > /dev/null 2>&1 && echo ON || echo OFF
scan_interval: 10
device_class: sound