2022-12-20 14:05:32 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
#
|
|
|
|
|
|
|
|
import logging
|
2022-12-21 17:04:55 +01:00
|
|
|
import task
|
2022-12-20 14:05:32 +01:00
|
|
|
|
|
|
|
try:
|
|
|
|
from config import APP_NAME as ROOT_LOGGER_NAME
|
|
|
|
except ImportError:
|
|
|
|
ROOT_LOGGER_NAME = 'root'
|
|
|
|
logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
|
|
|
|
|
2023-01-25 07:40:33 +01:00
|
|
|
# TODO: all_off: getattr and identify switchable devices switch those off (default method of device)
|
|
|
|
# - all devices are as attributes in the room class
|
|
|
|
# - implement a all_off blacklist to be initialised while __init__
|
|
|
|
# TODO: implement all off and user feedback method (all off save)
|
|
|
|
|
2022-12-20 14:05:32 +01:00
|
|
|
|
|
|
|
class room(object):
|
2022-12-21 07:12:17 +01:00
|
|
|
def __init__(self, mqtt_client):
|
|
|
|
self.mqtt_client = mqtt_client
|
2023-01-26 08:25:40 +01:00
|
|
|
|
|
|
|
def all_off(self, device=None, key=None, data=None):
|
|
|
|
logger.info("Switching all off \"%s\"", type(self).__name__)
|
2023-01-25 07:40:33 +01:00
|
|
|
try:
|
2023-01-26 08:25:40 +01:00
|
|
|
self.main_light_shelly.all_off()
|
2023-01-25 07:40:33 +01:00
|
|
|
except AttributeError:
|
|
|
|
logger.exception("Device self.main_light does not exist!")
|