@jorgei 0 Share Posted January 8, 2019 Hi. I can't get YR to find my destination automaticly, and i suppose that is the reason why i have no weatherdata from yr plugin. My Home Center top menu looks like this: Anyone? Quote Link to post Share on other sites
0 Ville78 0 Share Posted January 8, 2019 I have same problem! ..also with Yahoo Weather. YR says 0-temp and Yahoo the same last week temp Quote Link to post Share on other sites
0 ajlb 0 Share Posted January 9, 2019 Yes, I got the same also Quote Link to post Share on other sites
0 Ultimattum 0 Share Posted January 15, 2019 Same here, no YR no yahoo weather working. Quote Link to post Share on other sites
0 DoDoR 1 Share Posted January 15, 2019 I have same problem! ..also with Yahoo Weather - None of them work and update the system 36/5000 Quote Link to post Share on other sites
0 HKrook 11 Share Posted January 15, 2019 Me too …….. @Fibaro; solve this problem which exists already for a long time!!!!! Quote Link to post Share on other sites
0 Soft 17 Share Posted January 15, 2019 It takes me 7 hours to drive to my cabin and back, to make sure the heating is working according to the scripts, that are based on outside temp. From YR or Yahoo. Quote Link to post Share on other sites
0 Thomasn 73 Share Posted January 16, 2019 On 1/15/2019 at 9:52 PM, Soft said: It takes me 7 hours to drive to my cabin and back, to make sure the heating is working according to the scripts, that are based on outside temp. From YR or Yahoo. May I advise you to buy a z-wave temperature gauge and add it to your system. That will save you a long drive! Quote Link to post Share on other sites
0 Soft 17 Share Posted January 16, 2019 I think that is a valid reply I have remote access now, using a 4g modem. But my point is still valid, having the weather is the senter of the screen in all marketing from Fibaro Quote Link to post Share on other sites
0 Doki391 0 Share Posted January 19, 2019 same problem.. show 11 degrees while its 3 Quote Link to post Share on other sites
0 10der 654 Share Posted January 19, 2019 Yahoo api now is proprietary,, you must have yahoo email yahoo api key and register yahoo application. we can delete yahoo source from weather sources About yr https://api.met.no/ Quote Link to post Share on other sites
0 Thomasn 73 Share Posted January 20, 2019 On 1/16/2019 at 11:44 PM, Soft said: I think that is a valid reply I have remote access now, using a 4g modem. But my point is still valid, having the weather is the senter of the screen in all marketing from Fibaro Definitely. Quote Link to post Share on other sites
0 10der 654 Share Posted January 20, 2019 (edited) --[[ %% properties %% events %% globals --]] function dump(o) if type(o) == 'table' then local s = '{ ' for k,v in pairs(o) do if type(k) ~= 'number' then k = '"'..k..'"' end s = s .. '['..k..'] = ' .. dump(v) .. ',' end return s .. '} ' else return tostring(o) end end function parseXml(xml, fast) local namePattern = "[%a_:][%w%.%-_:]*" if not fast then xml = string.gsub(xml, "<!%[CDATA%[(.-)%]%]>", xmlEscape) -- replace CDATA with escaped text xml = string.gsub(xml, "<%?.-%?>", "") -- remove processing instructions xml = string.gsub(xml, "<!%-%-.-%-%->", "") -- remove comments xml = string.gsub(xml, "<!.->", "") end local root = {} local parents = {} local element = root for closing, name, attributes, empty, text in string.gmatch( xml, "<(/?)(" .. namePattern .. ")(.-)(/?)>%s*([^<]*)%s*" ) do if closing == "/" then local parent = parents[element] if parent and name == element.name then element = parent end else local child = {name = name, attribute = {}} table.insert(element, child) parents[child] = element if empty ~= "/" then element = child end for name, value in string.gmatch(attributes, "(" .. namePattern .. ')%s*=%s*"(.-)"') do child.attribute[name] = fast and value or xmlUnescape(value) end end if text ~= "" then local child = {text = fast and text or xmlUnescape(text)} table.insert(element, child) parents[child] = element end end return root[1] end function path(nodes, ...) nodes = {nodes} local arg = {...} for i, name in ipairs(arg) do local match = {} for i, node in ipairs(nodes) do for i, child in ipairs(node) do if child.name == name then table.insert(match, child) end end end nodes = match end return nodes end local controlHeaders = { ["User-Agent"] = "FibaroHC2/0.1", ["Content-Type"] = "application/json; charset=utf-8", ["Accept"] = "application/json, text/javascript, */*; q=0.01" } function yrWeather(url, onresult) local httpClient = net.HTTPClient() httpClient:request( url, { options = { headers = controlHeaders, method = "GET" }, success = function(response) if response.status == 200 then -- HTTP 200 => OK onresult(response.data) else print(response.status) end end, error = function(err) print(err) end } ) end function readAll(file) local f = assert(io.open(file, "rb")) local content = f:read("*all") f:close() return content end function getValue(item, name) local entity = path(item, "location", name)[1] if entity then return entity.attribute end return {} end local _forecast = { fromTime = "", toTime = "", windDirection = "", windSpeed = "", humidity = 0, pressure = 0, temperature = 0, minTemperature = 0, maxTemperature = 0, symbol = "", symbolId = 0 } function getForecast(fromStr, toStr, item) _forecast.fromTime = fromStr; _forecast.toTime = toStr; if fromStr == toStr then _forecast.temperature = getValue(item, "temperature").value _forecast.windDirection = getValue(item, "windDirection").name _forecast.windSpeed = getValue(item, "windSpeed").mps _forecast.humidity = getValue(item, "humidity").value _forecast.pressure = getValue(item, "pressure").value else local minTemperature = getValue(item, "minTemperature").value local maxTemperature = getValue(item, "maxTemperature").value if minTemperature and maxTemperature then local symbol = getValue(item, "symbol").id _forecast.symbol = symbol _forecast.symbolId = getValue(item, "symbol").number _forecast.minTemperature = minTemperature _forecast.maxTemperature = maxTemperature end end end function yrWeatherParse(xml) local dom = parseXml(xml, true) for i, itemTime in ipairs(path(dom, "product", "time")) do local fromStr = itemTime.attribute["from"] local toStr = itemTime.attribute["to"] local inYear, inMonth, inDay, inHour, inMinute, inSecond, inZone = string.match(fromStr, "^(%d%d%d%d)-(%d%d)-(%d%d)T(%d%d):(%d%d):(%d%d)(.-)$") local x = os.difftime( os.time(), os.time {day = inDay, year = inYear, month = inMonth, hour = inHour, min = inMinute, sec = inSecond} ) if x < 0 and math.abs(x) < (60 * 60) then getForecast(fromStr, toStr, itemTime) end end return _forecast; end local globName = "met_no" function getLastForecast() local v, m = fibaro:getGlobal(globName) if m == nil then api.post( "/globalVariables/", { name = globName } ) fibaro:sleep(400) api.put( "/globalVariables/" .. globName, { name = globName, value = json.encode({}), isEnum = true, enumValues = {"Table"} } ) return {}, 0 else return json.decode(v), m end end local v, m = getLastForecast() if (os.time() - m >= 60 * 30 ) or (v.symbol == nil) then local location = api.get("/settings/location") local url = string.format( "https://api.met.no/weatherapi/locationforecast/1.9/?lat=%s&lon=%s", location.latitude, location.longitude ) yrWeather( url, function(data) print("Update weather from site"); local forecast = yrWeatherParse(data) fibaro:setGlobal(globName, json.encode(forecast)); -- print(dump(forecast)); end ) else -- print("Update weather from cache"); -- print(dump(v)); end Weather_forecast.vfib Edited January 21, 2019 by 10der 1 Quote Link to post Share on other sites
0 DoDoR 1 Share Posted January 20, 2019 @10der thank you! can you please explain how to do it, the process? Thx Doron 10/5000 Quote Link to post Share on other sites
0 10der 654 Share Posted January 20, 2019 (edited) On 1/20/2019 at 1:34 PM, DoDoR said: thank you! can you please explain how to do it, the process? just create a scene. schedule or call this scene from your VD after the calling in global var now we have json object in "met_no" parameter. local forecast = { fromTime, -- from period for forecast toTime, -- into period for forecast windDirection, -- wind direction (string) humidity, -- humidity (%) pressure, -- pressure (hPa) minTemperature, -- minimim temperature for this period (celsius) maxTemperature, -- maximim temperature for this period symbol , -- forecast symbol symbolId -- forecast symbol Id } -- where symbol and symbolId id [1] --Sun [2] --LightCloud [3] --PartlyCloud [4] --Cloud [5] --LightRainSun [6] --LightRainThunderSun [7] --SleetSun [8] --SnowSun [9] --LightRain [10] --Rain [11] --RainThunder [12] --Sleet [13] --Snow [14] --SnowThunder [15] --Fog [20] --SleetSunThunder [21] --SnowSunThunder [22] --LightRainThunder [23] --SleetThunder [24] --DrizzleThunderSun [25] --RainThunderSun [26] --LightSleetThunderSun [27] --HeavySleetThunderSun [28] --LightSnowThunderSun [29] --HeavySnowThunderSun [30] --DrizzleThunder [31] --LightSleetThunder [32] --HeavySleetThunder [33] --LightSnowThunder [34] --HeavySnowThunder [40] --DrizzleSun [41] --RainSun [42] --LightSleetSun [43] --HeavySleetSun [44] --LightSnowSun [45] --HeavysnowSun [46] --Drizzle [47] --LightSleet [48] --HeavySleet [49] --LightSnow [50] --HeavySnow that's all. now you can display forecast data in your VD local value = fibaro:getGlobalValue("met_no") local forecast = json.decode(value); you may call scene with any time discreteness. script override your calling according to yr.no poll policy. my scene poll site api with 30m time discreteness. OK! in attachment sample VD, please do not ask me to adopt this VD for you, please make any change by itself. thank you for understanding. Edited January 21, 2019 by 10der Quote Link to post Share on other sites
Question
@jorgei 0
Hi. I can't get YR to find my destination automaticly, and i suppose that is the reason why i have no weatherdata from yr plugin. My Home Center top menu looks like this:
Anyone?
Link to post
Share on other sites
24 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.