Pārlūkot izejas kodu

Fix for warning import

tags/v1.3.0
Dirk Alders 1 gadu atpakaļ
vecāks
revīzija
b181478258

+ 1
- 1
__test__/devices/test_my_powerplug.py Parādīt failu

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

+ 2
- 2
__test__/devices/test_shelly.py Parādīt failu

@@ -1,6 +1,6 @@
1 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 4
 from mqtt import mqtt_client
5 5
 import pytest
6 6
 import time

+ 1
- 1
__test__/devices/test_silvercrest_motion_sensor.py Parādīt failu

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

+ 1
- 1
__test__/devices/test_silvercrest_powerplug.py Parādīt failu

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

+ 0
- 21
devices/__init__.py Parādīt failu

@@ -100,24 +100,3 @@ class group(object):
100 100
                 return getattr(self[0], name)
101 101
         else:
102 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 Parādīt failu

@@ -4,6 +4,7 @@
4 4
 from base import mqtt_base
5 5
 from base import videv_base
6 6
 import json
7
+import time
7 8
 
8 9
 BATTERY_WARN_LEVEL = 10
9 10
 
@@ -102,3 +103,24 @@ class base(mqtt_base):
102 103
                     self.mqtt_client.send('/'.join([self.topic, key, self.TX_TOPIC] if len(self.TX_TOPIC) > 0 else [self.topic, key]), data)
103 104
         else:
104 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 Parādīt failu

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

+ 1
- 0
devices/shelly.py Parādīt failu

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

+ 1
- 0
devices/silvercrest.py Parādīt failu

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

+ 1
- 0
devices/tradfri.py Parādīt failu

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

Notiek ielāde…
Atcelt
Saglabāt