all off improved
This commit is contained in:
parent
43308d858e
commit
d4c5411d47
@ -98,11 +98,6 @@ class all_functions(object):
|
|||||||
rv.append(obj)
|
rv.append(obj)
|
||||||
return rv
|
return rv
|
||||||
|
|
||||||
def common_off(self, device=None, key=None, data=None):
|
|
||||||
logger.info("Switching \"common\" off.")
|
|
||||||
for common in self.getmembers('common'):
|
|
||||||
common.all_off()
|
|
||||||
|
|
||||||
def gfw_off(self, device=None, key=None, data=None):
|
def gfw_off(self, device=None, key=None, data=None):
|
||||||
logger.info("Switching \"ground floor west\" off.")
|
logger.info("Switching \"ground floor west\" off.")
|
||||||
for gfw in self.getmembers('gfw'):
|
for gfw in self.getmembers('gfw'):
|
||||||
@ -124,20 +119,7 @@ class all_functions(object):
|
|||||||
stw.all_off()
|
stw.all_off()
|
||||||
|
|
||||||
def all_off(self, device=None, key=None, data=None):
|
def all_off(self, device=None, key=None, data=None):
|
||||||
self.common_off(device, key, data)
|
for name, obj in inspect.getmembers(self):
|
||||||
self.gfw_off(device, key, data)
|
parent_name = obj.__class__.__base__.__name__
|
||||||
self.ffw_off(device, key, data)
|
if parent_name == "room":
|
||||||
self.ffe_off(device, key, data)
|
obj.all_off()
|
||||||
self.stw_off(device, key, data)
|
|
||||||
|
|
||||||
def devicelist(self):
|
|
||||||
if self.__devices__ is None:
|
|
||||||
self.__devices__ = []
|
|
||||||
for name, obj in inspect.getmembers(self):
|
|
||||||
if obj.__class__.__module__ == "devices":
|
|
||||||
self.__devices__.append(obj)
|
|
||||||
elif obj.__class__.__module__.split('.')[0] == 'function':
|
|
||||||
for devicename, device in inspect.getmembers(obj):
|
|
||||||
if device.__class__.__module__ == "devices":
|
|
||||||
self.__devices__.append(device)
|
|
||||||
return self.__devices__
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import task
|
import inspect
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from config import APP_NAME as ROOT_LOGGER_NAME
|
from config import APP_NAME as ROOT_LOGGER_NAME
|
||||||
@ -11,11 +11,6 @@ except ImportError:
|
|||||||
ROOT_LOGGER_NAME = 'root'
|
ROOT_LOGGER_NAME = 'root'
|
||||||
logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
|
logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
|
||||||
|
|
||||||
# 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)
|
|
||||||
|
|
||||||
|
|
||||||
class room(object):
|
class room(object):
|
||||||
def __init__(self, mqtt_client):
|
def __init__(self, mqtt_client):
|
||||||
@ -23,7 +18,9 @@ class room(object):
|
|||||||
|
|
||||||
def all_off(self, device=None, key=None, data=None):
|
def all_off(self, device=None, key=None, data=None):
|
||||||
logger.info("Switching all off \"%s\"", type(self).__name__)
|
logger.info("Switching all off \"%s\"", type(self).__name__)
|
||||||
try:
|
for name, obj in inspect.getmembers(self):
|
||||||
self.main_light_shelly.all_off()
|
try:
|
||||||
except AttributeError:
|
if obj.__module__ == 'devices':
|
||||||
logger.exception("Device self.main_light does not exist!")
|
obj.all_off()
|
||||||
|
except AttributeError:
|
||||||
|
pass # not a module or has no method all_off
|
||||||
|
Loading…
x
Reference in New Issue
Block a user