Page 2 of 6
Re: Weather Underground Upload script
Posted: Thursday 13 August 2015 10:46
by theezeefje
I'm not a LUA programmer, have no clue how to add these items to the script.
Can you help me ?
Weather Underground Upload script: no updates
Posted: Sunday 06 September 2015 9:49
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,
Re: Weather Underground Upload script
Posted: Monday 07 September 2015 22:37
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.
Re: Weather Underground Upload script
Posted: Friday 11 September 2015 17:22
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
Re: Weather Underground Upload script
Posted: Saturday 12 September 2015 19:47
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.
Re: Weather Underground Upload script
Posted: Saturday 19 September 2015 11:19
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
Re: Weather Underground Upload script
Posted: Sunday 20 September 2015 17:20
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
Re: Weather Underground Upload script
Posted: Thursday 08 October 2015 11:40
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
Re: Weather Underground Upload script
Posted: Sunday 25 October 2015 8:24
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
Re: Weather Underground Upload script
Posted: Sunday 25 October 2015 10:13
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.
Re: Weather Underground Upload script
Posted: Sunday 25 October 2015 11:18
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
Re: Weather Underground Upload script
Posted: Sunday 25 October 2015 11:27
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]
Re: Weather Underground Upload script
Posted: Sunday 25 October 2015 11:33
by maxmizer
Thank You Toulon7559, works
with all the evidence that I had, in the end, in fact I had removed the two lines in front of commandarray
Interval = "<55" doen't work..( where <55 is 15) 15 minute..
Re: Weather Underground Upload script
Posted: Tuesday 27 October 2015 16:34
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.
Re: Weather Underground Upload script
Posted: Tuesday 02 February 2016 10:27
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
Re: Weather Underground Upload script
Posted: Thursday 05 May 2016 14:08
by gizmocuz
Could you post the luxtoWattsm2 function as well ?
What is the range of your 'Lux' sensor ? 0-100% or 0-20000 ?
Re: Weather Underground Upload script
Posted: Thursday 05 May 2016 17:09
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
Re: Weather Underground Upload script-WU_URL doesn't upload
Posted: Sunday 29 May 2016 11:06
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
Re: Weather Underground Upload script
Posted: Sunday 29 May 2016 12:01
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
Re: Weather Underground Upload script
Posted: Sunday 29 May 2016 12:18
by jms3700
I already did it, but no result
The same line with the explicit hardcode value of WU_URL works well