Add option to control bluetooth
This commit is contained in:
parent
1b36c9fc7e
commit
1d4eeaf549
1 changed files with 11 additions and 0 deletions
|
@ -44,6 +44,7 @@ def on_connect(client, userdata, flags, rc):
|
|||
logging.info("Connected with result code - %s", rc)
|
||||
|
||||
client.publish("speakers/pi-soulra/version", __version__)
|
||||
client.publish("speakers/pi-soulra/bluetooth", "on")
|
||||
client.subscribe("speakers/pi-soulra/command")
|
||||
|
||||
|
||||
|
@ -80,6 +81,16 @@ def on_message(client, userdata, message):
|
|||
logging.info("Shutting down...")
|
||||
subprocess.run(["systemctl", "poweroff"], check=False)
|
||||
|
||||
elif message.payload == b"bluetooth_on":
|
||||
logging.info("Turning on bluetooth")
|
||||
subprocess.run(["bluetoothctl", "power", "on"], check=False)
|
||||
client.publish("speakers/pi-soulra/bluetooth", "on")
|
||||
|
||||
elif message.payload == b"bluetooth_off":
|
||||
logging.info("Turning off bluetooth")
|
||||
subprocess.run(["bluetoothctl", "power", "off"], check=False)
|
||||
client.publish("speakers/pi-soulra/bluetooth", "off")
|
||||
|
||||
|
||||
def send(commands):
|
||||
for command in commands:
|
||||
|
|
Loading…
Add table
Reference in a new issue