feat(hass): turn on speaker automatically when openwakeword is used
All checks were successful
Discord / discord commits (push) Has been skipped
All checks were successful
Discord / discord commits (push) Has been skipped
This commit is contained in:
parent
45e671e2bb
commit
a5f7be062b
2 changed files with 58 additions and 39 deletions
|
@ -1,26 +1,9 @@
|
||||||
{
|
{
|
||||||
config,
|
config,
|
||||||
|
lib,
|
||||||
pkgs,
|
pkgs,
|
||||||
...
|
...
|
||||||
}: {
|
}: {
|
||||||
environment.systemPackages = [
|
|
||||||
(pkgs.writeShellApplication {
|
|
||||||
name = "turnOnUE";
|
|
||||||
|
|
||||||
runtimeInputs = [config.hardware.bluetooth.package];
|
|
||||||
|
|
||||||
text = ''
|
|
||||||
cmd=0x0003
|
|
||||||
bt_device_addr=88:C6:26:93:4B:77
|
|
||||||
|
|
||||||
# This is the MAC address on the first line of `bluetootctl show`
|
|
||||||
# without the `:` and with `01` added at the end
|
|
||||||
bt_controller_addr=E848B8C8200001
|
|
||||||
|
|
||||||
exec gatttool -b $bt_device_addr --char-write-req --handle=$cmd --value=$bt_controller_addr
|
|
||||||
'';
|
|
||||||
})
|
|
||||||
];
|
|
||||||
|
|
||||||
# Setup Bluetooth
|
# Setup Bluetooth
|
||||||
hardware.bluetooth = {
|
hardware.bluetooth = {
|
||||||
|
@ -43,6 +26,46 @@
|
||||||
systemd.user.services.pulseaudio.after = ["bluetooth.service"];
|
systemd.user.services.pulseaudio.after = ["bluetooth.service"];
|
||||||
systemd.user.targets.default.wants = ["pulseaudio.service"];
|
systemd.user.targets.default.wants = ["pulseaudio.service"];
|
||||||
|
|
||||||
|
# Turn On the speaker automatically when openwakeword is used
|
||||||
|
services.home-assistant.config = {
|
||||||
|
shell_command.turn_on_ue = lib.getExe (pkgs.writeShellApplication {
|
||||||
|
name = "turnOnUE";
|
||||||
|
|
||||||
|
runtimeInputs = [config.hardware.bluetooth.package];
|
||||||
|
|
||||||
|
text = ''
|
||||||
|
cmd=0x0003
|
||||||
|
bt_device_addr=88:C6:26:93:4B:77
|
||||||
|
|
||||||
|
# This is the MAC address on the first line of `bluetootctl show`
|
||||||
|
# without the `:` and with `01` added at the end
|
||||||
|
bt_controller_addr=E848B8C8200001
|
||||||
|
|
||||||
|
exec gatttool -b $bt_device_addr --char-write-req --handle=$cmd --value=$bt_controller_addr
|
||||||
|
'';
|
||||||
|
});
|
||||||
|
automation = [
|
||||||
|
{
|
||||||
|
alias = "Turn On UE";
|
||||||
|
mode = "single";
|
||||||
|
trigger = [
|
||||||
|
{
|
||||||
|
platform = "state";
|
||||||
|
entity_id = "wake_word.openwakeword";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
condition = [];
|
||||||
|
action = [
|
||||||
|
{
|
||||||
|
action = "shell_command.turn_on_ue";
|
||||||
|
metadata = {};
|
||||||
|
data = {};
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
# Allow pulseaudio to be managed by MPD
|
# Allow pulseaudio to be managed by MPD
|
||||||
hardware.pulseaudio = {
|
hardware.pulseaudio = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
@ -53,27 +76,24 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
# Setup MPD
|
# Setup MPD
|
||||||
services = {
|
services.home-assistant.extraComponents = [
|
||||||
home-assistant.extraComponents = [
|
"mpd"
|
||||||
"mpd"
|
];
|
||||||
];
|
services.mpd = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
mpd = {
|
network = {
|
||||||
enable = true;
|
listenAddress = "127.0.0.1";
|
||||||
|
port = 6600;
|
||||||
network = {
|
|
||||||
listenAddress = "127.0.0.1";
|
|
||||||
port = 6600;
|
|
||||||
};
|
|
||||||
|
|
||||||
extraConfig = ''
|
|
||||||
audio_output {
|
|
||||||
type "pulse"
|
|
||||||
name "UE Boom 2"
|
|
||||||
sink "bluez_sink.88_C6_26_93_4B_77.a2dp_sink"
|
|
||||||
server "127.0.0.1"
|
|
||||||
}
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extraConfig = ''
|
||||||
|
audio_output {
|
||||||
|
type "pulse"
|
||||||
|
name "UE Boom 2"
|
||||||
|
sink "bluez_sink.88_C6_26_93_4B_77.a2dp_sink"
|
||||||
|
server "127.0.0.1"
|
||||||
|
}
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,6 @@
|
||||||
mobile_app = {};
|
mobile_app = {};
|
||||||
my = {};
|
my = {};
|
||||||
sun = {};
|
sun = {};
|
||||||
automation = {};
|
|
||||||
zeroconf = {};
|
zeroconf = {};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue