Got the LUA script from this website
http://www.domoticz.com/forum/viewtopic.php?f=23&t=10077&hilit=%2Fusr%2Flocal+WMOID
Had to change it so that it would run on the Synology NAS.
- change the path to the LUA library script (JSON.lua needs to be copied into path /usr/local/domoticz/var/scripts/lua)
- make sure that you create the JSON.lua script inside the above lua folder. https://www.domoticz.com/wiki/Lua_-_json.lua
- Blog for solar script https://www.domoticz.com/forum/viewtopic.php?f=23&t=10077&p=92798#p92798
script modifications
local WMOID = '06370' -- (06370 Eindhoven Airport) Your nearest SYNOP Station for ogimet (to get Cloud layer). -- Run once with debug=1 to get it in the log. (LK doesn't give the right WMOID) -- (or, better, choose it there : http://www.ogimet.com/gsynop_nav.phtml.en ) -- ERROR: UTC is calculated wrong to 0700 but should be 0200, otherwise data fails
and
--json = (loadfile "/home/pi/domoticz/scripts/lua/JSON.lua")() -- For Linux --json = (loadfile "D:\\Domoticz\\scripts\\lua\\json.lua")() -- For Windows json = (loadfile "/usr/local/domoticz/var/scripts/lua/JSON.lua")() -- LK For Synology with via package installed Domoticz
also several other script modifications done
from this website
http://www.domoticz.com/forum/viewtopic.php?f=23&t=10077&p=92830#p92830
-- Get SYNOP message from Ogimet web site --[[ hourUTCminus1 = os.date("!%H")-1 if string.len(hourUTCminus1) == 1 then hourUTCminus1 = "0" .. hourUTCminus1 end UTC = os.date("%Y%m%d").. hourUTCminus1.."00" -- os.date("!%M") ]]-- UTC = os.date("!%Y%m%d%H").."00"
and also
if string.find(synop,"Status: 500") == nil then if string.find(synop, WMOID) ~= nil -- first 15 to 25 minutes of the hour ogimet returns an empty string then rslt = split(synop,",") CodeStation = rslt[1] rslt = split(synop, " "..CodeStation.. " ") Trame = string.gsub(rslt[2], "=", "") Trame = CodeStation .." ".. Trame rslt = split(Trame, " ") -- if( DEBUG == 1 ) then print(logprefix .. 'rslt[3]:'..rslt[3]) end Octa = string.sub(rslt[3], 1, 1) -- 3rd char is the cloud layer. 0=no cloud , 1-8= cloudy from 1 to 8 max , 9 =Fog , / = no data if Octa == "/" then -- not defined ? take the previous value print(logprefix .. 'Octa = /. i.e. no data available from WMOID '..WMOID) Octa = uservariables['octa'] elseif Octa == "9" then Octa = 8 end commandArray[indexArray] = {['Variable:octa'] = tostring(Octa)} indexArray=indexArray+1 else print(logprefix .. 'ogimet returned no valid data yet.') Octa = uservariables['octa'] end else print(logprefix .. 'ogimet returned error 500: '..synop) Octa = uservariables['octa'] end
Note that the script requests information to ogimet website based on the UTC time. UTC time is calculated based on your local time and timezone.
The ogimet website provides data for the next hour after 15 – 20 minutes into the next hour. That’s why above modifications are done to make sure script does not crash when no data is received yet.
Filed under: Uncategorized | Leave a comment »