{"name":"Rain delay sprinklers","type":"virtual_device","properties":{"deviceIcon":1011,"currentIcon":"1011","log":"","logTemp":"","mainLoop":"thisId = fibaro:getSelfId();\nHC2 = Net.FHttp(\"127.0.0.1\",11111)\nresponse, status, errorCode = HC2:GET(\"/api/panels/drenchers\")\njsonTable = json.decode(response)\nseconds = jsonTable.rainDelay\nlocal hours = string.format(\"%02.f\", math.floor(seconds/3600));\nlocal mins = string.format(\"%02.f\", math.floor(seconds/60 - (hours*60)));\nlocal secs = string.format(\"%02.f\", math.floor(seconds - hours*3600 - mins *60));\nfibaro:debug(\"Hod \" ..hours);\nfibaro:debug(\"Min \" ..mins);\nfibaro:debug(\"Secs \" ..secs);\n\nif seconds > 0 then\nfibaro:call(thisId, \"setProperty\", \"ui.Label1.value\", \"Delayed: \"..hours..\":\"..mins..\":\"..secs);\n else\n fibaro:call(thisId, \"setProperty\", \"ui.Label1.value\", \"..no delay\");\n end","ui.Label1.value":"..no delay","visible":"true","rows":[{"type":"button","elements":[{"id":1,"lua":true,"waitForResponse":false,"caption":"Cancel delay","name":"Button11","empty":false,"msg":"HC2 = Net.FHttp(\"127.0.0.1\",11111)\nresponse, status, errorCode = HC2:GET(\"/api/panels/drenchers\")\njsonTable = json.decode(response)\njsonTable.rainDelay = 0\njT = json.encode(jsonTable);\nHC2:PUT(\"/api/panels/drenchers\", jT)\n--fibaro:call(2, \"sendEmail\", \"FIBARO - Závlaha\", \"Odložení startu zavlažování zrušeno!\")\nfibaro:call(79,\"sendPush\",\"Odložení startu zavlažování zrušeno!\")","buttonIcon":1011,"favourite":false,"main":false},{"id":2,"lua":true,"waitForResponse":false,"caption":"Delay 12h","name":"Button12","empty":false,"msg":"HC2 = Net.FHttp(\"127.0.0.1\",11111)\nresponse, status, errorCode = HC2:GET(\"/api/panels/drenchers\")\njsonTable = json.decode(response)\njsonTable.rainDelay = 12\njT = json.encode(jsonTable);\nHC2:PUT(\"/api/panels/drenchers\", jT)\n--fibaro:call(2, \"sendEmail\", \"FIBARO - Závlaha\", \"Prší/pršelo, zavlažování je odloženo o 12h!\")\nfibaro:call(79,\"sendPush\",\"Prší/pršelo, zavlažování je odloženo o 12h!\")","buttonIcon":1010,"favourite":false,"main":false}]},{"type":"button","elements":[{"id":3,"lua":true,"waitForResponse":false,"caption":"Delay 4h","name":"Button21","empty":false,"msg":"HC2 = Net.FHttp(\"127.0.0.1\",11111)\nresponse, status, errorCode = HC2:GET(\"/api/panels/drenchers\")\njsonTable = json.decode(response)\njsonTable.rainDelay = 4\njT = json.encode(jsonTable);\nHC2:PUT(\"/api/panels/drenchers\", jT)\n--fibaro:call(2, \"sendEmail\", \"FIBARO - Závlaha\", \"Prší/pršelo, zavlažování je odloženo o 4h!\")\nfibaro:call(79,\"sendPush\",\"Prší/pršelo, zavlažování je odloženo o 4h!\")","buttonIcon":1010,"favourite":false,"main":false},{"id":4,"lua":true,"waitForResponse":false,"caption":"Delay 8h","name":"Button22","empty":false,"msg":"HC2 = Net.FHttp(\"127.0.0.1\",11111)\nresponse, status, errorCode = HC2:GET(\"/api/panels/drenchers\")\njsonTable = json.decode(response)\njsonTable.rainDelay = 8\njT = json.encode(jsonTable);\nHC2:PUT(\"/api/panels/drenchers\", jT)\n--fibaro:call(2, \"sendEmail\", \"FIBARO - Závlaha\", \"Prší/pršelo, zavlažování je odloženo o 8h!\")\nfibaro:call(79,\"sendPush\",\"Prší/pršelo, zavlažování je odloženo o 8h!\")","buttonIcon":1010,"favourite":false,"main":false}]},{"type":"label","elements":[{"id":5,"lua":false,"waitForResponse":false,"caption":"","name":"Label1","favourite":false,"main":false}]}]},"actions":{"pressButton":1,"setSlider":2,"setProperty":2}}