from my browser, I get the following back (just the first few lines):
[code]
[/code]
I am trying to get my hands on the “state” and “comment” attribute values in lua to I can act on certain values, such as an error - my code at the moment (that is not working) is:
local theState = ( luup.attr_get ('state', 0) or 999)
local theComment = ( luup.attr_get ('comment', 0) or "OK" )
if theState == 2 then
luup.call_action("urn:micasaverde-com:serviceId:HomeAutomationGateway1", "Reload", {}, 0)
end
Research has led me to believe that the root could be accessible through using device level ‘0’ when performing a luup.attr_get
This is not working however, as it always returns “999” and “OK” - so I must be accessing the wrong attributes and/or in the wrong way.
Does anyone have any suggestions of how I should be tweaking this code to make it work?
SDATA is just a subset of the user_data information … no way to customize it … it was created because user_data was too big … but it is to restrictive to be of user for any general purpose client. So almost everyone uses the user_data request.
Note: Your post is pretty vague … it sounds like you want to get LUA variables … there is no way to do that without writing/installing a request handler.
[quote=“cybrmage, post:2, topic:195142”]the luup.attr_get and luup.attr_set commands act on the user_data content NOT the sdata content. The sdata content is generated from the user_data.
The “state” and “comment” attributes do not exist, and are not contained in the user_data… hence your code returns “999” and “OK”.
The only way to access the sdata content from lua is to issue an http.request() for json data, capture the data, and parse the response.[/quote]
Thanks cybrmage.
You say that the sdata content is generated from the user_data which means that the “state” and “comment” attributes listed in the sdata content must be in some way derived from one or more user_data attributes by the sdata request handler. Do you know how those are derived, or is that hidden in the mysteries of the code?