stockholm/krebs/2configs/shack/glados/lib/default.nix

168 lines
4.7 KiB
Nix
Raw Normal View History

2020-01-07 15:52:31 +00:00
let
prefix = "glados";
in
{
2020-01-23 22:52:39 +00:00
say = let
# returns a list of actions to be performed on an mpd to say something
tts = { message, entity }:
[
{
service = "media_player.turn_on";
2020-02-19 13:36:21 +00:00
data.entity_id = "media_player.${entity}";
2020-01-23 22:52:39 +00:00
}
{ service = "media_player.play_media";
data = {
2020-02-19 13:36:21 +00:00
entity_id = "media_player.${entity}";
2020-01-23 22:52:39 +00:00
media_content_type = "playlist";
media_content_id = "ansage";
};
}
{
service = "media_player.turn_on";
2020-02-19 13:36:21 +00:00
data.entity_id = "media_player.${entity}";
2020-01-23 22:52:39 +00:00
}
{ delay.seconds = 8; }
{ service = "tts.say";
2020-02-19 13:36:21 +00:00
entity_id = "media_player.${entity}";
2020-01-23 22:52:39 +00:00
data_template = {
inherit message;
language = "de";
};
}
];
in
{
lounge = message: tts {
inherit message;
entity = "lounge";
};
herrenklo = message: tts {
inherit message;
entity = "herrenklo";
};
2020-02-19 13:36:21 +00:00
kiosk = message: tts {
inherit message;
entity = "kiosk";
};
2020-01-23 22:52:39 +00:00
};
2020-01-07 15:52:31 +00:00
esphome =
{
2020-01-10 08:59:11 +00:00
temp = {host, topic ? "temperature" }:
2020-01-07 15:52:31 +00:00
{
platform = "mqtt";
2020-01-10 08:59:11 +00:00
name = "${host} Temperature";
2020-01-07 15:52:31 +00:00
device_class = "temperature";
2020-01-08 09:16:21 +00:00
unit_of_measurement = "°C";
icon = "mdi:thermometer";
2020-01-10 08:59:11 +00:00
state_topic = "${prefix}/${host}/sensor/${topic}/state";
availability_topic = "${prefix}/${host}/status";
2020-01-07 15:52:31 +00:00
payload_available = "online";
payload_not_available = "offline";
};
2020-01-10 08:59:11 +00:00
hum = {host, topic ? "humidity" }:
2020-01-07 15:52:31 +00:00
{
platform = "mqtt";
2020-01-08 09:16:21 +00:00
unit_of_measurement = "%";
icon = "mdi:water-percent";
2020-01-07 15:52:31 +00:00
device_class = "humidity";
2020-01-10 08:59:11 +00:00
name = "${host} Humidity";
state_topic = "${prefix}/${host}/sensor/${topic}/state";
availability_topic = "${prefix}/${host}/status";
2020-01-07 15:52:31 +00:00
payload_available = "online";
payload_not_available = "offline";
};
2020-01-08 09:16:21 +00:00
# copied from "homeassistant/light/fablab_led/led_ring/config"
2020-01-10 08:59:11 +00:00
led = {host, topic ? "led", name ? host}:
2020-01-08 09:16:21 +00:00
{ # name: fablab_led
# topic: led_ring
platform = "mqtt";
inherit name;
schema = "json";
brightness = true;
rgb = true;
effect = true;
effect_list = [ # TODO: may be different
"Random"
"Strobe"
"Rainbow"
"Color Wipe"
"Scan"
"Twinkle"
"Fireworks"
"Addressable Flicker"
"None"
];
state_topic = "${prefix}/${host}/light/${topic}/state";
command_topic = "${prefix}/${host}/light/${topic}/command";
availability_topic = "${prefix}/${host}/status";
payload_available = "online";
payload_not_available = "offline";
qos = 1;
};
# Feinstaub
dust_25m = { host, name ? "${host} < 2.5µm", topic ? "particulate_matter_25m_concentration" }:
{
platform = "mqtt";
unit_of_measurement = "µg/m³";
icon = "mdi:chemical-weapon";
inherit name;
state_topic = "${prefix}/${host}/sensor/${topic}/state";
2020-01-10 08:59:11 +00:00
availability_topic = "${prefix}/${host}/status";
2020-01-08 09:16:21 +00:00
};
dust_100m = {host, name ? "${host} < 10µm", topic ? "particulate_matter_100m_concentration" }:
{
platform = "mqtt";
unit_of_measurement = "µg/m³";
icon = "mdi:chemical-weapon";
inherit name;
2020-01-10 08:59:11 +00:00
state_topic = "${prefix}/${host}/sensor/${topic}/state";
availability_topic = "${prefix}/${host}/status";
2020-01-08 09:16:21 +00:00
};
2020-02-19 13:36:21 +00:00
ip = {host, name ? "${host} IP", topic ? "ip_address" }:
{
platform = "mqtt";
inherit name;
state_topic = "${prefix}/${host}/sensor/${topic}/state";
availability_topic = "${prefix}/${host}/status";
};
wifi = {host, name ? "${host} Wifi Signal", topic ? "wifi_signal" }:
{
platform = "mqtt";
unit_of_measurement = "dB";
icon = "mdi:wifi";
inherit name;
state_topic = "${prefix}/${host}/sensor/${topic}/state";
availability_topic = "${prefix}/${host}/status";
};
2020-01-08 09:16:21 +00:00
switch = {host, name ? "${host} Button", topic ? "btn" }:
# host: ampel
# name: Button 1
# topic: btn1
{
inherit name;
platform = "mqtt";
state_topic = "${prefix}/${host}/sensor/${topic}/state";
command_topic = "${prefix}/${host}/switch/${topic}/state";
availability_topic = "${prefix}/${host}/status";
};
2020-01-07 15:52:31 +00:00
};
tasmota =
{
2020-01-10 08:59:11 +00:00
plug = {host, name ? host, topic ? host}:
2020-01-07 15:52:31 +00:00
{
platform = "mqtt";
inherit name;
state_topic = "sonoff/stat/${topic}/POWER1";
command_topic = "sonoff/cmnd/${topic}/POWER1";
availability_topic = "sonoff/tele/${topic}/LWT";
payload_on= "ON";
payload_off= "OFF";
payload_available= "Online";
payload_not_available= "Offline";
retain = false;
qos = 1;
};
};
}