Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

67 linhas
1.8KB

  1. # -*- coding: utf-8 -*-
  2. import os
  3. from os.path import join
  4. from modules.core.basetypes import Actor, Sensor, Action
  5. from modules 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(label="Set Dummy Temp", parameters={
  18. "p1":Property.Select(label="Temp",options=[1,2,3]),
  19. })
  20. def myaction(self, p1):
  21. self.text = p1
  22. self.update_value(int(p1))
  23. def execute(self):
  24. while True:
  25. try:
  26. self.update_value(int(self.text))
  27. except:
  28. pass
  29. self.api.sleep(5)
  30. @cbpi.addon.core.action(name="Delete All Logs")
  31. class ParameterAction(Action):
  32. p1 = Property.Number("P1", configurable=True, description="Target Temperature of Mash Step", unit="C")
  33. p2 = Property.Number("P2", configurable=True, description="Target Temperature of Mash Step", unit="C")
  34. def execute(self, p1, p2, **kwargs):
  35. for i in range(5):
  36. cbpi.sleep(1)
  37. cbpi.notify(headline="Woohoo", message="%s %s" % (p1, p2))
  38. @cbpi.addon.core.action(name="Delete All Logs")
  39. class DeleteAllLogs(Action):
  40. def execute(self, **kwargs):
  41. dir = "./logs"
  42. test = os.listdir(dir)
  43. for item in test:
  44. if item.endswith(".log"):
  45. os.remove(join(dir, item))
  46. cbpi.notify(headline="Logs Deleted", message="All Logs Cleared")