@@ -164,17 +164,14 @@ def _handle_response(self, data):
164164 elif message_type == 0x94 :
165165 self ._handle_data_extended_response (data )
166166 else :
167- pass
168167 _LOGGER .warning (
169168 "Ignore data package because invalid message type %s" % message_type
170169 )
171170
172171 def _handle_passcode_response (self , data ):
173- pass
174172 _LOGGER .warning ("Passcode resonse ignored" )
175173
176174 def _handle_login_response (self , data ):
177- pass
178175 _LOGGER .warning ("Login resonse ignored" )
179176
180177 def _handle_data_response (self , data ):
@@ -194,20 +191,12 @@ def _handle_data_response(self, data):
194191 self ._measurements .pop (0 )
195192 for callback in self ._callbacks :
196193 callback ()
197- else :
198- pass
199- _LOGGER .debug (meas )
194+ _LOGGER .debug (meas )
200195
201196 def _handle_data_extended_response (self , data ):
202- pass
203197 _LOGGER .warning ("Extended data ignored" )
204198
205199 def _handle_ping_pong_response (self ):
206- # if self._pong_thread is None or self._pong_thread.done:
207- # self._pong_thread = asyncio.create_task(self._async_queue_ping())
208- # pass
209- # else:
210- # _LOGGER.debug("Pong thread alredy running")
211200 _LOGGER .debug ("Pong message received" )
212201
213202 def _send_ping (self ):
@@ -220,10 +209,6 @@ def _ping_loop(self):
220209 self ._send_ping ()
221210 sleep (PH803W_PING_INTERVAL )
222211
223- # async def _async_queue_ping(self):
224- # await asyncio.sleep(PH803W_PING_INTERVAL)
225- # self._send_ping()
226-
227212 def abort (self ):
228213 self ._loop = False
229214
@@ -254,7 +239,7 @@ def __init__(self, ph: float, orp: float, history: int = 10) -> None:
254239 self ._ph_filter = OutlierFilter (ph , history )
255240 self ._orp_filter = OutlierFilter (orp , history )
256241
257- def add (self , ph , orp ) :
242+ def add (self , ph : float , orp : float ) -> None :
258243 self ._ph_filter .add (ph )
259244 self ._orp_filter .add (orp )
260245
@@ -271,7 +256,7 @@ def __init__(self, init_value: float, history: int = 10) -> None:
271256 self ._values .append (init_value )
272257 self ._history = history
273258
274- def add (self , value ) :
259+ def add (self , value : float ) -> None :
275260 self ._values .append (value )
276261 if len (self ._values ) > self ._history :
277262 self ._values .pop (0 )
@@ -284,9 +269,9 @@ def get(self) -> float:
284269 if (val <= mean_val + stddev_val ) and (val >= mean_val - stddev_val ):
285270 return val
286271 except StatisticsError :
287- return self ._values [0 ]
272+ return self ._values [- 1 ]
288273 _LOGGER .error ("No match in outlier filter shall never happen!" )
289- return None
274+ return self . _values [ - 1 ]
290275
291276
292277class Measurement :
@@ -298,25 +283,21 @@ def __init__(self, data) -> None:
298283 self .ph_on = flag2 & 0b0000_0001 != 0
299284 ph_raw = data [10 :12 ]
300285 self .ph = int .from_bytes (ph_raw , "big" ) * 0.01
301- self .ph_filt = None
302286 orp_raw = data [12 :14 ]
303287 self .orp = int .from_bytes (orp_raw , "big" ) - 2000
304- self .orp_filt = None
305288 unknown1_raw = data [14 :16 ]
306289 self .unknown1 = int .from_bytes (unknown1_raw , "big" )
307290 unknown2_raw = data [15 :18 ]
308291 self .unknown2 = int .from_bytes (unknown2_raw , "big" )
309292
310- def add_filtered (self , ph_filt , orp_filt ) :
311- self .ph_filt = ph_filt
312- self .orp_filt = orp_filt
293+ def add_filtered (self , ph_filt : float , orp_filt : float ) -> None :
294+ self .ph = ph_filt
295+ self .orp = orp_filt
313296
314297 def __str__ (self ) -> str :
315- return "pH: %s (%s) , Orp: %s (%s) , In-water: %s, pH-on: %s, Orp-on: %s" % (
298+ return "pH: %s, Orp: %s, In-water: %s, pH-on: %s, Orp-on: %s" % (
316299 self .ph ,
317- self .ph_filt ,
318300 self .orp ,
319- self .orp_filt ,
320301 self .in_water ,
321302 self .ph_on ,
322303 self .orp_on ,
0 commit comments