Sony Devices Binding

Just to let everyone know - I added some instruction on how to separate the sony logging into it’s own file (rather than mixed in with everything else) to the first post. Helpful if you ever need to send me a log file to analyze…

hi! i’ll give you feedback tomorrow.
it was 30 secs. maybe i i was too impatient :wink:

Hi robert,
one question about the polling via the SONY REST API. Do you have a specific polling interval in the binding?

Maybe some background to the question:
I currently have some IRCC and REST curls in my own rules, but I hate polling e.g. for the power status. Because then the TV would never go to deep sleep as the polling wakes him up again. I yet could not figure out if there is a chance that the TV makes some webhooks and tells me for example when he goes to slepp, changes channels etc.
Do you have something like this figured out?

It worked! It was set to 30s (both parameters) i set it to 3s and it works fine. Can you explain the difference of the 2 parameters?

I really wouldn’t set it much lower than 5 seconds - it’s a bit of a tradeoff between response time and how much work your openHAB is doing. Polling is rather heavy (I only poll for the items you have linked but even then it’s probably 5-10 http calls on average) and the more items you have linked, the more http calls their will be and the more cpu time will be taken.

Up to you of course..

In the configuration of the thing - you can set the polling interval or disable it completely (by specifying -1). I’m not sure what you mean by “deep sleep” because each model line defines ‘sleep’, ‘off’, ‘on’ differently and their are usually options in settings that affect it (ie turning the network port off, etc). My best advice would be to try it out and see what happens..

ahh ok cool, thanks for the quick answer - but you also have to use polling unfortunately :frowning: I think there is no way around this then

yeah my Sony TV (55xf90) has 2 different states (active and standby). The thing is, that in the “standby” mode there are two different modes in reality, which can be differentiated by their power drain. The one standby mode is basically the TV almost running without the screen on, consuming about 24w. The other deep sleep mode only consumes about 0,5w. Thus there is a big difference.

The problem is, that the TV only goes in the deep sleep if there is no activity, even on network level. Therefore polling every X second just to get information even though the TV is off and not used would keep him away from going into deep sleep → always 24w consumption.

So if there was a webhook, indicating that the TV is being shut off/turned on, there could be a rule stopping the polling and thus letting the TV go into deep sleep. Only when you know via the webhook that the TV is already on, you can poll again in the given interval. That’s the reason for my previous question

for reference:
getting the status I curl: getPowerStatus (v1.0) | BRAVIA Professional Displays Knowledge Center

Ah - much better description of the problem. The problem is that the scalar implementation on TVs is strictly a REST API (polling) - unlike AVRs/Soundbars/Blurarys where we have an interactive session (websockets). This pretty much forces a polling aspect.

As an alternative - if you TV supports it, use SimpleIP - that is a custom socket connection to the TV and provides instance feedback on power/volume/channels (only).

The other option would be to simply listen to the power channel (which uses getPowerStatus under the covers) and when it flips off - kill the polling.

1 Like

New release at Release 2.5-0806-01: [avmfritz] Added unit tests for templates (#5602) · tmrobert8/openhab-addons · GitHub

Biggest change is I optimized the build process a bit to bring the size back down and a few smaller bug fixes.

Note: unless someone posts anymore issues, the next step is to make a sony registry (kinda like the zwave db) that will help me find out what models are in use and what those models support (alerts me to API changes sony has made) and eventually a thing repository where I can customize the scalar API to the model.

However - this is more of an addon to the binding - so if you have issues, still post them because it seems fairly stable at the moment.

The step after that is to make the code mergable

Tim

3 Likes

Looking at it tomorrow :slight_smile: Thanks a lot!
i changed the parameters to 5s.

Thanks a lot for this explanation.
So is simpleip less demanding for the system than scalar is?
I assumed so and used the simple ip power item (with 5s delay)
for netflix etc. i use dial now.
A few questions came up during adaptation of my existing setup (with the old sony binding):

  1. I found a source item in the simple ip thing. On my previous installation the HDMI ports had a dedicated item so it was easier to trigger them. I guess i have to go with a rule now or do i miss it?
  2. I am missing the items for the tv channels. they had been discovered in the past so i changed them with a switch. sure the setup was long to create 40 switch items it worked.
    I was trying to map the channels in simple ip (numbers) to channel names but it does not seem to be elegant. maybe i am just doing something wrong. At the end of the day i want to be able to switch the channel with a drop down in the sitemap or directly with voice control (alexa).
  3. power consumption: i don’t need scalar since you split up most of the stuff i use in the dial thing. @NoneWhereTo do you think the TV will go into deep sleep when using dial instead of scalar? Unfortunately i don’t own a power metering socket. I guess i’ll get one :wink:

On question 3: I don’t get what you are trying to say with “dial thing” (please keep in mind, that I havn’t used this binding yet, I currently do everything ruile based with curl commands via the REST API and IRCC

Maybe some words to the deep sleep: If you search the internet, you see that there are many people complaining about their Sony TVs not going into deep sleep. No one really knows exactly why, may it be that the TV internal programm scheduler updates itself very often, so that the TV has to wake up a lot of times and therefore almost never goes to sleep.
Unfortunately there is no directly sendable command “please go to deep sleep”, though there is a powerset curl, but IMO it doesn’t do that much.
As I said before, the TV is very pickable when he wants to go into deep sleep. Foremost its because of network traffic. Therefore I want to reduce the network traffic and if you think now, that if I poll every X seconds, the TV will never go into deep sleep.
What I would like to have is that the TV sends to a given IP address a command (websocket) when something happens on his side. But unfortunately, Sony hasn’t implemented that, thus only leaving the polling about the different status.

An alternative is of course to use a smart plug, but I don’t know how my TV likes the instant power loss. Therefoer I would have preferred the deep sleep of 0,5W.

Out of my perspective, the methods @tmrobert8 is using in the binding are the only ones available and there isn’t more you can do about it atm. Though I will rewrite my rules based on time schedule, telling my TV the right setpower eg during night time, hoping it gets into deep sleep and then waking it up from deep sleep via WOL, if there is no response from the API (as Sony states and I think robert mentioned earlier)

Only less demanding in that it doesn’t need frequent polling - otherwise it’s about the same. If all you are doing is simple things (power/audio/inputs/etc) - then simple ip will work for you. Once you start wanting to do other things (like starting apps) - scalar is really the way to go since it combines pretty much everything. But - that’s why I give you all the options - so you can mix/max as you need.

Yep - simple ip depends on you knowing the capabilities of the tv - there is no way to discover anything. So you can send “hdmi53” to it without an issue (if you had 53 hdmi connections!) - the simple ip binding won’t know if it’s valid or not - all up to you to send valid stuff.

Again, can’t do that with simple ip. Scalar still allows you to discover it - but not simple ip.

As @NoneWhereTo has mentioned - it’s a tricky subject (and one that I have never gone down because I force mine not to sleep at all since I want everything ready at all times). All this revolves around the “remote start” and the “power consumption” (eco mode etc) options on the TV and the model (more advanced models have more options that control this [my 900 has more options than my 850s]). I’d also bet CEC options come into play on this as well since the hdmi ports need to be powered for those options.

The problem, as I understand it, is that if you go into what is described as “deep sleep” - the network port will likely power down - rendering the bindings useless. I’d be surprised if it even responds to a WOL packet (which is what the “remote start” option controls - whether to accept WOL packets).

@NoneWhereTo just for you information - I do send a WOL packet when you flip the power state switch in openHAB prior to calling setPowerStatus that may help you. Likewise, I expose all the power settings that scalar provides me. On my 900 - I have a bunch of different switches that may be helpful. You have all the CEC ones [mhl power feed and the various power sync modes], you have the power savings mode on system [in addition to power status], you have device modes [no idea what that is] and the WOL mode. I don’t know your model and what it supports - but the binding exposes everything to you and you can play with it to your hearts content..

EDIT: @NoneWhereTo - since you seem more technical. You may want to check out the webpage I put together that allows you to explore the scalar (rest) API on your device. After you’ve installed the binding and added the scalar thing for you tv, go to “{openhaburl:port}\sony”. The first page will allow you to read a file created by the binding (under userdata/sony/definitions/capabilities [guessed on that - it may be slightly different]) that will list all the REST apis supported by your TV and then to interactively call them and see their response.

Thank you.
I do start apps with DIAL now although they show up in scalar. So i run simple IP and Dial.
On previous installations my channels have been discovered (TV channels) in scalar.
Now i cant see them. I can use the simpleip as a workaround though :slight_smile:

They are still available in scalar - just it’s harder to find: Sony Devices Binding - #675 by tmrobert8

EDIT: I have been contemplating whether to manually create the various TV channels switches again. The upside is it’s easier for non-techie people to use it. The cost is that it’s much harder to maintain (and I have the whole issue with some TVs returning every possibility rather than what they have discovered [which was one of the reasons I did away with them and went with how sony approached it])

I will check it out, thank you!!

The first bit is right. When the TV enters deep sleep, the REST will stop working. However you can wake the TV up again with the WOL magic paket until the REST works again. But you first have to enable WOL on the TV setting of course

Thanks @tmrobert8 and I will definetely try out your binding as soon as I have the time again to do some stuff in my OH instance. Atm I’m just reading the forum within my travels on my smartphone…

new backport on 2.4 is available
https://github.com/markus7017/org.openhab.binding.sony.24/blob/master/target/org.openhab.binding.sony-2.4.0-SNAPSHOT.jar

This version should fix the nasty exceptions on startup and includes @tmrobert8 update as of 08/07/2019.

Please let me know if it works.

1 Like

Im having an issue. My openhab lost connection with my sony tv. ive installed the latest 2.5 binding (i am on 2.5 snapshot), But the tv is not being auto discovered. I can only use Simple IP. Any tips?

This is what i get when installing the 2.5 snapshot jar file in my addons folder.
But i dont get anything show in the inbox.

2019-08-10 11:00:01.320 [DEBUG] [org.openhab.binding.sony            ] - BundleEvent INSTALLED - org.openhab.binding.sony

2019-08-10 11:00:02.554 [DEBUG] [org.openhab.binding.sony            ] - BundleEvent RESOLVED - org.openhab.binding.sony

2019-08-10 11:00:03.380 [DEBUG] [org.openhab.binding.sony            ] - BundleEvent STARTING - org.openhab.binding.sony

2019-08-10 11:00:03.559 [DEBUG] [org.openhab.binding.sony            ] - ServiceEvent REGISTERED - {org.eclipse.smarthome.core.thing.type.DynamicStateDescriptionProvider, org.openhab.binding.sony.internal.providers.SonyDynamicStateProvider, org.openhab.binding.sony.internal.providers.SonyDefinitionProvider, org.eclipse.smarthome.core.thing.binding.ThingTypeProvider, org.eclipse.smarthome.core.thing.type.ChannelGroupTypeProvider}={service.id=914, service.bundleid=317, service.scope=bundle, component.name=org.openhab.binding.sony.internal.providers.SonyDefinitionProviderImpl, component.id=693} - org.openhab.binding.sony

2019-08-10 11:00:03.601 [DEBUG] [.internal.providers.SonyFolderSource] - Reading all files in /var/lib/openhab2/sony/db/types

2019-08-10 11:00:03.606 [DEBUG] [.internal.providers.SonyFolderSource] - Starting watch for new/modified entries /var/lib/openhab2/sony/db/types

2019-08-10 11:00:03.631 [DEBUG] [org.openhab.binding.sony            ] - ServiceEvent REGISTERED - {org.eclipse.smarthome.config.discovery.upnp.UpnpDiscoveryParticipant}={service.id=915, service.bundleid=317, service.scope=bundle, component.name=org.openhab.binding.sony.internal.dial.DialDiscoveryParticipant, component.id=691} - org.openhab.binding.sony

2019-08-10 11:00:03.653 [DEBUG] [org.openhab.binding.sony            ] - ServiceEvent REGISTERED - {org.eclipse.smarthome.config.discovery.upnp.UpnpDiscoveryParticipant}={service.id=916, service.bundleid=317, service.scope=bundle, component.name=org.openhab.binding.sony.internal.ircc.IrccDiscoveryParticipant, component.id=692} - org.openhab.binding.sony

2019-08-10 11:00:03.673 [DEBUG] [org.openhab.binding.sony            ] - ServiceEvent REGISTERED - {org.eclipse.smarthome.core.thing.binding.ThingHandlerFactory}={service.id=917, service.bundleid=317, service.scope=bundle, component.name=org.openhab.binding.sony.internal.SonyHandlerFactory, component.id=690} - org.openhab.binding.sony

2019-08-10 11:00:03.700 [DEBUG] [org.openhab.binding.sony            ] - ServiceEvent REGISTERED - {org.eclipse.smarthome.config.discovery.upnp.UpnpDiscoveryParticipant}={service.id=918, service.bundleid=317, service.scope=bundle, component.name=org.openhab.binding.sony.internal.scalarweb.ScalarWebDiscoveryParticipant, component.id=694} - org.openhab.binding.sony

2019-08-10 11:00:04.191 [DEBUG] [org.openhab.binding.sony            ] - ServiceEvent REGISTERED - {javax.servlet.ServletContext}={osgi.web.version=2.5.0.201907311839, osgi.web.contextpath=/, service.id=919, osgi.web.symbolicname=org.openhab.binding.sony, service.bundleid=317, service.scope=singleton, osgi.web.contextname=default} - org.openhab.binding.sony

2019-08-10 11:00:04.202 [DEBUG] [ternal.scalarweb.service.SonyServlet] - Started Sony Web service at /sony

2019-08-10 11:00:04.218 [DEBUG] [org.openhab.binding.sony            ] - ServiceEvent REGISTERED - {org.eclipse.smarthome.config.discovery.upnp.UpnpDiscoveryParticipant}={service.id=920, service.bundleid=317, service.scope=bundle, component.name=org.openhab.binding.sony.internal.simpleip.SimpleIpDiscoveryParticipant, component.id=696} - org.openhab.binding.sony

2019-08-10 11:00:04.227 [DEBUG] [org.openhab.binding.sony            ] - BundleEvent STARTED - org.openhab.binding.sony
```.