pepe: add osram lights

This commit is contained in:
Ingolf Wagner 2020-04-15 18:08:27 +02:00
parent 79fb6cc061
commit ed6c612fd8
Signed by: palo
GPG key ID: 76BF5F1928B9618B
4 changed files with 113 additions and 32 deletions

View file

@ -46,10 +46,16 @@ in {
from = "off"; from = "off";
to = "on"; to = "on";
}; };
action = { action = [
service = "switch.turn_on"; {
entity_id = "group.${room_group}"; service = "switch.turn_on";
}; entity_id = "group.${room_group}";
}
{
service = "light.turn_on";
entity_id = "group.${room_group}";
}
];
} }
{ {
alias = "absents -> turn off ${room_group} lights"; alias = "absents -> turn off ${room_group} lights";
@ -59,10 +65,16 @@ in {
from = "on"; from = "on";
to = "off"; to = "off";
}; };
action = { action = [
service = "switch.turn_off"; {
entity_id = "group.${room_group}"; service = "switch.turn_off";
}; entity_id = "group.${room_group}";
}
{
service = "light.turn_off";
entity_id = "group.${room_group}";
}
];
} }
]; ];
in (presents "kitchen_room" "kitchen_room_present") in (presents "kitchen_room" "kitchen_room_present")
@ -71,6 +83,8 @@ in {
++ (presents "living_essential_room" "living_room_essential_present") ++ (presents "living_essential_room" "living_room_essential_present")
++ (presents "floor_room" "floor_room_present") ++ (presents "floor_room" "floor_room_present")
++ (presents "floor_room_essential" "floor_room_essential_present") ++ (presents "floor_room_essential" "floor_room_essential_present")
++ (presents "bath_room" "bath_room_present")
++ (presents "bath_room_essential" "bath_room_essential_present")
++ (presents "bed_room" "bed_room_present") ++ (presents "bed_room" "bed_room_present")
++ (presents "bed_room_essential" "bed_room_essential_present") ++ [ ++ (presents "bed_room_essential" "bed_room_essential_present") ++ [
@ -87,7 +101,7 @@ in {
control = "hidden"; control = "hidden";
name = "${description} Anwesend"; name = "${description} Anwesend";
view = false; view = false;
entities = []; entities = [ ];
}; };
"${name}_essential" = { "${name}_essential" = {
control = "hidden"; control = "hidden";
@ -123,6 +137,10 @@ in {
name = "kitchen_room"; name = "kitchen_room";
description = "Küche"; description = "Küche";
} }
{
name = "bath_room";
description = "Klo";
}
]) // { ]) // {
view_rooms = { view_rooms = {
name = "Räume"; name = "Räume";
@ -137,39 +155,36 @@ in {
"group.living_room_essential_present" "group.living_room_essential_present"
"group.kitchen_room" "group.kitchen_room"
"group.kitchen_room_essential_present" "group.kitchen_room_essential_present"
"group.bath_room"
"group.bath_room_essential_present"
]; ];
}; };
view_bed_room = { view_bed_room = {
name = "Schlafzimmer"; name = "Schlafzimmer";
view = true; view = true;
entities = [ entities = [ "group.bed_room" "group.bed_room_essential_present" ];
"group.bed_room"
"group.bed_room_essential_present"
];
}; };
view_living_room = { view_living_room = {
name = "Wohnzimmer"; name = "Wohnzimmer";
view = true; view = true;
entities = [ entities =
"group.living_room" [ "group.living_room" "group.living_room_essential_present" ];
"group.living_room_essential_present"
];
}; };
view_kitchen_room = { view_kitchen_room = {
name = "Küche"; name = "Küche";
view = true; view = true;
entities = [ entities =
"group.kitchen_room" [ "group.kitchen_room" "group.kitchen_room_essential_present" ];
"group.kitchen_room_essential_present"
];
}; };
view_floor_room = { view_floor_room = {
name = "Flur"; name = "Flur";
view = true; view = true;
entities = [ entities = [ "group.floor_room" "group.floor_room_essential_present" ];
"group.floor_room" };
"group.floor_room_essential_present" view_bath_room = {
]; name = "Klo";
view = true;
entities = [ "group.bath_room" "group.bath_room_essential_present" ];
}; };
# overview # overview

View file

@ -11,7 +11,7 @@ let
"pal02" = { "pal02" = {
label = "Flur Lampe"; label = "Flur Lampe";
icon = "mdi:lightbulb-on"; icon = "mdi:lightbulb-on";
room = "floor_room_essential"; room = "living_room_essential";
type = "light"; type = "light";
}; };
"pal03" = { "pal03" = {

View file

@ -2,11 +2,40 @@
let let
# allow new devices to join # allow new devices to join
enablePairing = false; enablePairing = true;
device = "/dev/ttyACM0"; device = "/dev/ttyACM0";
dataFolder = "/srv/zigbee/data"; dataFolder = "/srv/zigbee/data";
lights = {
"light_1" = {
id = "0x7cb03eaa0a0347b5";
room = "floor_room_essential";
};
"light_2" = {
id = "0x7cb03eaa0a0387b9";
room = "floor_room";
};
"light_3" = {
id = "0x7cb03eaa0a033a86";
room = "living_room";
};
"light_4" = {
id = "0x7cb03eaa0a04aabf";
room = "bath_room_essential";
};
"light_5" = {
id = "0x7cb03eaa0a0346e4";
room = "living_room";
};
"light_6" = { id = "0x7cb03eaa0a034b46"; };
"light_7" = { id = "0x7cb03eaa0a033b4f"; };
"light_8" = {
id = "0x7cb03eaa0a0384d3";
room = "bed_room";
};
};
sensors = { sensors = {
buttons = { buttons = {
"button_1" = { "button_1" = {
@ -56,7 +85,7 @@ let
}; };
"motion_sensor_5" = { "motion_sensor_5" = {
id = "0x00158d0002f9a56f"; id = "0x00158d0002f9a56f";
room = "floor_room_present"; room = "bath_room_essential_present";
}; };
"motion_sensor_6" = { "motion_sensor_6" = {
id = "0x00158d0002f9a5cb"; id = "0x00158d0002f9a5cb";
@ -66,7 +95,10 @@ let
id = "0x00158d0002f9a6aa"; id = "0x00158d0002f9a6aa";
room = "bed_room_essential_present"; room = "bed_room_essential_present";
}; };
"motion_sensor_8" = { id = "0x00158d0002f04637"; }; "motion_sensor_8" = {
id = "0x00158d0002f04637";
room = "bath_room_essential_present";
};
}; };
door = { door = {
"door_sensor_1" = { id = "0x00158d000312dc52"; }; "door_sensor_1" = { id = "0x00158d000312dc52"; };
@ -85,6 +117,7 @@ let
# todo : generate automatically # todo : generate automatically
allSensors = with sensors; buttons // temperature // motion // door; allSensors = with sensors; buttons // temperature // motion // door;
allLights = lights;
zigBee2MqttConfig = { zigBee2MqttConfig = {
@ -120,7 +153,7 @@ let
retain = false; retain = false;
friendly_name = name; friendly_name = name;
}; };
}) allSensors; }) (allSensors // allLights);
}; };
configurationYaml = configurationYaml =
@ -150,6 +183,20 @@ in {
}) })
]) sensors.buttons))); ]) sensors.buttons)));
light = lib.mapAttrsToList (name:
{ ... }: {
platform = "mqtt";
name = name;
#icon = "mdi:toggle-switch";
state_topic = "zigbee2mqtt/${name}";
availability_topic = "zigbee2mqtt/bridge/state";
command_topic = "zigbee2mqtt/${name}/set";
value_template = "{{ value_json.click }}";
brightness = true;
color_temp = true;
schema = "json";
}) allLights;
# define sensors # define sensors
# -------------- # --------------
sensor = let sensor = let
@ -220,7 +267,7 @@ in {
unit_of_measurement = "lqi"; unit_of_measurement = "lqi";
value_template = "{{ value_json.linkquality }}"; value_template = "{{ value_json.linkquality }}";
} }
]) allSensors; ]) (allSensors // allLights);
in lib.flatten (buttons ++ temperature ++ informations); in lib.flatten (buttons ++ temperature ++ informations);
@ -265,6 +312,15 @@ in {
information = name: [ "sensor.battery_${name}" "sensor.link_${name}" ]; information = name: [ "sensor.battery_${name}" "sensor.link_${name}" ];
lightGroups = lib.mapAttrs' (name:
{ ... }: {
name = name;
value = {
control = "hidden";
entities = [ "light.${name}" ] ++ (information name);
};
}) allLights;
sensorButtons = lib.mapAttrs' (name: sensorButtons = lib.mapAttrs' (name:
{ states ? { }, ... }: { states ? { }, ... }:
let let
@ -353,19 +409,25 @@ in {
sensors = sensors.door; sensors = sensors.door;
entityNameing = ({ name, ... }: "binary_sensor.${name}"); entityNameing = ({ name, ... }: "binary_sensor.${name}");
}; };
lightGroups = createGroupEntities {
sensors = allLights;
entityNameing = ({ name, ... }: "light.${name}");
};
}; };
# merge all group entries # merge all group entries
in lib.mapAttrs (_: entities: { entities = lib.flatten entities; }) in lib.mapAttrs (_: entities: { entities = lib.flatten entities; })
(lib.zipAttrs (builtins.attrValues groupEntries)); (lib.zipAttrs (builtins.attrValues groupEntries));
in views // allRoomsGroups // sensorButtons // sensorMotions in lightGroups // views // allRoomsGroups // sensorButtons // sensorMotions
// sensorTemperature // sensorDoors // { // sensorTemperature // sensorDoors // {
all_sensors.entities = all_sensors.entities =
(lib.mapAttrsToList (name: { ... }: "sensor.${name}") (lib.mapAttrsToList (name: { ... }: "sensor.${name}")
(sensors.buttons // sensors.temperature)) (sensors.buttons // sensors.temperature))
++ (lib.mapAttrsToList (name: { ... }: "binary_sensor.${name}") ++ (lib.mapAttrsToList (name: { ... }: "binary_sensor.${name}")
(sensors.motion // sensors.door)); (sensors.motion // sensors.door));
all_lights.entities =
lib.mapAttrsToList (name: { ... }: "light.${name}") allLights;
}; };
# create automation # create automation

View file

@ -182,6 +182,10 @@ in {
default = null; default = null;
type = with types; nullOr (listOf attrs); type = with types; nullOr (listOf attrs);
}; };
light = mkOption {
default = null;
type = with types; nullOr (listOf attrs);
};
sensor = mkOption { sensor = mkOption {
default = null; default = null;
type = with types; nullOr (listOf attrs); type = with types; nullOr (listOf attrs);