2024-09-10 17:04:30 -04:00
|
|
|
{
|
|
|
|
config,
|
2024-09-10 20:55:38 -04:00
|
|
|
lib,
|
2024-09-10 17:04:30 -04:00
|
|
|
pkgs,
|
2024-09-19 22:16:11 -04:00
|
|
|
self,
|
2024-09-10 17:04:30 -04:00
|
|
|
...
|
2024-09-19 22:16:11 -04:00
|
|
|
}: let
|
|
|
|
inherit (lib) getExe;
|
|
|
|
|
|
|
|
turnOnUE = 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
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
in {
|
|
|
|
environment.systemPackages = [turnOnUE];
|
|
|
|
|
2024-09-18 15:26:17 -04:00
|
|
|
services.home-assistant = {
|
2024-09-19 22:16:11 -04:00
|
|
|
customComponents = builtins.attrValues {
|
|
|
|
inherit
|
|
|
|
(self.legacyPackages.${pkgs.system}.hass-components)
|
|
|
|
spotifyplus
|
|
|
|
;
|
|
|
|
};
|
|
|
|
|
2024-09-18 15:26:17 -04:00
|
|
|
extraComponents = [
|
|
|
|
"mpd"
|
|
|
|
|
|
|
|
# BT components
|
|
|
|
"ibeacon"
|
|
|
|
"led_ble"
|
|
|
|
"kegtron"
|
|
|
|
"xiaomi_ble"
|
2024-09-10 20:55:38 -04:00
|
|
|
];
|
2024-09-11 13:07:51 -04:00
|
|
|
|
2024-09-19 22:16:11 -04:00
|
|
|
# Turn On the speaker automatically when openwakeword is used
|
2024-09-18 15:26:17 -04:00
|
|
|
config = {
|
2024-09-19 22:16:11 -04:00
|
|
|
shell_command.turn_on_ue = getExe turnOnUE;
|
2024-09-18 15:26:17 -04:00
|
|
|
|
|
|
|
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 = {};
|
|
|
|
}
|
|
|
|
];
|
|
|
|
}
|
|
|
|
];
|
2024-09-10 01:21:08 -04:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|