Page 1 of 1

Getting device icons to work with Airfoil source

PostPosted: Fri Sep 16, 2022 10:16 am
by Different Computers
I've messed about with the control page device control icons "iTunesStatus_large+.png" et al, and I can't get them to follow Airfoil's device states. I've tried using "Source status is playing (True or false) and added "iTunesStatus_large+true.png" and "iTunesStatus_large+false.png" but that doesn't work. I've also tried using AirFoil's "Current Source Status" for the icon state and that doesn't work either.

How do you make this work on your control pages?

Re: Getting device icons to work with Airfoil source

PostPosted: Mon Sep 19, 2022 10:38 am
by jay (support)
It works when you select the Current Source Status. However, the Airfoil API doesn't provide the play status of the source, so the only way to get it is to specify an iTunes device (in your Airfoil device instance's config) from which Airfoil will get the play status. Since the iTunes plugin no longer works, then the play state will never get updated, so all you will ever see is the grayed out play button (which is what shows when the status is 'unavailable'.

Re: Getting device icons to work with Airfoil source

PostPosted: Mon Sep 19, 2022 12:56 pm
by Different Computers
Ah well. thanks Jay.

Re: Getting device icons to work with Airfoil source

PostPosted: Mon Mar 20, 2023 5:55 pm
by Different Computers
Revisiting this after removing AirFoil from the mix (because for some reason I can't get AirFoil to be reliable on my network, but AirPlay is) and I found a way to put Apple Music's status into an Indigo Variable--something I'd struggled with since the iTunes Server was deprecated.

Code: Select all
import objc
from Foundation import NSAppleScript

# Define an AppleScript to retrieve the playback state
script_source = """
tell application "Music"
   set playback_state to the player state as string
end tell
return playback_state
"""

# Compile the AppleScript
script = NSAppleScript.alloc().initWithSource_(script_source)

# Execute the AppleScript and retrieve the result
result, error = script.executeAndReturnError_(None)
if error:
    indigo.server.log("Error:", error.localizedDescription())
else:
    playback_state = result.stringValue()
    if playback_state == "paused":
        indigo.variable.updateValue("Apple Music Status", "Paused")
    else:
        indigo.variable.updateValue("Apple Music Status", "Playing")