@@ -63,23 +63,26 @@ def initialize(self):
6363 self .debug_log (f"\n **** INIT - AUTO 'CRAPPY INTERNET' REBOOTER ****\n D/L { self .threshold_download } \n U/L { self .threshold_upload } \n PING { self .threshold_ping } " )
6464
6565 self .debug = bool (self .args ["debug" ]) if "debug" in self .args else self .debug
66-
6766
68- def run_speedtest (self , kwargs ):
67+
68+ async def run_speedtest (self , kwargs ):
6969 self .debug_log ("INTERNET SPEED TEST IN PROGRESS" )
70- try :
71- # in try catch as this seems to be a synchronous call. AppDaemon timesout!
72- self .call_service ("speedtestdotnet/speedtest" )
73- except :
74- pass
70+ self .call_service ("homeassistant/update_entity" , entity_id = "sensor.speedtest_ping" )
7571
7672
7773 def evaluate_internet_health (self , entity , attribute , old , new , kwargs ):
7874
79- speed_download = float (self .get_state (self .sensor_download ))
80- speed_upload = float (self .get_state (self .sensor_upload ))
81- speed_ping = float (self .get_state (self .sensor_ping ))
82-
75+ speed_download = self .threshold_download
76+ speed_upload = self .threshold_upload
77+ speed_ping = self .threshold_ping
78+
79+ try :
80+ speed_download = float (self .get_state (self .sensor_download ))
81+ speed_upload = float (self .get_state (self .sensor_upload ))
82+ speed_ping = float (self .get_state (self .sensor_ping ))
83+ except :
84+ pass
85+
8386 d = speed_download < self .threshold_download
8487 u = speed_upload < self .threshold_upload
8588 p = speed_ping > self .threshold_ping
@@ -95,7 +98,8 @@ def evaluate_internet_health(self, entity, attribute, old, new, kwargs):
9598
9699 if self .notify and self .is_time_okay (self .notify_start_time , self .notify_end_time ):
97100 self .call_service ("notify/alexa_media" , data = {"type" :"tts" , "method" :"all" }, target = self .alexa , message = "Your attention please, internet power cycle in 30 seconds!" )
98-
101+ pass
102+
99103 self .run_in (self .turn_off_switch , 30 )
100104 self .run_in (self .turn_on_switch , 45 )
101105 else :
0 commit comments