feat(hass): add bluetooth speaker control
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
06d9119ded
commit
100e93bbdd
3 changed files with 73 additions and 5 deletions
56
devices/homie/modules/home-assistant/bluetooth.nix
Normal file
56
devices/homie/modules/home-assistant/bluetooth.nix
Normal file
|
@ -0,0 +1,56 @@
|
|||
{...}: {
|
||||
# Setup Bluetooth
|
||||
hardware.bluetooth = {
|
||||
enable = true;
|
||||
powerOnBoot = true;
|
||||
|
||||
settings = {
|
||||
General = {
|
||||
DiscoverableTimeout = 0;
|
||||
Experimental = true;
|
||||
KernelExperimental = true;
|
||||
};
|
||||
|
||||
Policy.AutoEnable = "true";
|
||||
};
|
||||
};
|
||||
|
||||
# Have pulseaudio.service itself start at boot but after bluetooth
|
||||
# so bluetooth accepts sound connections from the start.
|
||||
systemd.user.services.pulseaudio.after = ["bluetooth.service"];
|
||||
systemd.user.targets.default.wants = ["pulseaudio.service"];
|
||||
|
||||
# Allow pulseaudio to be managed by MPD
|
||||
hardware.pulseaudio = {
|
||||
enable = true;
|
||||
|
||||
extraConfig = ''
|
||||
load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1
|
||||
'';
|
||||
};
|
||||
|
||||
# Setup MPD
|
||||
services = {
|
||||
home-assistant.extraComponents = [
|
||||
"mpd"
|
||||
];
|
||||
|
||||
mpd = {
|
||||
enable = true;
|
||||
|
||||
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"
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
{...}: {
|
||||
imports = [
|
||||
./assist.nix
|
||||
./bluetooth.nix
|
||||
./firmware.nix
|
||||
./frontend.nix
|
||||
];
|
||||
|
@ -13,6 +14,7 @@
|
|||
"caldav"
|
||||
"holiday"
|
||||
"isal"
|
||||
"led_ble"
|
||||
"met"
|
||||
"spotify"
|
||||
"upnp"
|
||||
|
|
|
@ -138,7 +138,6 @@
|
|||
platform = "template";
|
||||
restore_mode = "RESTORE_DEFAULT_ON";
|
||||
|
||||
on_turn_off = ["voice_assistant.stop" {lambda = "id(va).set_use_wake_word(false);";} {"script.execute" = "reset_led";}];
|
||||
on_turn_on = [
|
||||
{lambda = "id(va).set_use_wake_word(true);";}
|
||||
{
|
||||
|
@ -149,7 +148,14 @@
|
|||
}
|
||||
{"script.execute" = "reset_led";}
|
||||
];
|
||||
|
||||
on_turn_off = [
|
||||
"voice_assistant.stop"
|
||||
{lambda = "id(va).set_use_wake_word(false);";}
|
||||
{"script.execute" = "reset_led";}
|
||||
];
|
||||
}
|
||||
|
||||
{
|
||||
id = "use_listen_light";
|
||||
name = "Use listen light";
|
||||
|
@ -159,9 +165,10 @@
|
|||
platform = "template";
|
||||
restore_mode = "RESTORE_DEFAULT_ON";
|
||||
|
||||
on_turn_off = [{"script.execute" = "reset_led";}];
|
||||
on_turn_on = [{"script.execute" = "reset_led";}];
|
||||
on_turn_off = [{"script.execute" = "reset_led";}];
|
||||
}
|
||||
|
||||
{
|
||||
id = "timer_ringing";
|
||||
|
||||
|
@ -207,7 +214,10 @@
|
|||
{
|
||||
"if" = {
|
||||
condition = "voice_assistant.is_running";
|
||||
"then" = [{"voice_assistant.stop" = {};} {"script.execute" = "reset_led";}];
|
||||
"then" = [
|
||||
{"voice_assistant.stop" = {};}
|
||||
{"script.execute" = "reset_led";}
|
||||
];
|
||||
"else" = [{"voice_assistant.start" = {};}];
|
||||
};
|
||||
}
|
||||
|
@ -239,14 +249,14 @@
|
|||
|
||||
external_components = [
|
||||
{
|
||||
source = "github://pr#5230";
|
||||
components = ["esp_adf"];
|
||||
refresh = "0s";
|
||||
source = "github://pr#5230";
|
||||
}
|
||||
{
|
||||
source = "github://jesserockz/esphome-components";
|
||||
components = ["file"];
|
||||
refresh = "0s";
|
||||
source = "github://jesserockz/esphome-components";
|
||||
}
|
||||
];
|
||||
|
||||
|
|
Loading…
Reference in a new issue