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
No known key found for this signature in database
GPG key ID: 76BF5F1928B9618B

View file

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