Page 1 of 4
Scraping only the temperature from WeatherUnderground sensor
Posted: Friday 31 October 2014 13:33
by ThinkPad
I would like to use the outside temperature i get from wunderground in an event. However, the data from Wunderground is all put in one single device. See screenshot below.

Above are virtual devices i got when i added the wunderground hardware.
I tried 3 different stations in my neighborhood, but they all put the data in one device like this.
How can i get outside temperature in one device?
Re: Use only variable from wunderground device
Posted: Friday 31 October 2014 15:10
by jackslayter
add the first line to device
create new virtual temperature sensor
create new lua script
Code: Select all
--script_device_tempWU.lua
local sensorwu = 'sensor' --sensor of wunderground
local tempsensor = 'temp' --virtual temp sensor of wunderground
local idx = 68 --idx of your virtual temp sensor of wunderground
commandArray = {}
if (otherdevices_lastupdate[sensorwu]) then
sWeatherTemp, sWeatherHumidity, sWeatherPressure = otherdevices_svalues[sensorwu]:match("([^;]+);([^;]+);([^;]+)")
sWeatherTemp = tonumber(sWeatherTemp)
commandArray['UpdateDevice'] = idx .. '|0|' .. tostring(sWeatherTemp)
end
return commandArray
Re: Use only variable from wunderground device
Posted: Friday 31 October 2014 16:03
by ThinkPad
Hey thanks!
But can you help me a little bit more?
I found out how to create a virtual temp sensor:
/json.htm?type=createvirtualsensor&idx=XX&sensortype=80
(XX is the IDX i have chosen, looked what the current highest IDX was and did that +1) 80 stands for temperature only.
But what to do now? I put the script in /home/pi/domoticz/scripts/lua/. I put in the IDX.
Do i need to change anything else? ('sensorwu' and 'tempsensor' ?)
And what do you mean by: "add the first line to device" ?
Re: Use only variable from wunderground device
Posted: Saturday 01 November 2014 8:38
by jackslayter
ThinkPad wrote:Hey thanks!
But can you help me a little bit more?
I found out how to create a virtual temp sensor:
/json.htm?type=createvirtualsensor&idx=XX&sensortype=80
(XX is the IDX i have chosen, looked what the current highest IDX was and did that +1) 80 stands for temperature only.
I never used that
ThinkPad wrote:But what to do now? I put the script in /home/pi/domoticz/scripts/lua/. I put in the IDX.
Do i need to change anything else? ('sensorwu' and 'tempsensor' ?)
And what do you mean by: "add the first line to device" ?
Yes
No
Add the line: 44 wunderground 0001 ...... in your device list (green arrow)
Re: Use only variable from wunderground device
Posted: Saturday 01 November 2014 10:39
by ThinkPad
I am sorry but i don't understand how to get it working. Can you please explain a little bit more?
How do you created a virtual sensor?
And you say: 'add the first line to device'. But i really don't understand that part. Which first line, and to which device, and mostly: HOW? :p
Re: Use only variable from wunderground device
Posted: Saturday 01 November 2014 11:33
by jackslayter
the arrow will be blue
if green click on to add device
Re: Use only variable from wunderground device
Posted: Saturday 01 November 2014 16:43
by ThinkPad
Together with someone from a Dutch IT forum i figured it out. I also added it to the wiki to help others:
http://www.domoticz.com/wiki/Virtual_we ... emperature
Re: Use only variable from wunderground device
Posted: Wednesday 14 January 2015 22:02
by ThinkPad
User 'nickyb2' did a few small modifications to the script, so it now runs as soon as the sensor from WU is updated. This instead of the version i had before, where it would run every 10 minutes. In the worst case the script could lag behind so the data in the virtual_temp sensor would be 19 minutes old. It is now instaneously updated as soon as the WU sensor is updated.
http://www.domoticz.com/wiki/Virtual_we ... emperature
Re: Use only variable from wunderground device
Posted: Monday 26 January 2015 23:37
by Siewert308SW
ThinkPad wrote:User 'nickyb2' did a few small modifications to the script, so it now runs as soon as the sensor from WU is updated. This instead of the version i had before, where it would run every 10 minutes. In the worst case the script could lag behind so the data in the virtual_temp sensor would be 19 minutes old. It is now instaneously updated as soon as the WU sensor is updated.
http://www.domoticz.com/wiki/Virtual_we ... emperature
It's still not very clear what to put in the "sensorwu"
idx, id, hardware or name?
No matter what i put in my virtual sensor isn't updated.
Re: Scraping only the temperature from WeatherUnderground se
Posted: Tuesday 27 January 2015 11:54
by Siewert308SW
Got it working but not by the WiKi.
Something is missing the script or something else is going on.
This is what i've done.
Added WeatherUnderground as my virtual Weatherstation per wiki.
Added the WeatherUnderground device with the ID 0001 under the unused devices list and called it WeatherUnderground
Then i got to Setup --> Hardware, and created new virtual hardware and called it "Buiten Temperatuur". (Outside Temperature)
Then i clicked 'Create virtual sensor' and created a sensor with type 'Temperature'.
Then i got to Setup --> Devices and added the new "Buiten Temperatuur" virtual device to Domo and looked up the Device ID in the devices menu
This is all according the WiKi.
But now the LUA script
When i use the LUA script in the WiKi it doesn't work and the new virtual "Buiten Temperatuur" device isn't updated.
Did some searching and some copy and past en the final script below does work.
Code: Select all
--script_device_tempWU.lua
local sensorwu = 'WeatherUnderground' --Original sensor of wunderground carrying the 0001 ID
local tempsensor = 'temp' --virtual temp sensor of wunderground (don't touch)
local idx = 157 --idx of your manual created virtual temp sensor
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: Tuesday 27 January 2015 16:27
by ThinkPad
That's weird, as it is working fine here.
script_device_sensorWU.lua
Code: Select all
local sensorwu = 'Buitentemperatuur' --sensor from wunderground
local idx = 102 --idx of your virtual temp sensor of wunderground
commandArray = {}
if devicechanged[sensorwu] then
sWeatherTemp, sWeatherHumidity, sWeatherPressure = otherdevices_svalues[sensorwu]:match("([^;]+);([^;]+);([^;]+)")
sWeatherTemp = tonumber(sWeatherTemp)
commandArray['UpdateDevice'] = idx .. '|0|' .. tostring(sWeatherTemp)
end
return commandArray
'Buitentemperatuur' is the device that is added when you configure WU. This is the device that contains multiple values, like temperature, pressure, humidity etc.
IDX 102 is a virtual temperature sensor i created.
I have 'script_device_sensorWU.lua' in /home/pi/domoticz/scripts/lua.
I uploaded the script contents again to the wiki, maybe there was a typo in it.
Re: Scraping only the temperature from WeatherUnderground se
Posted: Tuesday 27 January 2015 17:36
by D'rMorris
Re: Scraping only the temperature from WeatherUnderground se
Posted: Tuesday 10 February 2015 17:40
by myozone
This is what I have and it doesn't work ...
Code: Select all
local sensorwu = 'wx' --name of the sensor that gets created when you add the WU device (and that contains multiple values like temperature, humidity, barometer etc)
local idx = 21 --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['newtemp'] = idx .. '|27|' .. tostring(sWeatherTemp)
end
return commandArray
Re: Scraping only the temperature from WeatherUnderground se
Posted: Tuesday 10 February 2015 17:45
by ThinkPad
Change
in the script from 21 to 27 and see if it works.
Re: Scraping only the temperature from WeatherUnderground se
Posted: Tuesday 10 February 2015 18:06
by myozone
Thank you for the prompt reply! changed it - still not working...
Re: Scraping only the temperature from WeatherUnderground se
Posted: Tuesday 10 February 2015 18:10
by ThinkPad
Hmmm
I don't know, i compared my WU device and virtual sensor device to yours, and look identical.
Maybe try copying my script again:
Code: Select all
local sensorwu = 'Buitentemperatuur' --sensor from wunderground
local idx = 102 --idx of your virtual temp sensor of wunderground
commandArray = {}
if devicechanged[sensorwu] then
sWeatherTemp, sWeatherHumidity, sWeatherPressure = otherdevices_svalues[sensorwu]:match("([^;]+);([^;]+);([^;]+)")
sWeatherTemp = tonumber(sWeatherTemp)
commandArray['UpdateDevice'] = idx .. '|0|' .. tostring(sWeatherTemp)
end
return commandArray
Above code is directly pulled from my working setup, so nothing edited/modified.
Re: Scraping only the temperature from WeatherUnderground se
Posted: Tuesday 10 February 2015 18:19
by myozone
The only major difference is your line:
Code: Select all
commandArray['UpdateDevice'] = idx .. '|0|' .. tostring(sWeatherTemp)
and mine is
Code: Select all
commandArray['newtemp'] = idx .. '|27|' .. tostring(sWeatherTemp)
Re: Scraping only the temperature from WeatherUnderground se
Posted: Tuesday 10 February 2015 18:21
by ThinkPad
Ok, but why?
Just try my script and see if it works. I don't understand where your modification is needed for

Re: Scraping only the temperature from WeatherUnderground se
Posted: Tuesday 10 February 2015 18:23
by myozone
One other thing, I have mine running on a Windows 7 machine. The script is executing though - showing in the log.
Re: Scraping only the temperature from WeatherUnderground se
Posted: Tuesday 10 February 2015 18:27
by myozone
Got it working now !

- Thanks for your help. change the line
Code: Select all
commandArray['UpdateDevice'] = idx .. '|0|' .. tostring(sWeatherTemp)
I thought the script worked like that !