2020-06-01 14:34:23 +02:00
|
|
|
{ pkgs, lib, config, ... }: {
|
|
|
|
|
|
|
|
services.mqtt.light-control.enable = true;
|
|
|
|
services.mqtt.light-control.config = {
|
|
|
|
credentials = {
|
|
|
|
host = "tcp://localhost:1883";
|
|
|
|
user = "homeassistant";
|
|
|
|
password = "hallo";
|
|
|
|
};
|
|
|
|
scenes = [
|
|
|
|
{ name = "default"; }
|
|
|
|
{
|
|
|
|
name = "outside";
|
|
|
|
room_tracking_enabled = false;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "night";
|
|
|
|
room_tracking_enabled = false;
|
|
|
|
brightness = 25;
|
|
|
|
exclude_switches = [
|
|
|
|
"stat/PAL01/RESULT"
|
|
|
|
"stat/PAL03/RESULT"
|
|
|
|
"stat/PAL04/RESULT"
|
|
|
|
"zigbee2mqtt/light_2"
|
|
|
|
];
|
|
|
|
}
|
|
|
|
];
|
|
|
|
sensors = let
|
|
|
|
door = { topic, rooms }: {
|
|
|
|
topic = topic;
|
|
|
|
key = "contact";
|
|
|
|
rooms = rooms;
|
|
|
|
invert_state = true;
|
|
|
|
delay = {
|
|
|
|
secs = 90;
|
|
|
|
nanos = 0;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
motion = { topic, rooms }: {
|
|
|
|
topic = topic;
|
|
|
|
key = "occupancy";
|
|
|
|
rooms = rooms;
|
|
|
|
delay = {
|
|
|
|
secs = 60;
|
|
|
|
nanos = 0;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
in [
|
|
|
|
(motion {
|
|
|
|
topic = "zigbee2mqtt/motion_sensor_2";
|
|
|
|
rooms = [ "bed_room" ];
|
|
|
|
})
|
|
|
|
(motion {
|
|
|
|
topic = "zigbee2mqtt/motion_sensor_7";
|
|
|
|
rooms = [ "bed_room" ];
|
|
|
|
})
|
|
|
|
(motion {
|
|
|
|
topic = "zigbee2mqtt/motion_sensor_1";
|
|
|
|
rooms = [ "kitchen_room" ];
|
|
|
|
})
|
|
|
|
(motion {
|
|
|
|
topic = "zigbee2mqtt/motion_sensor_4";
|
|
|
|
rooms = [ "living_room" ];
|
|
|
|
})
|
|
|
|
(motion {
|
|
|
|
topic = "zigbee2mqtt/motion_sensor_5";
|
|
|
|
rooms = [ "living_room" ];
|
|
|
|
})
|
|
|
|
(motion {
|
|
|
|
topic = "zigbee2mqtt/motion_sensor_8";
|
|
|
|
rooms = [ "bath_room" ];
|
|
|
|
})
|
|
|
|
|
|
|
|
(door {
|
|
|
|
topic = "zigbee2mqtt/door_sensor_2";
|
|
|
|
rooms = [ "floor_room" ];
|
|
|
|
})
|
|
|
|
(door {
|
|
|
|
topic = "zigbee2mqtt/door_sensor_4";
|
|
|
|
rooms = [ "floor_room" ];
|
|
|
|
})
|
|
|
|
];
|
|
|
|
switches = let
|
|
|
|
sonoff = { id, rooms }: {
|
|
|
|
topic = "stat/${id}/RESULT";
|
|
|
|
key = "POWER";
|
|
|
|
rooms = rooms;
|
|
|
|
command = {
|
|
|
|
command = "{{state}}";
|
|
|
|
init_command = "(null)";
|
|
|
|
topic = "cmnd/${id}/POWER";
|
|
|
|
on = "ON";
|
|
|
|
off = "OFF";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
light = { topic, rooms }: {
|
|
|
|
topic = topic;
|
|
|
|
key = "state";
|
|
|
|
rooms = rooms;
|
|
|
|
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" ];
|
|
|
|
})
|
|
|
|
(light {
|
|
|
|
topic = "zigbee2mqtt/light_4";
|
|
|
|
rooms = [ "bath_room" ];
|
|
|
|
})
|
|
|
|
(light {
|
|
|
|
topic = "zigbee2mqtt/light_8";
|
|
|
|
rooms = [ "bed_room" ];
|
|
|
|
})
|
|
|
|
(sonoff {
|
|
|
|
id = "PAL01";
|
|
|
|
rooms = [ "bed_room" ];
|
|
|
|
})
|
|
|
|
(sonoff {
|
|
|
|
id = "PAL03";
|
|
|
|
rooms = [ "living_room" ];
|
|
|
|
})
|
|
|
|
(sonoff {
|
|
|
|
id = "PAL04";
|
|
|
|
rooms = [ "bed_room" ];
|
|
|
|
})
|
|
|
|
(sonoff {
|
|
|
|
id = "PAL06";
|
|
|
|
rooms = [ "kitchen_room" ];
|
|
|
|
})
|
|
|
|
];
|
2020-06-01 04:12:15 +02:00
|
|
|
};
|
2020-06-01 14:34:23 +02:00
|
|
|
|
2020-06-01 04:12:15 +02:00
|
|
|
}
|