選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

48 行
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")