|
@@ -16,8 +16,8 @@ class base(object):
|
16
|
16
|
FOLLOW_REQUEST_ERROR = 60 # Seconds, till error comes up, if device does not follow the command
|
17
|
17
|
FOLLOW_KEYS = ["current_heating_setpoint", ]
|
18
|
18
|
#
|
19
|
|
- BATTERY_LVL_WARNING = 20
|
20
|
|
- BATTERY_LVL_ERROR = 10
|
|
19
|
+ BATTERY_LVL_WARNING = 15
|
|
20
|
+ BATTERY_LVL_ERROR = 5
|
21
|
21
|
#
|
22
|
22
|
LAST_MSG_WARNING = 6 * 24 * 60 * 60
|
23
|
23
|
LAST_MSG_ERROR = 24 * 24 * 60 * 60
|
|
@@ -89,9 +89,9 @@ class base(object):
|
89
|
89
|
elif key == "battery":
|
90
|
90
|
if self.battery is None:
|
91
|
91
|
return {"status": nagios.Nagios.UNKNOWN, "msg": "Device exists, but no data received or unknown monitoring"}
|
92
|
|
- elif self.battery < self.BATTERY_LVL_ERROR:
|
|
92
|
+ elif self.battery <= self.BATTERY_LVL_ERROR:
|
93
|
93
|
return {"status": nagios.Nagios.ERROR, "msg": "Battery level critical low (%.1f%%)" % self.battery}
|
94
|
|
- elif self.battery < self.BATTERY_LVL_WARNING:
|
|
94
|
+ elif self.battery <= self.BATTERY_LVL_WARNING:
|
95
|
95
|
return {"status": nagios.Nagios.WARNING, "msg": "Battery level low (%.1f%%)" % self.battery}
|
96
|
96
|
else:
|
97
|
97
|
return {"status": nagios.Nagios.OK, "msg": "Battery okay (%.1f%%)" % self.battery}
|
|
@@ -119,7 +119,22 @@ class tradfri_sw_br_ct(base):
|
119
|
119
|
|
120
|
120
|
|
121
|
121
|
class tradfri_button(base):
|
122
|
|
- pass
|
|
122
|
+ def __rx__(self, client, userdata, message):
|
|
123
|
+ try:
|
|
124
|
+ payload = json.loads(message.payload)
|
|
125
|
+ except json.decoder.JSONDecodeError:
|
|
126
|
+ logger.warning("JSON decode error %s", self.topic)
|
|
127
|
+ else:
|
|
128
|
+ #
|
|
129
|
+ # heartbeat
|
|
130
|
+ #
|
|
131
|
+ if message.topic == self.topic:
|
|
132
|
+ self.last_device_msg = time.time()
|
|
133
|
+ #
|
|
134
|
+ # battery level
|
|
135
|
+ #
|
|
136
|
+ if "battery" in payload and message.topic == self.topic:
|
|
137
|
+ self.battery = payload["battery"]
|
123
|
138
|
|
124
|
139
|
|
125
|
140
|
class livarno_sw_br_ct(base):
|
|
@@ -127,32 +142,33 @@ class livarno_sw_br_ct(base):
|
127
|
142
|
|
128
|
143
|
|
129
|
144
|
class brennenstuhl_heatingvalve(base):
|
130
|
|
- BATTERY_LVL_WARNING = 10
|
131
|
|
- BATTERY_LVL_ERROR = 5
|
132
|
|
-
|
133
|
|
- def __init__(self, mqtt_client: mqtt.mqtt_client, topic):
|
134
|
|
- base.__init__(self, mqtt_client, topic)
|
|
145
|
+ BATTERY_LVL_WARNING = 4
|
|
146
|
+ BATTERY_LVL_ERROR = 3
|
135
|
147
|
|
136
|
148
|
def __rx__(self, client, userdata, message):
|
137
|
|
- payload = json.loads(message.payload)
|
138
|
|
- #
|
139
|
|
- # heartbeat
|
140
|
|
- #
|
141
|
|
- if message.topic == self.topic:
|
142
|
|
- self.last_device_msg = time.time()
|
143
|
|
- #
|
144
|
|
- # follow setpoint
|
145
|
|
- #
|
146
|
|
- if "current_heating_setpoint" in payload:
|
147
|
|
- if message.topic == self.topic + '/set':
|
148
|
|
- self.target("current_heating_setpoint", payload["current_heating_setpoint"])
|
|
149
|
+ try:
|
|
150
|
+ payload = json.loads(message.payload)
|
|
151
|
+ except json.decoder.JSONDecodeError:
|
|
152
|
+ logger.warning("JSON decode error %s", self.topic)
|
|
153
|
+ else:
|
|
154
|
+ #
|
|
155
|
+ # heartbeat
|
|
156
|
+ #
|
149
|
157
|
if message.topic == self.topic:
|
150
|
|
- self.state("current_heating_setpoint", payload["current_heating_setpoint"])
|
151
|
|
- #
|
152
|
|
- # battery level
|
153
|
|
- #
|
154
|
|
- if "battery" in payload and message.topic == self.topic:
|
155
|
|
- self.battery = payload["battery"]
|
|
158
|
+ self.last_device_msg = time.time()
|
|
159
|
+ #
|
|
160
|
+ # follow setpoint
|
|
161
|
+ #
|
|
162
|
+ if "current_heating_setpoint" in payload:
|
|
163
|
+ if message.topic == self.topic + '/set':
|
|
164
|
+ self.target("current_heating_setpoint", payload["current_heating_setpoint"])
|
|
165
|
+ if message.topic == self.topic:
|
|
166
|
+ self.state("current_heating_setpoint", payload["current_heating_setpoint"])
|
|
167
|
+ #
|
|
168
|
+ # battery level
|
|
169
|
+ #
|
|
170
|
+ if "battery" in payload and message.topic == self.topic:
|
|
171
|
+ self.battery = payload["battery"]
|
156
|
172
|
|
157
|
173
|
|
158
|
174
|
class silvercrest_powerplug(base):
|
|
@@ -160,7 +176,22 @@ class silvercrest_powerplug(base):
|
160
|
176
|
|
161
|
177
|
|
162
|
178
|
class silvercrest_motion_sensor(base):
|
163
|
|
- pass
|
|
179
|
+ def __rx__(self, client, userdata, message):
|
|
180
|
+ try:
|
|
181
|
+ payload = json.loads(message.payload)
|
|
182
|
+ except json.decoder.JSONDecodeError:
|
|
183
|
+ logger.warning("JSON decode error %s", self.topic)
|
|
184
|
+ else:
|
|
185
|
+ #
|
|
186
|
+ # heartbeat
|
|
187
|
+ #
|
|
188
|
+ if message.topic == self.topic:
|
|
189
|
+ self.last_device_msg = time.time()
|
|
190
|
+ #
|
|
191
|
+ # battery level
|
|
192
|
+ #
|
|
193
|
+ if "battery" in payload and message.topic == self.topic:
|
|
194
|
+ self.battery = payload["battery"]
|
164
|
195
|
|
165
|
196
|
|
166
|
197
|
class my_powerplug(base):
|