Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

48 строки
1.1KB

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