normen / homebridge-bravia

Homebridge plugin for Sony Bravia TVs (AndroidTV based ones and possibly others)
139 stars 26 forks source link

TV not responding after HomeBridge restart when using as external accessory #129

Closed benjaminbogdanovic closed 4 years ago

benjaminbogdanovic commented 4 years ago

HomeBride: v1.2.3 Node.js Version: v12.18.4 homebridge-bravia: v2.4.3 Config: "tvs": [ { "name": "Test TV", "ip": "192.168.1.67", "externalaccessory": true, "soundoutput": "speaker", "tvsource": "tv:dvbt", "channelupdaterate": 0 } ]


I have been testing out the plugin using the external accessory mode, and when HomeBridge restarts, the tv stops responding. The only way to get it working again is to remove, rename, and re-add the device.

normen commented 4 years ago

The TV needs to be scanned for channels on reboot before it can be used.

benjaminbogdanovic commented 4 years ago

It never responds again, even after several hours after the restart.

normen commented 4 years ago

So the channels probably can't be scanned. Hard to say without any info.

benjaminbogdanovic commented 4 years ago

I have removed channelupdaterate and I can see from the log that it has scanned as it has removed and added channels.

normen commented 4 years ago

You can try enabling debug mode and see if theres any additional info in the log ("debug" : true). Again, you have all the info, I have none, and I don't intend to pull everything out of your nose.

benjaminbogdanovic commented 4 years ago

The debug log is providing no additional output after running for an hour.

I did notice that that on another plug in that adds TV's as external accessories, this is in the log: image

It is in the log for this plug in, but only on the first run after install, not after any subsequent restart: image

normen commented 4 years ago

Mhm, after that message (cached accessory found and restored) the plugin would scan the TV for channels and then add it to HomeKit. So it probably can't scan the channels. Maybe the TV simply isn't turned on?

benjaminbogdanovic commented 4 years ago

The TV is on. I go through the setup procedure, entering the pin, the channels load, I set it up on the Home app, no renaming of the inputs, everything works, then I restart HomeBridge, the no response ever again. Happened the five times I have tried it.

benjaminbogdanovic commented 4 years ago

With my last set up I did it without channelupdaterate set at all from initial paring, and it loads channels after HomeBridge restart, loads the external device, but still does not respond in the Home app.

image

benjaminbogdanovic commented 4 years ago

On further inspection, it created a new external accessory! imageimage

normen commented 4 years ago

So in other words you probably poked a dead external accessory all this time?

benjaminbogdanovic commented 4 years ago

No. I erased the external accessories every time. The plug in creates one, it stops working after the the restart, then the plugin creates another external accessory that works after restarting HomeBridge. Why it needs to do needs to do it twice is beyond me.

This only works if "channelupdaterate" is removed from the config file. It stops the channel scan at the boot it seems.

normen commented 4 years ago

No. I erased the external accessories every time. The plug in creates one, it stops working after the the restart, then the plugin creates another external accessory that works after restarting HomeBridge. Why it needs to do needs to do it twice is beyond me.

Ah, now we're getting somewhere. Found an issue that might cause this. But you'll probably get another external device again (actually the first that appeared).

This only works if "channelupdaterate" is removed from the config file. It stops the channel scan at the boot it seems.

Right, it basically expects the channels to be loaded at boot (which they aren't for external accessories). However the funny issue with orphaned channels appearing in HomeKit seems to be gone in iOS 14.

normen commented 4 years ago

Okay, 2.4.4 should fix this. The manually restored devices reported a wrong UUID and were thus "new" devices for HomeKit. Any existing external TVs will probably have to be added again.

benjaminbogdanovic commented 4 years ago

Thanks. I'll test it later tonight.

To clarify the behaviour of channelupdaterate, when it is set to 0/false, it does not seem to run at boot. I know it should run, but is it stopping the run on boot inadvertently?

normen commented 4 years ago

Probably because the TV didn't yet report its power state so the channel update isn't pulled yet.

I could force an update but really setting this to "false" is a workaround for people who can only see their favorite inputs when the stars align and can then set this to to "freeze" it.

..obviously that only works when the channels are actually stored which is NOT the case for external devices but having channels stored would be the aim at some point. Homebridge itself currently only stores this info for non-external devices, sadly.

On Mon Sep 21, 2020 at 8:28 PM CEST, Benjamin wrote:

Thanks. I'll test it later tonight.

To clarify the behaviour of channelupdaterate, when it is set to 0/false, it does not seem to run at boot. I know it should run, but is it stopping the run on boot inadvertently?

-- You are receiving this because you modified the open/close state. Reply to this email directly or view it on GitHub: https://github.com/normen/homebridge-bravia/issues/129#issuecomment-696290739

benjaminbogdanovic commented 4 years ago

That makes sense. That is unfortunate that HomeBridge only stores that info for non-external devices. I might submit a improvement issue on their repo.

I assume this also means custom names of inputs do not persist?

normen commented 4 years ago

Probably, yeah, didn't even think of those. If you only have one TV I'd really suggest not using external accessory mode and just live with the icon on iOS, thats what I do. For homebridge maybe they could add some way to get access to the accessory cache for external devices, yeah. I'd really rather not re-implement all that myself if it basically already works with dynamic devices (aka "normal mode" in this plugin). Maybe there is already a way to "hack" into it but I didn't see anything in their official API.

On Mon Sep 21, 2020 at 9:10 PM CEST, Benjamin wrote:

That makes sense. That is unfortunate that HomeBridge only stores that info for non-external devices. I might submit a improvement issue on their repo.

I assume this also means custom names of inputs do not persist?

-- You are receiving this because you modified the open/close state. Reply to this email directly or view it on GitHub: https://github.com/normen/homebridge-bravia/issues/129#issuecomment-696314039

normen commented 4 years ago

As the HB devs didn't sound too cheerful about the idea on discord v2.4.6 now stores the channels to its own file for external devices. It should work with changed names, just give it 30 seconds or so after you change the name before rebooting homebridge, it saves the names in intervals of [channelupdaterate]

benjaminbogdanovic commented 4 years ago

That's a shame they did not play ball. v2.4.6 works exactly as described. I'll keep testing it for the next few days and see how it goes.

benjaminbogdanovic commented 4 years ago

Here is something odd, on my Mac running 10.15.7, the home app seems to add a tile for the one input changed the name of. It does not do anything, nor does it cause any issue. More of an FYI. Might be fixed on Big Sur.

ezgif com-video-to-gif-3

normen commented 4 years ago

See #74