Scraping only the temperature from WeatherUnderground sensor

Moderator: leecollings

ThinkPad
Posts: 890
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Scraping only the temperature from WeatherUnderground sensor

Post 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.
Image
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?
Last edited by ThinkPad on Wednesday 14 January 2015 22:04, edited 2 times in total.
Reason: Made title more clear
I am not active on this forum anymore.
jackslayter
Posts: 59
Joined: Tuesday 07 October 2014 11:00
Target OS: Raspberry Pi / ODroid
Domoticz version: stable
Location: France RA
Contact:

Re: Use only variable from wunderground device

Post 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
RPi2 + RFLink, Domoticz
Chacon - micromodule 200w, remote 3b, 2x module 1000w, remote 16b, smoke detector, door contact, 2x 3500w plug
Oregon - 3x Thgr122Nx / OWL - CM180 / TRC02_2 RGB / Cheap - PiR, door contact, Temp Hum / 4x REVOLT NC5461
ThinkPad
Posts: 890
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Use only variable from wunderground device

Post 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" ?
I am not active on this forum anymore.
jackslayter
Posts: 59
Joined: Tuesday 07 October 2014 11:00
Target OS: Raspberry Pi / ODroid
Domoticz version: stable
Location: France RA
Contact:

Re: Use only variable from wunderground device

Post 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)
RPi2 + RFLink, Domoticz
Chacon - micromodule 200w, remote 3b, 2x module 1000w, remote 16b, smoke detector, door contact, 2x 3500w plug
Oregon - 3x Thgr122Nx / OWL - CM180 / TRC02_2 RGB / Cheap - PiR, door contact, Temp Hum / 4x REVOLT NC5461
ThinkPad
Posts: 890
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Use only variable from wunderground device

Post 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
I am not active on this forum anymore.
jackslayter
Posts: 59
Joined: Tuesday 07 October 2014 11:00
Target OS: Raspberry Pi / ODroid
Domoticz version: stable
Location: France RA
Contact:

Re: Use only variable from wunderground device

Post by jackslayter »

the arrow will be blue
if green click on to add device
RPi2 + RFLink, Domoticz
Chacon - micromodule 200w, remote 3b, 2x module 1000w, remote 16b, smoke detector, door contact, 2x 3500w plug
Oregon - 3x Thgr122Nx / OWL - CM180 / TRC02_2 RGB / Cheap - PiR, door contact, Temp Hum / 4x REVOLT NC5461
ThinkPad
Posts: 890
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Use only variable from wunderground device

Post 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
I am not active on this forum anymore.
ThinkPad
Posts: 890
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Use only variable from wunderground device

Post 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
I am not active on this forum anymore.
User avatar
Siewert308SW
Posts: 290
Joined: Monday 29 December 2014 15:47
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: The Netherlands
Contact:

Re: Use only variable from wunderground device

Post 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.
Setup:
- RPi4 - Domo Stable / Aeotec Z-stick7 / PiHole Unbound Gemini
- RPi4 - PiHole / PiVPN Unbound Gemini
- Synology DS923+ / DS218j
- P1 Gas/Power, SmartGateway watermeter
- Fibaro switches, contacts, plugs, smoke/Co2 ect
- rootfs @ USB HDD
User avatar
Siewert308SW
Posts: 290
Joined: Monday 29 December 2014 15:47
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: The Netherlands
Contact:

Re: Scraping only the temperature from WeatherUnderground se

Post 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
Setup:
- RPi4 - Domo Stable / Aeotec Z-stick7 / PiHole Unbound Gemini
- RPi4 - PiHole / PiVPN Unbound Gemini
- Synology DS923+ / DS218j
- P1 Gas/Power, SmartGateway watermeter
- Fibaro switches, contacts, plugs, smoke/Co2 ect
- rootfs @ USB HDD
ThinkPad
Posts: 890
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Scraping only the temperature from WeatherUnderground se

Post 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.
I am not active on this forum anymore.
D'rMorris
Posts: 138
Joined: Thursday 01 May 2014 9:01
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands - Sittard
Contact:

Re: Scraping only the temperature from WeatherUnderground se

Post by D'rMorris »

Also check this wiki page.
myozone
Posts: 6
Joined: Monday 19 January 2015 13:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Scraping only the temperature from WeatherUnderground se

Post 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
Attachments
domo test.jpg
domo test.jpg (170.74 KiB) Viewed 12600 times
ThinkPad
Posts: 890
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Scraping only the temperature from WeatherUnderground se

Post by ThinkPad »

Change

Code: Select all

local idx = 21 
in the script from 21 to 27 and see if it works.
I am not active on this forum anymore.
myozone
Posts: 6
Joined: Monday 19 January 2015 13:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Scraping only the temperature from WeatherUnderground se

Post by myozone »

Thank you for the prompt reply! changed it - still not working...
ThinkPad
Posts: 890
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Scraping only the temperature from WeatherUnderground se

Post 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.
I am not active on this forum anymore.
myozone
Posts: 6
Joined: Monday 19 January 2015 13:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Scraping only the temperature from WeatherUnderground se

Post 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)
ThinkPad
Posts: 890
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Scraping only the temperature from WeatherUnderground se

Post by ThinkPad »

Ok, but why?

Just try my script and see if it works. I don't understand where your modification is needed for :mrgreen:
I am not active on this forum anymore.
myozone
Posts: 6
Joined: Monday 19 January 2015 13:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Scraping only the temperature from WeatherUnderground se

Post by myozone »

One other thing, I have mine running on a Windows 7 machine. The script is executing though - showing in the log.
myozone
Posts: 6
Joined: Monday 19 January 2015 13:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Scraping only the temperature from WeatherUnderground se

Post by myozone »

Got it working now ! :D - Thanks for your help. change the line

Code: Select all

commandArray['UpdateDevice'] = idx .. '|0|' .. tostring(sWeatherTemp)
I thought the script worked like that !
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest