Sdata and the omission of important variables

So a little background, I use a third-party remote control app called Home Remote. The developer just released a major upgrade to the platform that broke most of my lighting control through the app Linear WD500Z-1 wall switches.

In troubleshooting with the developer, he determined that because he is now using sdata the status of my switches is not available. The method previously used by the developer returned the status of the switches. Sdata is apparently shortcode that omits certain variables in this case the on/off status of my switches. He had said that Vera encourages third party developers to use sdata since it is much more efficient and cuts down on polling.

How is it that sdata would omit probably the most important piece of data such as on/off status?

The developer was able to work around it by keying off levels to get my dimmable switches working but I am out of luck as far as my non-dimable switches go. I suppose I could trigger a virtual switch to track the on/off status. of the non-dimable switches as a workaround.

If anyone knows of setting or method of having sdata pull status of a device, please let me know.

thanks

Vera extended the UPnP service definition to include a <shortCode> tag in the <stateVariable> sections of the service files. This defines the shortcode for the state variable. If not defined, the state variable is not published to an sdata/lu_sdata response.

The UPnP SwitchPower1 (abbrev.) service defined by Vera includes the shortcode status for the SwitchPower1/Status variable, and this is what your switches and Home Remote should be using. Some try to look at Target, but this is functionally wrong (you want the actual state, not the anticipated/commanded state), and there’s no shortcode for it either, so check that.

The problem with all of this, and it’s a huge problem for HomeAssistant and its underlying interface subsystem, pyvera, is that state variable names alone are not unique. State variables are uniquely identified not just by name, but the combination of the service ID and name. It is possible for a device to support several services, and if, for example, those services all define a Status variable with shortcode status for some purpose, then the shortcode names collide when generating the response output and which value you ultimately get is non-deterministic–you get only one “status” shortcode output of the many defined, and you have no access to the rest. Because of this, devices like thermostats with multiple setpoints are difficult to get to work right (as evidenced by the kludging necessary with pyvera and the Hass component). sdata also, as you know, limits the set of accessible state variables to the subset of what the service’s maintainer chose to publish that way, and sometimes you need access to something else.

So sdata is a terrible idea, and was from the start, IMO, and it should not be used. Use the more complete status request instead, which returns service IDs with the state variable names. Vera themselves does not appear to use sdata in their own UI. Go figure. Both the status/lu_status and user_data requests will give you all state variables for devices, the former being somewhat quicker at it. Both will also allow you to pass in a stamp from a previous response so it will give you back only deltas–changed variables since the last response–which greatly improves efficiency on the receiving end. Both also support “long polling” (it won’t return a response until there are deltas or a timeout occurs).

A fast JSON parser helps, too, so for the benefit of anyone who might try to parse user_data or status responses with dkjson, I recommend using opkg to update your dkjson and install LPeg, which improves parsing time by an order of magnitude.

Of course, who knows what the next-gen firmware will bring in this respect…

1 Like

Patrick, thanks for the very detailed explanation, I will pass this along to the developer.

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.