Lua: Problem reading Wind speed value)

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

Lua: Problem reading Wind speed value)

Post by CronoS » Tuesday 16 August 2016 21:34

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: 898
Joined: Tuesday 30 December 2014 20:25
Target OS: Raspberry Pi
Domoticz version: Stable
Location: Netherlands
Contact:

Re: Lua: Problem reading Wind speed value)

Post by jvdz » Tuesday 16 August 2016 21:37

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

Jos

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

Re: Lua: Problem reading Wind speed value)

Post by CronoS » Tuesday 16 August 2016 21:39

Thanks for the reply. Type Wind, Subtype weatherstation

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

Re: Lua: Problem reading Wind speed value)

Post by CronoS » Tuesday 16 August 2016 21:42

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: 898
Joined: Tuesday 30 December 2014 20:25
Target OS: Raspberry Pi
Domoticz version: Stable
Location: Netherlands
Contact:

Re: Lua: Problem reading Wind speed value)

Post by jvdz » Tuesday 16 August 2016 21:45

Do you have multiple devices with the same name?

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

Re: Lua: Problem reading Wind speed value)

Post by CronoS » Tuesday 16 August 2016 21:49

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: 51
Joined: Wednesday 15 July 2015 23:40
Target OS: -
Domoticz version:
Contact:

Re: Lua: Problem reading Wind speed value)

Post by CronoS » Tuesday 16 August 2016 22:18

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: 386
Joined: Sunday 23 February 2014 18:56
Target OS: Raspberry Pi
Domoticz version: latest
Location: Hengelo(Ov)/NL
Contact:

Re: Lua: Problem reading Wind speed value)

Post by Toulon7559 » Tuesday 16 August 2016 22:32

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-B+RFXCom433+S0PCM+Linksprite-shield for BMP180/DS18B20/RS485+DDS238ZN1
Set2 = RPI-3+RFLinkGTW+ESP8266s+PWS_WS7000
Common = 2*PVLogger+PWS_TFA_Nexus+KAKUs
=> Energy & Data Management based on Time and on PV&Consumption&Meteo

tlpeter
Posts: 360
Joined: Wednesday 26 November 2014 19:43
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Lua: Problem reading Wind speed value)

Post by tlpeter » Wednesday 17 August 2016 10:57

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.

User avatar
BakSeeDaa
Posts: 344
Joined: Thursday 17 September 2015 10:13
Target OS: Raspberry Pi
Domoticz version: beta
Contact:

Re: Lua: Problem reading Wind speed value)

Post by BakSeeDaa » Wednesday 11 January 2017 13:46

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.
Best wishes

// บักสีดา

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest