Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- schakel de pi uit indien meer dan 10 minuten op ups
- commandArray = {}
- if (otherdevices['UPS Status'] ~= 'Off') then
- -- print('UPS draait op 230V. Alles in orde, niets doen')
- return
- end
- print('UPS draait op accu!! na 10 minuten (600 sec) RaspberryPi uitschakelen')
- t1 = os.time()
- s = otherdevices_lastupdate['UPS Status']
- -- returns a date time like 2013-07-11 17:23:12
- year = string.sub(s, 1, 4)
- month = string.sub(s, 6, 7)
- day = string.sub(s, 9, 10)
- hour = string.sub(s, 12, 13)
- minutes = string.sub(s, 15, 16)
- seconds = string.sub(s, 18, 19)
- t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
- difference = (os.difftime (t1,t2))
- print('UPS draait al '..difference..' seconden op zijn accu.')
- if (difference > 600 ) then
- print('PI uitschakelen')
- -- Testen en -- weghalen
- print('Voordat de pi uitgaat, eerst de UPS Status switch weer aanzetten, anders gaat hij bij het booten direct weer uit!!')
- os.execute('curl -s -i -H "Accept: application/json" "http://<login>:<pass>@<IP Domoticz>:8080/json.htm?type=command¶m=switchlight&idx=100&switchcmd=On&level=0"')
- os.execute('curl -s -i -H "Accept: application/json" "http://<login>:<pass>@<IP Domoticz>:8080/json.htm?type=command¶m=system_shutdown"')
- end
- return commandArray
Advertisement
Add Comment
Please, Sign In to add comment