Skip to content

Commit

Permalink
1.0.1
Browse files Browse the repository at this point in the history
Plugin Store version
Update readme information

0.1.22
Refactor speak command
Thread Say for each device (with checks) and timeout if any part of say/conversion fails.
Remove runconcurrent as not used.
Few debugging changes/reduce logging
More logging info depending on what fails at appleTV Library end
Set error state until device is setup/paired.  So obvious what is going on.
Support new HomePod in lieu of library recognising
Check for same name on device creation
Report if Unquarantine command xattr doesn't seem to have been run
  • Loading branch information
Ghawken committed Mar 26, 2023
1 parent 880a02f commit dc6e7f6
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 107 deletions.
197 changes: 91 additions & 106 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,24 @@

Hi all,

This is a indigodomo appleTV plugin for remote control and monitoring of activities of your apple devices.
This is a indigodomo python3 appleTV plugin for remote control and monitoring of activities of your appleTV and HomePod devices.

It uses the pyatv library (many thanks!) and this needs to be installed via a pip3 terminal command before usage. (Packaging it wasn't an option unfortunately as to many depencencies)

It use the pyatv PushListeners for playback activities to be immediately 'pushed' to the plugin devices. No polling required.
This means if have lights dimming up on pause - it should happen immediately!

Notable Uses:

Pair you appleTV and HomePod devices. Once paired, Indigo receives immediate updates on status/play/pause being the most basic.

Enables:
1. Dim Lights on playback, turn on lights with pause with immediate response
2. Lauch a particularly App on the appleTV, via Indigo as action
3. Annouce across one or all HomePods - either a mp3 file, or a Device State/Variable or text which will be read out in the current OSX system voices.



But before anything

In a terminal window enter:
Expand All @@ -21,9 +32,18 @@ Double click the release indigoplugin File and install.

All going well - nothing will happen...

Return to the terminal window and copy and paste the below:

This removes the apple quarantine bit for downloaded files and is needed for full function, used in this plugin for ffmpeg and conversion of audio files.
Very annoyingly unlike the pip3 command it is needed everytime you upgrade!

Arghh.. Apple...

#### `sudo xattr -rd com.apple.quarantine /Library/Application\ Support/Perceptive\ Automation/Indigo\ 2022.1/Plugins`

If you get a ton of red/errors.
You will need to install Command line tools for Xcode. It is because of the dependencies of pyatv is miniaudio which requires Clang to be installed to compile.
See FAQ at bottom.
See FAQ at bottom of this page if ongoing issues
Can try: The below terminal command - if also fails see FAQ for manual method.
`xcode-select —install`

Expand All @@ -37,25 +57,33 @@ This one above.
Press the "Generate AppleTV Devices" - with some options if devices not found.

Options:
Force Discovery of all Devices:

**Force Discovery of all Devices**:

This seems to be required for more new OS devices.

This will create indigo devices for all airplay devices the plugin via library pyatv can find.
Any non-appleTV/Homepods (untested) will not function and ideally should be deleted.
THis is needed for the newer appleTV devices which are registered as yet such as 4k Gen 3 appleTV
Any non-appleTV or Homepods (untested) will not function and ideally should be deleted.
(often these will be Sonos devices or airplay amplifiers). These are not supported as use Airplay2.

Scan a single IP address
This is needed for the newer appleTV devices which are registered as yet such as 4k Gen 3 appleTV

**Scan a single IP address**
If your device is not found without using this option, you can enter its IP address and being a unicast scan based on IP
This is more robust that a wider network multicast scan.
If you device is not found with multicast, but correctly found with unicast you should assign it a fixed IP address
(router level - outside of plugin)
If not, when it's IP changes the plugin will loose it altogether.
(in your router level - outside of plugin)
If not, when it's IP changes the plugin may loose it altogether.

Generate AppleTV Devices
**Generate AppleTV Devices**
Using the options above.
This will search your network for appleTV device and generate plugin Devices corresponding.
These devices will be located in the main device folder, but can be moved anywhere you like later.
You can re-press and re-press the button (if you like), and new devices should not duplicate.

#### Devices
### Devices

Following the above generation of devices, all devices will be in the main Indigo Device directory. Once created they can be moved to whereever makes sense.

Next go to a Device:

Expand All @@ -66,51 +94,55 @@ Open a device, with the Edit Device Details
You should see the above.

Since OS16 and Apple4k you will need to pair your indigoplugin Device with your appleTV
Some devices do not need to be paired (such as Homepods) - the button below will setup them up for use

Some devices do not need to be paired (such as Homepods), but they still need to be connected. The Start Connection button below will setup them up for use

#### Steps:
Press the Start Connection Button.
Press the **Start Connection** Button. And keep an eye on the Indigo Log where info will be displayued.

The plugin should find and connect to your appleTV device, or Homepod.

If a pincode is needed the log will let you know. If not needed when prompted press SAVE and close the dialog.
If a pincode is needed the Indigo log will let you know. If not needed when prompted press SAVE and close the dialog.

Otherwise on the appleTV device - A pincode should be displayed on the screen.
Otherwise on the appleTV device - A pincode should be displayed on the screen of the appleTV device.

Enter the Pincode in the box, and press submit Pincode (Press) Button.

You should receive confirmation that pairing has been successful.
You should receive confirmation that pairing has been successful in the log.

Press the SAVE button on the Config Dialog.

(I believe we need to do this only once... but time will tell...)

**For Homepods:**

Simply press the Start Connection button, observe the indigo log for confirmation of setup and then click Save.

### Device Details

I expose a number of playback states (Thanks Karl for the typing on these!)

![https://github.com/Ghawken/appleTV-indigoPlugin/blob/master/Images/DeviceStates.png?raw=true](https://github.com/Ghawken/appleTV-indigoPlugin/blob/master/Images/DeviceStates.png?raw=true)

You will also see the device is an Indigo Relay - so there are Turn On/Turn Off/Toggle buttons that power down/power on the relevant appleTV.
(caveat here is power reporting is not perfect)

### Remote Control / Actions

![https://github.com/Ghawken/appleTV-indigoPlugin/blob/master/Images/remoteNew.png?raw=true](https://github.com/Ghawken/appleTV-indigoPlugin/blob/master/Images/remoteNew.png?raw=true)


### ! New Version 0.0.15

Exposes all command options supplied by very helpful pyatv library. Progammatically creates menu, so if more down the track should be available.
I have choosen to exposes all command options supplied by very helpful pyatv library. We Progammatically creates menu, so if more options with library updates, down the track should be immediately available.
Allows sending of arguments with remote command
To enable:
Seeking to set position
Set Volume (if supported)
and Play URL

For most commands the optional arguments should be left blank, however can select double tap, hold etc. as the Dialog
For most commands the optional arguments should be left blank, however can select double tap, hold etc. as per the Dialog

![https://github.com/Ghawken/appleTV-indigoPlugin/blob/master/Images/Action.png?raw=true](https://github.com/Ghawken/appleTV-indigoPlugin/blob/master/Images/Action.png?raw=true)
![https://github.com/Ghawken/appleTV-indigoPlugin/blob/master/Images/remoteNew.png?raw=true](https://github.com/Ghawken/appleTV-indigoPlugin/blob/master/Images/remoteNew.png?raw=true)

### Actions Available

![https://github.com/Ghawken/appleTV-indigoPlugin/blob/master/Images/Action.png?raw=true](https://github.com/Ghawken/appleTV-indigoPlugin/blob/master/Images/Action.png?raw=true)

### Launch App

Expand All @@ -120,137 +152,90 @@ I have also implemented Launch App - which allows you to launch a specific appli

Unfortunately it doesn't allow LiveTV within the app, or more detailed control - but this can be managed with a lauchApp command, and then, left, down, down, select remote commands for example

### Save current Artwork

This AG will save the current artwork for the selected appleTV if it exists.


### FAQ / Troubleshooting

#### pip3 install pyatv

Fails - with some red lines and an error about a dependency miniaudio (which we don't use...)
It appears to want to install some x-code "command line developer tools" -- commandline tools - to help build this dependency.
Install the xcode components, appears to be usr/bin/clang and hopefully will able to be installed.

Oh No - it looks like needs 14gig of Xcode for this to work. What a pain.
Try:
https://developer.apple.com/download/more/
Login and download Command Line Tools for Xcode and install.

The above worked for my production machine - which hit this issue. (avoided Xcode install thankfully)

#### Can't remote control certain device.

Currently I expose all airplay devices - Sonos included. I do not believe these can be controlled or report status - but have not specifically tested them.
The AppleTV devices are those we are aiming to support here.
No longer - by default only appleTV devices are generated. Use the forceDiscovery option to enable creation of all devices found.


See here for more related to pyatv library

## https://pyatv.dev/support/faq/

# Changelog
### Homepod Special Actions

## 0.1.1- 0.1.9 Add & Extend Homepod support
### 0.1.9

Add Action Group to Send Text to Speech annoucement to HomePods with current OSX System voice
(Change current voice in OSX settings voices)
Add an Action Group to Send Text to Speech annoucement to HomePods with current OSX System voice
(Change current voice in Macs OSX settings voices)

Allows Device and Variable subsitution so can read weather forcast etc. depending on setup

NEEDS ffmpeg (included in plugin), likely to need quaranatine command run on new install
Add messaging for this.
NEEDS ffmpeg (included in plugin), need to run quaranatine command on new install

Converts text to speech with system say command and then converts to mp3 for playback. Add a slight delay but seems to be under a second in my testing.


![https://github.com/Ghawken/appleTV-indigoPlugin/blob/master/Images/SpeakAnnoucement.png?raw=true](https://github.com/Ghawken/appleTV-indigoPlugin/blob/master/Images/SpeakAnnoucement.png?raw=true)

### 0.1.1

Add support for Homepod and potentially other devices...

Notes for HomePods
### Homepod Stream File

These devices do not need to be paired - but once created setup the connect in the Device Edit screen
This enables Homepod playback of a mp3 file. There are quite specific file aspects that the HomePods like, primarly mp3.

Play_URL for Homepod reports unsupported.

However Stream_File, or the Remote setting:
Stream_File, or the Remote setting:

"Stream local file or remote file to device"

Works

e.g:
Optional Argumment:
https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3

or
Local file: (like)
/Users/Indigo/Desktop/doorbell-1.mp3
Works.

You can pre-generate yuou own voice files as needed, if do not wish to use the action Group as above:
To do so
To generate voice file:
In terminal
`say "Person arrived Home" -o personhome.aiff`

Needs mp3 files
ffmpeg commandline tool can convert say generated aiff
This aiff generated file needs to be converted to mp3 files
ffmpeg, which is a commandline tool can convert say generated aiff

The follow command gives appropriate mp3 output to use.
`ffmpeg -i Input.aiff -f mp3 -acodec libmp3lame -ab 192000 -ar 44100 Output.mp3`

Tempted to add a Action Group to automate all this.. (done in 0.1.9 above)

Homepod:
Appears Pause/Play toggle button unsupported.
Use Output.mp3 in the "Stream local file or remote file to device"

But volume control and seperate play, and Pause button function fine.
### FAQ / Troubleshooting

The above Stream file means can use TTS and play your own mp3 files as annoucement action Groups
#### pip3 install pyatv

Fails - with some red lines and an error about a dependency miniaudio (which we don't use...)
It appears to want to install some x-code "command line developer tools" -- commandline tools - to help build this dependency.
Install the xcode components, appears to be usr/bin/clang and hopefully will able to be installed.

Oh No - it looks like needs 14gig of Xcode for this to work. What a pain.
Try:
https://developer.apple.com/download/more/
Login and download Command Line Tools for Xcode and install.

The above worked for my production machine - which hit this issue. (avoided Xcode install thankfully)

#### Can't remote control certain device.

Currently I expose all airplay devices - Sonos included. I do not believe these can be controlled or report status.
Confimred these use AirPlay2 which has not been reverse engineered, we use Airplay1 here.
The AppleTV devices are those we are aiming to support here.
No longer - by default only appleTV devices are generated. Use the forceDiscovery option to enable creation of all devices found.

Previously:
#### See plugin Config menu for option Log AppleTV

This gives a few options of logging information for particuarly appletv that may help troubleshooting issues

Additional Remote control states - allow arguments to be sent.
Enabling set volume, double tap, hold, play_URL etc.
MenuItem: Add Logging info to show all Commands possible (not available!)
MenuItem: Add Logging info to show Features available for each Device
Remove unrecognised devices from being created. (Tested Sonos devices can't work use Airplay2, and unknown encryption)
Should allow AppleTVs (all) and HomePods (untested)
Restart Device after pairing (avoiding need to restart plugin if connection issues)
Fine tuning some aspects.
More repeated reporting of PowerState
See here for more related to pyatv library

0.0.22
Fix for debug1 not turning off until
## https://pyatv.dev/support/faq/

0.0.23

Move to unicast connection for those devices that have a IP
(may help with intermittent connection issues)
Alternate back to multicast after 3 failures.
Messaging around commands being sent with arguments when they shouldnt
Move back to standard indigo file Logging given issue resolved.

0.0.24
Remove support for MRP disabled in OS16 and causes authentication failures

0.0.25
Re-Add MRP support, IF device supports it - without it PowerState Reporting fails/is not reliable. It seems that MRP state is being depreciated by apple so may go completely in future.
More debug logging of service setup.

0.0.26
Add pluginConfig option for unicast scanning of a single IP address for device creation.
Useful with multicast fails to find device without power cycle
Update images

0.0.27
Add action to download artwork



Expand Down
2 changes: 1 addition & 1 deletion appleTV.indigoPlugin/Contents/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>PluginVersion</key>
<string>0.1.22</string>
<string>1.0.1</string>
<key>ServerApiVersion</key>
<string>3.1</string>
<key>IwsApiVersion</key>
Expand Down

0 comments on commit dc6e7f6

Please sign in to comment.