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

180 lines
4.2 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-21 22:57:48 +02:00
scenes = [
{ name = "default"; }
{
name = "outside";
room_tracking_enabled = false;
ignored_sensors = [ "zigbee2mqtt/door_sensor_4" ];
}
{
name = "night";
room_tracking_enabled = false;
brightness = 25;
#disabled_switches = [
#"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 [
2020-10-21 22:57:48 +02:00
2020-06-01 14:34:23 +02:00
(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";
})
2020-12-06 23:54:46 +01:00
(motion {
topic = "zigbee2mqtt/motion_sensor_6";
room = "office_room";
})
2020-10-21 22:57:48 +02:00
(motion {
topic = "zigbee2mqtt/motion_sensor_7";
room = "sleeping_room";
})
2020-10-28 23:56:10 +01:00
(motion {
topic = "zigbee2mqtt/motion_sensor_5";
room = "kitchen";
})
2020-10-21 22:57:48 +02:00
(door {
topic = "zigbee2mqtt/door_sensor_1";
room = "storage_room";
})
(door {
topic = "zigbee2mqtt/door_sensor_5";
room = "sleeping_room";
})
(door {
# house 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";
};
};
2020-10-21 22:57:48 +02:00
led = { topic, rooms, delay ? 0 }: {
topic = topic;
key = "state";
rooms = rooms;
delay = delay;
command = {
2020-10-28 23:56:10 +01:00
# Configure it once to the color you like
2020-10-30 23:39:40 +01:00
# {"state":"{{state}}","brightness":{{brightness}},"color":{"hex":"#FFFFFF},"color_temp":255","transition":0}
command = ''
{"state":"{{state}}","brightness":{{brightness}},"transition":0}'';
2020-10-21 22:57:48 +02:00
topic = "${topic}/set";
on = "ON";
off = "OFF";
};
};
2020-06-01 14:34:23 +02:00
in [
2020-10-18 21:05:01 +02:00
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-21 22:57:48 +02:00
(light {
topic = "zigbee2mqtt/light_5";
rooms = [ "storage_room" ];
})
(light {
topic = "zigbee2mqtt/light_7";
rooms = [ "sleeping_room" ];
})
2020-11-02 23:23:29 +01:00
(led {
topic = "zigbee2mqtt/led_1";
rooms = [ "office_room" ];
})
(led {
topic = "zigbee2mqtt/led_2";
rooms = [ "kitchen" ];
})
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
}