Browse Source

devicelist method implemented

tags/v1.0.0
Dirk Alders 2 years ago
parent
commit
7a639e0d8f
2 changed files with 7 additions and 10 deletions
  1. 7
    7
      function/__init__.py
  2. 0
    3
      smart_brain.py

+ 7
- 7
function/__init__.py View File

@@ -5,6 +5,7 @@ import devices
5 5
 from function.ground_floor_west import ground_floor_west_floor, ground_floor_west_marion, ground_floor_west_dirk
6 6
 from function.first_floor_west import first_floor_west_julian, first_floor_west_living
7 7
 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
8
+import inspect
8 9
 
9 10
 # TODO: implement bed light dirk fading by input device
10 11
 # TODO: implement heating function sleep_madi
@@ -12,7 +13,7 @@ from function.first_floor_east import first_floor_east_floor, first_floor_east_k
12 13
 # TODO: implement switch off functionality (except of switch off button transportation)
13 14
 # TODO: implement garland (incl. day events like sunset, sunrise, ...)
14 15
 # TODO: implement existing nodered functionality "dirk" (ground floor west)
15
-# TODO: implement warning message (incl. fixing all_functions.devicelist
16
+# TODO: implement warning message
16 17
 
17 18
 
18 19
 class all_functions(object):
@@ -52,12 +53,11 @@ class all_functions(object):
52 53
                                                    self.ffe_floor.toggle_main_light)
53 54
 
54 55
     def devicelist(self):
55
-        raise Exception
56
-        # TODO: generate list by using getattr
57 56
         if self.__devices__ is None:
58 57
             self.__devices__ = []
59
-            for room in self.rooms:
60
-                for name, obj in inspect.getmembers(room):
61
-                    if type(obj) in devices.DEVICE_TYPE_LIST():
62
-                        self.__devices__.append(obj)
58
+            for name, obj in inspect.getmembers(self):
59
+                if obj.__class__.__module__.split('.')[0] == 'function':
60
+                    for devicename, device in inspect.getmembers(obj):
61
+                        if device.__class__.__module__ == "devices":
62
+                            self.__devices__.append(device)
63 63
         return self.__devices__

+ 0
- 3
smart_brain.py View File

@@ -1,10 +1,7 @@
1 1
 import config
2
-import devices
3 2
 import function
4
-import inspect
5 3
 import logging
6 4
 import mqtt
7
-import os
8 5
 import report
9 6
 import time
10 7
 

Loading…
Cancel
Save