Lua: Problem reading Wind speed value)

Moderator: leecollings

Post Reply
CronoS
Posts: 135
Joined: Wednesday 15 July 2015 23:40
Target OS: -
Domoticz version:
Contact:

Lua: Problem reading Wind speed value)

Post 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 :)
Last edited by CronoS on Tuesday 16 August 2016 21:37, edited 1 time in total.
User avatar
jvdz
Posts: 2334
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Lua: Problem reading Wind speed value)

Post by jvdz »

What content is shown in the devices list under Setup/Devices for this device?

Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
CronoS
Posts: 135
Joined: Wednesday 15 July 2015 23:40
Target OS: -
Domoticz version:
Contact:

Re: Lua: Problem reading Wind speed value)

Post by CronoS »

Thanks for the reply. Type Wind, Subtype weatherstation
CronoS
Posts: 135
Joined: Wednesday 15 July 2015 23:40
Target OS: -
Domoticz version:
Contact:

Re: Lua: Problem reading Wind speed value)

Post 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.
User avatar
jvdz
Posts: 2334
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Lua: Problem reading Wind speed value)

Post by jvdz »

Do you have multiple devices with the same name?
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
CronoS
Posts: 135
Joined: Wednesday 15 July 2015 23:40
Target OS: -
Domoticz version:
Contact:

Re: Lua: Problem reading Wind speed value)

Post 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.
CronoS
Posts: 135
Joined: Wednesday 15 July 2015 23:40
Target OS: -
Domoticz version:
Contact:

Re: Lua: Problem reading Wind speed value)

Post 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?
Toulon7559
Posts: 859
Joined: Sunday 23 February 2014 17:56
Target OS: Raspberry Pi / ODroid
Domoticz version: mixed
Location: Hengelo(Ov)/NL
Contact:

Re: Lua: Problem reading Wind speed value)

Post 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.
Set1 = RPI-Zero+RFXCom433+S0PCM+Shield for BMP180/DS18B20/RS485+DDS238-1ZNs
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
tlpeter
Posts: 191
Joined: Wednesday 26 November 2014 18:43
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Lua: Problem reading Wind speed value)

Post 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.
BakSeeDaa
Posts: 485
Joined: Thursday 17 September 2015 10:13
Target OS: Raspberry Pi / ODroid
Domoticz version:

Re: Lua: Problem reading Wind speed value)

Post 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.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest