I'm not a LUA programmer, have no clue how to add these items to the script.arnaudth wrote:Hi,
You can modify the script to fit your needs.
Here is some help http://wiki.wunderground.com/index.php/ ... d_Protocol.
Can you help me ?
Moderator: leecollings
I'm not a LUA programmer, have no clue how to add these items to the script.arnaudth wrote:Hi,
You can modify the script to fit your needs.
Here is some help http://wiki.wunderground.com/index.php/ ... d_Protocol.
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
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)
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
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.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]))
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)
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)'local function CelciusToFarenheit(C)
return (C * (9/5)) + 32
end
Ahhh OkToulon7559 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.
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
Code: Select all
local function luxtoWattsm2(mm)
if mm == nil then return 0 end
return mm * 0.0079
end
Code: Select all
--remove the line below to actualy upload it
--commandArray['OpenURL']=WU_URL
Code: Select all
commandArray['OpenURL']=WU_URL
Users browsing this forum: No registered users and 1 guest