25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.2KB

  1. # -*- coding: utf-8 -*-
  2. import os
  3. from os.path import join
  4. from modules.core.basetypes import Actor, Sensor
  5. from modules.core.core import cbpi
  6. from modules.core.proptypes import Property
  7. import random
  8. print "INit SENSOR"
  9. @cbpi.addon.sensor.type("Dummy Sensor")
  10. class Dummy(Sensor):
  11. text = Property.Text(label="Text", required=True, description="This is a parameter", configurable=True)
  12. p = Property.Select(label="hallo",options=[1,2,3])
  13. def init(self):
  14. if self.api.get_config_parameter("unit","C") == "C":
  15. self.unit = "°C"
  16. else:
  17. self.unit = "°F"
  18. @cbpi.addon.sensor.action("WOHOO")
  19. def myaction(self):
  20. print self.text
  21. print "SENSOR ACTION HALLO!!!"
  22. def execute(self):
  23. while True:
  24. try:
  25. self.update_value(int(self.text))
  26. except:
  27. pass
  28. self.api.sleep(1)
  29. @cbpi.addon.core.action(key="clear", label="Clear all Logs")
  30. def woohoo(cbpi):
  31. print "COOL"
  32. dir = "./logs"
  33. test = os.listdir(dir)
  34. for item in test:
  35. if item.endswith(".log"):
  36. os.remove(join(dir, item))
  37. cbpi.notify(headline="Logs Deleted",message="All Logs Cleared")