From 7a639e0d8f0b9dcb0b54de745bcabcb04e7d2bc3 Mon Sep 17 00:00:00 2001 From: Dirk Alders Date: Tue, 20 Dec 2022 14:28:44 +0100 Subject: [PATCH] devicelist method implemented --- function/__init__.py | 14 +++++++------- smart_brain.py | 3 --- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/function/__init__.py b/function/__init__.py index 75f3d53..512735c 100644 --- a/function/__init__.py +++ b/function/__init__.py @@ -5,6 +5,7 @@ import devices from function.ground_floor_west import ground_floor_west_floor, ground_floor_west_marion, ground_floor_west_dirk from function.first_floor_west import first_floor_west_julian, first_floor_west_living from function.first_floor_east import first_floor_east_floor, first_floor_east_kitchen, first_floor_east_dining, first_floor_east_sleep_madi, first_floor_east_living +import inspect # TODO: implement bed light dirk fading by input device # TODO: implement heating function sleep_madi @@ -12,7 +13,7 @@ from function.first_floor_east import first_floor_east_floor, first_floor_east_k # TODO: implement switch off functionality (except of switch off button transportation) # TODO: implement garland (incl. day events like sunset, sunrise, ...) # TODO: implement existing nodered functionality "dirk" (ground floor west) -# TODO: implement warning message (incl. fixing all_functions.devicelist +# TODO: implement warning message class all_functions(object): @@ -52,12 +53,11 @@ class all_functions(object): self.ffe_floor.toggle_main_light) def devicelist(self): - raise Exception - # TODO: generate list by using getattr if self.__devices__ is None: self.__devices__ = [] - for room in self.rooms: - for name, obj in inspect.getmembers(room): - if type(obj) in devices.DEVICE_TYPE_LIST(): - self.__devices__.append(obj) + for name, obj in inspect.getmembers(self): + if 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__ diff --git a/smart_brain.py b/smart_brain.py index cd6e097..9bda580 100644 --- a/smart_brain.py +++ b/smart_brain.py @@ -1,10 +1,7 @@ import config -import devices import function -import inspect import logging import mqtt -import os import report import time