Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TV] Polling Erroneously Triggers Automation #528

Open
JasonGoldenDDT opened this issue Apr 19, 2024 · 16 comments
Open

[TV] Polling Erroneously Triggers Automation #528

JasonGoldenDDT opened this issue Apr 19, 2024 · 16 comments

Comments

@JasonGoldenDDT
Copy link

Hello,

I have an LG TV and it use the TV's power status to control automation. I'm finding polling activity will trigger automation.

Use case:

When "TV Turns On" turn off Fan.

When LG server is polled and returns "on" value the automation is triggered again.

Is it possible to only inform HomeKit of actual changes instead of repeating known values? If polling returns the same value the push message sent when the device was turned on, nothing should happen.

Push (User powers on TV) - Tells HomeKit device is ON.
Polling - "Devices is on" - this equals the last Push message, do nothing.
Push (User powers off TV) - Tells HomeKit device is OFF.
Polling - "Devices is off" - This equals the last Push message, do nothing.

Could logic like this be applied to this plug in to avoid duplicate message being sent to HomeKit?

@merdok
Copy link
Owner

merdok commented Apr 19, 2024

Hi, i am not quite sure if i understand your issue correctly, but did you should be able to do what you describe in HomeKit already. You trigger some actions or automations based on the TV status. Is there an issue with that?

@JasonGoldenDDT
Copy link
Author

It a problem I have with other plugins on home bridge.

I'm not sure what the technical cause for this problem is. It expressed as repeated triggering of a "device controlled" automation in HomeKit.

If you turn on the tv, HomeKit reflects this instantly.

When the plug in polls the api, it seems like it tells HomeKit again the device is on, trigging the device is on automation again.

@merdok
Copy link
Owner

merdok commented Apr 19, 2024

What LG TV do you have?

@JasonGoldenDDT
Copy link
Author

Model number 32LQ63BPUA, webOSTV 7.0(2.4.4), TV Firmware 4.40.91.

The TV powers on and off perfectly with HomeKit. It's the repeated automation triggers that makes it difficult to tie automation to its use.

@merdok
Copy link
Owner

merdok commented Apr 20, 2024

As far as i can see your TV does not use polling to get the status but rather listens to the TV events as it is a newer one. The TV only sends the events when something happens and as far as i know it only sends the turn on event once. What you could is to enable deepDebugLog start homebridge in debug mode and check the log when the situations which you find is not correct happens, you can then post the log here so i can have a look.

@JasonGoldenDDT
Copy link
Author

I see this in the log.

Idk if this causes an update to HomeKit or not.

image

@merdok
Copy link
Owner

merdok commented Apr 20, 2024

That just states that the plugin is trying to connect to the tv, there might be something that causes it to disconnect, hence you need to enable the deepDebugLog so we can see the full log of what is happening.
https://github.com/merdok/homebridge-webos-tv?tab=readme-ov-file#troubleshooting

@JasonGoldenDDT
Copy link
Author

okay, I added,

{ "name": "Display", "ip": "10.0.145.9", "mac": "4c:ba:d7:e5:02:ea", "broadcastAdr": "10.0.145.233", "hideTvService": false, "volumeLimit": 100, "volumeControl": "none", "channelControl": false, **"deepDebugLog": true** }

And after rebooting homebridge, I see this in the log:

[4/20/2024, 8:42:45 AM] [homebridge-webos-tv] [Display] Error - Error: connect ETIMEDOUT 10.0.145.9:3000 at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1605:16) { errno: -110, code: 'ETIMEDOUT', syscall: 'connect', address: '10.0.145.9', port: 3000 } [4/20/2024, 8:42:50 AM] [homebridge-webos-tv] [Display] Connecting to TV [4/20/2024, 8:43:27 AM] [homebridge-webos-tv] [Display] Connecting to TV [4/20/2024, 8:44:04 AM] [homebridge-webos-tv] [Display] Connecting to TV [4/20/2024, 8:44:41 AM] [homebridge-webos-tv] [Display] Connecting to TV [4/20/2024, 8:45:18 AM] [homebridge-webos-tv] [Display] Connecting to TV [4/20/2024, 8:45:55 AM] [homebridge-webos-tv] [Display] Connecting to TV [4/20/2024, 8:46:31 AM] [homebridge-webos-tv] [Display] Connecting to TV

It's unclear how homebridge updates HomeKit. Automation I have tied to the TV's state repeat.

@merdok
Copy link
Owner

merdok commented Apr 20, 2024

But did you start homebridge in debug mode? This log only indicates that the plugin is trying to connect to your TV, based on that the plugin should not even work.

@JasonGoldenDDT
Copy link
Author

JasonGoldenDDT commented Apr 20, 2024

Yep, I've had it turned on to troubleshoot multiple plugins that can't keep homekit in sync. I added the "deep debug" to this webos plug in and started homebridge. What you see is the result. Without interacting with the TV (which I don't usually do during the day), I just get repeated "Connecting messages."

Running 2.4.4 of the plugin.

Screenshot 2024-04-20 at 10 22 35 AM

@merdok
Copy link
Owner

merdok commented Apr 21, 2024

Yeah, well that is certainly not the complete log so i guess that you are missing something. I would need the complete log, as without that it is impossible for me to tell why your TV constantly re-connects.

@JasonGoldenDDT
Copy link
Author

My use case for this is to trigger scenes based on device status. To turn off lights when the TV turns on for example.

There is a large delay between when the TV status changes and when and if a scene fires. Unsure how to track this down, but it's a rare use case for me so I'm not tracking it closely.

@merdok
Copy link
Owner

merdok commented Jul 25, 2024

I understand your use case, but that does not help much here to identify your issues. I would still need a proper debug log.

@JasonGoldenDDT
Copy link
Author

I'll pull deeplogs over the weekend. I suspect I'm dealing with wifi stability issues that are difficult to pin down. I live in a congested radio environment in a downtown area. I'm finding that fluctuations in radio signals can cause Homekit and related devices to disconnect and reconned despite having created separate SSIDs and having multiple APs tuned to reduce this.

It seems like every time the wifi device reconnects its status is repeated through the system causing triggers to fire again.

Seems like a programing solution could be implemented that checks to see what the last message received said and if the new message is the same, don't do anything.

@merdok
Copy link
Owner

merdok commented Aug 15, 2024

Every time the TV reconnects then the full state of the TV needs to be pulled, as there is no way to know for what reason the TV has gone offline. I guess the core issue here seems to be the highly unstable wifi connection, you would need to try to investigate that and possibly try out a wired connection and check if that fixes the issue.

@JasonGoldenDDT
Copy link
Author

I'm still trying out different options like extending the "refresh" to 60000 ms.

I rent, my options for creating a wired network are limited. Wifi is it sadly. I've tuned my network with multiple SSIDs, two MESH configured Amplifi Alien APs and using inSSIDER regularly to pick the "best" channel. since the router can't figure it out.

I acknowledge this isn't a life threatening problem. It's a luxury to have the ability to automate your home with technology. Having said that, it does improves quality of life, reduces energy consumption, and when it works well can have an economic benefit.

It would be awesome if the community as a whole could create solutions that are more resilient to common situations like mine. Assuming everyone has the ability to create a wired network eliminates a large population of people who could benefit from technology and ruins their experience with its advances. And waiting for the next version and the expense of replacing your hardware to take advantage of often incomplete promises of improved tech is hostile to consumers. Something I wish we would change as it waste a lot of time and money.

It would be great if code was written to be resilient, like always asking a device "did you get that command?" or providing better tools for tuning a product you your environment.

Thank you for your response and work on making this plugin in better. I'll do what I can to assist in it's evolution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants