normen / homebridge-bravia

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

Accessory randomly dissapears from HomeKit #59

Closed alladinian closed 4 years ago

alladinian commented 4 years ago

Hi there,

Great work!

The plugin works like a charm, the only problem though is that the accessory disappears from HomeKit after a while and then randomly appears again some times :/

The accessory is visible at all times in the homebridge UI though. Android tv's version is 8.0.0, plugin version is 1.3.4

Any ideas?

normen commented 4 years ago

Never heard of that issue. The channels sometimes change (e.g. CEC devices) and HomeKit then sometimes leaves "orphaned" TV channels as single devices visible for a while, those usually disappear after a while. Then theres the remote function which sometimes doesn't seem to be visible in the remote list on iOS devices. Both of these issues have more to do with HomeKit than with this plugin. But again, the whole TV accessory not being available - never had that issue crop up here.

alladinian commented 4 years ago

First of all... awesome reply times 😋 That's odd... I managed to grab a screen recording right now to demonstrate this issue. It appears that this happens after 1 minute or so (the recording is from my mac but exactly the same happens on iOS too). Also, fellow developer here with a lot of time on his hands (little experience with js but a lot of experience with iOS), so I guess if you pointed out some things that I could investigate on my own (any logs or a way to have a minimal standalone version of the plugin so I could try to debug this in real-time would be awesome).

Thanks again for the response and your time 🍻

normen commented 4 years ago

As said, I don't really have any idea, the plugin has been created from an old plugin I found and is pretty quick-n-dirty so theres no real development environment setup around it either.

Theres the "debug" parameter at the top of the code which might yield some more output. In general the plugin works so that the "accessories" callback is only fullfilled after all calls to the TV input lists have all been done so really after the plugin booted up everything should be pretty static.

normen commented 4 years ago

Does this still happen in 2.0?

alladinian commented 4 years ago

Just tried again. The behavior is the same. The setup progress is flawless but the accessory disappears after 10-20 seconds :/ The weird thing is that the accessory appears to be fine in Homebridge, it just keep getting removed from HomeKit for some reason.

normen commented 4 years ago

Is this maybe a name clash? Did you use a similar name elsewhere in HomeKit?

alladinian commented 4 years ago

No, the name is unique, the IP address of the device is static and the accessory sometimes re-appears for brief periods. I am not familiar with the underlying mechanisms but seems like a polling issue (?)

normen commented 4 years ago

By now I'd really put this on HomeKit. Would be awesome if you had another TV to try this which supported homekit out of the box. Or maybe another plugin that also supports the iOS12 TV functions.

alladinian commented 4 years ago

I guess you're right, it's either HomeKit or Homebridge that somehow stops advertising the accessory. Right now is the only TV in the house but if I get another device on my hands I'll let you know. Thanks very much for your time though!

normen commented 4 years ago

Could this be tied to https://github.com/normen/homebridge-bravia/issues/76 ? Maybe it just disappears from the favorites? That would mean that your TV is not actually in the favorites but when theres a "ghost device" that will pull it in there.

sephrioth commented 4 years ago

I have a very similar issue with Homekit in Homeassistant... still can't find the cause. https://github.com/home-assistant/core/issues/34914

normen commented 4 years ago

I think homebridges dynamic accessories are still a bit flakey. For example in my other plugin (homebridge-platform-maxcube) I have an issue where when homebridge crashes during boot it doesn't report any dynamic devices anymore but it still accepts adding new ones, causing my plugin to add devices a second time - which in turn causes issues on the next boot.

alladinian commented 4 years ago

@normen It's not just from favorites, it vanishes from the assigned room as well.

normen commented 4 years ago

Okay thanks, I'll leave this open then.

sephrioth commented 4 years ago

I found the cause, my two outdated iOS devices which turned on Homekit in iCloud settings. After I turn off, everything back to good. @normen

LeJeko commented 4 years ago

After recreated my accessory few days ago, it suddenly goes to orphan this morning.... IMG_1387 Here is the log:

[19/05/2020, 07:43:34] [BraviaPlatform] Error loading sources for extInput:cec
[19/05/2020, 07:43:34] [BraviaPlatform] Error: connect ETIMEDOUT 10.0.1.7:80
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16) {
errno: -110,
code: 'ETIMEDOUT', syscall: 'connect', address: '10.0.1.7', port: 80 } [19/05/2020, 07:43:52] [BraviaPlatform] Error loading applications: [19/05/2020, 07:43:52] [BraviaPlatform] Error: connect EHOSTUNREACH 10.0.1.7:80 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16) { errno: -113, code: 'EHOSTUNREACH', syscall: 'connect', address: '10.0.1.7', port: 80 } [19/05/2020, 07:43:52] [BraviaPlatform] Removing nonexisting channel netBox [19/05/2020, 07:43:52] [BraviaPlatform] Removing nonexisting channel YouTube [19/05/2020, 07:43:52] [BraviaPlatform] Updating HomeBridge Accessory for Sony OLED [19/05/2020, 07:45:37] [BraviaPlatform] Added input netBox [19/05/2020, 07:45:37] [BraviaPlatform] Added input YouTube [19/05/2020, 07:45:37] [BraviaPlatform] Updating HomeBridge Accessory for Sony OLED

normen commented 4 years ago

After recreated my accessory few days ago, it suddenly goes to orphan this morning.... IMG_1387 Here is the log:

[19/05/2020, 07:43:34] [BraviaPlatform] Error loading sources for extInput:cec [19/05/2020, 07:43:34] [BraviaPlatform] Error: connect ETIMEDOUT 10.0.1.7:80 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16) { errno: -110, code: 'ETIMEDOUT', syscall: 'connect', address: '10.0.1.7', port: 80 } [19/05/2020, 07:43:52] [BraviaPlatform] Error loading applications: [19/05/2020, 07:43:52] [BraviaPlatform] Error: connect EHOSTUNREACH 10.0.1.7:80 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16) { errno: -113, code: 'EHOSTUNREACH', syscall: 'connect', address: '10.0.1.7', port: 80 } [19/05/2020, 07:43:52] [BraviaPlatform] Removing nonexisting channel netBox [19/05/2020, 07:43:52] [BraviaPlatform] Removing nonexisting channel YouTube [19/05/2020, 07:43:52] [BraviaPlatform] Updating HomeBridge Accessory for Sony OLED [19/05/2020, 07:45:37] [BraviaPlatform] Added input netBox [19/05/2020, 07:45:37] [BraviaPlatform] Added input YouTube [19/05/2020, 07:45:37] [BraviaPlatform] Updating HomeBridge Accessory for Sony OLED

That very much looks like a network issue, EHOSTUNREACH happens before the plugin does anything. The display issue is #74

LeJeko commented 4 years ago

It may be a network reliability, but the error comes from [BraviaPlatform] ... why not manage this case?

normen commented 4 years ago

It may be a network reliability, but the error comes from [BraviaPlatform] ... why not manage this case?

What would I do? Hide the network error? I think the normal thing to do for an application is to report network errors, even if users might think the application caused that error. Though users generally freak out when they read "error" or "warning" even if theres no issues and they don't notice issues if theres no warnings so you might have a point. Please read #74 about the thing that actually annoys you.

LeJeko commented 4 years ago

Do not feel offended! I agree with you when there is no impact but in this case, I thought I could help by sharing a log that indicates the error that has (for me) caused a result that is similar to the issue # 74. I am also developing plug-ins and I haven't had this problem yet that's why I think there must be a solution.

normen commented 4 years ago

Do not feel offended! I agree with you when there is no impact but in this case, I thought I could help by sharing a log that indicates the error that has (for me) caused a result that is similar to the issue # 74. I am also developing plug-ins and I haven't had this problem yet that's why I think there must be a solution.

No idea why you think I'd be offended. If you actually have a dynamic platform plugin that updates the accessories at runtime using updatePlatformAccessories and doesn't cause the display issue then yes, I'd be very interested in that.

Otherwise your issue is nothing special. The querying of some channels failed one time - they got removed, next time it worked again - they got added again. HomeKit is HomeKit and messes up the display of the TV by separating the old channels. Nothing to find or understand there.

LeJeko commented 4 years ago

OK I understand. Indeed, I do not use updatePlatformAccessories. Only register and remove, which means restarting to update. I will set the channelupdaterate option to false which should solve my problem. Thank you.