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.

54 lines
1.1KB

  1. # -*- coding: utf-8 -*-
  2. import subprocess
  3. import time
  4. from modules import cbpi, socketio
  5. from modules.core.hardware import SensorActive
  6. from modules import cbpi
  7. from modules.core.props import Property
  8. @cbpi.sensor
  9. class DummyTempSensor(SensorActive):
  10. temp = Property.Number("Temperature", configurable=True, default_value=5, description="Dummy Temperature as decimal value")
  11. @cbpi.action("My Custom Action")
  12. def my_action(self):
  13. print("HELLO WORLD")
  14. pass
  15. def get_unit(self):
  16. '''
  17. :return: Unit of the sensor as string. Should not be longer than 3 characters
  18. '''
  19. return "°C" if self.get_config_parameter("unit", "C") == "C" else "°F"
  20. def stop(self):
  21. SensorActive.stop(self)
  22. def execute(self):
  23. '''
  24. Active sensor has to handle his own loop
  25. :return:
  26. '''
  27. while self.is_running() is True:
  28. self.data_received(self.temp)
  29. self.sleep(5)
  30. @classmethod
  31. def init_global(cls):
  32. '''
  33. Called one at the startup for all sensors
  34. :return:
  35. '''