Scraping only the temperature from WeatherUnderground sensor

User avatar
ThinkPad
Posts: 1754
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 » Friday 31 October 2014 14:33

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 23:04, edited 2 times in total.
Reason: Made title more clear
ThinkTheme - theme for Domoticz
My (Dutch) blog: http://thinkpad.tweakblogs.net - My Domoticz scripts: Bitbucket
I'm not (very) active anymore on this forum as i don't use Domoticz anymore.

jackslayter
Posts: 226
Joined: Tuesday 07 October 2014 11:00
Target OS: Raspberry Pi
Domoticz version: LastBeta
Location: France RA
Contact:

Re: Use only variable from wunderground device

Post by jackslayter » Friday 31 October 2014 16:10

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

User avatar
ThinkPad
Posts: 1754
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 » Friday 31 October 2014 17:03

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" ?
ThinkTheme - theme for Domoticz
My (Dutch) blog: http://thinkpad.tweakblogs.net - My Domoticz scripts: Bitbucket
I'm not (very) active anymore on this forum as i don't use Domoticz anymore.

jackslayter
Posts: 226
Joined: Tuesday 07 October 2014 11:00
Target OS: Raspberry Pi
Domoticz version: LastBeta
Location: France RA
Contact:

Re: Use only variable from wunderground device

Post by jackslayter » Saturday 01 November 2014 9:38

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

User avatar
ThinkPad
Posts: 1754
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 » Saturday 01 November 2014 11:39

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
ThinkTheme - theme for Domoticz
My (Dutch) blog: http://thinkpad.tweakblogs.net - My Domoticz scripts: Bitbucket
I'm not (very) active anymore on this forum as i don't use Domoticz anymore.

jackslayter
Posts: 226
Joined: Tuesday 07 October 2014 11:00
Target OS: Raspberry Pi
Domoticz version: LastBeta
Location: France RA
Contact:

Re: Use only variable from wunderground device

Post by jackslayter » Saturday 01 November 2014 12:33

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

User avatar
ThinkPad
Posts: 1754
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 » Saturday 01 November 2014 17:43

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
ThinkTheme - theme for Domoticz
My (Dutch) blog: http://thinkpad.tweakblogs.net - My Domoticz scripts: Bitbucket
I'm not (very) active anymore on this forum as i don't use Domoticz anymore.

User avatar
ThinkPad
Posts: 1754
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 » Wednesday 14 January 2015 23:02

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
ThinkTheme - theme for Domoticz
My (Dutch) blog: http://thinkpad.tweakblogs.net - My Domoticz scripts: Bitbucket
I'm not (very) active anymore on this forum as i don't use Domoticz anymore.

User avatar
Siewert308SW
Posts: 606
Joined: Monday 29 December 2014 16:47
Target OS: Raspberry Pi
Domoticz version: Beta
Location: The Netherlands - Zoutkamp (gn)
Contact:

Re: Use only variable from wunderground device

Post by Siewert308SW » Tuesday 27 January 2015 0:37

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:
- RPi3 - PIco HV3.0A / Domo Beta 3.9XXX / RFXtrx433E / Aeotec Gen5
- RPi3 - PIco HV3.0A / PiHole / PiVPN / NAS / Print Server
- Youless Elec&Gas
- FI9803P Cams
- KD101 detectors
- Zwave & KaKu

MyDomoticz scripts: @GitHub
PIco UPS Toolkit: @GitHub

User avatar
Siewert308SW
Posts: 606
Joined: Monday 29 December 2014 16:47
Target OS: Raspberry Pi
Domoticz version: Beta
Location: The Netherlands - Zoutkamp (gn)
Contact:

Re: Scraping only the temperature from WeatherUnderground se

Post by Siewert308SW » Tuesday 27 January 2015 12:54

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:
- RPi3 - PIco HV3.0A / Domo Beta 3.9XXX / RFXtrx433E / Aeotec Gen5
- RPi3 - PIco HV3.0A / PiHole / PiVPN / NAS / Print Server
- Youless Elec&Gas
- FI9803P Cams
- KD101 detectors
- Zwave & KaKu

MyDomoticz scripts: @GitHub
PIco UPS Toolkit: @GitHub

User avatar
ThinkPad
Posts: 1754
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 » Tuesday 27 January 2015 17:27

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.
ThinkTheme - theme for Domoticz
My (Dutch) blog: http://thinkpad.tweakblogs.net - My Domoticz scripts: Bitbucket
I'm not (very) active anymore on this forum as i don't use Domoticz anymore.

D'rMorris
Posts: 307
Joined: Thursday 01 May 2014 9:01
Target OS: Raspberry Pi
Domoticz version:
Location: Netherlands - Sittard
Contact:

Re: Scraping only the temperature from WeatherUnderground se

Post by D'rMorris » Tuesday 27 January 2015 18:36

Also check this wiki page.

myozone
Posts: 6
Joined: Monday 19 January 2015 14:03
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Scraping only the temperature from WeatherUnderground se

Post by myozone » Tuesday 10 February 2015 18:40

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 9181 times

User avatar
ThinkPad
Posts: 1754
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 » Tuesday 10 February 2015 18:45

Change

Code: Select all

local idx = 21 
in the script from 21 to 27 and see if it works.
ThinkTheme - theme for Domoticz
My (Dutch) blog: http://thinkpad.tweakblogs.net - My Domoticz scripts: Bitbucket
I'm not (very) active anymore on this forum as i don't use Domoticz anymore.

myozone
Posts: 6
Joined: Monday 19 January 2015 14:03
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Scraping only the temperature from WeatherUnderground se

Post by myozone » Tuesday 10 February 2015 19:06

Thank you for the prompt reply! changed it - still not working...

User avatar
ThinkPad
Posts: 1754
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 » Tuesday 10 February 2015 19:10

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.
ThinkTheme - theme for Domoticz
My (Dutch) blog: http://thinkpad.tweakblogs.net - My Domoticz scripts: Bitbucket
I'm not (very) active anymore on this forum as i don't use Domoticz anymore.

myozone
Posts: 6
Joined: Monday 19 January 2015 14:03
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Scraping only the temperature from WeatherUnderground se

Post by myozone » Tuesday 10 February 2015 19:19

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)

User avatar
ThinkPad
Posts: 1754
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 » Tuesday 10 February 2015 19:21

Ok, but why?

Just try my script and see if it works. I don't understand where your modification is needed for :mrgreen:
ThinkTheme - theme for Domoticz
My (Dutch) blog: http://thinkpad.tweakblogs.net - My Domoticz scripts: Bitbucket
I'm not (very) active anymore on this forum as i don't use Domoticz anymore.

myozone
Posts: 6
Joined: Monday 19 January 2015 14:03
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Scraping only the temperature from WeatherUnderground se

Post by myozone » Tuesday 10 February 2015 19:23

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 14:03
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Scraping only the temperature from WeatherUnderground se

Post by myozone » Tuesday 10 February 2015 19:27

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 2 guests