Scraping only the temperature from WeatherUnderground sensor

Moderator: leecollings

dpons039
Posts: 7
Joined: Monday 10 August 2015 12:38
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Scraping only the temperature from WeatherUnderground se

Post by dpons039 »

spudgunman wrote: and wacky on the dash
Image
Hello guys,

I have been checking the posts around the forum but I didn't found any solution for this.

Can someone help? I would relly like to have the barometer working without extra devices showing up on my dashboard.

Thank you in advance!

Edit:
Within the Bartometer, you need a second parameter in order to be diplayed correctly.
Synology NAS 415+ | Raspberry + Aeon Z-Stick Gen5
Sandman79
Posts: 12
Joined: Wednesday 30 September 2015 20:30
Target OS: NAS (Synology & others)
Domoticz version:
Location: Belgium
Contact:

Re: Scraping only the temperature from WeatherUnderground se

Post by Sandman79 »

just a question: is it also possible to log the dew point using the weatherunderground 'sensor' ? :)
rednas
Posts: 132
Joined: Tuesday 20 October 2015 12:23
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands
Contact:

Re: Scraping only the temperature from WeatherUnderground se

Post by rednas »

Did someone fix this already?

I am using this:
commandArray[3] = {['UpdateDevice'] = idxp .. '|0|' .. tostring(sWeatherPressure)}

The value is shown in the devices tab, but when I go to the weather tab I have this empty barometer box.
How can I fix this?
rednas
Posts: 132
Joined: Tuesday 20 October 2015 12:23
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands
Contact:

Re: Scraping only the temperature from WeatherUnderground se

Post by rednas »

dpons039 wrote: Edit:
Within the Bartometer, you need a second parameter in order to be diplayed correctly.
Does anybody know how I can make this work?
mrblond18
Posts: 9
Joined: Monday 21 December 2015 11:40
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: netherlands
Contact:

Re: Scraping only the temperature from WeatherUnderground se

Post by mrblond18 »

I was facing the same problem. Important to know is that a pressure sensor needs the pressure in bar, a barometer needs the pressure in hPa and weather underground supplies the pressure in hPa. Further a barometer also needs a so called BAR_FOR = Barometer forecast (see domoticz json/api docs for more details). I think weather underground supplies this forecast also.

I think I have fixed the problems for both types of sensors in LUA. I added an index for a barometer sensor, I also read the last value of the Temperature-Humidity-Barometer object (stored it in sWeatherPressureForecast ) and converted from hPa to bar.

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 = 'TempHumiBaro-WU' --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 = 51 --idx of the virtual temperature sensor you need to change this to your own Device IDx
local idxh = 52 --idx of the virtual humidity sensor you need to change this to your own Device IDx
local idxp = 54 --idx of the virtual pressure sensor you need to change this to your own Device IDx
local idxb = 53 --idx of virtual barometer sensor you need to change this to your own Device IDx
--

commandArray = {}

if devicechanged[sensorwu] then
        sWeatherTemp, sWeatherHumidity, sHumFeelsLike, sWeatherPressure, sWeatherPressureForecast = otherdevices_svalues[sensorwu]:match("([^;]+);([^;]+);([^;]+);([^;]+);([^;]+)")
        sWeatherTemp = tonumber(sWeatherTemp)
        sWeatherHumidity = tonumber(sWeatherHumidity)
        sHumFeelsLike = tonumber(sHumFeelsLike)
        sWeatherPressure = tonumber(sWeatherPressure) -- hPa
        sWeatherPressureBar = sWeatherPressure/1000 -- bar
        sWeatherPressureForecast = tonumber(sWeatherPressureForecast)
        parseDebug = ('WU Script Parsed Temperat=' .. sWeatherTemp)
        print(parseDebug)
        parseDebug = ('WU Script Parsed Humidity=' .. sWeatherHumidity)
        print(parseDebug)
        parseDebug = ('WU Script Parsed HumidityFeelsLike=' .. sHumFeelsLike)
        print(parseDebug)
        parseDebug = ('WU Script Parsed Pressure=' .. sWeatherPressure .. ' hPa')
        print(parseDebug)
        parseDebug = ('WU Script Parsed Pressure=' .. sWeatherPressureBar .. ' bar')
        print(parseDebug)
        parseDebug = ('WU Script Parsed PressureForecast=' .. sWeatherPressureForecast)
        print(parseDebug)



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

return commandArray


I see that values are read correctly. I still see some weird behaviour of the pressure sensor. It only stores one decimal, everything between 0.95 and 1.05 bar is seen as 1.0 bar. I send 1.019 bars, which is stored as 1.0 bar. The differences in air pressure are normally not that big, so a lot of info is lost.
tigo72
Posts: 22
Joined: Friday 13 March 2015 9:19
Target OS: Linux
Domoticz version: Beta
Contact:

Re: Scraping only the temperature from WeatherUnderground sensor

Post by tigo72 »

Thanks to your examples I managed to scrape Temp, Humid, Pressure etc. data from the combined WU sensor using LUA scripts. Everything is displayed correctly in some virtual sensors I created, such as Outisde Temperature and Humidity. However, when I use these virtual sensors in Blocky, nothing happens. The built-in sensors for temp/humid/pressure work, but not those I created myself using the info in this thread.

I would like to use scraped wind data from WU (speed, gust, feelsliketemperature) in Blocky events. These individual sensors are not by default available in Domoticz. Again, I can create virtual sensors, they do display the correct values, but they do not trigger events. Is it possible to do this in Blocky?
stlaha2007
Posts: 370
Joined: Monday 05 October 2015 10:16
Target OS: -
Domoticz version:
Contact:

Re: RE: Re: Scraping only the temperature from WeatherUnderground se

Post by stlaha2007 »

I see that values are read correctly. I still see some weird behaviour of the pressure sensor. It only stores one decimal, everything between 0.95 and 1.05 bar is seen as 1.0 bar. I send 1.019 bars, which is stored as 1.0 bar. The differences in air pressure are normally not that big, so a lot of info is lost.
Ran into sumular problem with my own BME280. Adafruit script gives a presure of 1012.523 Domoticz showed 1012.5.
Problem with json-api is that it expects a single decimal and there rounds it up/down.

So 0.95 and 1.04 will go into as 1.0 bar.
I solved this by rounding to one decimal first before sending to domoticz.

Grtz,
Stephan
rednas
Posts: 132
Joined: Tuesday 20 October 2015 12:23
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands
Contact:

Re: Scraping only the temperature from WeatherUnderground sensor

Post by rednas »

You should use the barometer device! This device has a hPa (hecto Pascal) scale, so that would be exactly the values your Adafruit scripts gives you.
So change the device from pressure to barometer and don't convert it into bar and you're done!
nosehook
Posts: 49
Joined: Thursday 31 March 2016 20:49
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Scraping only the temperature from WeatherUnderground sensor

Post by nosehook »

I seem to have a small issue with the script:
2016-04-05 23:24:00.480 Error: EventSystem: in WU sensors7: [string "--Script To Parse WeatherUnderground Multi-Va..."]:17: attempt to index global 'devicechanged' (a nil value)

This line reads:
if devicechanged[sensorwu] then

I do not seem to be able to find out how to resolve this. The script does it's job, only I want to get rid of this error :?
Pi3 Domoticz | RFXcom 433E | KAKU/COCO |Harmony Hub | Samsung TV | HS100 | HS110| HUE | Tradfri | Tado| Xiaomi |sensors | scripts| Pi3 Node Red | Pi2 SDS_011 + MH-Z19B | PiAware (zero) | Pi2 breadboard with Node red and Domoticz
User avatar
Westcott
Posts: 423
Joined: Tuesday 09 December 2014 17:04
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: UK - Glos
Contact:

Re: Scraping only the temperature from WeatherUnderground sensor

Post by Westcott »

Is it a 'time' script?
They don't access 'devicechanged'
Zwave - Sigma Z+ stick, Fibaro, Horstmann, Neo Coolcam, EUROtronic
RFlink - IR detectors and temperatures
Wifi - YeeLights, ESP32s, Anoop sockets
Zigbee - lots with zigbee2mqtt and ZbBridge
nosehook
Posts: 49
Joined: Thursday 31 March 2016 20:49
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Scraping only the temperature from WeatherUnderground sensor

Post by nosehook »

It is a modification of the previous posted code for the dummy sensors via Weather Underground. I do not think this is time based, only event based

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 sensorwu2 = 'Wind Utrecht FC'
local sensorwu = 'Temp Humidity Baro Utrecht ACT' --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 = 21 --idx of the virtual temperature sensor you need to change this to your own Device IDx
local idxh = 39 --idx of the virtual humidity sensor you need to change this to your own Device IDx
-- local idxp = 44 --idx of the virtual pressure sensor you need to change this to your own Device IDx
local idxb = 43 --idx of virtual barometer sensor you need to change this to your own Device IDx
-- local idxw = 28 --idx of virtual windsensor
local idxg = 45 --idx of gevoelstemperatuur

commandArray = {}

if devicechanged[sensorwu] then
    
        sWeatherTemp, sWeatherHumidity, sHumFeelsLike, sWeatherPressure, sWeatherPressureForecast = otherdevices_svalues[sensorwu]:match("([^;]+);([^;]+);([^;]+);([^;]+);([^;]+)")
        sWeatherTemp = tonumber(sWeatherTemp)
        sWeatherHumidity = tonumber(sWeatherHumidity)
        sHumFeelsLike = tonumber(sHumFeelsLike)
        sWeatherPressure = tonumber(sWeatherPressure) -- hPa
        -- sWeatherPressureBar = sWeatherPressure/1000 -- bar
        sWeatherPressureForecast = tonumber(sWeatherPressureForecast)
        
        -- parseDebug = ('WU Script Parsed Temperat=' .. sWeatherTemp)
        -- print(parseDebug)
        -- parseDebug = ('WU Script Parsed Humidity=' .. sWeatherHumidity)
        -- print(parseDebug)
        -- parseDebug = ('WU Script Parsed HumidityFeelsLike=' .. sHumFeelsLike)
        -- print(parseDebug)
        -- parseDebug = ('WU Script Parsed Pressure=' .. sWeatherPressure .. ' hPa')
        -- print(parseDebug)
        -- parseDebug = ('WU Script Parsed Pressure=' .. sWeatherPressureBar .. ' bar')
        -- print(parseDebug)
        -- parseDebug = ('WU Script Parsed PressureForecast=' .. sWeatherPressureForecast)
        -- print(parseDebug)
        
        if (sWeatherHumidity > 60 ) then
            verw = 3 -->60 = 3 wet
        elseif (sWeatherHumidity  < 25 ) then
            verw = 2 --<25 = 2 dry
        else
            verw = 1 -->=25 of <=60 = 1 comfortable
        end


        commandArray[1] = {['UpdateDevice'] = idxt .. '|0|' .. sWeatherTemp}
        commandArray[2] = {['UpdateDevice'] = idxh .. '|' .. tostring(sWeatherHumidity) .. '|' .. tostring(sHumFeelsLike)} -- .. '|' .. tostring(verw)}
        -- commandArray[3] = {['UpdateDevice'] = idxp .. '|0|' .. sWeatherPressureBar}
        commandArray[4] = {['UpdateDevice'] = idxb .. '|0|' .. sWeatherPressure .. ';' .. sWeatherPressureForecast}

elseif devicechanged[sensorwu2] then

        sWindDirectionDegrees, sWindDirection, sWindSpeed, sWindGust, sWindTemperature, sWindFeel = otherdevices_svalues[sensorwu2]:match("([^;]+);([^;]+);([^;]+);([^;]+);([^;]+);([^;]+)")
        sWindDirectionDegrees = tonumber(sWindDirectionDegrees);
        sWindDirection = (sWindDirection);
        sWindSpeed = tonumber(sWindSpeed);
        sWindGust = tonumber(sWindGust);
        sWindTemperature = tonumber(sWindTemperature);
        sWindFeel = tonumber(sWindFeel);

        -- print("Windmeter: Winddirection (in degrees) is: " .. sWindDirectionDegrees .. " ");
        -- print("Windmeter: Winddirection is: " .. sWindDirection .. " ");
        -- print("Windmeter: Windspeed is: " .. sWindSpeed .. " ");
        -- print("Windmeter: Windgust is: " .. sWindGust .. " ");
        -- print("Windmeter: Windtemperature is: " .. sWindTemperature .. " ");
        -- print("Windmeter: Windfeel is: " .. sWindFeel .. " ");
        
        -- commandArray[5] = {['UpdateDevice'] = idxw .. sWindDirectionDegrees .. ';' .. sWindDirection .. ';' .. sWindSpeed .. ';' .. sWindGust .. ';' .. sWindTemperature .. ';' ..sWindFeel}
        commandArray[6] = {['UpdateDevice'] = idxg .. '|0|'.. sWindFeel}
end

return commandArray

Pi3 Domoticz | RFXcom 433E | KAKU/COCO |Harmony Hub | Samsung TV | HS100 | HS110| HUE | Tradfri | Tado| Xiaomi |sensors | scripts| Pi3 Node Red | Pi2 SDS_011 + MH-Z19B | PiAware (zero) | Pi2 breadboard with Node red and Domoticz
User avatar
Westcott
Posts: 423
Joined: Tuesday 09 December 2014 17:04
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: UK - Glos
Contact:

Re: Scraping only the temperature from WeatherUnderground sensor

Post by Westcott »

OK, what is its name. and where is it stored?
Zwave - Sigma Z+ stick, Fibaro, Horstmann, Neo Coolcam, EUROtronic
RFlink - IR detectors and temperatures
Wifi - YeeLights, ESP32s, Anoop sockets
Zigbee - lots with zigbee2mqtt and ZbBridge
nosehook
Posts: 49
Joined: Thursday 31 March 2016 20:49
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Scraping only the temperature from WeatherUnderground sensor

Post by nosehook »

Hi Westcott,

Appreciate the help!
It's name is WU sensors7. I created it via the webinterface of Domoticz, so I assume it is in the standard forlder/directory.
I am currently away and can not SSH into my Raspberry Pi..

I trailed the devicechanged in a different script too and that one gives an error too, the same one.

Does this help?
Pi3 Domoticz | RFXcom 433E | KAKU/COCO |Harmony Hub | Samsung TV | HS100 | HS110| HUE | Tradfri | Tado| Xiaomi |sensors | scripts| Pi3 Node Red | Pi2 SDS_011 + MH-Z19B | PiAware (zero) | Pi2 breadboard with Node red and Domoticz
User avatar
Westcott
Posts: 423
Joined: Tuesday 09 December 2014 17:04
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: UK - Glos
Contact:

Re: Scraping only the temperature from WeatherUnderground sensor

Post by Westcott »

Ah - I actually meant what is the script's name, and where is it stored?
Zwave - Sigma Z+ stick, Fibaro, Horstmann, Neo Coolcam, EUROtronic
RFlink - IR detectors and temperatures
Wifi - YeeLights, ESP32s, Anoop sockets
Zigbee - lots with zigbee2mqtt and ZbBridge
nosehook
Posts: 49
Joined: Thursday 31 March 2016 20:49
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Scraping only the temperature from WeatherUnderground sensor

Post by nosehook »

The issue is resolved, I disabled the script I made in the webinterface and created one in the folder.
No more errors!
Thanks for the help.
Pi3 Domoticz | RFXcom 433E | KAKU/COCO |Harmony Hub | Samsung TV | HS100 | HS110| HUE | Tradfri | Tado| Xiaomi |sensors | scripts| Pi3 Node Red | Pi2 SDS_011 + MH-Z19B | PiAware (zero) | Pi2 breadboard with Node red and Domoticz
wergeld
Posts: 14
Joined: Thursday 31 December 2015 23:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Scraping only the temperature from WeatherUnderground sensor

Post by wergeld »

I have been trying to do this for a couple of days of an on. I have my script taken from:
https://www.domoticz.com/wiki/Virtual_weather_devices

I have set my sensorwu to my WU's name and created the virtual device to hold the temp. I have the script in domiticz/scritps/lua. However, the script does not get run. No messages in log (error or otherwise) regarding it and no updates to the virtual device's value. I have even allowed the debug output in the script and nothing. I know I have to missing something but I am not sure what.

Here is my script:

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 = 'WUHudson' --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 = 18 --idx of the virtual temperature sensor you need to change this to your own Device IDx
--local idxh = 999 --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
        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|' .. tostring(sWeatherPressure) .. ';' .. tostring(sWeatherPressForcast)}
end
 
return commandArray
jonkjon
Posts: 3
Joined: Tuesday 10 May 2016 23:37
Target OS: Linux
Domoticz version:
Contact:

Re: Scraping only the temperature from WeatherUnderground sensor

Post by jonkjon »

Ditto here....I have tried all of the scripts here and it just never runs....
jonkjon
Posts: 3
Joined: Tuesday 10 May 2016 23:37
Target OS: Linux
Domoticz version:
Contact:

Re: Scraping only the temperature from WeatherUnderground sensor

Post by jonkjon »

I got this sorted. As usual, it was my error of course as I was putting the name of the hardware device and not the name of the sensor that contained the data.....

--Jon
wergeld
Posts: 14
Joined: Thursday 31 December 2015 23:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Scraping only the temperature from WeatherUnderground sensor

Post by wergeld »

So finally got this to work starting off with un-modded script and filling in my values. It worked! Beautifully!

For about three hours. Now it constantly throws:

Code: Select all

script_device_sensorWU.lua:19: attempt to concatenate global 'sWeatherPressure' (a nil value)
Turns out that is the debug output line. So I have commented that out. Now I get an error on line 22:
commandArray[1] = {['UpdateDevice'] = idxt .. '|0|' .. sWeatherTemp}
Saying that sWeatherTemp is nil. Except, just above it I am printing out what the WU device is sending. Under events it should be something like:

Code: Select all

25.8;75;3;1020;2
My debug is output is just:

Code: Select all

22.1
So...huh? This is the last value sent to my virtual temp-only device. I am really confused here.
jonkjon
Posts: 3
Joined: Tuesday 10 May 2016 23:37
Target OS: Linux
Domoticz version:
Contact:

Re: Scraping only the temperature from WeatherUnderground sensor

Post by jonkjon »

Is there some way to increase the number of decimal places for rainfall? It defaults to "0.0 mm". It would be nice to be able to convert rain to inches in Domoticz directly but that doesn't seem to be an option. Today my WU site recorded .01 inches rain (.254 mm) but the rain device still shows "0.0 mm". Not sure what's up with that....

--Jon
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests