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

167 lines
3.8 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";
};
scenes = [
{ name = "default"; }
{
name = "outside";
room_tracking_enabled = false;
}
2020-06-11 12:28:29 +02:00
{
name = "cooking";
enabled_switches = [ "stat/PAL07/RESULT" "stat/PAL08/RESULT" ];
}
2020-06-01 14:34:23 +02:00
{
name = "night";
room_tracking_enabled = false;
brightness = 25;
2020-06-07 18:29:38 +02:00
disabled_switches = [
2020-06-01 14:34:23 +02:00
"stat/PAL01/RESULT"
"stat/PAL03/RESULT"
"stat/PAL04/RESULT"
"stat/PAL07/RESULT"
"stat/PAL08/RESULT"
2020-06-01 14:34:23 +02:00
"zigbee2mqtt/light_2"
];
}
];
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_2";
2020-06-05 00:15:46 +02:00
room = "bed_room";
2020-06-01 14:34:23 +02:00
})
(motion {
topic = "zigbee2mqtt/motion_sensor_7";
2020-06-05 00:15:46 +02:00
room = "bed_room";
2020-06-01 14:34:23 +02:00
})
(motion {
topic = "zigbee2mqtt/motion_sensor_1";
2020-06-05 00:15:46 +02:00
room = "kitchen_room";
2020-06-01 14:34:23 +02:00
})
(motion {
topic = "zigbee2mqtt/motion_sensor_3";
2020-06-05 00:15:46 +02:00
room = "living_room";
})
2020-06-01 14:34:23 +02:00
(motion {
topic = "zigbee2mqtt/motion_sensor_4";
2020-06-05 00:15:46 +02:00
room = "living_room";
2020-06-01 14:34:23 +02:00
})
(motion {
topic = "zigbee2mqtt/motion_sensor_5";
2020-06-05 00:15:46 +02:00
room = "bath_room";
2020-06-01 14:34:23 +02:00
})
(motion {
topic = "zigbee2mqtt/motion_sensor_8";
2020-06-05 00:15:46 +02:00
room = "bath_room";
2020-06-01 14:34:23 +02:00
})
(door {
topic = "zigbee2mqtt/door_sensor_2";
2020-06-05 00:15:46 +02:00
room = "floor_room";
2020-06-01 14:34:23 +02:00
})
(door {
topic = "zigbee2mqtt/door_sensor_4";
2020-06-05 00:15:46 +02:00
room = "floor_room";
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 [
(light {
topic = "zigbee2mqtt/light_1";
rooms = [ "floor_room" ];
})
(light {
topic = "zigbee2mqtt/light_2";
rooms = [ "floor_room" ];
})
(light {
topic = "zigbee2mqtt/light_3";
rooms = [ "living_room" ];
delay = 10;
2020-06-01 14:34:23 +02:00
})
(light {
topic = "zigbee2mqtt/light_4";
rooms = [ "bath_room" ];
})
(light {
topic = "zigbee2mqtt/light_8";
rooms = [ "bed_room" ];
delay = 10;
2020-06-01 14:34:23 +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_room" ];
})
# 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
}