Open mrlad opened 5 months ago
Two initial questions:
I see these statements in the log
Instance/Controller: Adding connection companion-module-android-tv androidtv
Instance/ModuleHost: Starting connection: "androidtv"(ClientID)
Instance/ModuleHost: Connection "androidtv" started
Instance/ModuleHost: Registered module client "ClientID"
Instance/Controller: instance "androidtv" configuration updated
Instance/Wrapper/androidtv: Searching for Devices.
Instance/Controller: instance "androidtv" configuration updated
Instance/Controller: instance "androidtv" configuration updated
Instance/Wrapper/androidtv: Searching for Devices a second time.
Instance/Wrapper/androidtv: Searching for Devices a third time.
Hey,
Yeah, I recently tested this with an android tv and the auto-population wasn't working reliably. I'll take a look at this and see if I can get this working and more reliable again.
Thanks @zerbzman. I just realized that I didn't capture the biggest issue in the bug report.
Turning on the TV is very unreliable (only seems to work once during the initial connection) and turning it off doesn't work at all.
I can verify a similar scenario on TCL tvs running Android TV. They don't respond to power on commands, but do respond to power off and other commands.
Ahh, yeah that means the MAC address isn't being used. Those tvs and a lot of tvs use a wake on lan packet to turn on. I'll see if I can fix that here soon.
Thank you, @zerbzman!
Ahh, yeah that means the MAC address isn't being used. Those tvs and a lot of tvs use a wake on lan packet to turn on. I'll see if I can fix that here soon.
WoL packets work on the HiSense too to turn on the TV. The issue I have with WoL is I need to access the TV from a different subnet so a subnet broadcast wouldn't work for me.
Hey! Here is a version to test.
Please test this out and let me know if you run into any issues or it fails. Thanks
Hi @zerbzman , took me a second to figure out where the zip file was but I found it.
I tried it but it kept immediately crashing with an unhandled exception.
Unhandled error restarting connection: Error: Restart forced
Never got to the settings screen.
Same here. I couldn’t configure anything. Kept crashing.
Ok, sorry for the confusion. Would you mind clicking on this button >_ next to the trash can icon. That shows the logs for just that module and should show more info. Thanks!
Here's the exception details
error: node:internal/modules/cjs/loader:1080
throw err;
^
Error: Cannot find module '@companion-module/base'
Require stack:
- f:\media\documents\Companion\devModules\companion-module-android-tv-issue-14-fix-mac-address-and-user-flow\main.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
at Module._load (node:internal/modules/cjs/loader:922:27)
at Module.require (node:internal/modules/cjs/loader:1143:19)
at require (node:internal/modules/cjs/helpers:119:18)
at Object.<anonymous> (f:\media\documents\Companion\devModules\companion-module-android-tv-issue-14-fix-mac-address-and-user-flow\main.js:1:64)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Module._load (node:internal/modules/cjs/loader:960:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:86:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'f:\\media\\documents\\Companion\\devModules\\companion-module-android-tv-issue-14-fix-mac-address-and-user-flow\\main.js'
]
}
Node.js v18.18.1
@mrlad my apologies, the way that I told you to set this up won't work. Can you and @scotttroyer shoot me an email at my GitHub username at gmail.com? I'll send you a dropbox link to the module to test.
@zerbzman thank you for sending the files via Dropbox. I've just tested this new module on a clean install of Companion running on an Apple MacBook Air M1. I am able to input the IP address and pair the device. It auto-detects the TV's wireless MAC address. All actions seem to work fine except powering on the device.
I tried the default "androidtv: Set Power State" action as well as the "androidtv: Send Button Command" action with the 4 different available "power" commands.
I'm wondering if there's an issue here with the specific TV I have. In the opening part of your set up guide, my TV's settings don't look exactly the same as your's below. I hit the cog button, click on a cog icon, go to Network & Internet, but don't see the Networked Standby anywhere.
TV Setup For this to turn on the tv you need to turn on Networked Standby.
- Hit the Settings Cog Button on your remote.
- Go to More Settings
- Select Network & Internet
- Scroll down to Networked Standby and turn it on.
TCL Model Number: 43S350G Software Version: V8-T221T04-LF1V080.000507 Android TV Model: Smart TV ANdroid TV OS Version: 11 Kernel Version: 4.19.116+ # 1 Thu Jun 20 16:08:20 CST 2023 Android TV OS Build: AR2101 Both the System and Service Updates are current. Connected to the network via Wifi with a static IP
I found this Reddit post, which maybe implies that some TCL TVs do power the network card when in standby mode.
I've also just confirmed that the TV is not pingable when the power is off. Looks like this particular model may not be able to be powered on from standby via network. Perhaps which is why the "Networked standby" option is not shown as an option on this TV. 😔
Thanks @scotttroyer! I've been down that rabbit hole of trying to keep the TV in a "waked" state but nothing worked for me. I did have an issue where I factory reset the TV but then it had a different OS version and that version did not work with this plugin. Eventually it updated but that was frustrating.
What Networked Standby does is turn on the TV when someone casts to it. You could see if there is any option for that. You could also test if you can cast from your phone to it.
Another thing you could test is a wired connection.
Also just thought I would say that Networked Standby on my tv is between IP Settings and Check Internet Connection.
@zerbzman, I did get this to work (with some caveats) after trying your suggestion to cast to the TV. Here's what worked:
So, for now this is working, but not super reliably. I really appreciate your help on this module.
Ugh...replied too soon.
When a Google account is signed in, the TV no longer obeys the "Power On Behavior" of "Last used input" and instead defaults to the Google TV home screen every time. Not a big deal, but the "androidtv-lobby: Send Button Command" with Select Button "KEYCODE_TV_INPUT_1" action no longer works either, so there is no way to change the input to our feed.
I've removed the Google account, which factory reset the TV. Going to keep using the TCL in Basic TV mode for now so it will power up with the correct input.
Tried the dropbox version. Was able to pair two TVs. I am able to power off the TVs, but I can't power them on.
I have a standalone WoL app that I can send the WoL magic packet and wake up the TVs. but no luck from the Android TV module. Interestingly enough, the Companion WoL module doesn't work either to wake up the TVs. Windows, Android and iOS WoL apps do work to turn on the TV.
@mrlad Here is another thing you can try. I remember you saying that the TVs are on another subnet and it sounds like you are running companion on a windows computer.
Can you try using the Companion Wake on LAN module and change the Destination IP to the following pattern: "192.168.1.255" where the first three blocks are the first three blocks of the TV ip address. Everything else can stay the default, besides the Mac address of course. Also, you can also try hitting the button twice or separated by 3 seconds.
@scotttroyer Aw man, that was a roller coaster. Nice job on troubleshooting that and thinking that through. That's a bummer to hear that it always loads to the home screen. On my TV, the input button command doesn't actually do anything so that was interesting to hear that it actually worked. When I first tested all the buttons I found that on my TV the KEYCODE_F3 button brought up the input screen and then I could use the arrow keys to set the input. You might be able to try that. You could hit the KEYCODE_F3 button, then hit the KEYCODE_DPAD_UP button 3 times, and hit the KEYCODE_DPAD_CENTER button to select it. If you go to the preset tab in companion, I made some presets for navigation that helps. Or, I'm just testing this on my TV right now, if I have the home screen up and then hit the F3 button, I just have to hit the DPAD Center button ("OK" in my preset) and it will go back to the HDMI input. That might work for you. You may just have to play around with the timing of the commands in Companion.
As for powering the TV on, I sent you an email with an updated version of the module to include the regular power on command to the TV when using the power state action. It basically sends both the Wake on Lan command and the power command at the same time. I also found when initially working on this plugin that powering on the TV using Wake on lan was pretty inconsistent. I stumbled on success sending the command multiple times and found that a three second gap between commands was the sweet spot. Hopefully this can remedy the power issue for you.
Let me know how it goes!
@zerbzman , for the purposes of simplifying testing, the report above was using the WoL functionality on the same subnet (the real use case is in fact on a different subnet, but for now, I'm trying to limit complexity).
Given that I was testing on the same subnet, would the x.y.z.255 broadcast make any difference?
Also, you can also try hitting the button twice or separated by 3 seconds.
I did use the retry option for the Companion WoL module and that didn't help, but I'll try with your module also.
On the same subnet, I increased the retry window for the Companion WoL module from 100ms to 3000ms and used the x.y.z.255 address. This has worked two of the three times I pressed the button. I'm unsure if its the retry window that made the difference or the broadcast address.
Went back to the 100ms retry window and the x.y.z.255 address and this continues to work. So it would appear the broadcast address is the key not the duration of the retry window.
@mrlad Awesome. Yeah, a manual broadcast address is really what I was looking for. I looked back at the wake on LAN library that this module and companion's module uses and it mentions that on a windows computer the wake on LAN utility works differently than on Unix machines because of limitations on windows and it needs a manual broadcast address. I'll have to do a little bit of work but I'll see if I can fix that relatively soon and send you a version.
Thanks for testing both of those.
Thanks for the update @zerbzman . Our use case is a Windows box (same subnet/VLAN) and a Mac (different subnet/VLAN). I'm assuming the Mac would be considered *nix from the WoL companion module perspective? I haven't tested the Mac with your new code yet.
@mrlad Gotcha, yes sorry the Mac is Unix so it should work but I would be curious if there would be any issues with the different subnet.
Hi @zerbzman , tried your latest drop. I have two TVs I'm testing w/this module. Both don't turn on with the first power on attempt. They do turn on the second attempt (assuming I wait at least 3-5 seconds).
@mrlad Awesome! It should automatically send another wake command at 3 seconds to turn it on. Can you try it again without a second manual command and let me know how it goes? Thanks
@zerbzman , sorry for not being clearer. I did try with only one power on command and that didn't work. I had to press the button a second time to get it to work.
So I tried adding four power on commands per button press, didn't help. It wouldn't turn on. I have to press the button twice for the TV to wake up and come out of standby.
I tried an experiment. I had a assumed the first power on command wasn't working. I may not have been waiting long enough. Seems like the second press turns on the TV after about 10-12 seconds. The first press I waited up to 30 seconds (sometimes it turns on in the 10 second window, sometimes it doesn't).
How many retries are you doing and how frequently are the retries happening?
Hey @mrlad, sorry for the delay. This plugin sends a wake command and then again after 3 seconds. That was the sweet spot in my testing. I can try to make a version that sends a third command at 6 seconds. I'll test that and send a version to you.
Thanks @zerbzman .
@zerbzman, having quite a few problems with the new drop.
Hey @mrlad, so I found that using the WIFI connection on the TV is way more reliable than using the Ethernet connection for turning on and off the TV. I'm doing some testing to see if I can help the ethernet connection but in the meantime I would suggest testing out the Wifi connection and seeing if it resolves your problems.
Tried v5. Here are my findings
Tried the 30 second retry. Didn't notice an appreciable difference (turns on sporadically).
When it did turn on, it was about 6-12 seconds after the original PowerOn request.
Did some more experimenting tonight.
My Windows WoL app works reliably to turn on our two TVs when I have the "Internet" send option activated. If I switch the send option to "local network" is becomes very unreliable. Unsure what the technical difference is between the two but functionally, one is intended for access outside the local subnet so I'm guessing its a broadcast option.
Also, one time the code got stuck in a retry state and I had to kill/restart companion to recover.
The very first time the module is added it connects to the Hisense Android TV, but the MAC address doesn't auto-populate like the help says it should. I can manually add the MAC but I suspect this is indicative of a bigger issues. Once you disconnect and try to reconnect, the module gets stuck in a permanent "Connecting" state.