homebridge-appletv-enhanced: Accessory "Apple TV" does not "turn on" with native remote
Analysis
I have successfully installed v1.0.0 of the Plugin, all logs are looking good, the Apple TV is discovered and no error shows up. I also get the Accessory running so far and i can turn it on/off successfully by using the Accessory trough Homebridge.
Now, the thing that i actually want to achieve - i have an automation in place that declines the canvas and turn off all lights when the Apple TV is getting activated.
The automation works great when i turn the Apple TV on trough the Accessory, or with the “Turn On” command - but it’s not working great when i just use the native remote.
Expected Behavior
I would like to have a reliable “active state”, especially when i use the native remote.
Steps To Reproduce
- Setup Apple TV Enhanced (and freshly boot the homebridge/childbridge)
- Add the Apple TV Accessory in Homekit
- Turn the Apple TV on with the native remote, it works!
- Wait for a few hours or one or two days
- Coming back to the setup (logs are showing nothing special), turn on the Apple TV with the native remote and watch how the state doesn’t change at all!
Logs
[02/01/2024, 08:56:08] [Apple TV Enhanced] Child bridge process ended
[02/01/2024, 08:56:08] [Apple TV Enhanced] Process Ended. Code: 143, Signal: null
[02/01/2024, 08:56:15] [Apple TV Enhanced] Restarting Process...
[02/01/2024, 08:56:15] [Apple TV Enhanced] Launched child bridge with PID 523338
[02/01/2024, 08:56:16] Registering platform 'homebridge-appletv-enhanced.AppleTVEnhanced'
[02/01/2024, 08:56:16] [Apple TV Enhanced] Loaded homebridge-appletv-enhanced v1.0.0 child bridge successfully
[02/01/2024, 08:56:16] Loaded 0 cached accessories from cachedAccessories.0ED7621AE9BD.
[02/01/2024, 08:56:16] [Apple TV Enhanced] Platform: Finished initializing platform: Apple TV Enhanced
[02/01/2024, 08:56:16] [Apple TV Enhanced] Python check: Starting python check.
[02/01/2024, 08:56:16] [Apple TV Enhanced] Python check: plugin dir exists.
[02/01/2024, 08:56:16] Homebridge v1.7.0 (HAP v0.11.1) (Apple TV Enhanced) is running on port 30495.
[02/01/2024, 08:56:16] [Apple TV Enhanced] Python check: Python 3.11.2 is installed and supported by the plugin.
[02/01/2024, 08:56:16] [Apple TV Enhanced] Python check: Virtual environment already exists.
[02/01/2024, 08:56:16] [Apple TV Enhanced] Python check: Venv is using current system python version (3.11.2).
[02/01/2024, 08:56:16] [Apple TV Enhanced] Python check: Checking if pip is up-to-date ...
[02/01/2024, 08:56:34] [Apple TV Enhanced] Python check: Pip is up-to-date
[02/01/2024, 08:56:35] [Apple TV Enhanced] Python check: Python requirements are satisfied.
[02/01/2024, 08:56:35] [Apple TV Enhanced] Python check: Finished
[02/01/2024, 08:56:35] [Apple TV Enhanced] Platform: Starting device discovery ...
[02/01/2024, 08:56:42] [Apple TV Enhanced] Platform: Adding Apple TV Apple TV (C0:95:6D:5F:33:4B)
[02/01/2024, 08:56:42] [Apple TV Enhanced] Apple TV (C0:95:6D:5F:33:4B): verifying credentials ...
[02/01/2024, 08:56:44] [Apple TV Enhanced] Apple TV (C0:95:6D:5F:33:4B): Credentials are still valid. Continuing ...
[02/01/2024, 08:56:46] [Apple TV Enhanced] Apple TV (C0:95:6D:5F:33:4B): Finished initializing
[02/01/2024, 08:56:46] Apple TV Apple TV 0760 is running on port 45589.
[02/01/2024, 08:56:46] Please add [Apple TV Apple TV 0760] manually in Home app. Setup Code: 770-02-137
[02/01/2024, 08:56:48] [Apple TV Enhanced] Apple TV (C0:95:6D:5F:33:4B): New Active State: off
[02/01/2024, 08:56:48] [Apple TV Enhanced] Apple TV (C0:95:6D:5F:33:4B): Current App: com.apple.TVMusic
Configuration
{
"mediaTypes": [
"music",
"video"
],
"deviceStates": [
"idle",
"paused",
"playing",
"stopped"
],
"remoteKeysAsSwitch": [
"home",
"turn_off",
"turn_on",
"volume_down",
"volume_up"
],
"customInputURIs": [],
"discover": {
"unicast": [],
"blacklist": [],
"multicast": true
},
"name": "Apple TV Enhanced",
"deviceStateDelay": 0,
"avadaKedavraAppAmount": 15,
"disableVolumeControlRemote": false,
"forceVenvRecreate": false,
"logLevel": 3,
"_bridge": {
"username": "0E:D7:62:1A:E9:BD",
"port": 30495
},
"platform": "AppleTVEnhanced"
},
Environment
- OS: Debian GNU/Linux Bookworm (12)
- Docker: false
- Homebridge: 1.7.0
- Apple TV Enhanced: 1.0.0
- Node: 20.10.0
- npm: 10.2.3
- Python: 3.11.2
Additional Context
Sometimes when i come home after a day, i see the following Warning in the Logs:
Apple TV (C0:95:6D:5F:33:4B): Apple TV can be reached on OSI Layer 2 but not on 3. This is likely a network problem. Restart the plugin after you have fixed the root cause.
Of course, this can be a reason why it suddenly stops working - i just don’t know what to fix in my network, because, the network is working fine! I see my Apple TV online in my connected wifi devices with the static IP it always gets
About this issue
- Original URL
- State: closed
- Created 6 months ago
- Comments: 52 (26 by maintainers)
@mufler Nothing to do on your side. I will update you guys here once the fix to the problem is released …
@maxileith All good so far and sorry for my passive aggressive tone i stumbled into meanwhile 🙏 I can get very emotional with tech stuff and that’s not good in open source communities (i basically should know that after 20 years of programming -.-)
I have a solution now - it’s the Flirc USB dongle and the Flirc Skip Remote:
For anybody curious, here is my virtual-button plugin: https://github.com/rocket-monkey/homebridge-virtual-button But it’s not finished yet, i’m working on the HTTP updates right now and will deliver documentation too once done
@felipehjcosta from the README:
@maxileith I have submitted the bug report here: https://github.com/postlund/pyatv/issues/2331
Hi @rvetere,
I think I have found the root cause. However, before that I want to say something …
Way of communication
You can always do your own projects if you do not have the trust into this project. No software project is perfect, there are always some bugs. You will just not get around this! What is bugging me here is that you are only complaining all the time and providing suggestions for solutions that are ridiculous, like …
or
… which is kind of concerning. Nevertheless, you have really found a bug here and I am willing to fix that bug with you, but I need you to cooperate on this with me. Open-source should be fun, and I do not have the feeling that you are appreciating what I am doing here … I want this issue to be fixed for you and potentially others, too. I just cannot reproduce the error with my setup. This is why I need you to provide the exact outputs that I need to investigate the problem.
You truely need to work on your tone. This is by far the most disrespectful way of dealing with an issue that I have experienced in this project.
I did not ask you to turn on your Apple TV, then execute the
atvscript
, terminate it, turn off your Apple TV, then executearvscript
and terminate it again. If you had just looked at the documentation of pyatv once, you would have seen thatatvscript push_updates
streams all updates regarding an Apple TV. So I still would like to see how it looks like when you are executingatvscript push_updates
and keep it running while you are turning on or off your Apple TV. This is a big difference!I think I have found the root cause …
I think I have found the root cause. Let us look at the following:
There are 4 lines in this log, that have different JSON schemas, let just refer to them as line 1, 2, 3 and 4. I did only know of the schema of line 1, 3 and 4 since 2 never appeared on my setup. So this is an unexpected pattern to me.
As it turns out, the developer of sebbo2002/node-pyatv did not know of that either (I suppose). I am using this dependency to integrate pyatv into my plugin. Just recently I have discovered a bug in this dependency which resulted in a very similar error pattern, see #147. In order to fix that, I have opened https://github.com/sebbo2002/node-pyatv/pull/291 (if you want to know the details about the root cause, please take a look into the PR, this will apply for this issue as well). I think we will need a similar fix for this issue, so
output_devices
in theatvscript push_updates
output are handled similar tovolume
andpower_state
.https://github.com/sebbo2002/node-pyatv/blob/60a414daeaac29c53254611ef25a54dbf671a720/src/lib/device-events.ts#L38-L52
I have created an issue here: https://github.com/sebbo2002/node-pyatv/issues/295
So now we need to wait for the developer to review the issue, provide a fix and release it. But I am confident that this is the problem we were looking for.
@rvetere thank you for providing the logs 👍🏻
It is documented in the
config.schema.json
which is displayed when using the Cofnig UI 😉Way too much overhead … this can definetly be determined the way I am currently doing it. At my side it is rock solid.
Just look at the source code, this is what FOSS is all about 😉
https://github.com/maxileith/homebridge-appletv-enhanced/blob/328e5b86647b1c2e613bd10584918af76ace9e13/src/appleTVEnhancedAccessory.ts#L247
What do you mean with “running”? Is music/video playing? If not, this is the expected behaviour.
What I need you to do @rvetere: Send me the output of
/var/lib/homebridge/appletv-enhanced/.venv/bin/atvscript -s xxx.xxx.xxx.xxx push_updates
wherexxx.xxx.xxx.xxx
is the IP of your Apple TV. Then turn on / off your Apple TV a few times and post the logs here. (assuming/var/lib/homebridge
is your homebridge dir)It may be the case that the output of this script differs wether or not one has a HDMI CEC setup or not.
That’s sad. 😢
I will follow the original issue on pyatv thanks!
Hey @maxileith, I’ve changed to Log Level 4 (Debug) as you suggested however any kind of log appears when I use the native remote controller.