Guest User

Domoticz - Raspi uitschakelen als UPS op accu

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