pepe: configured zigbee devices and automation rules

This commit is contained in:
Ingolf Wagner 2020-04-12 01:48:30 +02:00
parent 7756e5319d
commit a51c8f1549
Signed by: palo
GPG key ID: 76BF5F1928B9618B

View file

@ -72,14 +72,14 @@ in {
sensor = let sensor = let
buttons = with lib; buttons = with lib;
mapAttrsToList (name: mapAttrsToList (name:
{ ... }: { { ... }: [{
platform = "mqtt"; platform = "mqtt";
name = name; name = name;
icon = "mdi:toggle-switch"; icon = "mdi:toggle-switch";
state_topic = "zigbee2mqtt/${name}"; state_topic = "zigbee2mqtt/${name}";
availability_topic = "zigbee2mqtt/bridge/state"; availability_topic = "zigbee2mqtt/bridge/state";
value_template = "{{ value_json.click }}"; value_template = "{{ value_json.click }}";
}) sensors.buttons; }]) sensors.buttons;
temperature = with lib; temperature = with lib;
mapAttrsToList (name: mapAttrsToList (name:
@ -116,12 +116,11 @@ in {
informations = lib.mapAttrsToList (name: informations = lib.mapAttrsToList (name:
{ ... }: [ { ... }: [
{ {
platform = "mqtt";
name = "battery_${name}"; name = "battery_${name}";
platform = "mqtt";
state_topic = "zigbee2mqtt/${name}"; state_topic = "zigbee2mqtt/${name}";
availability_topic = "zigbee2mqtt/bridge/state"; availability_topic = "zigbee2mqtt/bridge/state";
unit_of_measurement = "%"; unit_of_measurement = "%";
device_class = "battery";
value_template = "{{ value_json.battery }}"; value_template = "{{ value_json.battery }}";
} }
{ {
@ -129,7 +128,8 @@ in {
platform = "mqtt"; platform = "mqtt";
state_topic = "zigbee2mqtt/${name}"; state_topic = "zigbee2mqtt/${name}";
availability_topic = "zigbee2mqtt/bridge/state"; availability_topic = "zigbee2mqtt/bridge/state";
unit_of_measurement = "-"; icon = "mdi:signal";
unit_of_measurement = "lqi";
value_template = "{{ value_json.linkquality }}"; value_template = "{{ value_json.linkquality }}";
} }
]) allSensors; ]) allSensors;
@ -143,7 +143,6 @@ in {
name = name; name = name;
platform = "mqtt"; platform = "mqtt";
device_class = "motion"; device_class = "motion";
#icon = "mdi:motion-sensor";
state_topic = "zigbee2mqtt/${name}"; state_topic = "zigbee2mqtt/${name}";
availability_topic = "zigbee2mqtt/bridge/state"; availability_topic = "zigbee2mqtt/bridge/state";
payload_on = true; payload_on = true;
@ -200,6 +199,7 @@ in {
in views // sensor // binarySensor // sensorTemperature; in views // sensor // binarySensor // sensorTemperature;
automation = let automation = let
lights = map (button: { lights = map (button: {
alias = "Toggle all lights, on click"; alias = "Toggle all lights, on click";
trigger = { trigger = {
@ -215,23 +215,55 @@ in {
entity_id = "group.all_lights"; entity_id = "group.all_lights";
}; };
}) [ "button_1" "button_2" "button_3" ]; }) [ "button_1" "button_2" "button_3" ];
mpd = map (button: {
alias = "Toggle mpd, on double click"; #mpd = map (button: {
trigger = { # alias = "Toggle mpd, on double click";
platform = "mqtt"; # trigger = {
topic = "zigbee2mqtt/${button}"; # platform = "mqtt";
}; # topic = "zigbee2mqtt/${button}";
condition = { # };
condition = "template"; # condition = {
value_template = ''{{ "double" == trigger.payload_json.click }}''; # condition = "template";
}; # value_template = ''{{ "double" == trigger.payload_json.click }}'';
action = { # };
service = "media_player.toggle"; # action = {
# todo use a group here # service = "media_player.toggle";
entity_id = "media_player.mpd"; # # todo use a group here
}; # entity_id = "media_player.mpd";
}) [ "button_1" "button_2" "button_3" ]; # };
in lights ++ mpd; #}) [ "button_1" "button_2" "button_3" ];
# https://www.home-assistant.io/integrations/binary_sensor.template/
kitchen_lights = map (motion: [
{
alias = "turn on lights, on motion";
trigger = {
platform = "state";
entity_id = "binary_sensor.${motion}";
from = "off";
to = "on";
};
action = {
service = "switch.turn_on";
entity_id = "group.kitchen";
};
}
{
alias = "turn off lights, on no motion";
trigger = {
platform = "state";
entity_id = "binary_sensor.${motion}";
from = "on";
to = "off";
};
action = {
service = "switch.turn_off";
entity_id = "group.kitchen";
};
}
]) [ "motion_sensor_1" ];
in lib.flatten (lights ++ kitchen_lights);
# click = double => music an aus # click = double => music an aus