Vizio TV Binding

logo

The Vizio binding is now available in the official release of openHAB 3.4.0. It is no longer necessary to install via the Marketplace. The link below to the jar file will remain available for users wishing to manually install the binding in OH 3.3.0 only (previous versions will not work due to missing features in core).

Resources

https://github.com/mlobstein/openhab-addons/releases/download/1.0.0/org.openhab.binding.vizio-3.4.0-SNAPSHOT.jar

1 Like

Thanks for your efforts.
I recently bought a Vizio for use as both a PC monitor and TV. I ran into an error with the start_pairing maybe because I was using a monitor?. When I switched to Smartcast I do not see any code. I searched settings and found a 4 digit code under Admin & Privacyā€¦Support Code. Is that how it is supposed to work? I entered the code and OH shows as online, channels appear, but do not work yet, but I did not submit the code in the console yet. I wanted to make sure this was just not some random code.

The PIN code will actually display on the top of the screen when the pairing process is triggered. Here is what it looks like on mine. You probably want to just be on an HDMI input or TV channel (not in a streaming app) when doing this.

This is what the console interaction will look like:

You mention that your Vizio is a monitor? Or you are using a TV as a monitor? Can you try to use the Vizio Mobile app on android? It uses the same pairing process that the binding it attempting to emulate.

Thanks for the information I was using the HDMI and did not get that display. Let me try again. Iā€™ll also copy the error message if I get oneā€¦ Iā€™m on IOS, but there should be a vizio app for that will check that out too.

Edit: ok worked ! Thanks. Do not know what the earlier problem was.

Thanks for the feedback and I am glad to hear that it worked. There were a few minor issues with the pairing process that I have fixed in the latest build.

When I turn the TV off, the ā€œThingā€ shows Offline communication error. Thatā€™s okay as it is true. What is odd, is that I get a log full of errors when the TV is turned back on. Everything works, so there is no lasting issue. Odder still, of the three times, no errors once. That time it was only off for a couple of hours. The other times it was overnight. Maybe a timing issue?
Visio-errors.txt (24.9 KB)

It looks like the code that gets the self-signed certificate from the TV is getting sent a mangled host name/IP address somehow. I will try to address that. Can you try and see if the issues go away if the ā€˜Eco Modeā€™ setting on the TV is turned off?

Turned eco off, will let you know.
Bob
Edit: None of the above error messages in the last two days with eco off. it does use 8 watts in this quick start mode

I donā€™t know how it happened for you, but in the error messages the binding was trying to use an ipv6 address to communicate with the TV. I have updated the code to correctly create the URL if an ipv6 address is encountered.

I turned on Eco Mode on my TV and did not observe this behavior. My TV dropped off of the wi-fi network almost immediately when switched off in Eco Mode.

I canā€™t explain the ipv6. Loaded new jar and will go back to eco mode. Will let you know. Since it seemed to happen only overnight, will need a day or so. Again thanks

Bob

Still seems to be an issue with eco mode after an overnight shutdown
Visio-errors.txt (34.8 KB)
Binding


Sorry to be a bother

Just to understand, do you shutdown your openHAB instance at night? The behavior seen is when the binding attempts to retrieve the self-signed certificate from the TV at startup. It fails to connect if the TV is off in Eco mode.
Currently the TlsTrustManagerProvider code cannot handle this properly. @cweitkamp Do you have any suggestions to make the getTrustManager() method able to handle a temporarily un-reachable host?

No nightly S/D of OH. I try to help out in the forum with testing, so only shutdown is to get next milestone. Iā€™m on 3.4M1 at this point. My whole testing of the Vizio has been with no interruption of OH

I did notice the first error message was from the core. I was wondering if there is a way in the UI to extend the certificate expiration? These errors only has happen overnight, so donā€™t know if the cert is cleared at midnight if the device is down or after some number of hours. Also since it does work (even after the error messages, maybe some delay to get the certs in order?

Another thought, my wife actually unplugs the Sony overnight, but the sony binding seems to come back ok. I donā€™t know the details, but it does some sort of wake on lan (WOL). That log over a few days (we plug the TV in about 8pm;

2022-08-29 19:55:18.041 [INFO ] [g.sony.internal.AbstractThingHandler] - Starting state polling every 60 seconds
2022-08-30 20:10:23.210 [INFO ] [g.sony.internal.AbstractThingHandler] - Starting state polling every 60 seconds
2022-08-31 19:52:16.701 [INFO ] [g.sony.internal.AbstractThingHandler] - Starting state polling every 60 seconds
2022-09-01 19:17:10.566 [INFO ] [g.sony.internal.AbstractThingHandler] - Starting state polling every 60 seconds
2022-09-02 19:41:23.883 [INFO ] [g.sony.internal.AbstractThingHandler] - Starting state polling every 60 seconds

Hi @mlobstein,

after reviewing my code for the PEMTrunstManager I think it might be the better way to rethrow occuring IOExceptions instead of swallowing them and just log a warning.

After that change the calling instances are able to implement a proper error handling. One more question isnā€™t there a CertificateInstantiationException if the server is unreachable after an IOException? How do you handle that in your code?

I have updated the build to suppress the error message that is generated when the attempt to retrieve the TVā€™s certificate fails. I will revisit once @cweitkamp adjusts the PEMTrustManager code. If an IOException is thrown, I could catch this and re-try until successful.

Wonā€™t I still get the first error from the core? Anyway will give it a go (I had just removed the binding until this was sorted)

edit: If Iā€™m on the right page, it looks like the last change was 5 days ago?

Yeah you are right the ā€œAn unexpected exception occurredā€ message from getPEMCertificateFromServer() in core will still occur. Any exceptions from VizioTlsTrustManagerProvider (malformed url, etc.) will now go to the debug log instead of the error log.

@cweitkamp I will need to change my code to handle the certificate retrieval failure. I think a simple flag being set after the successful retrieval will be enough. If the flag is not set, any commands send to the TV will trigger another retrieval attempt.

The method getInstanceFromServer(URL) either returns a valid PEMTrustManager or throws an exception if the instantiation fails. I will change the code to throw a CertificateInstantiationException which cause is set to the IOException thrown. The log message will be suppressed in such case. This way there is no breaking change in core implementation, just an improvement of the code.

1 Like

PR

I have (3) Vizio TVā€™s conected to OpenHab. Sometime after migrating to V4, the bedroom TV started turning on when I would send it a Power Off command. It mysteriously stopped after a few months, but another Vizio started doing the same. Has anyone else experienced this behavior?

2024-01-13 01:30:00.788 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'VizioGarageTV_Power' received command OFF
2024-01-13 01:30:00.813 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'VizioGarageTV_Power' predicted to become ON

Additionally, all of these TVā€™s bounce online/offline numerous times per day. I havenā€™t been able to identify any issues on my network that would disrupt the communications. Is it possible to handle this error and retry once or twice before taking the thing offline? Two out of three of my Vizioā€™s are wired ethernet. Wi-fi vs wired doesnā€™t seem to affect this exception.

2024-01-15 15:46:01.669 [DEBUG] [.vizio.internal.handler.VizioHandler] - Unable to retrieve Vizio TV power mode info. Exception: Error executing vizio GET command, URL: https://10.0.5.45:7345/state/device/power_mode java.io.EOFException: HttpConnectionOverHTTP@5157dcc6::DecryptedEndPoint@5d36bced{l=/10.0.5.30:50820,r=/10.0.5.45:7345,OPEN,fill=-,flush=-,to=5198/0}
org.openhab.binding.vizio.internal.VizioException: Error executing vizio GET command, URL: https://10.0.5.45:7345/state/device/power_mode java.io.EOFException: HttpConnectionOverHTTP@5157dcc6::DecryptedEndPoint@5d36bced{l=/10.0.5.30:50820,r=/10.0.5.45:7345,OPEN,fill=-,flush=-,to=5198/0}
	at org.openhab.binding.vizio.internal.communication.VizioCommunicator.getCommand(VizioCommunicator.java:244) ~[?:?]
	at org.openhab.binding.vizio.internal.communication.VizioCommunicator.getPowerMode(VizioCommunicator.java:97) ~[?:?]
	at org.openhab.binding.vizio.internal.handler.VizioHandler.refreshVizioState(VizioHandler.java:205) ~[?:?]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) [?:?]
	at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305) [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305) [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) [?:?]
	at java.lang.Thread.run(Thread.java:840) [?:?]
2024-01-15 15:46:01.672 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'vizio:vizio_tv:2c641f55b82a' changed from ONLINE to OFFLINE (COMMUNICATION_ERROR): Unable to retrieve power mode info from TV
2024-01-15 15:46:11.759 [TRACE] [rnal.communication.VizioCommunicator] - GET url: https://10.0.5.45:7345/state/device/power_mode, response: {"STATUS":{"RESULT":"SUCCESS","DETAIL":"Success"},"URI":"/state/device/power_mode","ITEMS":[{"NAME":"Power Mode","CNAME":"power_mode","TYPE":"T_VALUE_V1","VALUE":0}]}
2024-01-15 15:46:11.760 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'vizio:vizio_tv:2c641f55b82a' changed from OFFLINE (COMMUNICATION_ERROR): Unable to retrieve power mode info from TV to ONLINE