RainEagle library plus script for polling data
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

57 lines
1.3 KiB

  1. import RainEagle
  2. import time
  3. from pprint import pprint
  4. def too_unix_time(t) :
  5. """ converts time stored as
  6. offset in seconds from "Jan 1 00:00:00 2000"
  7. to unix's epoch of 1970
  8. """
  9. if isinstance(t, (int, long, float) ) :
  10. return t + 946684800
  11. if isinstance(t, str) and t.startswith('0x') :
  12. return 946684800 + int(t, 16)
  13. eg = RainEagle.Eagle( debug=0 , addr="10.1.1.39")
  14. print "\nlist_devices :"
  15. r = eg.list_devices()
  16. pprint(r)
  17. # print "\nget_device_data :"
  18. # r = eg.get_device_data()
  19. # pprint(r)
  20. # time_stamp_str=r['InstantaneousDemand']['TimeStamp']
  21. # time_stamp = eg.to_unix_time(time_stamp_str)
  22. # print "time = ", time.asctime(time.localtime(time_stamp))
  23. print "\nget_instantaneous_demand :"
  24. r = eg.get_instantaneous_demand()
  25. pprint(r)
  26. print "\nget_demand_values :"
  27. r = eg.get_demand_values(eg.macid, interval="hour")
  28. pprint(r)
  29. print "\nget_summation_values :"
  30. r = eg.get_summation_values(eg.macid, interval="day")
  31. pprint(r)
  32. # set_fast_poll(self, macid=None, frequency, duration) :
  33. print "\nget_fast_poll_status :"
  34. r = eg.get_fast_poll_status(eg.macid)
  35. pprint(r)
  36. etime = eg.to_unix_time( r['FastPollStatus']['EndTime'])
  37. print "EndTime = ", time.asctime(time.localtime(etime))
  38. # def get_history_data(self, macid=None, starttime,
  39. # endtime=None, frequency=None ) :