nixos-config/configs/pepe/home-assistant/light-control.nix

181 lines
4.1 KiB
Nix
Raw Normal View History

2020-06-01 14:34:23 +02:00
{ pkgs, lib, config, ... }: {
services.mqtt.light-control.enable = true;
2020-06-04 01:44:50 +02:00
services.mqtt.light-control.loglevel = "debug";
2020-06-01 14:34:23 +02:00
services.mqtt.light-control.config = {
credentials = {
host = "tcp://localhost:1883";
user = "homeassistant";
password = "hallo";
};
2020-10-18 21:05:01 +02:00
scenes = [{
name = "default";
room_tracking_enabled = false;
}
#{
# name = "outside";
# room_tracking_enabled = false;
# ignored_sensors = [ "zigbee2mqtt/door_sensor_4" ];
#}
#{
# name = "cooking";
# enabled_switches = [ "stat/PAL07/RESULT" "stat/PAL08/RESULT" ];
#}
#{
# name = "night";
# room_tracking_enabled = false;
# brightness = 25;
# disabled_switches = [
# "stat/PAL01/RESULT"
# "stat/PAL03/RESULT"
# "stat/PAL04/RESULT"
# "stat/PAL07/RESULT"
# "stat/PAL08/RESULT"
# "zigbee2mqtt/light_2"
# ];
# ignored_sensors = [ "zigbee2mqtt/motion_sensor_7" ];
#}
];
2020-06-01 14:34:23 +02:00
sensors = let
2020-06-05 00:15:46 +02:00
door = { topic, room }: {
2020-06-01 14:34:23 +02:00
topic = topic;
key = "contact";
2020-06-05 00:15:46 +02:00
room = room;
2020-06-01 14:34:23 +02:00
invert_state = true;
delay = 90;
2020-06-01 14:34:23 +02:00
};
2020-06-05 00:15:46 +02:00
motion = { topic, room }: {
2020-06-01 14:34:23 +02:00
topic = topic;
key = "occupancy";
2020-06-05 00:15:46 +02:00
room = room;
delay = 60;
2020-06-01 14:34:23 +02:00
};
in [
(motion {
topic = "zigbee2mqtt/motion_sensor_1";
2020-10-18 21:05:01 +02:00
room = "office_room";
})
2020-06-01 14:34:23 +02:00
(motion {
2020-10-18 21:05:01 +02:00
topic = "zigbee2mqtt/motion_sensor_2";
room = "office_room";
})
#(motion {
# topic = "zigbee2mqtt/motion_sensor_7";
# room = "bed_room";
#})
#(motion {
# topic = "zigbee2mqtt/motion_sensor_1";
# room = "kitchen";
#})
#(motion {
# topic = "zigbee2mqtt/motion_sensor_3";
# room = "living_room";
#})
#(motion {
# topic = "zigbee2mqtt/motion_sensor_4";
# room = "living_room";
#})
#(motion {
# topic = "zigbee2mqtt/motion_sensor_5";
# room = "bath_room";
#})
#(motion {
# topic = "zigbee2mqtt/motion_sensor_8";
# room = "bath_room";
#})
#(motion {
# topic = "zigbee2mqtt/motion_sensor_6";
# room = "floor";
#})
#(door {
# topic = "zigbee2mqtt/door_sensor_2";
# room = "floor";
#})
#(door {
# topic = "zigbee2mqtt/door_sensor_4";
# room = "floor";
#})
2020-06-01 14:34:23 +02:00
];
switches = let
sonoff = { id, rooms, delay ? 0 }: {
2020-06-01 14:34:23 +02:00
topic = "stat/${id}/RESULT";
key = "POWER";
rooms = rooms;
delay = delay;
2020-06-01 14:34:23 +02:00
command = {
command = "{{state}}";
init_command = "(null)";
topic = "cmnd/${id}/POWER";
on = "ON";
off = "OFF";
};
};
light = { topic, rooms, delay ? 0 }: {
2020-06-01 14:34:23 +02:00
topic = topic;
key = "state";
rooms = rooms;
delay = delay;
2020-06-01 14:34:23 +02:00
command = {
command = ''{"state":"{{state}}","brightness":{{brightness}}}'';
topic = "${topic}/set";
on = "ON";
off = "OFF";
};
};
in [
2020-10-18 21:05:01 +02:00
#(light {
# topic = "zigbee2mqtt/light_1";
# rooms = [ "floor" ];
#})
#(light {
# topic = "zigbee2mqtt/light_2";
# rooms = [ "floor" ];
#})
#(light {
# topic = "zigbee2mqtt/light_3";
# rooms = [ "living_room" ];
# delay = 10;
#})
2020-06-01 14:34:23 +02:00
(light {
topic = "zigbee2mqtt/light_2";
2020-10-18 21:05:01 +02:00
rooms = [ "office_room" ];
2020-06-01 14:34:23 +02:00
})
(light {
topic = "zigbee2mqtt/light_4";
2020-10-18 21:05:01 +02:00
rooms = [ "office_room" ];
})
2020-10-18 21:05:01 +02:00
#(sonoff {
# id = "PAL01";
# rooms = [ "bed_room" ];
#})
#(sonoff {
# id = "PAL03";
# rooms = [ "living_room" ];
#})
#(sonoff {
# id = "PAL04";
# rooms = [ "bed_room" ];
#})
#(sonoff {
# id = "PAL06";
# rooms = [ "kitchen" ];
#})
## monitor and speakers
#(sonoff {
# id = "PAL07";
# rooms = [ "bed_room" ];
# delay = 180;
#})
#(sonoff {
# id = "PAL08";
# rooms = [ "bed_room" ];
# delay = 180;
#})
2020-06-01 14:34:23 +02:00
];
2020-06-01 04:12:15 +02:00
};
2020-06-01 14:34:23 +02:00
2020-06-01 04:12:15 +02:00
}