From 406e7e049d5ea9c3c7eae5571b1c805d988ba0c3 Mon Sep 17 00:00:00 2001 From: Georgi Gardev Date: Mon, 8 Jun 2020 22:07:59 +0300 Subject: [PATCH] Add trust_remote config. zigbee2mqtt is awesome :) --- .../devices/living_room/trust_remote.yaml | 114 ++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 config/packages/devices/living_room/trust_remote.yaml diff --git a/config/packages/devices/living_room/trust_remote.yaml b/config/packages/devices/living_room/trust_remote.yaml new file mode 100644 index 0000000..f9cb9ac --- /dev/null +++ b/config/packages/devices/living_room/trust_remote.yaml @@ -0,0 +1,114 @@ +sensor: + - platform: mqtt + name: "Trust remote action" + state_topic: "zigbee2mqtt/trust_remote" + availability_topic: "zigbee2mqtt/bridge/state" + icon: "mdi:gesture-double-tap" + value_template: "{{ value_json.action }}" + - platform: mqtt + name: "Trust remote group" + state_topic: "zigbee2mqtt/trust_remote" + availability_topic: "zigbee2mqtt/bridge/state" + icon: "mdi:lightbulb-group" + value_template: "{{ value_json.action_group }}" + - platform: mqtt + name: "Trust remote LQI" + state_topic: "zigbee2mqtt/trust_remote" + availability_topic: "zigbee2mqtt/bridge/state" + icon: "mdi:signal" + unit_of_measurement: "lqi" + value_template: "{{ value_json.linkquality }}" + +automation: + - alias: Trust remote · Dimming + trigger: + - platform: state + entity_id: sensor.trust_remote_action + to: "down-press" + - platform: state + entity_id: sensor.trust_remote_action + to: "up-press" + action: + - service: light.turn_on + data_template: + entity_id: >- + {% set groupId = states('sensor.trust_remote_group')[4] | int %} + {% if groupId == 5 %} + {% set entityId = 'light.living_room' %} + {% elif groupId == 0 %} + {% set entityId = 'light.living_room_main' %} + {% elif groupId == 1 %} + {% set entityId = 'light.light_avatar_small_2' %} + {% elif groupId == 2 %} + {% set entityId = 'light.living_room_ambient' %} + {% elif groupId == 3 %} + {% set entityId = 'light.living_room_ambient_main' %} + {% elif groupId == 4 %} + {% set entityId = 'light.light_avatar_small_1' %} + {% endif %} + + {{ entityId }} + + brightness_step_pct: >- + {% if trigger.to_state.state == "up-press" %} + 20 + {% else %} + -20 + {% endif %} + + - alias: Trust remote · Turn on + trigger: + - platform: mqtt + topic: zigbee2mqtt/trust_remote + condition: + - condition: template + value_template: > + {{ trigger.payload_json.action == "on" }} + action: + - service_template: light.turn_on + data_template: + entity_id: >- + {% set groupId = (trigger.payload_json.action_group % 10) %} + {% if groupId == 5 %} + light.living_room + {% elif groupId == 0 %} + light.living_room_main + {% elif groupId == 1 %} + light.light_avatar_small_2 + {% elif groupId == 2 %} + light.living_room_ambient + {% elif groupId == 3 %} + light.living_room_ambient_main + {% elif groupId == 4 %} + light.light_avatar_small_1 + {% endif %} + brightness_pct: 100 + + - alias: Trust remote · Turn off + trigger: + - platform: mqtt + topic: zigbee2mqtt/trust_remote + condition: + - condition: template + value_template: >- + {{ trigger.payload_json.action == "off" }} + action: + - service: light.turn_off + data_template: + entity_id: >- + {% set groupId = (trigger.payload_json.action_group % 10) %} + {% if groupId == 5 %} + {% set entityId = 'light.living_room' %} + {% elif groupId == 0 %} + {% set entityId = 'light.living_room_main' %} + {% elif groupId == 1 %} + {% set entityId = 'light.light_avatar_small_2' %} + {% elif groupId == 2 %} + {% set entityId = 'light.living_room_ambient' %} + {% elif groupId == 3 %} + {% set entityId = 'light.living_room_ambient_main' %} + {% elif groupId == 4 %} + {% set entityId = 'light.light_avatar_small_1' %} + {% endif %} + + {{ entityId }}