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.

49 lines
976B

  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)
  11. def get_unit(self):
  12. '''
  13. :return: Unit of the sensor as string. Should not be longer than 3 characters
  14. '''
  15. return "°C" if self.get_config_parameter("unit", "C") == "C" else "°F"
  16. def stop(self):
  17. SensorActive.stop(self)
  18. def execute(self):
  19. '''
  20. Active sensor has to handle his own loop
  21. :return:
  22. '''
  23. while self.is_running() is True:
  24. self.data_received(self.temp)
  25. socketio.sleep(5)
  26. @classmethod
  27. def init_global(cls):
  28. '''
  29. Called one at the startup for all sensors
  30. :return:
  31. '''