Get temperature preference in Lua?

Is there a way to get the user’s preferred temperature scale (ºF or ºC) through Luup?

Not that I’ve seen. The Metric setting in te Weather plugin was intended as a short term work around for this missing bit of info.

It’s at the top of the userdata: <root timezone="0" firmware_version="1" ServerBackup="1" TemperatureFormat="C"...
If there isn’t a way to query userdata in LuaUPnP then maybe you could request it with either of the two methods on this page: http://wiki.micasaverde.com/index.php/UI_Notes and then parse for it?

Yeah, there’s a previous post from @mcvflorin on reading that and, like anything not present in the API, it’s always in the JSON … but… on my machine that’s 400-500k of data, so I tend not to recommending reading that to anyone with a resource constrained box…

Of course, if it’s at the top of the file, then that’s a different matter…

… and the temperature preference is in [tt]lu_sdata[/tt] (at least for Vera V1@1.1.1338).

Maybe we should compile a list of Luup API bugs and Luup API feature requests?

Its in lu_sdata on UI5 too. I’ve installed json.lua in /usr/lib/lua but can’t quite get the syntax right.

Yes, lu_sdata has it as well. This is the preferred method to get status data for 3rd party plugins. The size is also much much smaller than user_data2. However, there should always be a direct way to poll that data with out obtaining the whole data. I agree with Ap15e, we should put a list together.

  • Garrett

In the mean time, this is quick-n-dirty:

local status, data = luup.inet.wget("http://localhost:3480/data_request?id=lu_sdata")
_, _, pref = string.find(data,"temperature..%s.(.)")

Thanks for the ideas. I was hoping for something a bit less heavyweight than sdata.

Feature request 2082 raised.