I've just finished my 1st Domoticz script: it will give you external temperature and barometer by querying METAR (https://en.wikipedia.org/wiki/METAR) stations.
1- Make sure you have the "curl" package on your PI
2- Simply find your nearest METAR stations and edit the station variable below.
3- Idx is of course the index of a virtual sensor "Temp + Humidity + Baro".
script_time_metar.lua:
Code: Select all
-- METAR time script
local idx = 10
local station = "LFJL"
command = "curl http://tgftp.nws.noaa.gov/data/observations/metar/stations/" .. station .. ".TXT"
commandArray = {}
local m = os.date('%M')
if (m % 30 == 5) then
-- update at 5 and 35 minutes of every hour
local handle = io.popen(command)
local data = handle:read("*a")
handle:close()
if (data == '') then
print("Error metar data not fetched")
return
end
data = string.gsub(data, "M", "-")
local pres = tonumber(string.match(data, ' Q([0-9]+)'))
local temp = tonumber(string.match(data, ' ([-0-9]+)/[-0-9]+ '))
local dew = tonumber(string.match(data, ' [-0-9]+/([-0-9]+) '))
local fore = 5
-- very basic prediction
if (pres < 1000) then
fore = 4
elseif (pres < 1020) then
fore = 3
elseif (pres < 1030) then
fore = 2
else
fore = 1
end
-- print (data, pres, temp)
local hum = 100*(math.exp((17.625*dew)/(243.04+dew))/math.exp((17.625*temp)/(243.04+temp)))
commandArray[1] = {['UpdateDevice'] = idx .. '|0|' .. temp .. ';' .. hum .. ';0;' .. pres .. ';' .. fore}
end
return commandArray
I may improve that script with weather prediction soon.
Enjoy!