Weather Underground Upload script Topic is solved

Moderator: leecollings

theezeefje
Posts: 5
Joined: Wednesday 11 December 2013 22:56
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Contact:

Re: Weather Underground Upload script

Post by theezeefje »

arnaudth wrote:Hi,
You can modify the script to fit your needs.
Here is some help http://wiki.wunderground.com/index.php/ ... d_Protocol.
I'm not a LUA programmer, have no clue how to add these items to the script.
Can you help me ?
westd001
Posts: 22
Joined: Friday 28 August 2015 21:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Weather Underground Upload script: no updates

Post by westd001 »

Hi there,

Maybe somebody knows this issue and can help me solving it.

I am using the upload script a few days now. I tested the generated URL with the print statement in the log and it's working fine, but after removing the remarks before the CommandArray statement Wunderground isn't updated at all. So my PWS will only update when I use the generated URL in my browser.
Anyone ?

Thanks in advance,
Toulon7559
Posts: 843
Joined: Sunday 23 February 2014 17:56
Target OS: Raspberry Pi / ODroid
Domoticz version: mixed
Location: Hengelo(Ov)/NL
Contact:

Re: Weather Underground Upload script

Post by Toulon7559 »

Perhaps a minor detail: which value do you apply in scriptline 16 for 'Interval'?
If you use the latest script-version incl. the lines for BMP180 and have not changed that Interval-value, then the default value for Interval is 55 minutes (intended for an hourly update), which means that you usually have to wait very, very long before you will see an upload to Wunderground .......
At least for initial testing suggest to change that value to 5: then it takes only 5 minutes before you can expect an upload.
Set1 = RPI-Zero+RFXCom433+S0PCM+Shield for BMP180/DS18B20/RS485+DDS238-1ZNs
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
westd001
Posts: 22
Joined: Friday 28 August 2015 21:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Weather Underground Upload script

Post by westd001 »

Toulon7559,

The timer value is OK, though, I deleted my script and copied yours (with the BMP180 and 55 min. timer), changed the timer to 2 minutes and that works !! I changed the code a bit because it gives an error every minute because the URL is null. Don't know the difference between the two versions but it works. See below, thanks for your reply !

Code: Select all

-- Weatherunderground PWS upload script
-- (C)2013 GizMoCuz, adapted by Toulon7559 for periodic upload of info received via RFXCom, supplemented by pressure-info from a BMP180 sensor

date = os.date("*t")
if (date.min % 55 == 0) then
--start script every 55 minutes

-- Line 05, Defintion of inputs
Outside_Temp_Hum = 'Temperatuur buiten'
Barometer = 'Barometer'
RainMeter = 'Regenmeter'
WindMeter = 'Windmeter'
-- UVMeter = ' '

-- Line 12, WU Settings
baseurl = "http://weatherstation.wunderground.com/weatherstation/updateweatherstation.php?"
ID = <ID>
PASSWORD = <password>

-- Line 18, Local functions
local function CelciusToFarenheit(C)
   return (C * (9/5)) + 32
end

local function hPatoInches(hpa)
   return hpa * 0.0295301
end

local function mmtoInches(mm)
   return mm * 0.039370
end

-- Line 31, Extraction of required calendar info
utc_dtime = os.date("!%m-%d-%y %H:%M:%S",os.time())
month = string.sub(utc_dtime, 1, 2)
day = string.sub(utc_dtime, 4, 5)
year = "20" .. string.sub(utc_dtime, 7, 8)
hour = string.sub(utc_dtime, 10, 11)
minutes = string.sub(utc_dtime, 13, 14)
seconds = string.sub(utc_dtime, 16, 17)

timestring = year .. "-" .. month .. "-" .. day .. "+" .. hour .. "%3A" .. minutes .. "%3A" .. seconds

SoftwareType="Domoticz"

-- Line 44, Current date as date.year, date.month, date.day, date.hour, date.min, date.sec
WU_URL= baseurl .. "ID=" .. ID .. "&PASSWORD=" .. PASSWORD .. "&dateutc=" .. timestring
--&winddir=230
--&windspeedmph=12
--&windgustmph=12

-- Line 53, Extraction of data from BMP180
sBMP180T, sBMP180B = otherdevices_svalues[Barometer]:match("([^;]+);([^;]+)")
-- sBMP180T = tonumber(sBMP180T);
-- print ('BMP180_temp = '.. sBMP180T) 
sBMP180B = tonumber(sBMP180B);
-- print ('BMP180_druk = '.. sBMP180B)

if Outside_Temp_Hum ~= '' then
   WU_URL = WU_URL .. "&tempf=" .. string.format("%3.1f", CelciusToFarenheit(otherdevices_temperature[Outside_Temp_Hum]))
   WU_URL = WU_URL .. "&humidity=" .. otherdevices_humidity[Outside_Temp_Hum]
   WU_URL = WU_URL .. "&dewptf=" .. string.format("%3.1f", CelciusToFarenheit(otherdevices_dewpoint[Outside_Temp_Hum]))
end

if Barometer ~= '' then
   WU_URL = WU_URL .. "&baromin=" .. string.format("%2.2f", hPatoInches(sBMP180B))
end

if RainMeter ~= '' then
   WU_URL = WU_URL .. "&dailyrainin=" .. string.format("%2.2f", mmtoInches(otherdevices_rain[RainMeter]))
   WU_URL = WU_URL .. "&rainin=" .. string.format("%2.2f", mmtoInches(otherdevices_rain_lasthour[RainMeter]))
end

if WindMeter ~= '' then
   WU_URL = WU_URL .. "&winddir=" .. string.format("%.0f", otherdevices_winddir[WindMeter])
   WU_URL = WU_URL .. "&windspeedmph=" .. string.format("%.0f", (otherdevices_windspeed[WindMeter]/0.1)*0.223693629205)
   WU_URL = WU_URL .. "&windgustmph=" .. string.format("%.0f", (otherdevices_windgust[WindMeter]/0.1)*0.223693629205)
end

-- if UVMeter ~= '' then
--    WU_URL = WU_URL .. "&UV=" .. string.format("%.1f", mmtoInches(otherdevices_uv[UVMeter]))
-- end

--&weather=
--&clouds=

WU_URL = WU_URL .. "&softwaretype=" .. SoftwareType .. "&action=updateraw"

--print (WU_URL)

commandArray = {}

--remove -- before the line below to actually upload
commandArray['OpenURL']=WU_URL

return commandArray

-- end of script

else
  commandArray = {}
  return commandArray
end
Toulon7559
Posts: 843
Joined: Sunday 23 February 2014 17:56
Target OS: Raspberry Pi / ODroid
Domoticz version: mixed
Location: Hengelo(Ov)/NL
Contact:

Re: Weather Underground Upload script

Post by Toulon7559 »

;-) That is the best way to apply the example-script: borrow & adapt to your situation&wishes!

Note: The '1-minute-error' was already recognized for my original script of 8th of January, but the URL-error is in the background and therefore no further effort done to 'clean' that aspect.
Set1 = RPI-Zero+RFXCom433+S0PCM+Shield for BMP180/DS18B20/RS485+DDS238-1ZNs
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
Robin
Posts: 1
Joined: Monday 31 August 2015 18:11
Target OS: Raspberry Pi / ODroid
Domoticz version: 2.3530
Location: Assen, The Netherlands
Contact:

Re: Weather Underground Upload script

Post by Robin »

Since this morning i keep getting the same error:

Code: Select all

2015-09-19 11:09:00.346 Error: EventSystem: /home/pi/domoticz/scripts/lua/script_time_wu.lua:16: attempt to perform arithmetic on local 'C' (a nil value)
My script looks like this:

Code: Select all

-- Weatherunderground PWS upload script
-- (C)2013 GizMoCuz

Outside_Temp_Hum = 'Buiten'
Barometer = ''
RainMeter = 'Regen'
WindMeter = 'Wind'
UVMeter = ''

--WU Settings
baseurl = "http://weatherstation.wunderground.com/weatherstation/updateweatherstation.php?"
ID = "IDRENTHE83"
PASSWORD = "PASSWORD"

local function CelciusToFarenheit(C)
   return (C * (9/5)) + 32
end 

local function hPatoInches(hpa)
   return hpa * 0.0295301
end

local function mmtoInches(mm)
   return mm * 0.039370
end

utc_dtime = os.date("!%m-%d-%y %H:%M:%S",os.time())

month = string.sub(utc_dtime, 1, 2)
day = string.sub(utc_dtime, 4, 5)
year = "20" .. string.sub(utc_dtime, 7, 8)
hour = string.sub(utc_dtime, 10, 11)
minutes = string.sub(utc_dtime, 13, 14)
seconds = string.sub(utc_dtime, 16, 17) 

timestring = year .. "-" .. month .. "-" .. day .. "+" .. hour .. "%3A" .. minutes .. "%3A" .. seconds

SoftwareType="Domoticz"

WU_URL= baseurl .. "ID=" .. ID .. "&PASSWORD=" .. PASSWORD .. "&dateutc=" .. timestring
--&winddir=230
--&windspeedmph=12
--&windgustmph=12

if Outside_Temp_Hum ~= '' then
   WU_URL = WU_URL .. "&tempf=" .. string.format("%3.1f", CelciusToFarenheit(otherdevices_temperature[Outside_Temp_Hum]))
   WU_URL = WU_URL .. "&humidity=" .. otherdevices_humidity[Outside_Temp_Hum]
   WU_URL = WU_URL .. "&dewptf=" .. string.format("%3.1f", CelciusToFarenheit(otherdevices_dewpoint[Outside_Temp_Hum]))
end

if Barometer ~= '' then
   WU_URL = WU_URL .. "&baromin=" .. string.format("%2.2f", hPatoInches(otherdevices_barometer[Barometer]))
end

if RainMeter ~= '' then
   WU_URL = WU_URL .. "&dailyrainin=" .. string.format("%2.2f", mmtoInches(otherdevices_rain[RainMeter]))
   WU_URL = WU_URL .. "&rainin=" .. string.format("%2.2f", mmtoInches(otherdevices_rain_lasthour[RainMeter]))
end

if WindMeter ~= '' then
   WU_URL = WU_URL .. "&winddir=" .. string.format("%.0f", otherdevices_winddir[WindMeter])
   WU_URL = WU_URL .. "&windspeedmph=" .. string.format("%.0f", (otherdevices_windspeed[WindMeter]/0.1)*0.223693629205)
   WU_URL = WU_URL .. "&windgustmph=" .. string.format("%.0f", (otherdevices_windgust[WindMeter]/0.1)*0.223693629205)
end

if UVMeter ~= '' then
   WU_URL = WU_URL .. "&UV=" .. string.format("%.1f", mmtoInches(otherdevices_uv[UVMeter]))
end

--&weather=
--&clouds=

WU_URL = WU_URL .. "&softwaretype=" .. SoftwareType .. "&action=updateraw"

--print (WU_URL)

commandArray = {}

--remove the line below to actualy upload it
--commandArray['OpenURL']=WU_URL

return commandArray
Image
Toulon7559
Posts: 843
Joined: Sunday 23 February 2014 17:56
Target OS: Raspberry Pi / ODroid
Domoticz version: mixed
Location: Hengelo(Ov)/NL
Contact:

Re: Weather Underground Upload script

Post by Toulon7559 »

No typo visible in line 16, but recheck anyway ....

The mentioned local function is called in script-lines 46 and 48.
if Outside_Temp_Hum ~= '' then
WU_URL = WU_URL .. "&tempf=" .. string.format("%3.1f", CelciusToFarenheit(otherdevices_temperature[Outside_Temp_Hum]))
WU_URL = WU_URL .. "&humidity=" .. otherdevices_humidity[Outside_Temp_Hum]
WU_URL = WU_URL .. "&dewptf=" .. string.format("%3.1f", CelciusToFarenheit(otherdevices_dewpoint[Outside_Temp_Hum]))
THAT the local function is called implies that the initial check in line 45 is passed, which means that you have data for Outside_Temp_Hum.
You could check which next line is causing the errorreport, by putting -- in front of line 46 (disabling that line, resulting in an WU_URL without "&tempf") and look what happens.
If you still see an error for line 16, it means that that the next function call in line 48 has failed.
If you see an errorreport not for line 16, but for line 47, it means that you unfortunately have a problem with Outside_Temp_Hum, because the 'humidity'-function gets no data [which causes some headscratching related to script-line 45].
In latter case, check whether you have actual reception of data from the 'Buiten'-sensor: the latest reception-time can be found under Dashboard/Devices, most right column
Set1 = RPI-Zero+RFXCom433+S0PCM+Shield for BMP180/DS18B20/RS485+DDS238-1ZNs
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
westanfelda
Posts: 4
Joined: Thursday 08 October 2015 10:52
Target OS: -
Domoticz version:
Contact:

Re: Weather Underground Upload script

Post by westanfelda »

Hello all,

i´m also using the upload script. It works great for me.

Now i have an Aeon Multisensor 6, which reads the solar radiation in Lux. Is it possible to integrate this in the script?
In the Wunderground Wiki i found something about "solarradiation", but after some searching, i still have no clue how to get this into the script.

Could you help me with this?

Guido
maxmizer
Posts: 8
Joined: Sunday 25 October 2015 8:17
Target OS: Windows
Domoticz version:
Contact:

Re: Weather Underground Upload script

Post by maxmizer »

Hello to all
my system gives me this error

Code: Select all

EventSystem: /usr/local/domoticz/var/scripts/lua/script_time_wu.lua:16: attempt to perform arithmetic on local 'C' (a nil value)
anyone knows why?

thank you
Toulon7559
Posts: 843
Joined: Sunday 23 February 2014 17:56
Target OS: Raspberry Pi / ODroid
Domoticz version: mixed
Location: Hengelo(Ov)/NL
Contact:

Re: Weather Underground Upload script

Post by Toulon7559 »

The error report probably refers to the local function starting at line 16
local function CelciusToFarenheit(C)
return (C * (9/5)) + 32
end
The meaning of the error is that the local function is called (further down in your script), but ín the call there is no value C present for 'CelciusToFarenheit(C)'
For more extended explanation, see my response of 20 september 2015 to Robin on similar question.
Sometimes trivial reason for such error:
for example, check (approx. in line 6 of the script) that the applied 'name' in Outside_Temp_Hum = 'name' is in line with the sValue used by Domoticz, otherwise no data is extracted.
Set1 = RPI-Zero+RFXCom433+S0PCM+Shield for BMP180/DS18B20/RS485+DDS238-1ZNs
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
maxmizer
Posts: 8
Joined: Sunday 25 October 2015 8:17
Target OS: Windows
Domoticz version:
Contact:

Re: Weather Underground Upload script

Post by maxmizer »

Toulon7559 wrote:The error report probably refers to the local function starting at line 16

for example, check (approx. in line 6 of the script) that the applied 'name' in Outside_Temp_Hum = 'name' is in line with the sValue used by Domoticz, otherwise no data is extracted.
Ahhh Ok
It was something wrong in the name.
now it does not give me the error and seems to be okay ... no log.

How do I know how if the send data, because it seems that not come to Wundermaps, in my station?

Thank You
Toulon7559
Posts: 843
Joined: Sunday 23 February 2014 17:56
Target OS: Raspberry Pi / ODroid
Domoticz version: mixed
Location: Hengelo(Ov)/NL
Contact:

Re: Weather Underground Upload script

Post by Toulon7559 »

Suggest to check in the script that following values are correctly set for your uploads to Wunderground:
ID
PASSWORD
Interval [for a value < 55, otherwise long wait till upload: e.g. set to 5 for upload each 5 minutes]
Set1 = RPI-Zero+RFXCom433+S0PCM+Shield for BMP180/DS18B20/RS485+DDS238-1ZNs
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
maxmizer
Posts: 8
Joined: Sunday 25 October 2015 8:17
Target OS: Windows
Domoticz version:
Contact:

Re: Weather Underground Upload script

Post by maxmizer »

Thank You Toulon7559, works :D
with all the evidence that I had, in the end, in fact I had removed the two lines in front of commandarray :!: :oops:

Interval = "<55" doen't work..( where <55 is 15) 15 minute..
Toulon7559
Posts: 843
Joined: Sunday 23 February 2014 17:56
Target OS: Raspberry Pi / ODroid
Domoticz version: mixed
Location: Hengelo(Ov)/NL
Contact:

Re: Weather Underground Upload script

Post by Toulon7559 »

@maxmizer
Perhaps cryptic, but with "<55" I intended to say: "a value smaller than 55"
As you already detected, you must insert just a numeric value without any sign in front.
Set1 = RPI-Zero+RFXCom433+S0PCM+Shield for BMP180/DS18B20/RS485+DDS238-1ZNs
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
User avatar
epierre
Posts: 522
Joined: Wednesday 05 March 2014 13:16
Target OS: Linux
Domoticz version:
Location: France
Contact:

Re: Weather Underground Upload script

Post by epierre »

My small contribution to add solar radiation from a lux meter, and PM10 / PM25 (here they all come from mysensors nodes):

Code: Select all

if LuxMeter ~= '' then
   WU_URL = WU_URL .. "&solarradiation=" .. string.format("%2.2f", luxtoWattsm2(otherdevices_svalues[LuxMeter]))
end

if PM25 ~= '' then
   WU_URL = WU_URL .. "&AqPM2.5=" .. string.format("%u", otherdevices_utility[PM25])
end

if PM10 ~= '' then
   WU_URL = WU_URL .. "&AqPM10=" .. string.format("%u", otherdevices_utility[PM10])
end
ImperiHome & MyDomoAtHome on top of:
868.42Mhz - Vera Lite - Fibaro SS-101, S-211, K-101, FWP - Fortress SSA2
433Mhz - Cubie Domoticz + RFXtrx + Oregon || Foscam 9821W
2,4Ghz - Cubie MySensors Gateway + COV + TempHumidity + Pressure + WaterMeter
User avatar
gizmocuz
Posts: 2373
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: Weather Underground Upload script

Post by gizmocuz »

Could you post the luxtoWattsm2 function as well ?
What is the range of your 'Lux' sensor ? 0-100% or 0-20000 ?
Quality outlives Quantity!
User avatar
epierre
Posts: 522
Joined: Wednesday 05 March 2014 13:16
Target OS: Linux
Domoticz version:
Location: France
Contact:

Re: Weather Underground Upload script

Post by epierre »

sorry here it is:

Code: Select all

local function luxtoWattsm2(mm)
   if mm == nil then return 0 end
   return mm * 0.0079
end

Mine has been up to 54k
ImperiHome & MyDomoAtHome on top of:
868.42Mhz - Vera Lite - Fibaro SS-101, S-211, K-101, FWP - Fortress SSA2
433Mhz - Cubie Domoticz + RFXtrx + Oregon || Foscam 9821W
2,4Ghz - Cubie MySensors Gateway + COV + TempHumidity + Pressure + WaterMeter
jms3700
Posts: 6
Joined: Sunday 29 May 2016 10:18
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.4834
Location: Tongeren, Belgium
Contact:

Re: Weather Underground Upload script-WU_URL doesn't upload

Post by jms3700 »

the script works well, but i can't realize an upload to weatherstation.wunderground

the line commandArray['OpenURL']=WU_URL result in the log as
2016-05-29 10:49:00.077 EventSystem: Fetching url...
2016-05-29 10:49:00.077 EventSystem: Script event triggered: /home/pi/domoticz/scripts/lua/script_time_ws.lua
but doesn't update de weather station

when I copy the value of the variable WU_URL in the log file (result from print(WU_URL) , and paste it litterally in the script as command. The updates works fine of the weather station.
of course: i sent all the time the same data to weather underground , but the scripts works.
Example of the working update script
'http://weatherstation.wunderground.com/ ... ewptf=58.2........

remark: Obviously I have no rights problem, but for some reason directly with the variable WU_URL the script doesn't update the site.
What can be the reason for this.

beste regards

jean-marie
User avatar
gizmocuz
Posts: 2373
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: Weather Underground Upload script

Post by gizmocuz »

you unmarked the last line that actually does do the uploading part?

So this

Code: Select all

--remove the line below to actualy upload it
--commandArray['OpenURL']=WU_URL
becomes this

Code: Select all

commandArray['OpenURL']=WU_URL
Quality outlives Quantity!
jms3700
Posts: 6
Joined: Sunday 29 May 2016 10:18
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.4834
Location: Tongeren, Belgium
Contact:

Re: Weather Underground Upload script

Post by jms3700 »

I already did it, but no result
The same line with the explicit hardcode value of WU_URL works well
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest