Browse Source

Fix for warning import

tags/v1.3.0
Dirk Alders 1 year ago
parent
commit
b181478258

+ 1
- 1
__test__/devices/test_my_powerplug.py View File

1
 from module import mqtt_test_client, init_state, state_change_by_mqtt
1
 from module import mqtt_test_client, init_state, state_change_by_mqtt
2
 from devices import my_powerplug as test_device
2
 from devices import my_powerplug as test_device
3
-from devices import warning
3
+from devices.base import warning
4
 from mqtt import mqtt_client
4
 from mqtt import mqtt_client
5
 import pytest
5
 import pytest
6
 import time
6
 import time

+ 2
- 2
__test__/devices/test_shelly.py View File

1
 from module import mqtt_test_client, init_state, state_change_by_mqtt
1
 from module import mqtt_test_client, init_state, state_change_by_mqtt
2
-from devices import shelly as test_device
3
-from devices import warning
2
+from devices import shelly_sw1 as test_device
3
+from devices.base import warning
4
 from mqtt import mqtt_client
4
 from mqtt import mqtt_client
5
 import pytest
5
 import pytest
6
 import time
6
 import time

+ 1
- 1
__test__/devices/test_silvercrest_motion_sensor.py View File

1
 from module import mqtt_test_client, init_state, state_change_by_mqtt
1
 from module import mqtt_test_client, init_state, state_change_by_mqtt
2
 from devices import silvercrest_motion_sensor as test_device
2
 from devices import silvercrest_motion_sensor as test_device
3
-from devices import warning
3
+from devices.base import warning
4
 from mqtt import mqtt_client
4
 from mqtt import mqtt_client
5
 import pytest
5
 import pytest
6
 import time
6
 import time

+ 1
- 1
__test__/devices/test_silvercrest_powerplug.py View File

1
 from module import mqtt_test_client, init_state, state_change_by_mqtt
1
 from module import mqtt_test_client, init_state, state_change_by_mqtt
2
 from devices import silvercrest_powerplug as test_device
2
 from devices import silvercrest_powerplug as test_device
3
-from devices import warning
3
+from devices.base import warning
4
 from mqtt import mqtt_client
4
 from mqtt import mqtt_client
5
 import pytest
5
 import pytest
6
 import time
6
 import time

+ 0
- 21
devices/__init__.py View File

100
                 return getattr(self[0], name)
100
                 return getattr(self[0], name)
101
         else:
101
         else:
102
             return rv
102
             return rv
103
-
104
-
105
-class warning(dict):
106
-    TYPE_BATTERY_LOW = 1
107
-    TYPE_OVERTEMPERATURE = 2
108
-    #
109
-    KEY_ID = 'id'
110
-    KEY_TYPE = 'type'
111
-    KEY_TEXT = 'text'
112
-    KEY_TM = 'tm'
113
-
114
-    def __init__(self, identification, type, text, args):
115
-        super().__init__({
116
-            self.KEY_ID: identification,
117
-            self.KEY_TYPE: type,
118
-            self.KEY_TEXT: text % args,
119
-            self.KEY_TM: time.localtime(),
120
-        })
121
-
122
-    def __str__(self):
123
-        return time.asctime(self.get(self.KEY_TM)) + ": " + self[self.KEY_TEXT] + " - " + self[self.KEY_ID]

+ 22
- 0
devices/base.py View File

4
 from base import mqtt_base
4
 from base import mqtt_base
5
 from base import videv_base
5
 from base import videv_base
6
 import json
6
 import json
7
+import time
7
 
8
 
8
 BATTERY_WARN_LEVEL = 10
9
 BATTERY_WARN_LEVEL = 10
9
 
10
 
102
                     self.mqtt_client.send('/'.join([self.topic, key, self.TX_TOPIC] if len(self.TX_TOPIC) > 0 else [self.topic, key]), data)
103
                     self.mqtt_client.send('/'.join([self.topic, key, self.TX_TOPIC] if len(self.TX_TOPIC) > 0 else [self.topic, key]), data)
103
         else:
104
         else:
104
             self.logger.error("Unknown tx toptic. Set TX_TOPIC of class to a known value")
105
             self.logger.error("Unknown tx toptic. Set TX_TOPIC of class to a known value")
106
+
107
+
108
+class warning(dict):
109
+    TYPE_BATTERY_LOW = 1
110
+    TYPE_OVERTEMPERATURE = 2
111
+    #
112
+    KEY_ID = 'id'
113
+    KEY_TYPE = 'type'
114
+    KEY_TEXT = 'text'
115
+    KEY_TM = 'tm'
116
+
117
+    def __init__(self, identification, type, text, args):
118
+        super().__init__({
119
+            self.KEY_ID: identification,
120
+            self.KEY_TYPE: type,
121
+            self.KEY_TEXT: text % args,
122
+            self.KEY_TM: time.localtime(),
123
+        })
124
+
125
+    def __str__(self):
126
+        return time.asctime(self.get(self.KEY_TM)) + ": " + self[self.KEY_TEXT] + " - " + self[self.KEY_ID]

+ 1
- 0
devices/brennenstuhl.py View File

3
 #
3
 #
4
 from devices.base import base
4
 from devices.base import base
5
 from devices.base import BATTERY_WARN_LEVEL
5
 from devices.base import BATTERY_WARN_LEVEL
6
+from devices.base import warning
6
 import json
7
 import json
7
 
8
 
8
 
9
 

+ 1
- 0
devices/shelly.py View File

2
 # -*- coding: utf-8 -*-
2
 # -*- coding: utf-8 -*-
3
 #
3
 #
4
 from devices.base import base
4
 from devices.base import base
5
+from devices.base import warning
5
 import logging
6
 import logging
6
 import task
7
 import task
7
 
8
 

+ 1
- 0
devices/silvercrest.py View File

2
 # -*- coding: utf-8 -*-
2
 # -*- coding: utf-8 -*-
3
 #
3
 #
4
 from devices.base import base
4
 from devices.base import base
5
+from devices.base import warning
5
 import logging
6
 import logging
6
 
7
 
7
 
8
 

+ 1
- 0
devices/tradfri.py View File

3
 #
3
 #
4
 from devices.base import base
4
 from devices.base import base
5
 from devices.base import BATTERY_WARN_LEVEL
5
 from devices.base import BATTERY_WARN_LEVEL
6
+from devices.base import warning
6
 import logging
7
 import logging
7
 
8
 
8
 
9
 

Loading…
Cancel
Save