Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Candle - the privacy friendly smart home authored Mar 10, 2022
1 parent 246f201 commit 06ebd54
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 37 deletions.
1 change: 1 addition & 0 deletions css/extension.css
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,7 @@
}


#extension-voco-mqtt-error,
#extension-voco-injection-failure,
#extension-voco-debug-warning{
max-width:60rem;
Expand Down
6 changes: 3 additions & 3 deletions js/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,11 @@

if('is_satellite' in body){
if(body['is_satellite'] == false){
document.getElementById('extension-voco-content-container').classList.add('extension-voco-add-token');
//document.getElementById('extension-voco-content-container').classList.add('extension-voco-add-token');
}
}
else{
document.getElementById('extension-voco-content-container').classList.add('extension-voco-add-token');
//document.getElementById('extension-voco-content-container').classList.add('extension-voco-add-token');
}


Expand Down Expand Up @@ -341,7 +341,7 @@

if('possible_injection_failure' in body && 'mqtt_connected' in body){
if(body.mqtt_connected == false){
document.getElementById("extension-voco-mqtt-error").style.display = 'block';
//document.getElementById("extension-voco-mqtt-error").style.display = 'block';
}
else if(body.possible_injection_failure){
document.getElementById("extension-voco-injection-failure").style.display = 'block';
Expand Down
10 changes: 3 additions & 7 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"Auto",
"Headphone jack",
"HDMI",
"Bluetooth"
"Bluetooth speaker"
],
"type": "string"
},
Expand Down Expand Up @@ -185,16 +185,12 @@
"type": "boolean"
}
},
"required": [
"Microphone",
"Speaker",
"Authorization token"
],
"required": [],
"type": "object"
}
},
"short_name": "Voco",
"version": "2.8.15",
"version": "2.8.17",
"web_accessible_resources": [
"css/*.css",
"images/*.svg",
Expand Down
67 changes: 40 additions & 27 deletions pkg/voco_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def __init__(self, verbose=True):
self.sample_rate = 16000

# Bluetooth
self.bluealsa = False
self.bluealsa_available = False
self.kill_ffplay_before_speaking = False


Expand Down Expand Up @@ -434,6 +434,9 @@ def __init__(self, verbose=True):
print(str(self.persistent_data))


# If Bluealsa is detected, then this will add bluetooth as an option to the output dropdown of the thing
self.bluetooth_device_check()


# Create Voco device
try:
Expand Down Expand Up @@ -574,7 +577,7 @@ def __init__(self, verbose=True):
if self.DEBUG:
print("Setting Pi audio_output to HDMI")
run_command("amixer cset numid=3 2")
elif self.speaker == "Bluetooth":
elif self.speaker == "Bluetooth speaker":
if self.DEBUG:
print("Setting Pi audio_output to Bluetooth")
time.sleep(10) # give BluetoothPairing some time to reconnect to the speaker
Expand Down Expand Up @@ -726,7 +729,7 @@ def bluetooth_device_check(self):
print("aplay_pcm_check: " + str(aplay_pcm_check))

if 'bluealsa' in aplay_pcm_check:
self.bluealsa = True
self.bluealsa_available = True
if self.DEBUG:
print("BlueAlsa was detected as PCM option")

Expand Down Expand Up @@ -1140,37 +1143,47 @@ def set_audio_output(self, selection):
if self.DEBUG:
print("Setting audio_output selection to: " + str(selection))

# Get the latest audio controls
self.audio_controls = get_audio_controls()
if self.DEBUG:
print(self.audio_controls)
if selection == 'Bluetooth speaker':

self.bluetooth_device_check()

self.persistent_data['audio_output'] = str(selection)
self.save_persistent_data()

self.devices['voco'].properties['audio_output'].update( str(selection) )

else:
# Get the latest audio controls
self.audio_controls = get_audio_controls()
if self.DEBUG:
print(self.audio_controls)

try:
for option in self.audio_controls:
if str(option['human_device_name']) == str(selection):
try:
for option in self.audio_controls:
if str(option['human_device_name']) == str(selection):

self.current_simple_card_name = option['simple_card_name']
self.current_card_id = option['card_id']
self.current_device_id = option['device_id']
self.current_simple_card_name = option['simple_card_name']
self.current_card_id = option['card_id']
self.current_device_id = option['device_id']

# Set selection in persistence data
self.persistent_data['audio_output'] = str(selection)
self.save_persistent_data()
# Set selection in persistence data
self.persistent_data['audio_output'] = str(selection)
self.save_persistent_data()

if self.DEBUG:
print("new output selection on thing: " + str(selection))
try:
if self.DEBUG:
print("self.devices = " + str(self.devices))
if self.devices['voco'] != None:
self.devices['voco'].properties['audio_output'].update( str(selection) )
except Exception as ex:
print("Error setting new audio_output selection:" + str(ex))
print("new output selection on thing: " + str(selection))
try:
if self.DEBUG:
print("self.devices = " + str(self.devices))
if self.devices['voco'] != None:
self.devices['voco'].properties['audio_output'].update( str(selection) )
except Exception as ex:
print("Error setting new audio_output selection:" + str(ex))

break
break

except Exception as ex:
print("Error in set_audio_output: " + str(ex))
except Exception as ex:
print("Error in set_audio_output: " + str(ex))



Expand Down

0 comments on commit 06ebd54

Please sign in to comment.