|
blueprint: |
|
name: Smart Dimmer x ZHA Tradfri Double |
|
|
|
description: >- |
|
Smart Dimmer for the ZHA Tradfri Double. All in one blueprint. |
|
domain: automation |
|
input: |
|
remote: |
|
name: IKEA TRADFRI remote control |
|
description: Select the remote control you wish to use. |
|
selector: |
|
device: |
|
integration: zha |
|
manufacturer: IKEA of Sweden |
|
model: TRADFRI on/off switch |
|
light: |
|
name: Light 1 |
|
description: Select the light entity you wish to control. |
|
selector: |
|
target: |
|
entity: |
|
domain: light |
|
light2: |
|
name: Light 2 |
|
description: Select the light entity you wish to control. |
|
selector: |
|
target: |
|
entity: |
|
domain: light |
|
dimmer: |
|
name: Dimmer helper (input_boolean) |
|
description: An input_boolean helper that can be used to store temporary data. |
|
selector: |
|
entity: |
|
domain: input_boolean |
|
cts: |
|
name: Dimmer helper (input_text) |
|
description: An input_text helper that can be used to store temporary data. |
|
selector: |
|
entity: |
|
domain: input_text |
|
l1mode: |
|
name: Light 1 dimming mode |
|
default: "Timestamp" |
|
selector: |
|
select: |
|
options: |
|
- Timestamp (BETA) |
|
- ZHA ZLL light |
|
- ZHA Group of ZLL lights |
|
l1ieee: |
|
name: Light 1's IEEE or Group ID |
|
default: "0" |
|
selector: |
|
text: |
|
l2mode: |
|
name: Light 2 dimming mode |
|
default: "Timestamp" |
|
selector: |
|
select: |
|
options: |
|
- Timestamp |
|
- ZHA ZLL light |
|
- ZHA Group of ZLL lights |
|
l2ieee: |
|
name: Light 2's IEEE or Group ID |
|
default: "0" |
|
selector: |
|
text: |
|
|
|
mode: restart |
|
max_exceeded: silent |
|
|
|
trigger: |
|
- platform: event |
|
event_type: zha_event |
|
event_data: |
|
device_id: !input remote |
|
|
|
action: |
|
- choose: |
|
# Short-Press the on button |
|
- conditions: |
|
- condition: template |
|
value_template: '{{ trigger.event.data.command == "on" }}' |
|
- condition: template |
|
value_template: '{{ is_state(main_light_eid, "off") }}' |
|
sequence: |
|
- service: light.turn_on |
|
target: !input light |
|
|
|
- conditions: |
|
- condition: template |
|
value_template: '{{ trigger.event.data.command == "on" }}' |
|
- condition: template |
|
value_template: '{{ is_state(main_light_eid, "on") }}' |
|
sequence: |
|
- service: light.turn_off |
|
target: !input light |
|
|
|
# Long-Press the on button |
|
- conditions: |
|
- condition: template |
|
value_template: '{{ trigger.event.data.command == "move_with_on_off" }}' |
|
- condition: template |
|
value_template: '{{ (is_state(main_light_eid, "off")) or (state_attr(main_light_eid, "brightness") < 200) }}' |
|
- condition: or |
|
conditions: |
|
- condition: template |
|
value_template: '{{ is_state(main_light_eid, "off") }}' |
|
- condition: template |
|
value_template: '{{ state_attr(main_light_eid, "brightness") < 30 }}' |
|
- condition: state |
|
entity_id: !input dimmer |
|
state: "on" |
|
sequence: |
|
- service: input_boolean.turn_off |
|
target: |
|
entity_id: !input dimmer |
|
|
|
- service: input_text.set_value |
|
data: |
|
entity_id: !input cts |
|
value: "1 {{ now().timestamp() }} {{ state_attr(main_light_eid, 'brightness') if states(main_light_eid) == 'on' else 1 }}" |
|
|
|
- service: light.turn_on |
|
target: !input light |
|
data: |
|
brightness: 255 |
|
transition: 3 |
|
|
|
- conditions: |
|
- condition: template |
|
value_template: '{{ trigger.event.data.command == "move_with_on_off" }}' |
|
- condition: template |
|
value_template: '{{ is_state(main_light_eid, "on") }}' |
|
- condition: template |
|
value_template: '{{ state_attr(main_light_eid, "brightness") > 30 }}' |
|
- condition: or |
|
conditions: |
|
- condition: template |
|
value_template: '{{ state_attr(main_light_eid, "brightness") > 200 }}' |
|
- condition: state |
|
entity_id: !input dimmer |
|
state: "off" |
|
sequence: |
|
- service: input_boolean.turn_on |
|
target: |
|
entity_id: !input dimmer |
|
|
|
- service: input_text.set_value |
|
data: |
|
entity_id: !input cts |
|
value: "1 {{ now().timestamp() }} {{ state_attr(main_light_eid, 'brightness') if states(main_light_eid) == 'on' else 1 }}" |
|
|
|
- service: light.turn_on |
|
target: !input light |
|
data: |
|
brightness: 1 |
|
transition: 3 |
|
|
|
# Short-Press the off button |
|
- conditions: |
|
- condition: template |
|
value_template: '{{ trigger.event.data.command == "off" }}' |
|
- condition: template |
|
value_template: '{{ is_state(main_light2_eid, "off") }}' |
|
sequence: |
|
- service: light.turn_on |
|
target: !input light2 |
|
|
|
- conditions: |
|
- condition: template |
|
value_template: '{{ trigger.event.data.command == "off" }}' |
|
- condition: template |
|
value_template: '{{ is_state(main_light2_eid, "on") }}' |
|
sequence: |
|
- service: light.turn_off |
|
target: !input light2 |
|
|
|
# Long-Press the off button |
|
- conditions: |
|
- condition: template |
|
value_template: '{{ trigger.event.data.command == "move" }}' |
|
- condition: template |
|
value_template: '{{ (is_state(main_light2_eid, "off")) or (state_attr(main_light2_eid, "brightness") < 200) }}' |
|
- condition: or |
|
conditions: |
|
- condition: template |
|
value_template: '{{ is_state(main_light2_eid, "off") }}' |
|
- condition: template |
|
value_template: '{{ state_attr(main_light2_eid, "brightness") < 30 }}' |
|
- condition: state |
|
entity_id: !input dimmer |
|
state: "on" |
|
sequence: |
|
- service: input_boolean.turn_on |
|
target: |
|
entity_id: !input dimmer |
|
|
|
- service: input_text.set_value |
|
data: |
|
entity_id: !input cts |
|
value: "2 {{ now().timestamp() }} {{ state_attr(main_light2_eid, 'brightness') if states(main_light2_eid) == 'on' else 1 }}" |
|
|
|
- service: light.turn_on |
|
target: !input light2 |
|
data: |
|
brightness: 255 |
|
transition: 3 |
|
|
|
- conditions: |
|
- condition: template |
|
value_template: '{{ trigger.event.data.command == "move" }}' |
|
- condition: template |
|
value_template: '{{ is_state(main_light2_eid, "on") }}' |
|
- condition: template |
|
value_template: '{{ state_attr(main_light2_eid, "brightness") > 30 }}' |
|
- condition: or |
|
conditions: |
|
- condition: template |
|
value_template: '{{ state_attr(main_light2_eid, "brightness") > 200 }}' |
|
- condition: state |
|
entity_id: !input dimmer |
|
state: "off" |
|
sequence: |
|
- service: input_boolean.turn_on |
|
target: |
|
entity_id: !input dimmer |
|
|
|
- service: input_text.set_value |
|
data: |
|
entity_id: !input cts |
|
value: "2 {{ now().timestamp() }} {{ state_attr(main_light2_eid, 'brightness') if states(main_light2_eid) == 'on' else 1 }}" |
|
|
|
- service: light.turn_on |
|
target: !input light2 |
|
data: |
|
brightness: 1 |
|
transition: 3 |
|
|
|
default: |
|
- choose: |
|
- conditions: |
|
- condition: template |
|
value_template: '{{ states(cts_entity).split(" ")[0] == "1" }}' |
|
- condition: template |
|
value_template: '{{ l1mode == "Timestamp" }}' |
|
sequence: |
|
- service: light.turn_on |
|
target: !input light |
|
data: |
|
brightness: '{% set delta = (now().timestamp() - (states(cts_entity).split(" ")[1]|float)) %}{% set start = (((states(cts_entity).split(" ")[2]|int) / 3)|round) %}{% set up = states(dimmer_entity) == "off" %}{{ (((255 - start) / 3) * (delta + 0.2)) + start if up else 240 - (((255 - start) / 3) * (delta + 0.2)) }}' |
|
transition: 0 |
|
|
|
- conditions: |
|
- condition: template |
|
value_template: '{{ states(cts_entity).split(" ")[0] == "1" }}' |
|
- condition: template |
|
value_template: '{{ l1mode == "ZHA ZLL light" }}' |
|
sequence: |
|
- service: zha.issue_zigbee_cluster_command |
|
data: |
|
ieee: !input l1ieee |
|
cluster_id: 8 |
|
endpoint_id: 1 |
|
command: 3 |
|
command_type: server |
|
args: [] |
|
|
|
- conditions: |
|
- condition: template |
|
value_template: '{{ states(cts_entity).split(" ")[0] == "1" }}' |
|
- condition: template |
|
value_template: '{{ l1mode == "ZHA Group of ZLL lights" }}' |
|
sequence: |
|
- service: zha.issue_zigbee_group_command |
|
data: |
|
group: !input l1ieee |
|
cluster_id: 8 |
|
command: 3 |
|
args: [] |
|
# 2 |
|
- conditions: |
|
- condition: template |
|
value_template: '{{ states(cts_entity).split(" ")[0] == "2" }}' |
|
- condition: template |
|
value_template: '{{ l2mode == "ZHA ZLL light" }}' |
|
sequence: |
|
- service: zha.issue_zigbee_cluster_command |
|
data: |
|
ieee: !input l2ieee |
|
cluster_id: 8 |
|
endpoint_id: 1 |
|
command: 3 |
|
command_type: server |
|
args: [] |
|
|
|
- conditions: |
|
- condition: template |
|
value_template: '{{ states(cts_entity).split(" ")[0] == "2" }}' |
|
- condition: template |
|
value_template: '{{ l2mode == "ZHA Group of ZLL lights" }}' |
|
sequence: |
|
- service: zha.issue_zigbee_group_command |
|
data: |
|
group: !input l2ieee |
|
cluster_id: 8 |
|
command: 3 |
|
args: [] |
|
|
|
default: |
|
- service: light.turn_on |
|
target: !input light2 |
|
data: |
|
brightness: '{% set delta = (now().timestamp() - (states(cts_entity).split(" ")[1]|float)) %}{% set start = (((states(cts_entity).split(" ")[2]|int) / 3)|round) %}{% set up = states(dimmer_entity) == "off" %}{{ (((255 - start) / 3) * (delta + 0.2)) + start if up else 240 - (((255 - start) / 3) * (delta + 0.2)) }}' |
|
transition: 0 |
|
|
|
variables: |
|
main_light: !input light |
|
maind_light: !input light2 |
|
dimmer_entity: !input dimmer |
|
cts_entity: !input cts |
|
l1mode: !input l1mode |
|
l2mode: !input l2mode |
|
l1ieee: !input l1ieee |
|
l2ieee: !input l2ieee |
|
main_light_eid: '{% if main_light["entity_id"] is string %}{{ main_light["entity_id"] }}{% else %}{{ main_light["entity_id"][0] }}{% endif %}' |
|
main_light2_eid: '{% if maind_light["entity_id"] is string %}{{ maind_light["entity_id"] }}{% else %}{{ maind_light["entity_id"][0] }}{% endif %}' |