pepe: configured zigbee devices and automation rules
This commit is contained in:
parent
7756e5319d
commit
a51c8f1549
1 changed files with 55 additions and 23 deletions
|
@ -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: {
|
||||||
|
# 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 = {
|
trigger = {
|
||||||
platform = "mqtt";
|
platform = "state";
|
||||||
topic = "zigbee2mqtt/${button}";
|
entity_id = "binary_sensor.${motion}";
|
||||||
};
|
from = "off";
|
||||||
condition = {
|
to = "on";
|
||||||
condition = "template";
|
|
||||||
value_template = ''{{ "double" == trigger.payload_json.click }}'';
|
|
||||||
};
|
};
|
||||||
action = {
|
action = {
|
||||||
service = "media_player.toggle";
|
service = "switch.turn_on";
|
||||||
# todo use a group here
|
entity_id = "group.kitchen";
|
||||||
entity_id = "media_player.mpd";
|
|
||||||
};
|
};
|
||||||
}) [ "button_1" "button_2" "button_3" ];
|
}
|
||||||
in lights ++ mpd;
|
{
|
||||||
|
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
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue