Smarthome Functionen
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.

garden.py 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. import config
  5. import devdi.topic as props
  6. from function.helpers import day_event
  7. from function.rooms import room, room_collection
  8. from function.videv import videv_switching, videv_pure_switch
  9. import logging
  10. try:
  11. from config import APP_NAME as ROOT_LOGGER_NAME
  12. except ImportError:
  13. ROOT_LOGGER_NAME = 'root'
  14. logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
  15. loc = props.LOC_GAR
  16. class garden(room_collection):
  17. def __init__(self, mqtt_client, pd, vd):
  18. super().__init__(mqtt_client, pd, vd)
  19. self.garden = garden_garden(mqtt_client, pd, vd)
  20. class garden_garden(room):
  21. def __init__(self, mqtt_client, pd, vd):
  22. roo = props.ROO_GAR
  23. #
  24. # Device initialisation
  25. #
  26. self.day_events = day_event((6, 0), (22, 0), 30, -30)
  27. self.garland_powerplug = pd.get(props.STG_ZGW, loc, roo, props.FUN_GAR)
  28. super().__init__(mqtt_client, pd, vd)
  29. #
  30. # Functionality initialisation
  31. #
  32. self.day_events.add_callback(None, True, self.__day_events__, True)
  33. #
  34. # Virtual Device Interface
  35. #
  36. # mode
  37. self.mode_videv = videv_pure_switch(
  38. mqtt_client, config.TOPIC_GAR_GARDEN_MODE_VIDEV
  39. )
  40. # garland
  41. self.garland_videv = videv_switching(
  42. mqtt_client, config.TOPIC_GAR_GARDEN_GARLAND_VIDEV,
  43. self.garland_powerplug, self.garland_powerplug.KEY_OUTPUT_0
  44. )
  45. def __day_events__(self, device, key, data):
  46. if self.mode_videv.get(self.mode_videv.KEY_STATE):
  47. if key in (self.day_events.KEY_SUNSET, self.day_events.KEY_START_OF_DAY):
  48. self.garland_powerplug.set_output_0(True)
  49. elif key in (self.day_events.KEY_START_OF_NIGHT, self.day_events.KEY_SUNRISE):
  50. self.garland_powerplug.set_output_0(False)