Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save rdorys/dc7a352a8d7b835ccdece8528b59820f to your computer and use it in GitHub Desktop.

Select an option

Save rdorys/dc7a352a8d7b835ccdece8528b59820f to your computer and use it in GitHub Desktop.

Revisions

  1. rdorys revised this gist Jan 4, 2023. 1 changed file with 82 additions and 77 deletions.
    159 changes: 82 additions & 77 deletions EnOcean PTM 215Z (Friends of Hue) switch.yaml
    Original file line number Diff line number Diff line change
    @@ -1,28 +1,29 @@
    blueprint:
    name: Controller - EnOcean PTM 215Z (Friends of Hue) switch
    description: 'Controller automation for executing press/hold/release actions triggered by
    EnOcean PTM 215Z (Friends of Hue) switch.'

    description: Controller automation for executing press/hold/release actions triggered
    by EnOcean PTM 215Z (Friends of Hue) switch.
    domain: automation
    input:
    input:
    controller_entity:
    name: (Zigbee2MQTT) Controller Entity
    description: The action sensor of the controller to use for the automation.
    default: ''
    selector:
    entity:
    domain: sensor
    multiple: false
    hold_delay:
    name: Hold delay
    description: If the button has been held more than the configured Hold delay, the corresponding held action is triggered.
    description: If the button has been held more than the configured Hold delay,
    the corresponding held action is triggered.
    default: 500
    selector:
    number:
    min: 100.0
    max: 1000.0
    unit_of_measurement: milliseconds
    mode: box
    step: 10.0
    step: 10.0
    button_1_pressed:
    name: Button 1 Pressed
    description: Action to run, when button 1 is pressed.
    @@ -40,7 +41,7 @@ blueprint:
    description: Action to run, when the button 1 is released.
    default: []
    selector:
    action: {}
    action: {}
    button_2_pressed:
    name: Button 2 Pressed
    description: Action to run, when the button 2 pressed.
    @@ -58,7 +59,7 @@ blueprint:
    description: Action to run, when the button 2 is released.
    default: []
    selector:
    action: {}
    action: {}
    button_3_pressed:
    name: Button 3 Pressed
    description: Action to run, when the button 3 is pressed.
    @@ -76,7 +77,7 @@ blueprint:
    description: Action to run, when the button 3 is released.
    default: []
    selector:
    action: {}
    action: {}
    button_4_pressed:
    name: Button 4 Pressed
    description: Action to run, when the button 4 is pressed.
    @@ -88,7 +89,7 @@ blueprint:
    description: Action to run, when the button 4 is held.
    default: []
    selector:
    action: {}
    action: {}
    button_4_released:
    name: Button 4 released
    description: Action to run, when the button 4 is released.
    @@ -106,13 +107,13 @@ blueprint:
    description: Action to run, when the button 1 and 3 is held.
    default: []
    selector:
    action: {}
    action: {}
    button_1_and_3_released:
    name: Button 1 and 3 released
    description: Action to run, when the button 1 and 3 is released.
    default: []
    selector:
    action: {}
    action: {}
    button_2_and_4_pressed:
    name: Button 2 and 4 Pressed
    description: Action to run, when the button 2 and 4 is pressed.
    @@ -124,87 +125,91 @@ blueprint:
    description: Action to run, when the button 2 and 4 is held.
    default: []
    selector:
    action: {}
    action: {}
    button_2_and_4_released:
    name: Button 2 and 4 released
    description: Action to run, when the button 2 and 4 is released.
    default: []
    selector:
    action: {}
    mode: parallel
    action: {}
    source_url: https://gist.github.com/rdorys/dc7a352a8d7b835ccdece8528b59820f
    mode: queued
    max: 25
    max_exceeded: silent
    trigger:
    - platform: event
    event_type: state_changed
    event_data:
    entity_id: !input 'controller_entity'
    entity_id: !input controller_entity
    condition: '{{ trigger.event.data.new_state.state not in ["","None"] }}'
    action:
    - variables:
    trigger_action: '{{ trigger.event.data.new_state.state }}'

    - choose:
    - conditions: '{{ "press_" | string in trigger_action }}'
    sequence:
    - wait_for_trigger:
    - platform: state
    entity_id: !input 'controller_entity'
    to: "release_1"
    - platform: state
    entity_id: !input 'controller_entity'
    to: "release_2"
    - platform: state
    entity_id: !input 'controller_entity'
    to: "release_3"
    - platform: state
    entity_id: !input 'controller_entity'
    to: "release_4"
    - platform: state
    entity_id: !input 'controller_entity'
    to: "release_1_and_3"
    - platform: state
    entity_id: !input 'controller_entity'
    to: "release_2_and_4"
    timeout:
    milliseconds: !input 'hold_delay'
    - choose:
    - conditions: '{{ trigger_action == "press_1" and wait.trigger != None }}'
    sequence: !input 'button_1_pressed'
    - conditions: '{{ trigger_action == "press_2" and wait.trigger != None }}'
    sequence: !input 'button_2_pressed'
    - conditions: '{{ trigger_action == "press_3" and wait.trigger != None }}'
    sequence: !input 'button_3_pressed'
    - conditions: '{{ trigger_action == "press_4" and wait.trigger != None }}'
    sequence: !input 'button_4_pressed'
    - conditions: '{{ trigger_action == "press_1_and_3" and wait.trigger != None }}'
    sequence: !input 'button_1_and_3_pressed'
    - conditions: '{{ trigger_action == "press_2_and_4" and wait.trigger != None }}'
    sequence: !input 'button_2_and_4_pressed'
    - conditions: '{{ trigger_action == "press_1" and wait.trigger == None }}'
    sequence: !input 'button_1_held'
    - conditions: '{{ trigger_action == "press_2" and wait.trigger == None }}'
    sequence: !input 'button_2_held'
    - conditions: '{{ trigger_action == "press_3" and wait.trigger == None }}'
    sequence: !input 'button_3_held'
    - conditions: '{{ trigger_action == "press_4" and wait.trigger == None }}'
    sequence: !input 'button_4_held'
    - conditions: '{{ trigger_action == "press_1_and_3" and wait.trigger == None }}'
    sequence: !input 'button_1_and_3_held'
    - conditions: '{{ trigger_action == "press_2_and_4" and wait.trigger == None }}'
    sequence: !input 'button_2_and_4_held'

    - wait_for_trigger:
    - platform: state
    entity_id: !input controller_entity
    to: release_1
    - platform: state
    entity_id: !input controller_entity
    to: release_2
    - platform: state
    entity_id: !input controller_entity
    to: release_3
    - platform: state
    entity_id: !input controller_entity
    to: release_4
    - platform: state
    entity_id: !input controller_entity
    to: release_1_and_3
    - platform: state
    entity_id: !input controller_entity
    to: release_2_and_4
    timeout:
    milliseconds: !input hold_delay
    - choose:
    - conditions: '{{ trigger_action == "press_1" and wait.trigger != None }}'
    sequence: !input button_1_pressed
    - conditions: '{{ trigger_action == "press_2" and wait.trigger != None }}'
    sequence: !input button_2_pressed
    - conditions: '{{ trigger_action == "press_3" and wait.trigger != None }}'
    sequence: !input button_3_pressed
    - conditions: '{{ trigger_action == "press_4" and wait.trigger != None }}'
    sequence: !input button_4_pressed
    - conditions: '{{ trigger_action == "press_1_and_3" and wait.trigger != None
    }}'
    sequence: !input button_1_and_3_pressed
    - conditions: '{{ trigger_action == "press_2_and_4" and wait.trigger != None
    }}'
    sequence: !input button_2_and_4_pressed
    - conditions: '{{ trigger_action == "press_1" and wait.trigger == None }}'
    sequence: !input button_1_held
    - conditions: '{{ trigger_action == "press_2" and wait.trigger == None }}'
    sequence: !input button_2_held
    - conditions: '{{ trigger_action == "press_3" and wait.trigger == None }}'
    sequence: !input button_3_held
    - conditions: '{{ trigger_action == "press_4" and wait.trigger == None }}'
    sequence: !input button_4_held
    - conditions: '{{ trigger_action == "press_1_and_3" and wait.trigger == None
    }}'
    sequence: !input button_1_and_3_held
    - conditions: '{{ trigger_action == "press_2_and_4" and wait.trigger == None
    }}'
    sequence: !input button_2_and_4_held
    - conditions: '{{ "release_" | string in trigger_action }}'
    sequence:
    - choose:
    - conditions: '{{ trigger_action == "release_1" }}'
    sequence: !input 'button_1_released'
    - conditions: '{{ trigger_action == "release_2" }}'
    sequence: !input 'button_2_released'
    - conditions: '{{ trigger_action == "release_3" }}'
    sequence: !input 'button_3_released'
    - conditions: '{{ trigger_action == "release_4" }}'
    sequence: !input 'button_4_released'
    - conditions: '{{ trigger_action == "release_1_and_3" }}'
    sequence: !input 'button_1_and_3_released'
    - conditions: '{{ trigger_action == "release_2_and_4" }}'
    sequence: !input 'button_2_and_4_released'
    - choose:
    - conditions: '{{ trigger_action == "release_1" }}'
    sequence: !input button_1_released
    - conditions: '{{ trigger_action == "release_2" }}'
    sequence: !input button_2_released
    - conditions: '{{ trigger_action == "release_3" }}'
    sequence: !input button_3_released
    - conditions: '{{ trigger_action == "release_4" }}'
    sequence: !input button_4_released
    - conditions: '{{ trigger_action == "release_1_and_3" }}'
    sequence: !input button_1_and_3_released
    - conditions: '{{ trigger_action == "release_2_and_4" }}'
    sequence: !input button_2_and_4_released
  2. rdorys revised this gist Jan 4, 2023. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion EnOcean PTM 215Z (Friends of Hue) switch.yaml
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,6 @@ blueprint:
    selector:
    entity:
    domain: sensor
    multiple: true
    hold_delay:
    name: Hold delay
    description: If the button has been held more than the configured Hold delay, the corresponding held action is triggered.
  3. rdorys revised this gist Jan 4, 2023. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion EnOcean PTM 215Z (Friends of Hue) switch.yaml
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,8 @@ blueprint:
    default: ''
    selector:
    entity:
    domain: sensor
    domain: sensor
    multiple: true
    hold_delay:
    name: Hold delay
    description: If the button has been held more than the configured Hold delay, the corresponding held action is triggered.
  4. rdorys revised this gist Jan 4, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion EnOcean PTM 215Z (Friends of Hue) switch.yaml
    Original file line number Diff line number Diff line change
    @@ -131,7 +131,7 @@ blueprint:
    default: []
    selector:
    action: {}
    mode: single
    mode: parallel
    max_exceeded: silent
    trigger:
    - platform: event
  5. rdorys revised this gist Jan 4, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion EnOcean PTM 215Z (Friends of Hue) switch.yaml
    Original file line number Diff line number Diff line change
    @@ -131,7 +131,7 @@ blueprint:
    default: []
    selector:
    action: {}
    mode: queued
    mode: single
    max_exceeded: silent
    trigger:
    - platform: event
  6. rdorys revised this gist Jan 4, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion EnOcean PTM 215Z (Friends of Hue) switch.yaml
    Original file line number Diff line number Diff line change
    @@ -131,7 +131,7 @@ blueprint:
    default: []
    selector:
    action: {}
    mode: single
    mode: queued
    max_exceeded: silent
    trigger:
    - platform: event
  7. @samuolis samuolis revised this gist Oct 9, 2022. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions EnOcean PTM 215Z (Friends of Hue) switch.yaml
    Original file line number Diff line number Diff line change
    @@ -194,6 +194,7 @@ action:
    sequence: !input 'button_2_and_4_held'

    - conditions: '{{ "release_" | string in trigger_action }}'
    sequence:
    - choose:
    - conditions: '{{ trigger_action == "release_1" }}'
    sequence: !input 'button_1_released'
  8. @samuolis samuolis revised this gist Oct 9, 2022. 1 changed file with 57 additions and 21 deletions.
    78 changes: 57 additions & 21 deletions EnOcean PTM 215Z (Friends of Hue) switch.yaml
    Original file line number Diff line number Diff line change
    @@ -94,7 +94,43 @@ blueprint:
    description: Action to run, when the button 4 is released.
    default: []
    selector:
    action: {}
    action: {}
    button_1_and_3_pressed:
    name: Button 1 and 3 Pressed
    description: Action to run, when the button 1 and 3 is pressed.
    default: []
    selector:
    action: {}
    button_1_and_3_held:
    name: Button 1 and 3 Held
    description: Action to run, when the button 1 and 3 is held.
    default: []
    selector:
    action: {}
    button_1_and_3_released:
    name: Button 1 and 3 released
    description: Action to run, when the button 1 and 3 is released.
    default: []
    selector:
    action: {}
    button_2_and_4_pressed:
    name: Button 2 and 4 Pressed
    description: Action to run, when the button 2 and 4 is pressed.
    default: []
    selector:
    action: {}
    button_2_and_4_held:
    name: Button 2 and 4 Held
    description: Action to run, when the button 2 and 4 is held.
    default: []
    selector:
    action: {}
    button_2_and_4_released:
    name: Button 2 and 4 released
    description: Action to run, when the button 2 and 4 is released.
    default: []
    selector:
    action: {}
    mode: single
    max_exceeded: silent
    trigger:
    @@ -123,21 +159,14 @@ action:
    - platform: state
    entity_id: !input 'controller_entity'
    to: "release_4"
    - platform: state
    entity_id: !input 'controller_entity'
    to: "release_1_and_3"
    - platform: state
    entity_id: !input 'controller_entity'
    to: "release_2_and_4"
    timeout:
    milliseconds: !input 'hold_delay'
    # - choose:
    # - conditions: '{{ wait.trigger != None }}'
    # sequence:
    # - service: logbook.log
    # data:
    # name: Button Id
    # message: '{{ trigger_action }} - press action'
    # - conditions: '{{ wait.trigger == None }}'
    # sequence:
    # - service: logbook.log
    # data:
    # name: Button Id
    # message: '{{ trigger_action }} - hold action'
    milliseconds: !input 'hold_delay'
    - choose:
    - conditions: '{{ trigger_action == "press_1" and wait.trigger != None }}'
    sequence: !input 'button_1_pressed'
    @@ -147,6 +176,10 @@ action:
    sequence: !input 'button_3_pressed'
    - conditions: '{{ trigger_action == "press_4" and wait.trigger != None }}'
    sequence: !input 'button_4_pressed'
    - conditions: '{{ trigger_action == "press_1_and_3" and wait.trigger != None }}'
    sequence: !input 'button_1_and_3_pressed'
    - conditions: '{{ trigger_action == "press_2_and_4" and wait.trigger != None }}'
    sequence: !input 'button_2_and_4_pressed'
    - conditions: '{{ trigger_action == "press_1" and wait.trigger == None }}'
    sequence: !input 'button_1_held'
    - conditions: '{{ trigger_action == "press_2" and wait.trigger == None }}'
    @@ -155,13 +188,12 @@ action:
    sequence: !input 'button_3_held'
    - conditions: '{{ trigger_action == "press_4" and wait.trigger == None }}'
    sequence: !input 'button_4_held'
    - conditions: '{{ trigger_action == "press_1_and_3" and wait.trigger == None }}'
    sequence: !input 'button_1_and_3_held'
    - conditions: '{{ trigger_action == "press_2_and_4" and wait.trigger == None }}'
    sequence: !input 'button_2_and_4_held'

    - conditions: '{{ "release_" | string in trigger_action }}'
    sequence:
    # - service: logbook.log
    # data:
    # name: Button Id
    # message: '{{ trigger_action }} - release action'
    - choose:
    - conditions: '{{ trigger_action == "release_1" }}'
    sequence: !input 'button_1_released'
    @@ -170,4 +202,8 @@ action:
    - conditions: '{{ trigger_action == "release_3" }}'
    sequence: !input 'button_3_released'
    - conditions: '{{ trigger_action == "release_4" }}'
    sequence: !input 'button_4_released'
    sequence: !input 'button_4_released'
    - conditions: '{{ trigger_action == "release_1_and_3" }}'
    sequence: !input 'button_1_and_3_released'
    - conditions: '{{ trigger_action == "release_2_and_4" }}'
    sequence: !input 'button_2_and_4_released'
  9. @nickknissen nickknissen renamed this gist Dec 9, 2021. 1 changed file with 0 additions and 0 deletions.
  10. @nickknissen nickknissen created this gist Dec 9, 2021.
    173 changes: 173 additions & 0 deletions EnOcean PTM 215Z (Friends of Hue) switch
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,173 @@
    blueprint:
    name: Controller - EnOcean PTM 215Z (Friends of Hue) switch
    description: 'Controller automation for executing press/hold/release actions triggered by
    EnOcean PTM 215Z (Friends of Hue) switch.'

    domain: automation
    input:
    controller_entity:
    name: (Zigbee2MQTT) Controller Entity
    description: The action sensor of the controller to use for the automation.
    default: ''
    selector:
    entity:
    domain: sensor
    hold_delay:
    name: Hold delay
    description: If the button has been held more than the configured Hold delay, the corresponding held action is triggered.
    default: 500
    selector:
    number:
    min: 100.0
    max: 1000.0
    unit_of_measurement: milliseconds
    mode: box
    step: 10.0
    button_1_pressed:
    name: Button 1 Pressed
    description: Action to run, when button 1 is pressed.
    default: []
    selector:
    action: {}
    button_1_held:
    name: Button 1 Held
    description: Action to run, when the button 1 is held.
    default: []
    selector:
    action: {}
    button_1_released:
    name: Button 1 released
    description: Action to run, when the button 1 is released.
    default: []
    selector:
    action: {}
    button_2_pressed:
    name: Button 2 Pressed
    description: Action to run, when the button 2 pressed.
    default: []
    selector:
    action: {}
    button_2_held:
    name: Button 2 Held
    description: Action to run, when the button 2 is held.
    default: []
    selector:
    action: {}
    button_2_released:
    name: Button 2 released
    description: Action to run, when the button 2 is released.
    default: []
    selector:
    action: {}
    button_3_pressed:
    name: Button 3 Pressed
    description: Action to run, when the button 3 is pressed.
    default: []
    selector:
    action: {}
    button_3_held:
    name: Button 3 Held
    description: Action to run, when the button 3 is held.
    default: []
    selector:
    action: {}
    button_3_released:
    name: Button 3 released
    description: Action to run, when the button 3 is released.
    default: []
    selector:
    action: {}
    button_4_pressed:
    name: Button 4 Pressed
    description: Action to run, when the button 4 is pressed.
    default: []
    selector:
    action: {}
    button_4_held:
    name: Button 4 Held
    description: Action to run, when the button 4 is held.
    default: []
    selector:
    action: {}
    button_4_released:
    name: Button 4 released
    description: Action to run, when the button 4 is released.
    default: []
    selector:
    action: {}
    mode: single
    max_exceeded: silent
    trigger:
    - platform: event
    event_type: state_changed
    event_data:
    entity_id: !input 'controller_entity'
    condition: '{{ trigger.event.data.new_state.state not in ["","None"] }}'
    action:
    - variables:
    trigger_action: '{{ trigger.event.data.new_state.state }}'

    - choose:
    - conditions: '{{ "press_" | string in trigger_action }}'
    sequence:
    - wait_for_trigger:
    - platform: state
    entity_id: !input 'controller_entity'
    to: "release_1"
    - platform: state
    entity_id: !input 'controller_entity'
    to: "release_2"
    - platform: state
    entity_id: !input 'controller_entity'
    to: "release_3"
    - platform: state
    entity_id: !input 'controller_entity'
    to: "release_4"
    timeout:
    milliseconds: !input 'hold_delay'
    # - choose:
    # - conditions: '{{ wait.trigger != None }}'
    # sequence:
    # - service: logbook.log
    # data:
    # name: Button Id
    # message: '{{ trigger_action }} - press action'
    # - conditions: '{{ wait.trigger == None }}'
    # sequence:
    # - service: logbook.log
    # data:
    # name: Button Id
    # message: '{{ trigger_action }} - hold action'
    - choose:
    - conditions: '{{ trigger_action == "press_1" and wait.trigger != None }}'
    sequence: !input 'button_1_pressed'
    - conditions: '{{ trigger_action == "press_2" and wait.trigger != None }}'
    sequence: !input 'button_2_pressed'
    - conditions: '{{ trigger_action == "press_3" and wait.trigger != None }}'
    sequence: !input 'button_3_pressed'
    - conditions: '{{ trigger_action == "press_4" and wait.trigger != None }}'
    sequence: !input 'button_4_pressed'
    - conditions: '{{ trigger_action == "press_1" and wait.trigger == None }}'
    sequence: !input 'button_1_held'
    - conditions: '{{ trigger_action == "press_2" and wait.trigger == None }}'
    sequence: !input 'button_2_held'
    - conditions: '{{ trigger_action == "press_3" and wait.trigger == None }}'
    sequence: !input 'button_3_held'
    - conditions: '{{ trigger_action == "press_4" and wait.trigger == None }}'
    sequence: !input 'button_4_held'

    - conditions: '{{ "release_" | string in trigger_action }}'
    sequence:
    # - service: logbook.log
    # data:
    # name: Button Id
    # message: '{{ trigger_action }} - release action'
    - choose:
    - conditions: '{{ trigger_action == "release_1" }}'
    sequence: !input 'button_1_released'
    - conditions: '{{ trigger_action == "release_2" }}'
    sequence: !input 'button_2_released'
    - conditions: '{{ trigger_action == "release_3" }}'
    sequence: !input 'button_3_released'
    - conditions: '{{ trigger_action == "release_4" }}'
    sequence: !input 'button_4_released'