{ pkgs, lib, config, ... }: { services.mqtt.light-control.enable = true; services.mqtt.light-control.loglevel = "debug"; services.mqtt.light-control.config = { credentials = { host = "tcp://localhost:1883"; user = "homeassistant"; password = "hallo"; }; 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" ]; #} ]; sensors = let door = { topic, room }: { topic = topic; key = "contact"; room = room; invert_state = true; delay = 90; }; motion = { topic, room }: { topic = topic; key = "occupancy"; room = room; delay = 60; }; in [ (motion { topic = "zigbee2mqtt/motion_sensor_1"; room = "office_room"; }) (motion { 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"; #}) ]; switches = let sonoff = { id, rooms, delay ? 0 }: { topic = "stat/${id}/RESULT"; key = "POWER"; rooms = rooms; delay = delay; command = { command = "{{state}}"; init_command = "(null)"; topic = "cmnd/${id}/POWER"; on = "ON"; off = "OFF"; }; }; light = { topic, rooms, delay ? 0 }: { topic = topic; key = "state"; rooms = rooms; delay = delay; command = { command = ''{"state":"{{state}}","brightness":{{brightness}}}''; topic = "${topic}/set"; on = "ON"; off = "OFF"; }; }; in [ #(light { # topic = "zigbee2mqtt/light_1"; # rooms = [ "floor" ]; #}) #(light { # topic = "zigbee2mqtt/light_2"; # rooms = [ "floor" ]; #}) #(light { # topic = "zigbee2mqtt/light_3"; # rooms = [ "living_room" ]; # delay = 10; #}) (light { topic = "zigbee2mqtt/light_2"; rooms = [ "office_room" ]; }) (light { topic = "zigbee2mqtt/light_4"; rooms = [ "office_room" ]; }) #(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; #}) ]; }; }