New Python3 AppleTV indigo Plugin

Posted on
Sun Mar 19, 2023 2:10 pm
GlennNZ offline
User avatar
Posts: 1562
Joined: Dec 07, 2014
Location: Central Coast, Australia

Re: New Python3 AppleTV indigo Plugin

berkinet wrote:
GlennNZ wrote:
...Try 0.1.22
Pretty wholesale refactoring of the Say/Speak command.

Ok... Just installed the update. Hopefully this is the fix :D

BTW, I did find an interface error, well, more of a data validation error. The plugin let me close an action without having selected an AppleTV device. It correctly identified the error in the log
Code: Select all
appleTV Plugin                  Sending Command set_volume=80 to appleTV Device ID 139647395
   appleTV Plugin                  No AppleTV selected.
But, it probably shouldn't have let me close the configuration :wink:

In any case, THANKS for all the work you have put into this plugin.
Lets wait and see. Does seem pretty isolated to you! But the speak codebase was in a early state of enthusiastic lets see if works and needed a revamp.

Yeah - the Config window, personally find being unable to close config windows (particularly here in Action groups which are manually run) super annoying. Not sure whether that is a windows background thing? maybe..


Sent from my iPad using Tapatalk

Posted on
Mon Mar 20, 2023 8:17 am
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: New Python3 AppleTV indigo Plugin

Ok, still seems to be working, once I remembered to issue the unquarantine command. BTW, I thought that was printed to the log on plugin startup. Did you remove it? I ask, because the plugin doc mentions running the command, but doesn't actually give it.

Posted on
Mon Mar 20, 2023 2:14 pm
GlennNZ offline
User avatar
Posts: 1562
Joined: Dec 07, 2014
Location: Central Coast, Australia

New Python3 AppleTV indigo Plugin

On first run of new version - it prints an info message in the log. Once and only, after an upgrade. I do see it, so normally is there - but only once after version increase.

Glenn


Sent from my iPad using Tapatalk

Posted on
Fri Mar 31, 2023 4:10 am
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: New Python3 AppleTV indigo Plugin

The saga continues...
v1.0.1 installed from the App store, BTW, thanks for doing that.
I upgraded my HomePod to 16.4, though it was already on the new architecture.

Now I have a new issue, still with playing a sound file from Intogo on the HomePod. It takes 2 attempts. The first failed, the second logs the same errors and succeeds.
Code: Select all
31 Mar 2023 at 11:45:44
   Stopping plugin appleTV Plugin (pid 17164)
   appleTV Plugin                  Removed AppleTV Manager for device: CM-Homepod
   appleTV Plugin                  Shutting down Plugin
   Stopped plugin appleTV Plugin
   Upgrading plugin appleTV Plugin to newer version 1.0.1 (previous version moved to trash)
   Loading plugin "appleTV Plugin 1.0.1" using API v3.1
   Starting plugin "appleTV Plugin 1.0.1" (pid 17266)
   appleTV Plugin                 
   appleTV Plugin                  ================================================ Initializing New Plugin Session =================================================
   appleTV Plugin                  Plugin name:                   appleTV Plugin
   appleTV Plugin                  Plugin version:                1.0.1
   appleTV Plugin                  Plugin ID:                     com.GlennNZ.indigoplugin.appleTV
   appleTV Plugin                  Indigo version:                2022.2.0
   appleTV Plugin                  Python version:                3.10.2 (v3.10.2:a58ebcc701, Jan 13 2022, 14:50:16) [Clang 13.0.0 (clang-1300.0.29.30)]
   appleTV Plugin                  Python Directory:              /Library/Frameworks/Python.framework/Versions/3.10
   appleTV Plugin                 
   appleTV Plugin                  ================================================== End Initializing New Plugin  ==================================================
   appleTV Plugin                  Plugin Updated Version Detected.  Please run xattr command as below (copy & paste to terminal)
   appleTV Plugin                  This enables Say Annoucements on HomePods.  If unused, then will not affect other functioning.
   appleTV Plugin                  sudo xattr -rd com.apple.quarantine '/Library/Application Support/Perceptive Automation/Indigo 2022.2/Plugins'
   appleTV Plugin                  ========================================================== End of Setup ==========================================================
   Started plugin "appleTV Plugin 1.0.1"
   appleTV Plugin                  CM-Homepod Device has been Setup, attempting to connect.
   appleTV Plugin                  Scanning for device using IP address: 192.168.5.240 and using Unicast.
   appleTV Plugin                  CM-Homepod successfully connected and real-time Push updating enabled. (if available!

<Execute the command>
31 Mar 2023 at 11:47:30
   Trigger                         Espresso Ready: Announce
   appleTV Plugin                  Sending Command set_volume=70 to appleTV Device ID 139647395
   Schedule                        trigger "Espresso Ready: Announce" (delayed action)
   appleTV Plugin                  Sending Command stream_file=/Users/rdp/Music/nescafe.mp3 to appleTV Device ID 139647395
   appleTV Plugin                  Could not run this command at this time.
   appleTV Plugin                  Connection to appleTV - CM-Homepod lost.
   appleTV Plugin                  Scanning for device using IP address: 192.168.5.240 and using Unicast.
   appleTV Plugin                  CM-Homepod successfully connected and real-time Push updating enabled. (if available!)
<no output>

<Execute the command again>
   Trigger                         Espresso Ready: Announce
   appleTV Plugin                  Sending Command set_volume=70 to appleTV Device ID 139647395
   Schedule                        trigger "Espresso Ready: Announce" (delayed action)
   appleTV Plugin                  Sending Command stream_file=/Users/rdp/Music/nescafe.mp3 to appleTV Device ID 139647395
   appleTV Plugin                  Could not run this command at this time.
<this time it worked>
I have also attached a debugging output from the log file. You will see an error is thrown. But oddly, it does not throw the error on every attempt. It seems random, though I am sure it isn't.
Attachments
appleTV-log.txt
(12.29 KiB) Downloaded 24 times

Posted on
Fri Mar 31, 2023 7:00 pm
GlennNZ offline
User avatar
Posts: 1562
Joined: Dec 07, 2014
Location: Central Coast, Australia

Re: New Python3 AppleTV indigo Plugin

Hi

I think saga is probably slightly strongly worded... :D

Hopefully you ran the terminal command - it the 2 minutes before the voice announcement. Good to see that the message regarding it is there.

16.4 on Homepods has some major issues, and is likely leading to this
I've upgraded and had to reset 2 and still can't play anything (using the Home app)
I've reset one with no change.
Following 16.4 update - HomePods spend ages doing something. Within the Home app - would say configuring...
During this time wouldn't be able to access.
After an hour and 2 resets and reconnection - seems to be now accessible. Who knows what they have been doing....

The error you are seeing is library based. Without rebasing and editing library not to much I can do about it currently.
& rapid quick fire requests to the same device will cause a async lock issue.
Code: Select all
Running through the Debug log:  (which isn't the same timing as attached - seems only one failure)
First:  CM-Homepod Powerstate update Old PowerState.On and new PowerState.Off
(almost looks like Homepod restarting, or potentially sleeping?? If 16.4 has introduced some new sleep behaviour that will be issue)
11:52:17 - Connection to appleTV - CM-Homepod lost.    Nothing plugin based, something either device restarting or network.
Then:
11:52:28  - send Remote Command which fails.
11:52:31 BlockstateError - is because the device is disconnected when attempt command.
20 seconda later (thats the async loop which can shorten)
Plugin sees disconnection and restart this appleTV/Homepod handler
11:52:32
11:52:33 Scans IP with unicast - finds and reconnects here


I'll have a look and see. Can drop the loop timing so that disconnects are recognised sooner and reconnected (its async loop so won't matter)
If sleep handling has changed, may even need to make before command..

Clearly relates to 16.4 Upgrade

Seems to have updated the Device_Info message, causing a Power off/Power On to be toggled.
Winding back to 16.3.2 - fixes - no idea how to do that - but is possible.
Sending message twice works - because of toggle above oddly.
Library has reported this (some beta users apparently), and I have re-reported.

Posted on
Sat Apr 01, 2023 1:14 am
GlennNZ offline
User avatar
Posts: 1562
Joined: Dec 07, 2014
Location: Central Coast, Australia

New Python3 AppleTV indigo Plugin

Okay.

Try

Code: Select all
pip3 install git+https://github.com/Ghawken/pyatv@os16.4fix


& latest 1.0.2 - incorporating checks for this version of pyatv - which is backwards compatible and fixes an play/pause button labelling error as well.,

I have forked the library and tracked down the issue to a low timeout, which in OS16.4 seems to delay stream_file every 2nd time

The power handling also is borked, well the power state reporting - that was always bad, seems to report on/off, off/on I suspect there is a new state here not being captured.

I'll update the plugin details.

Glenn
Last edited by GlennNZ on Sat Apr 01, 2023 3:40 am, edited 1 time in total.

Posted on
Sat Apr 01, 2023 1:53 am
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: New Python3 AppleTV indigo Plugin

GlennNZ wrote:
Code: Select all
pip3 install git+https://github.com/Ghawken/pyatv@os16.4fix
Somewhat easier said than done. My Python3 installation is a complete mess and I never remember which installed version is used by Indigo. But, I see the plugin reports that. Nice touch! I'm on it.

And...
  1. By "saga," I meant the saga of you having to put up with my complaints :wink:
  2. I have reset my HomePod 3 times this morning, just because.
  3. Just FYI. While I did just upgrade to 16.4, I have been on the new architecture since I purchased the HomePod. I got it during the narrow window when the new architecture was originally available.
  4. And, yes, I had run the unquarantine command.

That's it for now

Posted on
Sat Apr 01, 2023 2:09 am
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: New Python3 AppleTV indigo Plugin

I wrote:
I'm on it.
Looks Good :D
Code: Select all
1 Apr 2023 at 09:59:58
   Reloading plugin "appleTV Plugin 1.0.1" using API v3.1
   Stopping plugin "appleTV Plugin 1.0.1" (pid 17266)
   appleTV Plugin                  Removed AppleTV Manager for device: CM-Homepod
   appleTV Plugin                  Shutting down Plugin
   Stopped plugin "appleTV Plugin 1.0.1"
   Starting plugin "appleTV Plugin 1.0.1" (pid 50049)
   appleTV Plugin                 
   appleTV Plugin                  ================================================ Initializing New Plugin Session =================================================
   appleTV Plugin                  Plugin name:                   appleTV Plugin
   appleTV Plugin                  Plugin version:                1.0.1
   appleTV Plugin                  Plugin ID:                     com.GlennNZ.indigoplugin.appleTV
   appleTV Plugin                  Indigo version:                2022.2.0
   appleTV Plugin                  Python version:                3.10.2 (v3.10.2:a58ebcc701, Jan 13 2022, 14:50:16) [Clang 13.0.0 (clang-1300.0.29.30)]
   appleTV Plugin                  Python Directory:              /Library/Frameworks/Python.framework/Versions/3.10
   appleTV Plugin                 
   appleTV Plugin                  ================================================== End Initializing New Plugin  ==================================================
   Started plugin "appleTV Plugin 1.0.1"
   appleTV Plugin                  CM-Homepod Device has been Setup, attempting to connect.
   appleTV Plugin                  Scanning for device using IP address: 192.168.5.240 and using Unicast.
   appleTV Plugin                  CM-Homepod successfully connected and real-time Push updating enabled. (if available!)

1 Apr 2023 at 10:00:57
   Trigger                         Espresso Ready: Announce
   appleTV Plugin                  Sending Command set_volume=70 to appleTV Device ID 139647395
   Schedule                        trigger "Espresso Ready: Announce" (delayed action)
   appleTV Plugin                  Sending Command stream_file=/Users/rdp/Music/nescafe.mp3 to appleTV Device ID 139647395
<and, the music played... first time!>
Question. Would it be worth adding the pyatv version to the plugin startup log message?

Again, thanks for all your work on this. I have tried all sorts of announcement options in Indigo and this is by far the most straight forward and dependable.

Posted on
Sat Apr 01, 2023 2:13 am
GlennNZ offline
User avatar
Posts: 1562
Joined: Dec 07, 2014
Location: Central Coast, Australia

Re: New Python3 AppleTV indigo Plugin

berkinet wrote:
I wrote:
I'm on it.
Looks Good :D
Code: Select all
1 Apr 2023 at 09:59:58
   Reloading plugin "appleTV Plugin 1.0.1" using API v3.1
   Stopping plugin "appleTV Plugin 1.0.1" (pid 17266)
   appleTV Plugin                  Removed AppleTV Manager for device: CM-Homepod
   appleTV Plugin                  Shutting down Plugin
   Stopped plugin "appleTV Plugin 1.0.1"
   Starting plugin "appleTV Plugin 1.0.1" (pid 50049)
   appleTV Plugin                 
   appleTV Plugin                  ================================================ Initializing New Plugin Session =================================================
   appleTV Plugin                  Plugin name:                   appleTV Plugin
   appleTV Plugin                  Plugin version:                1.0.1
   appleTV Plugin                  Plugin ID:                     com.GlennNZ.indigoplugin.appleTV
   appleTV Plugin                  Indigo version:                2022.2.0
   appleTV Plugin                  Python version:                3.10.2 (v3.10.2:a58ebcc701, Jan 13 2022, 14:50:16) [Clang 13.0.0 (clang-1300.0.29.30)]
   appleTV Plugin                  Python Directory:              /Library/Frameworks/Python.framework/Versions/3.10
   appleTV Plugin                 
   appleTV Plugin                  ================================================== End Initializing New Plugin  ==================================================
   Started plugin "appleTV Plugin 1.0.1"
   appleTV Plugin                  CM-Homepod Device has been Setup, attempting to connect.
   appleTV Plugin                  Scanning for device using IP address: 192.168.5.240 and using Unicast.
   appleTV Plugin                  CM-Homepod successfully connected and real-time Push updating enabled. (if available!)

1 Apr 2023 at 10:00:57
   Trigger                         Espresso Ready: Announce
   appleTV Plugin                  Sending Command set_volume=70 to appleTV Device ID 139647395
   Schedule                        trigger "Espresso Ready: Announce" (delayed action)
   appleTV Plugin                  Sending Command stream_file=/Users/rdp/Music/nescafe.mp3 to appleTV Device ID 139647395
<and, the music played... first time!>
Question. Would it be worth adding the pyatv version to the plugin startup log message?

Again, thanks for all your work on this. I have tried all sorts of announcement options in Indigo and this is by far the most straight forward and dependable.


Good good. Hopefully no more breaking OS changes...

An interesting side effect of the change is that it seems that multiple devices are now more in sync... not quite I understand why....

The plugin will give an error message about upgrading if incorrect pyatv version (currently is 0.10.4 = which is version I increased). Not quite sure the rules around version number increase of a forked library,... oh well... hopefully they update based on the pull with these changes.

Posted on
Sat Apr 01, 2023 2:18 am
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: New Python3 AppleTV indigo Plugin

GlennNZ wrote:
...hopefully they update based on the pull with these changes.
:!:

BTW, Does the NZ in GlenNZ mean you are really a kiwi and just live on the West Island?

Posted on
Sat Apr 01, 2023 2:36 am
GlennNZ offline
User avatar
Posts: 1562
Joined: Dec 07, 2014
Location: Central Coast, Australia

Re: New Python3 AppleTV indigo Plugin

berkinet wrote:
GlennNZ wrote:
...hopefully they update based on the pull with these changes.
:!:

BTW, Does the NZ in GlenNZ mean you are really a kiwi and just live on the West Island?
Pretty much!


Sent from my iPad using Tapatalk

Posted on
Sat Apr 01, 2023 3:10 am
durosity offline
User avatar
Posts: 4320
Joined: May 10, 2012
Location: Newcastle Upon Tyne, Ye Ol' England.

Re: New Python3 AppleTV indigo Plugin

GlennNZ wrote:
Good good. Hopefully no more breaking OS changes...


iOS 17 lurking round the corner…

On a side note, I’ve actually found 16.4 very stable on my HomePods. Although I’m still annoyed by the bug that stops it auto directing airplay to the requesting HomePod when running shortcuts!


Sent from my iPhone using Tapatalk Pro

Computer says no.

Posted on
Sat Apr 01, 2023 3:55 am
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: New Python3 AppleTV indigo Plugin

durosity wrote:
On a side note, I’ve actually found 16.4 very stable on my HomePods.

I literally just got off the phone with Apple “support” about a bug in automations. Starting in 16.4, if you play a song in response to an event, the HomePod no longer respects a “turn off” time and just keeps on playing music it chooses. Though it does seem to try to keep to the same genre.

Posted on
Mon May 08, 2023 3:41 pm
durosity offline
User avatar
Posts: 4320
Joined: May 10, 2012
Location: Newcastle Upon Tyne, Ye Ol' England.

Re: New Python3 AppleTV indigo Plugin

berkinet wrote:
durosity wrote:
On a side note, I’ve actually found 16.4 very stable on my HomePods.

I literally just got off the phone with Apple “support” about a bug in automations. Starting in 16.4, if you play a song in response to an event, the HomePod no longer respects a “turn off” time and just keeps on playing music it chooses. Though it does seem to try to keep to the same genre.


I believe this would be considered intentional as it just moves into 'Infinite play' mode?

Computer says no.

Posted on
Mon May 08, 2023 3:45 pm
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: New Python3 AppleTV indigo Plugin

durosity wrote:
berkinet wrote:
durosity wrote:
On a side note, I’ve actually found 16.4 very stable on my HomePods.

I literally just got off the phone with Apple “support” about a bug in automations. Starting in 16.4, if you play a song in response to an event, the HomePod no longer respects a “turn off” time and just keeps on playing music it chooses. Though it does seem to try to keep to the same genre.


I believe this would be considered intentional as it just moves into 'Infinite play' mode?

It was actually a bug and has been fixed and now operates again as it originally did. It plays just the requested track.

Who is online

Users browsing this forum: No registered users and 1 guest