Page 1 of 1
Lua: Problem reading Wind speed value)
Posted: Tuesday 16 August 2016 21:34
by CronoS
Hi,
I have setup a new anemometer (wind speed meter) in my Domoticz setup. Now, I want to use a LUA script to turn a virtual switch on/off when the wind is above a particular value.
But, for some reason.. the LUA variable is always reading 0.00 as windspeed. I have looked at the Wiki, but I don't know exactly what is incorrect?
When I simply read the Windmeter value:
Code: Select all
sWindvalue =(otherdevices_svalues['WindMeter'])
print ("sWindvalue: "..sWindvalue)
I get a long line of numbers (where you can extract the windspeed from), but the outcome is strange. This is shown in my log file:
LUA: sWindvalue: 0.00;N;6;6;0.0;0.0
So it reads something, but everything is looking pretty much 0

On my Domoticz dashboard I do see a good value. What am I doing wrong here?
Any help is appreciated

Re: Lua: Problem reading Wind speed value)
Posted: Tuesday 16 August 2016 21:37
by jvdz
What content is shown in the devices list under Setup/Devices for this device?
Jos
Re: Lua: Problem reading Wind speed value)
Posted: Tuesday 16 August 2016 21:39
by CronoS
Thanks for the reply. Type Wind, Subtype weatherstation
Re: Lua: Problem reading Wind speed value)
Posted: Tuesday 16 August 2016 21:42
by CronoS
Hmm.. very strange. On the devices, the value is the same basically as what is shown in the logfile. But the device itself shows different value's in the dashboard, where it shows a m/s value which is not shown on the devices page for this particular device.
Re: Lua: Problem reading Wind speed value)
Posted: Tuesday 16 August 2016 21:45
by jvdz
Do you have multiple devices with the same name?
Re: Lua: Problem reading Wind speed value)
Posted: Tuesday 16 August 2016 21:49
by CronoS
Hmmm.. as far as I can see, not..
I do have another windsensor (the one from weather underground), but the names are different. Also the data that is shown in general is looking differently for the WU wind sensor.
Re: Lua: Problem reading Wind speed value)
Posted: Tuesday 16 August 2016 22:18
by CronoS
I think I have got it. The raw sensor data is different then what Domoticz is showing in it's dashboard. I mis red the Wiki basically, it was correctly written there. Basically I think the third value is windspeed and the others are zero, because I don't collect anymore data coming from this windspeed sensor.
Only, what I don't get. I get an integer value.. saying 1,2,3,4,5,6 etc .. but I want to change this to m/s, the same way the sensor does in the dashboard. A threshold value of "50" is not saying that much for me

Somebody knows how I can change this to m/s in lua the same way as in the dashboard?
Re: Lua: Problem reading Wind speed value)
Posted: Tuesday 16 August 2016 22:32
by Toulon7559
If you want to know the components of the svalue for wind, perhaps a json-call is helpful.
In your browser call http://<ip_domoticz>:8080/json.htm?type=devices&rid=<wind-idx>
Obviously you have to fill the red values with info valid for your own configuration.
Reading the response you can probably distinguish the position of the info in the string.
Re: Lua: Problem reading Wind speed value)
Posted: Wednesday 17 August 2016 10:57
by tlpeter
Use this and see what comes out:
Code: Select all
--Windmeter data:
sWindDirectionDegrees, sWindDirection, sWindSpeed, sWindGust, sWindTemperature, sWindFeel = otherdevices_svalues['Wind']:match("([^;]+);([^;]+);([^;]+);([^;]+);([^;]+);([^;]+)")
sWindDirectionDegrees = tonumber(sWindDirectionDegrees);
sWindDirection = (sWindDirection);
sWindSpeed = tonumber(sWindSpeed);
sWindGust = tonumber(sWindGust);
sWindTemperature = tonumber(sWindTemperature);
sWindFeel = tonumber(sWindFeel);
print("______________________________________________________________________________________")
print("Windmeter: Winddirection (in degrees) is: " .. sWindDirectionDegrees .. " ");
print("Windmeter: Winddirection is: " .. sWindDirection .. " ");
print("Windmeter: Windspeed is: " .. sWindSpeed .. " ");
print("Windmeter: Windgust is: " .. sWindGust .. " ");
print("Windmeter: Windtemperature is: " .. sWindTemperature .. " ");
print("Windmeter: Windfeel is: " .. sWindFeel .. " ");
print("______________________________________________________________________________________")
I use this to read wind form weather underground.
Re: Lua: Problem reading Wind speed value)
Posted: Wednesday 11 January 2017 12:46
by BakSeeDaa
tlpeter wrote:Use this and see what comes out:
...
I use this to read wind form weather underground.
Thanks for sharing that piece of code. It's very useful.