New Python3 AppleTV indigo Plugin

Posted on
Wed Mar 08, 2023 2:49 pm
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: New Python3 AppleTV indigo Plugin

GlennNZ wrote:
Thats an odd indigo client error - do you have a config window open somewhere?
Sorry if I was clear, that error was thrown while trying to open the device config from an Indigo remote client.

BTW, I only have one active ATV device, a HomePod-II
Last edited by berkinet on Thu Mar 09, 2023 6:19 am, edited 1 time in total.

Posted on
Wed Mar 08, 2023 6:34 pm
GlennNZ offline
User avatar
Posts: 1555
Joined: Dec 07, 2014
Location: Central Coast, Australia

Re: New Python3 AppleTV indigo Plugin

Opening the device only?
Or going into settings of the device?

(Will presume later and check )


Sent from my iPhone using Tapatalk

Posted on
Wed Mar 08, 2023 7:17 pm
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: New Python3 AppleTV indigo Plugin

GlennNZ wrote:
Opening the device only?
Or going into settings of the device?

(Will presume later and check )
Correct assumption.

Posted on
Wed Mar 08, 2023 11:07 pm
GlennNZ offline
User avatar
Posts: 1555
Joined: Dec 07, 2014
Location: Central Coast, Australia

New Python3 AppleTV indigo Plugin

Ok.
I also presume that the reason you are opening a device edit dialog is because the plugin is not responding?

In light of that, debug logging for the plugin will be needed for the time up to it being non-responsive, which should be fairly straight forward because if has died so well would presume the logging would end.. Set the file logging to Debug in the plugin Config. Can leave the indigo log level unchanged so doesn't flood log.

Next time happens PM the log and will see what can see.

Meanwhile - whilst waiting log and repeat issue,

1. ? Whether you are using static IP addresses - I and others are - and may relate to connect/disconnect if IP address cycling every ~72 hours
2. Try version 0.1.19 - there now, changes disconnect handling which may or may not be issue.
3, If not static IP for homepod - change to static IP for the Homepod

Glenn

Posted on
Thu Mar 09, 2023 4:32 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:
Ok.
I also presume that the reason you are opening a device edit dialog is because the plugin is not responding?
Yes. Just as a test

In light of that, debug logging for the plugin will be needed for the time up to it being non-responsive, which should be fairly straight forward because if has died so well would presume the logging would end.. Set the file logging to Debug in the plugin Config. Can leave the indigo log level unchanged so doesn't flood log.
Done.

Next time happens PM the log and will see what can see.
Will do.

1. ? Whether you are using static IP addresses - I and others are - and may relate to connect/disconnect if IP address cycling every ~72 hours
This is the device config dialog. I do not see an option to set a static IP.
Screen Shot 2023-03-09 at 11.27.45.png
Screen Shot 2023-03-09 at 11.27.45.png (402.8 KiB) Viewed 1298 times

2. Try version 0.1.19 - there now, changes disconnect handling which may or may not be issue.

Ok. Done.
3, If not static IP for homepod - change to static IP for the Homepod
Do you mean like this in there Plugin config?
Screen Shot 2023-03-09 at 11.27.45.png
Screen Shot 2023-03-09 at 11.27.45.png (402.8 KiB) Viewed 1298 times


And, here is a log of the device...
Code: Select all
================================================================== Device: Iden: AC:BC:B5:C8:A7:5A===================================================================
   appleTV Plugin                 
        Name: CM-Homepod
   Model/SW: AudioAccessory6,1, Unknown OS 16.3.2
    Address: 192.168.5.240
        MAC: AC:BC:B5:C8:A7:5A
 Deep Sleep: False
Identifiers:
 - AC:BC:B5:C8:A7:5A
 - ACBCB5C8A75A
Services:
 - Protocol: AirPlay, Port: 7000, Credentials: None, Requires Password: False, Password: None, Pairing: NotNeeded
 - Protocol: Companion, Port: 49153, Credentials: None, Requires Password: False, Password: None, Pairing: Unsupported
 - Protocol: RAOP, Port: 7000, Credentials: None, Requires Password: False, Password: None, Pairing: NotNeeded

   appleTV Plugin                  ============================================================================ End of Data ============================================================================


Thanks for looking into this.

Richard

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

Re: New Python3 AppleTV indigo Plugin

New information.

It appears the "crash" may (I.e. I am not yet certain) be caused by running a Speak Annlouncement command with incorrect permissions set on the plugin directory.

I had previously run the command
Code: Select all
sudo xattr -rd com.apple.quarantine /Library/Application\ Support/Perceptive\ Automation/Indigo\ 2022.2/Plugins
But, perhaps installing some plugin update reset that. In any case, from the desktop of the Indigo server I tried to run an action which: 1, set the volume, 2, played a local mp3, and, 3, spoke an announcement. That is when I noticed the plugin crashed and macOS displayed
Screen Shot 2023-03-09 at 13.35.08.png
Screen Shot 2023-03-09 at 13.35.08.png (22.33 KiB) Viewed 1372 times


Here is the log of the speak request.
Code: Select all
***** Play Status Debug *****
Playstatus   Media type: Music
Device state: Playing
    Position: 0/4s (0.0%)
PlayState Title None
09-03-2023 13:17:56.710 DEBUG   Plugin.process_playstatus:plugin.py:1435:       App Playing  and App Name None
09-03-2023 13:17:57.099 DEBUG   Plugin.speakText:plugin.py:1372:        You have mail
09-03-2023 13:17:57.099 DEBUG   Plugin.speakText:plugin.py:1373:        say return code:0 output:None error:None
09-03-2023 13:17:57.100 DEBUG   Plugin.speakText:plugin.py:1381:        "./ffmpeg/ffmpeg" -y -i "/Library/Application Support/Perceptive Automation/Indigo 2022.2/Preferences/Plugins/com.GlennNZ.indigoplugin.appleTV/speak/139647395.aiff" -f mp3 "/Library/Application Support/Perceptive Automation/Indigo 2022.2/Preferences/Plugins/com.GlennNZ.indigoplugin.appleTV/speak/139647395.mp3"
09-03-2023 13:18:00.400 DEBUG   Plugin.loop_atv:plugin.py:621:  Within main sleep 20 second loop killconnection False
09-03-2023 13:18:02.144 INFO    Plugin.speakText:plugin.py:1391:        None
09-03-2023 13:18:02.144 WARNING Plugin.speakText:plugin.py:1392:        None
09-03-2023 13:18:02.144 DEBUG   Plugin.speakText:plugin.py:1396:        None
09-03-2023 13:18:02.144 DEBUG   Plugin.speakText:plugin.py:1397:        None
09-03-2023 13:18:02.144 DEBUG   Plugin.speakText:plugin.py:1404:        Sending Command stream_file=/Library/Application Support/Perceptive Automation/Indigo 2022.2/Preferences/Plugins/com.GlennNZ.indigoplugin.appleTV/speak/139647395.mp3 to appleTV Device ID 139647395
09-03-2023 13:18:02.144 DEBUG   Plugin.speakText:plugin.py:1408:        Found correct AppleTV listener/manager. <__main__.appleTVListener object at 0x106adb220> and id 139647395
09-03-2023 13:18:02.144 DEBUG   Plugin.send_command:plugin.py:513:      Within send_command and command & args - stream_file=/Library/Application Support/Perceptive Automation/Indigo 2022.2/Preferences/Plugins/com.GlennNZ.indigoplugin.appleTV/speak/139647395.mp3 and args /Library/Application Support/Perceptive Automation/Indigo 2022.2/Preferences/Plugins/com.GlennNZ.indigoplugin.appleTV/speak/139647395.mp3
09-03-2023 13:18:02.147 DEBUG   Plugin._handle_device_command:plugin.py:410:    _handle_device_command called - Args: /Library/Application Support/Perceptive Automation/Indigo 2022.2/Preferences/Plugins/com.GlennNZ.indigoplugin.appleTV/speak/139647395.mp3  Cmd:stream_file=/Library/Application Support/Perceptive Automation/Indigo 2022.2/Preferences/Plugins/com.GlennNZ.indigoplugin.appleTV/speak/139647395.mp3
09-03-2023 13:18:02.148 DEBUG   Plugin._handle_device_command:plugin.py:426:    cmd and cmd_args extracted and Cmd stream_file and cmd_args ['/Library/Application Support/Perceptive Automation/Indigo 2022.2/Preferences/Plugins/com.GlennNZ.indigoplugin.appleTV/speak/139647395.mp3']
09-03-2023 13:18:02.148 DEBUG   Plugin._exec_command:plugin.py:496:     General Exception Caught:
Traceback (most recent call last):
  File "plugin.py", line 475, in _exec_command
    value = await tmp(*args)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pyatv/core/facade.py", line 392, in stream_file
    await self.relay("stream_file")(file, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pyatv/protocols/raop/__init__.py", line 341, in stream_file
    self.playback_manager.acquire()
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pyatv/protocols/raop/__init__.py", line 141, in acquire
    raise exceptions.InvalidStateError("already streaming to device")
pyatv.exceptions.InvalidStateError: already streaming to device
09-03-2023 13:18:02.150 INFO    Plugin._exec_command:plugin.py:497:     Could not run this command at this time.
09-03-2023 13:18:03.400 DEBUG   Plugin.playstatus_update:plugin.py:326: Playstatus Update Called for CM-Homepod
09-03-2023 13:18:03.401 DEBUG   Plugin.playstatus_update:plugin.py:327: & PlayStatus
   Media type: Unknown
Device state: Idle
      Repeat: Off
     Shuffle: Off
09-03-2023 13:18:03.401 DEBUG   Plugin.process_playstatus:plugin.py:1424:

So, IF this is what is causing the plugin to hang, and IF this is caused by incorrect permissions, THEN maybe you can trap the error and log a message with instructions on how to fix the problem.

Posted on
Thu Mar 09, 2023 2:11 pm
GlennNZ offline
User avatar
Posts: 1555
Joined: Dec 07, 2014
Location: Central Coast, Australia

New Python3 AppleTV indigo Plugin

berkinet wrote:
GlennNZ wrote:
Ok.
I also presume that the reason you are opening a device edit dialog is because the plugin is not responding?
Yes. Just as a test

In light of that, debug logging for the plugin will be needed for the time up to it being non-responsive, which should be fairly straight forward because if has died so well would presume the logging would end.. Set the file logging to Debug in the plugin Config. Can leave the indigo log level unchanged so doesn't flood log.
Done.

Next time happens PM the log and will see what can see.
Will do.

1. ? Whether you are using static IP addresses - I and others are - and may relate to connect/disconnect if IP address cycling every ~72 hours
This is the device config dialog. I do not see an option to set a static IP.
Screen Shot 2023-03-09 at 11.27.45.png

2. Try version 0.1.19 - there now, changes disconnect handling which may or may not be issue.

Ok. Done.
3, If not static IP for homepod - change to static IP for the Homepod
Do you mean like this in there Plugin config?
Screen Shot 2023-03-09 at 11.27.45.png


And, here is a log of the device...
Code: Select all
================================================================== Device: Iden: AC:BC:B5:C8:A7:5A===================================================================
   appleTV Plugin                 
        Name: CM-Homepod
   Model/SW: AudioAccessory6,1, Unknown OS 16.3.2
    Address: 192.168.5.240
        MAC: AC:BC:B5:C8:A7:5A
 Deep Sleep: False
Identifiers:
 - AC:BC:B5:C8:A7:5A
 - ACBCB5C8A75A
Services:
 - Protocol: AirPlay, Port: 7000, Credentials: None, Requires Password: False, Password: None, Pairing: NotNeeded
 - Protocol: Companion, Port: 49153, Credentials: None, Requires Password: False, Password: None, Pairing: Unsupported
 - Protocol: RAOP, Port: 7000, Credentials: None, Requires Password: False, Password: None, Pairing: NotNeeded

   appleTV Plugin                  ============================================================================ End of Data ============================================================================


Thanks for looking into this.

Richard
Ok.

Few things here:

Static IP/Fixed IP - is a router setting for that Homepod that you will need to set up. Much like need fixed or static IP’s for various usages. Still likely it is this I would be guessing. You will need to set that up for your router.

The Plugin Error message if haven’t run the xattr command - is probably related to you upgrading plugin to most recently. This will occur with every command after upgrading. Should be easy to spot as will happen immediately - and never later. After upgrading, run cmd xattr and check all is working. The plugin also gives a message reminding you to run command again. Unfortunately I don’t believe this can be ‘caught’ as is happening much higher than the plugin process - be that security for Mac OSX. But can look into it.



Glenn


Sent from my iPad using Tapatalk
Last edited by GlennNZ on Thu Mar 09, 2023 3:12 pm, edited 1 time in total.

Posted on
Thu Mar 09, 2023 2:20 pm
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: New Python3 AppleTV indigo Plugin

GlennNZ wrote:
:Static IP/Fixed IP - is a router setting for that Homepod that you will need to set up. Much like need fixed or static IP’s for various usages. Still likely it is this I would be guessing. You will need to set that up for your router.
Ah, sorry, I thought you we’re referring to a plug-in setting. Yes, the HomePod is now on DHCP, But, the address hasn’t changed since I installed it. Still, I can easily make the address static if you think it might make a difference.

Posted on
Thu Mar 09, 2023 4:06 pm
GlennNZ offline
User avatar
Posts: 1555
Joined: Dec 07, 2014
Location: Central Coast, Australia

New Python3 AppleTV indigo Plugin

Ok - probably would put it on a staticIP, in case there has been a change of IP which may have caused issues when becomes unresponsive.

Certainly I’m running 5 appleTVs, 2 Homepods, including II and haven’t had any issues for a few months. We would notice because have one of the appleTVs setup to turn on/off lights if paused/playing. And do use the announcements regularly a few times a day.

Glenn


Sent from my iPad using Tapatalk

Posted on
Fri Mar 10, 2023 10:09 pm
GlennNZ offline
User avatar
Posts: 1555
Joined: Dec 07, 2014
Location: Central Coast, Australia

New Python3 AppleTV indigo Plugin

Update:

Update to version 0.1.20
Thanks to autologs requirements.py check - it checks that you are running the correct version of pyatv (which if not may cause issues)
I suspect you are! Can check with
Code: Select all
pip3 show pyatv


But plugin will now check for you all going to plan.

Will need to unquarantine again after update - as per the messaging.

Thanks

Glenn

Posted on
Sat Mar 11, 2023 5:28 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:
...Update to version 0.1.20
Code: Select all
 Upgrading plugin appleTV Plugin to newer version 0.1.20 (previous version moved to trash)
   Loading plugin "appleTV Plugin 0.1.20" using API v3.1
   Starting plugin "appleTV Plugin 0.1.20" (pid 66865)
   appleTV Plugin                 
   appleTV Plugin                  ================================================ Initializing New Plugin Session =================================================
   appleTV Plugin                  Plugin name:                   appleTV Plugin
   appleTV Plugin                  Plugin version:                0.1.20
   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 0.1.20"
   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!)
Thanks to autologs requirements.py check - it checks that you are running the correct version of pyatv (which if not may cause issues)
I suspect you are!...
Code: Select all
% pip3 show pyatv
Name: pyatv
Version: 0.10.3
Will need to unquarantine again after update - as per the messaging.
Done.

Interestingly, since upgrading to 0.1.19 and unquarantining 2 days ago, all has been well.

Thanks for the support

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

Re: New Python3 AppleTV indigo Plugin

berkinet wrote:
...Interestingly, since upgrading to 0.1.19 and unquarantining 2 days ago, all has been well.

Thanks for the support

Well, I spoke too soon. I am still seeing the same behavior. The plugin continues to be able to perform most commands, except for the speak text command. At the same time, the device configuration either will not load, or loads very slowly. Reloading the plugin clears the problem. However, the reload takes a fairly long time and Indigo seems to finally kill it (probably -9).

I have logging to file turned on, but nothing even remotely significant is being logged. The best guess at this point is the problem is caused as a result of an improper speak request resulting in an untapped error.

I hope this helps.

Posted on
Sat Mar 18, 2023 2:58 pm
GlennNZ offline
User avatar
Posts: 1555
Joined: Dec 07, 2014
Location: Central Coast, Australia

Re: New Python3 AppleTV indigo Plugin

Ok. Thats annoying that nothing obvious.

I’ll have a look and wrap it up tightly, and post a new version soonish.


Sent from my iPad using Tapatalk

Posted on
Sat Mar 18, 2023 9:35 pm
GlennNZ offline
User avatar
Posts: 1555
Joined: Dec 07, 2014
Location: Central Coast, Australia

Re: New Python3 AppleTV indigo Plugin

Ok

The UI hanging is the odd bit, presumably the first UI async loop must hang somewhere. Presumed that one of the subprocesses doesn't complete or timeout probably leading to this.

So:

Try 0.1.22

Pretty wholesale refactoring of the Say/Speak command.


Changelog:
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


Thanks

Posted on
Sun Mar 19, 2023 7:35 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:
...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.

Who is online

Users browsing this forum: No registered users and 0 guests