diff --git a/js/extension.js b/js/extension.js index 2fc41664..06f9d86a 100644 --- a/js/extension.js +++ b/js/extension.js @@ -285,6 +285,10 @@ } } + if(this.debug){ + console.log("Voco init response: ", body); + } + if('is_satellite' in body){ if(body['is_satellite']){ @@ -293,6 +297,17 @@ document.getElementById('extension-voco-content').classList.remove('extension-voco-show-tab-timers'); document.getElementById('extension-voco-content').classList.add('extension-voco-show-tab-satellites'); } + else{ + // Not a satellite, so succesful injection matters + if('possible_injection_failure' in body && 'mqtt_connected' in body){ + if(body.mqtt_connected == false){ + //document.getElementById("extension-voco-mqtt-error").style.display = 'block'; + } + else if(body.possible_injection_failure){ + document.getElementById("extension-voco-injection-failure").style.display = 'block'; + } + } + } if('connected_satellites' in body){ this.show_connected_satellites( body['connected_satellites'], body['is_satellite'] ); @@ -300,15 +315,7 @@ } else{ - // Not a satellite, so succesful injection matters - if('possible_injection_failure' in body && 'mqtt_connected' in body){ - if(body.mqtt_connected == false){ - //document.getElementById("extension-voco-mqtt-error").style.display = 'block'; - } - else if(body.possible_injection_failure){ - document.getElementById("extension-voco-injection-failure").style.display = 'block'; - } - } + console.error("voco: is_satellite was not in response?"); } if('hostname' in body){ @@ -320,11 +327,15 @@ if('satellite_targets' in body){ //console.log("satellite_targets in body: " + body['satellite_targets']); if(Object.keys(body['satellite_targets']).length > 0){ - //console.log("A satellite is possible"); + if(this.debug){ + console.log("Voco: at least one potential main voco controller detected"); + } if('is_satellite' in body){ //console.log("is_satellite: " + body['is_satellite']); if(body['is_satellite']){ - //console.log("I am a satellite"); + if(this.debug){ + console.log("I am a satellite"); + } document.getElementById('extension-voco-select-satellite-checkbox').checked = true; } } @@ -344,7 +355,9 @@ document.getElementById('extension-voco-server-list').innerHTML = list_html; } else{ - //console.log("satellites length was 0 - no other potential satellites spotted"); + if(this.debug){ + console.log("Voco: satellites length was 0 - no other potential satellites/controllers spotted"); + } } } } @@ -356,7 +369,6 @@ }).catch((e) => { console.log("Error getting Voco init data: " , e); - //pre.innerText = "Error getting initial Voco data: " , e; }); @@ -497,8 +509,6 @@ try{ if( main_view.classList.contains('selected') ){ - - if(this.busy_polling){ if(this.debug){ console.log("voco: was still polling, aborting new poll"); @@ -506,17 +516,22 @@ this.busy_polling_count++; if(this.busy_polling_count > 10){ + this.busy_polling = false; + this.busy_polling_count = 0; if(this.debug){ - console.log("Busy polling for over 20 seconds"); + console.log("Busy polling for over 20 seconds. Resetting this.busy_polling"); } document.getElementById('extension-voco-main-controller-not-responding').style.display = 'block'; document.getElementById('extension-voco-text-commands-container').style.display = 'none'; } + else{ + return; + } - return; } else{ //console.log("starting poll"); + document.getElementById('extension-voco-main-controller-not-responding').style.display = 'none'; } var refresh_chat_members = false diff --git a/manifest.json b/manifest.json index 6b41625d..7cf70b8a 100644 --- a/manifest.json +++ b/manifest.json @@ -211,7 +211,7 @@ } }, "short_name": "Voco", - "version": "4.1.8", + "version": "4.1.9", "web_accessible_resources": [ "css/*.css", "images/*.svg", diff --git a/pkg/voco_adapter.py b/pkg/voco_adapter.py index 66fa5850..313a297b 100644 --- a/pkg/voco_adapter.py +++ b/pkg/voco_adapter.py @@ -547,6 +547,7 @@ def __init__(self, verbose=True): #self.satellite_asr_payload = None # temporarily holds the ASR payload that the satellite passes on to the main controller self.last_spoken_sentence = "" # Used to avoid speaking the same sentence twice in quick succession self.last_spoken_sentence_time = 0 # Used to avoid speaking the same sentence twice in quick succession + self.previous_intent_callback_time = 0 # avoid "echo" problem where the main controller and a satellite both hear a command (sometimes slightly differently), which causes a command to be run twice in a row. # MQTT client self.mqtt_client = None @@ -4006,8 +4007,8 @@ def on_second_message(self, client, userdata, msg): self.injection_in_progress = False # Voco is now really ready if self.initial_injection_completed == False: - self.initial_injection_completed = True self.speak_welcome_message() + self.initial_injection_completed = True """ if self.persistent_data['is_satellite']: if self.DEBUG: @@ -5100,6 +5101,15 @@ def parse_ping(self,payload,ping_type="ping"): # def master_intent_callback(self, intent_message, try_alternative=False): # Triggered everytime Snips succesfully recognizes a voice intent + if self.DEBUG: + print("in master_intent_callback") + + # This is an imperfect way of handling the situation when the main controller and a satellite both hear a voice command. Oddly, in theory this "echo" problem should already be handled by Snips. + if time.time() - self.previous_intent_callback_time < 5: + if self.DEBUG: + print("master_intent_callback ran less than 5 seconds ago, ignoring this one.") + return + self.previous_intent_callback_time = time.time() final_test = False # there is a main incoming intent, and potentially some alternatives that can ale be tested. If we're on the last alternative (and still haven't gotten a good match), then this will cause various failure-related voice message to be spoken. this_is_origin_site = False # Whether the origin site of the intent (e.g. a satellite or the main controller) is the same site as this controller. diff --git a/pkg/voco_api_handler.py b/pkg/voco_api_handler.py index d28eb6d7..d498f0a6 100644 --- a/pkg/voco_api_handler.py +++ b/pkg/voco_api_handler.py @@ -83,7 +83,7 @@ def handle_request(self, request): return APIResponse( status=500, content_type='application/json', - content=json.dumps({'state': False, 'satellite_targets':{}, 'site_id':self.adapter.persistent_data[site_id] }), + content=json.dumps({'state': False, 'satellite_targets':self.adapter.satellite_targets, 'site_id':self.adapter.persistent_data[site_id] }), ) else: