Page 2 of 4

Re: Scraping only the temperature from WeatherUnderground se

Posted: Tuesday 10 February 2015 18:51
by myozone
If this the correct way to control via the temperature

Re: Scraping only the temperature from WeatherUnderground se

Posted: Thursday 12 February 2015 15:20
by TallGuy212
I am wondering what the syntax is to scrape the humidity from the same device. Getting the temperature was no problem but it proves difficult to scrape the next value. I guess it has to do with being a % instead of a temperature.

What is correct syntax?

Re: Scraping only the temperature from WeatherUnderground se

Posted: Monday 04 May 2015 20:31
by DutchHans
Hi Tallguy,

Did you figure it out? I am very interested and struggling with the same.
Regards,
Hans

Re: Scraping only the temperature from WeatherUnderground se

Posted: Monday 04 May 2015 22:03
by jcjames13009
Hi Hans,

I used the following command in my lua script to scrap Temperature and Hulidity from my WU sensor

Code: Select all

sWeatherTemp, sWeatherHumidity, sWeatherHumidityStat, sWeatherBarometer, sWeatherBarometerFor = otherdevices_svalues[capteurwu1]:match("([^;]+);([^;]+);([^;]+);([^;]+);([^;]+)")
commandArray[1]={['UpdateDevice'] = idx1 .. '|0|' .. tostring(sWeatherTemp)}
commandArray[2]={['UpdateDevice'] = idx2 .. '|' .. tostring(sWeatherHumidity) .. '|' .. '|' .. tostring(sWeatherHumidityStat) .. '|'}
And I have this in my Domoticz
Capture8.PNG
Capture8.PNG (23.18 KiB) Viewed 6620 times
Hope it'll help

JC

Re: Scraping only the temperature from WeatherUnderground se

Posted: Wednesday 06 May 2015 21:10
by DutchHans
Hello all,

There is something strange.. when I look in the Logfile the lua script is not triggered.
I am not a programmer, I try to read code and understand it. I have tried to change the WU script for my needs... but I have no idea

But am I missing something?
The WU script is triggered, thats what the log says, but my Cresta lua file isnt.
What am i doing wrong?

Code: Select all

--script_device_tempCresta.lua
local sensorLR = 'ThermoRFXCOM' --Original sensor of wunderground carrying the 0001 ID 
local idx = 102 --idx of your manual created virtual temp sensor
commandArray = {}
if devicechanged[sensorLR] then
sWeatherTemp, sWeatherHumidity = otherdevices_svalues[sensorLR]:match("([^;]+);([^;]+)")
--sWeatherTemp = tonumber(sWeatherTemp)
commandArray['UpdateDevice'] = idx .. '|0|' .. tostring(sWeatherTemp)
end

return commandArray
Hope someone can help me out.
Kind regards, Hans

Re: Scraping only the temperature from WeatherUnderground se

Posted: Wednesday 06 May 2015 23:19
by Domosapiens
Are you sure that this is the correct IDX of your dummy temp sensor ?
It looks exact like the number from the Wiki
local idx = 102 --idx of the virtual temperature sensor you created above
:?
Domosapiens

Re: Scraping only the temperature from WeatherUnderground se

Posted: Thursday 07 May 2015 0:38
by Siewert308SW
DutchHans wrote:Hello all,

There is something strange.. when I look in the Logfile the lua script is not triggered.
I am not a programmer, I try to read code and understand it. I have tried to change the WU script for my needs... but I have no idea

But am I missing something?
The WU script is triggered, thats what the log says, but my Cresta lua file isnt.
What am i doing wrong?

Code: Select all

--script_device_tempCresta.lua
local sensorLR = 'ThermoRFXCOM' --Original sensor of wunderground carrying the 0001 ID 
local idx = 102 --idx of your manual created virtual temp sensor
commandArray = {}
if devicechanged[sensorLR] then
sWeatherTemp, sWeatherHumidity = otherdevices_svalues[sensorLR]:match("([^;]+);([^;]+)")
--sWeatherTemp = tonumber(sWeatherTemp)
commandArray['UpdateDevice'] = idx .. '|0|' .. tostring(sWeatherTemp)
end

return commandArray
Hope someone can help me out.
Kind regards, Hans
Added a cresta sensor from my neighbors to Domoticz
Added a new virtual temp sensor
and adjusted the current names in de SensorWU script for testing.
Seems it just works fine, you could test it.

Code: Select all


--script_device_sensorCR.lua
local sensorcr = 'Weerstation' --name of the sensor that gets created when you add the Cresta device (and that contains multiple values like temperature, humidity, barometer etc)
local idx = 327 --idx of the virtual temperature sensor you created for scrapping the temperature
commandArray = {}
 
if devicechanged[sensorcr] then
	sCrestaTemp, sCrestaHumidity, sCrestaPressure = otherdevices_svalues[sensorcr]:match("([^;]+);([^;]+);([^;]+)")
	sCrestaTemp = tonumber(sCrestaTemp)
	commandArray['UpdateDevice'] = idx .. '|0|' .. tostring(sCrestaTemp)
end
return commandArray

Re: Scraping only the temperature from WeatherUnderground se

Posted: Thursday 07 May 2015 14:41
by DutchHans
Hello Siewert308SW

FANTASTIC!
It works perfectly


Im starting to understand how it works now.
Thank you very much.

Re: Scraping only the temperature from WeatherUnderground se

Posted: Saturday 09 May 2015 13:50
by h143
how can i scraping the humidity to a virtual humidity sensor?
the value is always 0 i have the following script:

Code: Select all

--script_device_sensorCR.lua
local sensorcr = 'Weerstation' --name of the sensor that gets created when you add the Cresta device (and that contains multiple values like temperature, humidity, barometer etc)
local idx = 435 --idx of the virtual temperature sensor you created for scrapping the temperature
commandArray = {}
 
if devicechanged[sensorcr] then
   sCrestaTemp, sCrestaHumidity, sCrestaPressure = otherdevices_svalues[sensorcr]:match("([^;]+);([^;]+);([^;]+)")
   sCrestaHumidity = tonumber(sCrestaHumidity)
   commandArray['UpdateDevice'] = idx .. '|0|' .. tostring(sCrestaHumidity)
end
return commandArray

Re: Scraping only the temperature from WeatherUnderground se

Posted: Saturday 09 May 2015 14:26
by tlpeter
Why define a new name instead of using the real device name in the script?

Re: Scraping only the temperature from WeatherUnderground se

Posted: Saturday 09 May 2015 15:29
by jannl
Like Peter says.
Start using the actual device name.
Print the value to the log in domoticz and check if it works first. (should work)

Re: Scraping only the temperature from WeatherUnderground se

Posted: Thursday 28 May 2015 6:18
by spudgunman
note sure what I am missing here - new to this whole project and wondering where to troubleshoot next, I have also tried this on the SVN build with same results (the results that my virtual temp device wont update)

version 2.2492

Code: Select all

2015-05-27 21:10:00.430 EventSystem: Script event triggered: /home/pi/domoticz/scripts/lua/script_device_sensorWU.lua
2015-05-27 21:10:00.420 (WeatherUnderground) Temp + Humidity + Baro (WUCombo)
2015-05-27 21:10:00.440 Hardware Monitor: Fetching data (System sensors)
2015-05-27 21:10:00.437 (WeatherUnderground) Wind (Wind)
2015-05-27 21:10:00.450 (WeatherUnderground) UV (UV)
2015-05-27 21:10:00.476 (WeatherUnderground) Rain (Rain)
Capture.JPG
Capture.JPG (71.85 KiB) Viewed 6460 times

Code: Select all

local sensorwu = 'WUCombo' --name of the sensor that gets created when you add the WU device (and that contains multiple values like $
local idx = 14065 --idx of the virtual temperature sensor you created above
commandArray = {}

if devicechanged[sensorwu] then
        sWeatherTemp, sWeatherHumidity, sWeatherPressure = otherdevices_svalues[sensorwu]:match("([^;]+);([^;]+);([^;]+)")
        sWeatherTemp = tonumber(sWeatherTemp)
        commandArray['UpdateDevice'] = idx .. '|0|' .. tostring(sWeatherTemp)
end
return commandArray

Re: Scraping only the temperature from WeatherUnderground se

Posted: Thursday 28 May 2015 6:21
by spudgunman
AI hacked up the scrip to pull all data.
updated May 28

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 enviroment get the 'Idx' or 'Name' off the Device tab. By default only the Temp is 'uncommented or enabled' in this script.
local sensorwu = 'ChangeME' --name of the sensor that gets created when you add the WU device (and that contains multiple values like temperature, humidity, barometer etc)
local idxt = 999 --idx of the virtual temperature sensor you need to change this to your own Device ID
local idxh = 999 --idx of the virtual humidity sensor you need to change this to your own Device ID
local idxp = 999 --idx of the virtual pressure sensor you need to change this to your own Device ID
--

commandArray = {}

if devicechanged[sensorwu] then
        sWeatherTemp, sWeatherHumidity, sHumFeelsLike, sWeatherPressure = otherdevices_svalues[sensorwu]:match("([^;]+);([^;]+);([^;]+);([^;]+);([^;]+)")
        sWeatherTemp = tonumber(sWeatherTemp)
        sWeatherHumidity = tonumber(sWeatherHumidity)
        sWeatherPressure = tonumber(sWeatherPressure)
        --parseDebug = ('WU Script Parsed Temp=' .. sWeatherTemp .. ' Humidity=' .. sWeatherHumidity .. ' Pressure=' .. sWeatherPressure)
        --print(parseDebug)

        commandArray[1] = {['UpdateDevice'] = idxt .. '|0|' .. sWeatherTemp}
        --commandArray[2] = {['UpdateDevice'] = idxh .. '|' .. tostring(sWeatherHumidity) .. '|' .. tostring(sHumFeelsLike)}
        --commandArray[3] = {['UpdateDevice'] = idxp .. '|0|' .. sWeatherPressure}
end

return commandArray

Re: Scraping only the temperature from WeatherUnderground se

Posted: Thursday 28 May 2015 20:59
by spudgunman
spudgunman wrote:note sure what I am missing here - new to this whole project and wondering where to troubleshoot next, I have also tried this on the SVN build with same results (the results that my virtual temp device wont update)
found my error I was using the ID and not the idx

Re: Scraping only the temperature from WeatherUnderground se

Posted: Thursday 28 May 2015 21:16
by spudgunman
So my script 2 posts up to parse all the data (humidity and pressure) the script is working but I think there is a bug now..

I see all values in the events show current states screen
sensor-issues.JPG
sensor-issues.JPG (30.97 KiB) Viewed 6442 times
but the virtual humidity and pressure are at 0 on the device tab
sensor-issues-2.JPG
sensor-issues-2.JPG (31.16 KiB) Viewed 6442 times
and wacky on the dash
sensor-issues-3.JPG
sensor-issues-3.JPG (18.94 KiB) Viewed 6442 times

Re: Scraping only the temperature from WeatherUnderground se

Posted: Monday 01 June 2015 21:30
by Jem101
I have to say, I've tried many variations of these scripts and finally managed to get one to run properly without logging errors, but I get the same results as spudgunman above. The temperature scrapes and works OK, the virtual humidity sensor gets reset to 0 (and stays at 0), the pressure appears to work OK but i have the same dashboard problem as above.

I've tried deleting and recreating the virtual sensors many times but I always get the same results.

Re: Scraping only the temperature from WeatherUnderground se

Posted: Monday 01 June 2015 21:51
by G3rard
You have to change to script a bit for the humidity, see the last line from (a part of) my code below. I am not using it for the pressure, so I can't help you with that, but maybe it works the same way.

Code: Select all

sWeatherTempwu, sWeatherHumiditywu, sWeatherPressurewu = otherdevices_svalues[sensorwu]:match("([^;]+);([^;]+);([^;]+)")
sWeatherTempwu = tonumber(sWeatherTempwu)
sWeatherHumiditywu = tonumber(sWeatherHumiditywu)	
if (sWeatherHumiditywu > 60 ) then
   verw = 3 -->60 = 3 wet
elseif (sWeatherHumiditywu  < 25 ) then
   verw = 2 --<25 = 2 dry
else
   verw = 1 -->=25 of <=60 = 1 comfortable
end
commandArray[2]={['UpdateDevice'] = idxwut .. '|0|' .. tostring(sWeatherTempwu)}
commandArray[3]={['UpdateDevice'] = idxwuh .. '|' .. tostring(sWeatherHumiditywu) .. '|' .. tostring(verw)}

Re: Scraping only the temperature from WeatherUnderground se

Posted: Tuesday 02 June 2015 2:41
by spudgunman
ok that helps a ton - i updated my script to work with humidity now.. all that is remaining is to figure out pressure and what it expects.. so far the same trick of using 1,2,3 gave funny results

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 enviroment get the 'Idx' or 'Name' off the Device tab. By default only the Temp is 'uncommented or enabled' in this script.
local sensorwu = 'ChangeME' --name of the sensor that gets created when you add the WU device (and that contains multiple values like temperature, humidity, barometer etc)
local idxt = 999 --idx of the virtual temperature sensor you need to change this to your own Device ID
local idxh = 999 --idx of the virtual humidity sensor you need to change this to your own Device ID
local idxp = 999 --idx of the virtual pressure sensor you need to change this to your own Device ID
--

commandArray = {}

if devicechanged[sensorwu] then
        sWeatherTemp, sWeatherHumidity, sHumFeelsLike, sWeatherPressure = otherdevices_svalues[sensorwu]:match("([^;]+);([^;]+);([^;]+);([^;]+);([^;]+)")
        sWeatherTemp = tonumber(sWeatherTemp)
        sWeatherHumidity = tonumber(sWeatherHumidity)
        sWeatherPressure = tonumber(sWeatherPressure)
        --parseDebug = ('WU Script Parsed Temp=' .. sWeatherTemp .. ' Humidity=' .. sWeatherHumidity .. ' Pressure=' .. sWeatherPressure)
        --print(parseDebug)

        commandArray[1] = {['UpdateDevice'] = idxt .. '|0|' .. sWeatherTemp}
        --commandArray[2] = {['UpdateDevice'] = idxh .. '|' .. tostring(sWeatherHumidity) .. '|' .. tostring(sHumFeelsLike)}
        --commandArray[3] = {['UpdateDevice'] = idxp .. '|0|' .. sWeatherPressure}
end

return commandArray

Re: Scraping only the temperature from WeatherUnderground se

Posted: Tuesday 02 June 2015 21:03
by Jem101
Yes indeed using the code above, I've also managed to get the virtual Humidity sensor working and giving the proper values but just like spudgunman the Pressure value is still giving problems.

So far, I've created a virtual 'Barometer' sensor which appears in devices, I've setup the script to scrape the value for 'pressure' from WU and this runs without showing any errors. In the 'devices' tab, I can see that the value has updated and does show the correct figure, which, I assume, means that the scraping is working OK. However I get the exact same odd value in the Dashboard as spudgunman posted earlier.

It looks as if the dashboard code is expecting different data (or a different format) to what it is receiving. Oddly enough I tried creating a virtual generic 'Pressure' sensor, plugged the idx for this into the script and this worked properly. The only problem is that this sensor appears in the 'Utilities' tab rather than the Weather one.

I'm wondering if the issue is something to do with the forecast field. I've notice that the output from WU will be something like 1004 (the pressure value) followed by a forecast, wet for example. So might the Barometer virtual sensor be expecting additional data (which isn't being scraped properly so it just doesn't display correctly) - or maybe I'm just talking complete rubbish!

Any help or suggestions would be gratefully received.

Re: Scraping only the temperature from WeatherUnderground se

Posted: Wednesday 03 June 2015 7:33
by spudgunman
I have the device updating with the following but the graphic is still messed up and wont display on the dash at all, I tried a ton of different combos' according to the git-source the prediction text should not matter in the web.js it should take it either way but its not?

Code: Select all

sPressiureFeelsLike = 3 --basically just a placeholder I dont know what this should be
commandArray[3] = {['UpdateDevice'] = idxp .. '|' .. sPressiureFeelsLike .. '|' .. sWeatherPressure}
void SendBaroSensor(const int NodeID, const int ChildID, const int BatteryLevel, const float pressure, const int forecast);

But this isnt decoding still...