scraping value from virtual weather device

Moderator: leecollings

Post Reply
curious
Posts: 132
Joined: Saturday 02 April 2016 19:38
Target OS: -
Domoticz version:
Contact:

scraping value from virtual weather device

Post by curious »

From the wiki I "borrowed"the code to scrape values from a virtual weather device.
when using the script to get the temperature it works fine.

Now I would like to get some wind-values from this virtual weather device. However I don't get the right values, and besides that I get a strange icon returned (see picture)
The virtual weather device returns 6 values : 277.00;W;65;0;11.6;11.6

After running the script idx99 has a string 0;277 and idx 100 has the string 0;nil

I hope someone will check my code and checks what is wrong (and explain why)


Edit : Strange ? When checking the current status of both devices the values are displayed correct

Code: Select all

--Script To Parse WeatherUnderground Multi-Value Sensor, Additionally using PWS: system from WU with a new output format
--This script assumes the output (which can be viewed in events show current state button) is like this 19.5;79;3;1019;3 (temp;humidity;null;pressure;null)
--more details at this wiki http://www.domoticz.com/wiki/Virtual_weather_devices
--
--The following need updated for your environment get the 'Idx' or 'Name' off the Device tab. By default only the Temp is 'uncommented or enabled' in this script.
local sensorwu = 'Wind' --name of the sensor that gets created when you add the WU device (and that contains multiple values like temperature, humidity, barometer etc)
local idxw = 99 --idx of the virtual temperature sensor you need to change this to your own Device IDx
local idxx = 100 --idx of the virtual humidity sensor you need to change this to your own Device IDx
local idxp = 999 --idx of the virtual pressure sensor you need to change this to your own Device IDx
--
 
commandArray = {}
 
if devicechanged[sensorwu] then
        sWindspeed, sWinddirection, sWind3, sWind4,sTemp1,sTemp2 = otherdevices_svalues[sensorwu]:match("([^;]+);([^;]+);([^;]+);([^;]+);([^;]+)")
        sWindspeed = tonumber(sWindspeed)
        sWinddirection = tonumber(sWinddirection)
        sWind3 = tonumber(sWind3)
		 sWind4 = tonumber(sWind4)
		 sTemp1 = tonumber(sTemp1)
		  sTemp2 = tonumber(sTemp2)
        --parseDebug = ('WU Script Parsed Temp=' .. sWeatherTemp .. ' Humidity=' .. sWeatherHumidity .. ' Pressure=' .. sWeatherPressure)
        --print(parseDebug)
 
        commandArray[1] = {['UpdateDevice'] = idxw .. '|0|' .. sWindspeed}
        commandArray[2] = {['UpdateDevice'] = idxx .. '|' .. tostring(sWinddirection) .. '|' .. tostring(sWinddirection)}
        --commandArray[3] = {['UpdateDevice'] = idxp .. '|0|' .. tostring(sWeatherPressure) .. ';' .. tostring(sWeatherPressForcast)}
end
 
return commandArray 
Attachments
wind.jpg
wind.jpg (22.73 KiB) Viewed 830 times
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest