[quote=“dawiinci, post:1, topic:180219”]How can I get this data from html to use it with virtual switches, global variables or variable containers?
Kind of like take the number after "temperature: " (and put it in the virtual TemperatureSensor). The second part is clear though.[/quote]
Look into making a “web service” that uses RESTful APIs to query the sensor data over HTTP, and returns JSON payloads that can be easily parsed by a plugin. Then make a plugin that HTTP GETs from your API, and parses the JSON data that’s returned.
So a web server on the Arduino would reply to http://1.1.1.1/api/1/sensor/0/get with something like [tt]{status:{temperature:19,humidity:39,leak:0,…}}[/tt]
(You can obviously use whatever URL you want.)
Back in the plugin, you then inspect the Lua tables that were created from the JSON payload, and set Luup device variables as needed from that data. This shouldn’t take very much code on the web server or Vera plugin. The Nest plugin does this, but it is not the clearest example. You can see the plugin code here: [url=https://github.com/watou/vera-nest-thermostat]https://github.com/watou/vera-nest-thermostat[/url].
I used the dkjson.lua module in the Nest plugin, but you could use other JSON codecs for Lua 5.1. Here is an example:
[code] local dkjson = require(“L_nest_dkjson”)
local json = dkjson
local veraTemperatureScale = "F"
local function getVeraTemperatureScale()
local code, data = luup.inet.wget("http://localhost:3480/data_request?id=lu_sdata")
if (code == 0) then
data = json.decode(data)
end
veraTemperatureScale = ((code == 0) and (data ~= nil) and (data.temperature ~= nil)) and data.temperature or "F"
end
[/code]
Best Home Automation shopping experience. Shop at Ezlo!