A input boolean must be created, named dimming occured (with a underscore between dimming and occured, cant insert that here ?)
blueprint:
name: zigbee2mqtt - EnOcean PTM 215Z On-Off-Dimming
description: Top buttons on/off and dimming of light. Bottom buttons control on/off and dimming of light
domain: automation
input:
switch:
name: Switch
description: on/off/dimming sensor
selector:
entity:
domain: sensor
light_top:
name: Light_top
description: The light to control with top buttons
selector:
target:
entity:
domain: light
light_buttom:
name: Light_buttom
description: The light to control with bottom buttons
selector:
target:
entity:
domain: light
mode: restart
max_exceeded: silent
trigger:
- platform: state
entity_id: !input "switch"
attribute: action
condition:
- condition: template
value_template: '{{ trigger.to_state.attributes.action in ("press_1","release_1","press_2","release_2","press_3","release_3","press_4","release_4") }}'
action:
- variables:
command: "{{ trigger.to_state.state }}"
- choose:
- conditions:
- "{{ command == 'press_2' }}"
sequence:
- service: light.turn_on
target: !input "light_buttom"
data: {}
- delay: "0.5"
- repeat:
count: "7"
sequence:
- service: light.turn_on
data:
brightness_step_pct: 15
transition: 0
target: !input "light_buttom"
- delay: "0.5"
- conditions:
- "{{ command == 'release_4' }}"
sequence:
- choose:
- conditions:
- condition: state
entity_id: input_boolean.dimming_occured
state: "off"
sequence:
- service: light.turn_off
data: {}
target: !input "light_buttom"
- conditions:
- condition: state
entity_id: input_boolean.dimming_occured
state: "on"
sequence:
- service: input_boolean.turn_off
target:
entity_id: input_boolean.dimming_occured
data: {}
- conditions:
- "{{ command == 'press_4' }}"
sequence:
- delay: "0.5"
- service: input_boolean.turn_on
target:
entity_id: input_boolean.dimming_occured
data: {}
- repeat:
count: "7"
sequence:
- service: light.turn_on
data:
brightness_step_pct: -15
transition: 0
target: !input "light_buttom"
- delay: "0.5"
- conditions:
- "{{ command == 'press_1' }}"
sequence:
- service: light.turn_on
target: !input "light_top"
data: {}
- delay: "0.5"
- repeat:
count: "7"
sequence:
- service: light.turn_on
data:
brightness_step_pct: 15
transition: 0
target: !input "light_top"
- delay: "0.5"
- conditions:
- "{{ command == 'release_3' }}"
sequence:
- choose:
- conditions:
- condition: state
entity_id: input_boolean.dimming_occured
state: "off"
sequence:
- service: light.turn_off
data: {}
target: !input "light_top"
- conditions:
- condition: state
entity_id: input_boolean.dimming_occured
state: "on"
sequence:
- service: input_boolean.turn_off
target:
entity_id: input_boolean.dimming_occured
data: {}
- conditions:
- "{{ command == 'press_3' }}"
sequence:
- delay: "0.5"
- service: input_boolean.turn_on
target:
entity_id: input_boolean.dimming_occured
data: {}
- repeat:
count: "7"
sequence:
- service: light.turn_on
data:
brightness_step_pct: -15
transition: 0
target: !input "light_top"
- delay: "0.5"