{"name":"Mond-Status","type":"virtual_device","properties":{"deviceIcon":240,"currentIcon":"240","log":"","logTemp":"","mainLoop":"","ui.Label1.value":"22:41","ui.Label2.value":"Waning Gibbous = Abnehmender Mond","ui.Label3.value":"97 %","ui.Label4.value":"16.5 Tage","ui.Label5.value":"102 °","ui.Label6.value":"23.05.2016 20:52:16","visible":"true","rows":[{"type":"label","elements":[{"id":1,"lua":false,"waitForResponse":false,"caption":"Mondaufgang","name":"Label1","favourite":false,"main":false}]},{"type":"label","elements":[{"id":2,"lua":false,"waitForResponse":false,"caption":"Phase","name":"Label2","favourite":false,"main":false}]},{"type":"label","elements":[{"id":3,"lua":false,"waitForResponse":false,"caption":"Sichtbarkeit","name":"Label3","favourite":false,"main":false}]},{"type":"label","elements":[{"id":4,"lua":false,"waitForResponse":false,"caption":"Mondalter","name":"Label4","favourite":false,"main":false}]},{"type":"label","elements":[{"id":5,"lua":false,"waitForResponse":false,"caption":"Mondstand","name":"Label5","favourite":false,"main":true}]},{"type":"label","elements":[{"id":6,"lua":false,"waitForResponse":false,"caption":"Update","name":"Label6","favourite":false,"main":false}]},{"type":"button","elements":[{"id":7,"lua":true,"waitForResponse":false,"caption":"Update","name":"Button11","empty":false,"msg":"-------------------------------------------------------------------------------------------\n-- HOWTO --\n--http://www.mondverlauf.de oder \n--http://www.sonnenverlauf.de\n--API-Key von http://www.torsten-hoffmann.de/apis/suncalcmooncalc/api_en.html\n--Die Globale Variable (GV) \"Abendaemmerung\" wird benötigt; steuert anderes Script\n\nlocal APIkey = \"xxxxx\" \t-- Put your Api key here\nlocal lat = 50.000000 \t\t--Latitude des Standorttes eingeben\nlocal lon = 10.000000\t--Longitude des Standorttes eingeben\n\n\nlocal VDid = fibaro:getSelfId()\n\nfunction setDevicePropertyValue(id, label, value)\n fibaro:call(id, \"setProperty\", \"ui.\"..label..\".value\", value)\nend\n\n-------------------------------------------\nlocal FHTE = Net.FHttp(\"www.torsten-hoffmann.de\"); \nlocal response, status, errorCode = FHTE:GET(\"/apis/suncalcmooncalc/xml/?key=\"..APIkey..\"&lat=\"..lat..\"&lon=\"..lon); \nif (tonumber(status) == 200 and tonumber(errorCode)==0) then \nlocal status_resp = response:match('(.+)')\nlocal MoonPhase = response:match('(.+)') \nlocal Mondaufgang_resp = response:match('(.+)') \nlocal Mondaufgang = string.sub(Mondaufgang_resp, 1, 5); \n \n--local time = string.gsub(\"15:26 = 15.441\", \"%S+\")\n--local time = string.sub(\"15:26 = 15.441\", 1 , 5)\n \n--local Mondaufgang = split(tostring(Mondaufgang_resp), \"%S+\");\n--fibaro:debug(Mondaufgang);\n \nlocal Sichtbarkeit_resp = response:match('(.+)') \nSichtbarkeit = tonumber(string.format(\"%.0f\", Sichtbarkeit_resp)) --Runded den Wert \nlocal Mondstand_resp = response:match('(.+)') \nMondstand = tonumber(string.format(\"%.0f\", Mondstand_resp)) --Runded den Wert \nlocal Mondalter_resp = response:match('(.+)')\nMondalter = tonumber(string.format(\"%.1f\", Mondalter_resp)) --Runded den Wert \n\n-----------------------------------------------------\n--Setzt Globale Variable für andere Zwecke als dieses VD \nlocal Abendaemmerung_resp = response:match('(.+)') \nlocal Abendaemmerung = string.sub(Abendaemmerung_resp, 1, 5)\nfibaro:setGlobal(\"Abenddaemmerung\", Abendaemmerung) \n \nfibaro:debug(\"Mondstand ist: \"..Mondstand);\n\nsetDevicePropertyValue(VDid, \"Label1\", Mondaufgang)\nsetDevicePropertyValue(VDid, \"Label2\", MoonPhase)\nsetDevicePropertyValue(VDid, \"Label3\", Sichtbarkeit..\" %\") \nsetDevicePropertyValue(VDid, \"Label4\", Mondalter..\" Tage\")\nsetDevicePropertyValue(VDid, \"Label5\", Mondstand..\" °\")\n \nend\n\nDate = os.date(\"%d.%m.%Y %H:%M:%S\", os.time())\nsetDevicePropertyValue(VDid, \"Label6\", Date)","buttonIcon":239,"favourite":false,"main":true}]}]},"actions":{"pressButton":1,"setSlider":2,"setProperty":2}}