Skip to content

Instantly share code, notes, and snippets.

@jeffreykog
Last active December 17, 2024 06:09
Show Gist options
  • Select an option

  • Save jeffreykog/362ccd662176097255d0eeb8a46bad22 to your computer and use it in GitHub Desktop.

Select an option

Save jeffreykog/362ccd662176097255d0eeb8a46bad22 to your computer and use it in GitHub Desktop.

Revisions

  1. jeffreykog revised this gist Aug 19, 2024. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions somrig-cover-remote.yaml
    Original file line number Diff line number Diff line change
    @@ -41,6 +41,12 @@ max_exceeded: silent
    trigger:
    - platform: state
    entity_id: !input remote_entity
    from: ''
    to: '1_initial_press'
    - platform: state
    entity_id: !input remote_entity
    from: ''
    to: '2_initial_press'
    action:
    - variables:
    window_sensor_entity: !input window_sensor_entity
  2. jeffreykog revised this gist Aug 19, 2024. 1 changed file with 16 additions and 15 deletions.
    31 changes: 16 additions & 15 deletions somrig-cover-remote.yaml
    Original file line number Diff line number Diff line change
    @@ -41,7 +41,6 @@ max_exceeded: silent
    trigger:
    - platform: state
    entity_id: !input remote_entity
    from: ''
    action:
    - variables:
    window_sensor_entity: !input window_sensor_entity
    @@ -56,26 +55,28 @@ action:
    state: closing
    then:
    - action: cover.stop_cover
    metadata: {}
    data: {}
    target:
    entity_id: !input cover_entity
    else:
    - if:
    - condition: template
    value_template: "{{ trigger.to_state.state == \"1_initial_press\" and (window_sensor_entity is none or is_state(window_sensor_entity, 'off')) }}"
    value_template: "{{ trigger.to_state.state == \"1_initial_press\" }}"
    then:
    - action: cover.open_cover
    metadata: {}
    data: {}
    target:
    entity_id: !input cover_entity
    - if:
    - condition: template
    value_template: "{{ window_sensor_entity is none or is_state(window_sensor_entity, 'off') }}"
    then:
    - action: cover.open_cover
    target:
    entity_id: !input cover_entity
    - if:
    - condition: template
    value_template: "{{ trigger.to_state.state == \"2_initial_press\" and (window_sensor_entity is none or is_state(window_sensor_entity, 'off')) }}"
    value_template: "{{ trigger.to_state.state == \"2_initial_press\" }}"
    then:
    - action: cover.close_cover
    metadata: {}
    data: {}
    target:
    entity_id: !input cover_entity
    - if:
    - condition: template
    value_template: "{{ window_sensor_entity is none or is_state(window_sensor_entity, 'off') }}"
    then:
    - action: cover.close_cover
    target:
    entity_id: !input cover_entity
  3. jeffreykog revised this gist Aug 19, 2024. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions somrig-cover-remote.yaml
    Original file line number Diff line number Diff line change
    @@ -41,6 +41,7 @@ max_exceeded: silent
    trigger:
    - platform: state
    entity_id: !input remote_entity
    from: ''
    action:
    - variables:
    window_sensor_entity: !input window_sensor_entity
  4. jeffreykog renamed this gist Aug 19, 2024. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  5. jeffreykog created this gist Aug 19, 2024.
    80 changes: 80 additions & 0 deletions somrig.yaml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,80 @@
    blueprint:
    name: IKEA Somrig Cover Control (Z2M)
    description: "## Control any cover with IKEA Somrig shortcut button
    Should be used with Zigbee2MQTT
    Available controls:
    - Single dot: Open cover
    - Double dot: Close cover
    - While the cover is moving, press any button to stop the movement
    "
    source_url: https://gist.github.com/jeffreykog/f5d9db269c52b55e87a93c0097e8400a
    domain: automation
    input:
    remote_entity:
    name: Somrig Remote Action Entity
    description: The "Action" entity of the Somrig remote, as created by Zigbee2MQTT
    selector:
    entity:
    filter:
    - integration: mqtt
    domain: sensor
    cover_entity:
    name: Cover entity
    description: The cover entity that should be controlled by the Somrig remote.
    selector:
    entity:
    filter:
    - domain: cover
    window_sensor_entity:
    name: Open window sensor
    description: Optional window sensor entity. Movement of the cover will be blocked when the window is open.
    default:
    selector:
    entity:
    filter:
    - domain: binary_sensor
    device_class: door
    mode: single
    max_exceeded: silent
    trigger:
    - platform: state
    entity_id: !input remote_entity
    action:
    - variables:
    window_sensor_entity: !input window_sensor_entity
    - if:
    - condition: or
    conditions:
    - condition: state
    entity_id: !input cover_entity
    state: opening
    - condition: state
    entity_id: !input cover_entity
    state: closing
    then:
    - action: cover.stop_cover
    metadata: {}
    data: {}
    target:
    entity_id: !input cover_entity
    else:
    - if:
    - condition: template
    value_template: "{{ trigger.to_state.state == \"1_initial_press\" and (window_sensor_entity is none or is_state(window_sensor_entity, 'off')) }}"
    then:
    - action: cover.open_cover
    metadata: {}
    data: {}
    target:
    entity_id: !input cover_entity
    - if:
    - condition: template
    value_template: "{{ trigger.to_state.state == \"2_initial_press\" and (window_sensor_entity is none or is_state(window_sensor_entity, 'off')) }}"
    then:
    - action: cover.close_cover
    metadata: {}
    data: {}
    target:
    entity_id: !input cover_entity