Smarthome Functionen
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

garden.py 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. # garden powerplugs
  28. self.garland_powerplug = pd.get(props.STG_ZGW, loc, roo, props.FUN_GAR)
  29. # repeater
  30. self.repeater = pd.get(props.STG_ZGW, loc, roo, props.FUN_REP)
  31. super().__init__(mqtt_client, pd, vd)
  32. #
  33. # Functionality initialisation
  34. #
  35. self.day_events.add_callback(None, True, self.__day_events__, True)
  36. #
  37. # Virtual Device Interface
  38. #
  39. # mode
  40. self.mode_videv = videv_pure_switch(
  41. mqtt_client, config.TOPIC_GAR_GARDEN_MODE_VIDEV
  42. )
  43. # garland
  44. self.garland_videv = videv_switching(
  45. mqtt_client, config.TOPIC_GAR_GARDEN_GARLAND_VIDEV,
  46. self.garland_powerplug, self.garland_powerplug.KEY_OUTPUT_0
  47. )
  48. # repeater
  49. self.repeater_videv = videv_switching(
  50. mqtt_client, config.TOPIC_GAR_GARDEN_REPEATER_VIDEV,
  51. self.repeater, self.repeater.KEY_OUTPUT_0
  52. )
  53. def __day_events__(self, device, key, data):
  54. if self.mode_videv.get(self.mode_videv.KEY_STATE):
  55. if key in (self.day_events.KEY_SUNSET, self.day_events.KEY_START_OF_DAY):
  56. self.garland_powerplug.set_output_0(True)
  57. elif key in (self.day_events.KEY_START_OF_NIGHT, self.day_events.KEY_SUNRISE):
  58. self.garland_powerplug.set_output_0(False)