pepe: add osram lights
This commit is contained in:
parent
79fb6cc061
commit
ed6c612fd8
4 changed files with 113 additions and 32 deletions
|
@ -46,10 +46,16 @@ in {
|
|||
from = "off";
|
||||
to = "on";
|
||||
};
|
||||
action = {
|
||||
action = [
|
||||
{
|
||||
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";
|
||||
|
@ -59,10 +65,16 @@ in {
|
|||
from = "on";
|
||||
to = "off";
|
||||
};
|
||||
action = {
|
||||
action = [
|
||||
{
|
||||
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")
|
||||
|
@ -71,6 +83,8 @@ in {
|
|||
++ (presents "living_essential_room" "living_room_essential_present")
|
||||
++ (presents "floor_room" "floor_room_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_essential" "bed_room_essential_present") ++ [
|
||||
|
||||
|
@ -123,6 +137,10 @@ in {
|
|||
name = "kitchen_room";
|
||||
description = "Küche";
|
||||
}
|
||||
{
|
||||
name = "bath_room";
|
||||
description = "Klo";
|
||||
}
|
||||
]) // {
|
||||
view_rooms = {
|
||||
name = "Räume";
|
||||
|
@ -137,39 +155,36 @@ in {
|
|||
"group.living_room_essential_present"
|
||||
"group.kitchen_room"
|
||||
"group.kitchen_room_essential_present"
|
||||
"group.bath_room"
|
||||
"group.bath_room_essential_present"
|
||||
];
|
||||
};
|
||||
view_bed_room = {
|
||||
name = "Schlafzimmer";
|
||||
view = true;
|
||||
entities = [
|
||||
"group.bed_room"
|
||||
"group.bed_room_essential_present"
|
||||
];
|
||||
entities = [ "group.bed_room" "group.bed_room_essential_present" ];
|
||||
};
|
||||
view_living_room = {
|
||||
name = "Wohnzimmer";
|
||||
view = true;
|
||||
entities = [
|
||||
"group.living_room"
|
||||
"group.living_room_essential_present"
|
||||
];
|
||||
entities =
|
||||
[ "group.living_room" "group.living_room_essential_present" ];
|
||||
};
|
||||
view_kitchen_room = {
|
||||
name = "Küche";
|
||||
view = true;
|
||||
entities = [
|
||||
"group.kitchen_room"
|
||||
"group.kitchen_room_essential_present"
|
||||
];
|
||||
entities =
|
||||
[ "group.kitchen_room" "group.kitchen_room_essential_present" ];
|
||||
};
|
||||
view_floor_room = {
|
||||
name = "Flur";
|
||||
view = true;
|
||||
entities = [
|
||||
"group.floor_room"
|
||||
"group.floor_room_essential_present"
|
||||
];
|
||||
entities = [ "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
|
||||
|
|
|
@ -11,7 +11,7 @@ let
|
|||
"pal02" = {
|
||||
label = "Flur Lampe";
|
||||
icon = "mdi:lightbulb-on";
|
||||
room = "floor_room_essential";
|
||||
room = "living_room_essential";
|
||||
type = "light";
|
||||
};
|
||||
"pal03" = {
|
||||
|
|
|
@ -2,11 +2,40 @@
|
|||
let
|
||||
|
||||
# allow new devices to join
|
||||
enablePairing = false;
|
||||
enablePairing = true;
|
||||
|
||||
device = "/dev/ttyACM0";
|
||||
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 = {
|
||||
buttons = {
|
||||
"button_1" = {
|
||||
|
@ -56,7 +85,7 @@ let
|
|||
};
|
||||
"motion_sensor_5" = {
|
||||
id = "0x00158d0002f9a56f";
|
||||
room = "floor_room_present";
|
||||
room = "bath_room_essential_present";
|
||||
};
|
||||
"motion_sensor_6" = {
|
||||
id = "0x00158d0002f9a5cb";
|
||||
|
@ -66,7 +95,10 @@ let
|
|||
id = "0x00158d0002f9a6aa";
|
||||
room = "bed_room_essential_present";
|
||||
};
|
||||
"motion_sensor_8" = { id = "0x00158d0002f04637"; };
|
||||
"motion_sensor_8" = {
|
||||
id = "0x00158d0002f04637";
|
||||
room = "bath_room_essential_present";
|
||||
};
|
||||
};
|
||||
door = {
|
||||
"door_sensor_1" = { id = "0x00158d000312dc52"; };
|
||||
|
@ -85,6 +117,7 @@ let
|
|||
|
||||
# todo : generate automatically
|
||||
allSensors = with sensors; buttons // temperature // motion // door;
|
||||
allLights = lights;
|
||||
|
||||
zigBee2MqttConfig = {
|
||||
|
||||
|
@ -120,7 +153,7 @@ let
|
|||
retain = false;
|
||||
friendly_name = name;
|
||||
};
|
||||
}) allSensors;
|
||||
}) (allSensors // allLights);
|
||||
};
|
||||
|
||||
configurationYaml =
|
||||
|
@ -150,6 +183,20 @@ in {
|
|||
})
|
||||
]) 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
|
||||
# --------------
|
||||
sensor = let
|
||||
|
@ -220,7 +267,7 @@ in {
|
|||
unit_of_measurement = "lqi";
|
||||
value_template = "{{ value_json.linkquality }}";
|
||||
}
|
||||
]) allSensors;
|
||||
]) (allSensors // allLights);
|
||||
|
||||
in lib.flatten (buttons ++ temperature ++ informations);
|
||||
|
||||
|
@ -265,6 +312,15 @@ in {
|
|||
|
||||
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:
|
||||
{ states ? { }, ... }:
|
||||
let
|
||||
|
@ -353,19 +409,25 @@ in {
|
|||
sensors = sensors.door;
|
||||
entityNameing = ({ name, ... }: "binary_sensor.${name}");
|
||||
};
|
||||
lightGroups = createGroupEntities {
|
||||
sensors = allLights;
|
||||
entityNameing = ({ name, ... }: "light.${name}");
|
||||
};
|
||||
};
|
||||
|
||||
# merge all group entries
|
||||
in lib.mapAttrs (_: entities: { entities = lib.flatten entities; })
|
||||
(lib.zipAttrs (builtins.attrValues groupEntries));
|
||||
|
||||
in views // allRoomsGroups // sensorButtons // sensorMotions
|
||||
in lightGroups // views // allRoomsGroups // sensorButtons // sensorMotions
|
||||
// sensorTemperature // sensorDoors // {
|
||||
all_sensors.entities =
|
||||
(lib.mapAttrsToList (name: { ... }: "sensor.${name}")
|
||||
(sensors.buttons // sensors.temperature))
|
||||
++ (lib.mapAttrsToList (name: { ... }: "binary_sensor.${name}")
|
||||
(sensors.motion // sensors.door));
|
||||
all_lights.entities =
|
||||
lib.mapAttrsToList (name: { ... }: "light.${name}") allLights;
|
||||
};
|
||||
|
||||
# create automation
|
||||
|
|
|
@ -182,6 +182,10 @@ in {
|
|||
default = null;
|
||||
type = with types; nullOr (listOf attrs);
|
||||
};
|
||||
light = mkOption {
|
||||
default = null;
|
||||
type = with types; nullOr (listOf attrs);
|
||||
};
|
||||
sensor = mkOption {
|
||||
default = null;
|
||||
type = with types; nullOr (listOf attrs);
|
||||
|
|
Loading…
Reference in a new issue