Smarthome Functionen
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

rooms.py 934B

1234567891011121314151617181920212223242526272829
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. import logging
  5. import task
  6. try:
  7. from config import APP_NAME as ROOT_LOGGER_NAME
  8. except ImportError:
  9. ROOT_LOGGER_NAME = 'root'
  10. logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
  11. # TODO: all_off: getattr and identify switchable devices switch those off (default method of device)
  12. # - all devices are as attributes in the room class
  13. # - implement a all_off blacklist to be initialised while __init__
  14. # TODO: implement all off and user feedback method (all off save)
  15. class room(object):
  16. def __init__(self, mqtt_client):
  17. self.mqtt_client = mqtt_client
  18. def all_off(self, device=None, key=None, data=None):
  19. logger.info("Switching all off \"%s\"", type(self).__name__)
  20. try:
  21. self.main_light_shelly.all_off()
  22. except AttributeError:
  23. logger.exception("Device self.main_light does not exist!")