Skip to content
⚠️ This wiki is versioned — you are currently viewing the docs for the bleeding edge (main), not the latest release.
HASS Automations

HASS Automations

Examples

Here you can find some example on how to setup simple automations using MQTT Topics or the Tags.

~ Synchronizing Physical Lock State with HomeKey-ESP32 ~

alias: NFC Lock State change
description: ""
trigger:
  - platform: state
    entity_id:
      - lock.hk_lock_2
condition:
  - condition: template
    value_template: >-
      {{ not( now() - state_attr('automation.nfc_lock', 'last_triggered') <
      timedelta(seconds=10)) }}
action:
  - if:
      - condition: state
        entity_id: lock.hk_lock_2
        state: unlocked
    then:
      - action: lock.unlock
        metadata: {}
        data: {}
        target:
          entity_id: lock.l600137
    else:
      - if:
          - condition: state
            entity_id: lock.hk_lock_2
            state: locked
        then:
          - action: lock.lock
            metadata: {}
            data: {}
            target:
              entity_id: lock.l600137
mode: single

~ Synchronizing HomeKey-ESP32 with the physical lock ~

alias: NFC Lock State change
description: ""
trigger:
  - platform: state
    entity_id:
      - lock.hk_lock
    from: null
    to: null
condition:
  - condition: template
    value_template: >-
      {{ not( now() - state_attr('automation.nfc_lock', 'last_triggered') <
      timedelta(seconds=10)) }}
action:
  - if:
      - condition: state
        entity_id: lock.hk_lock
        state: unlocked
    then:
      - action: lock.unlock
        metadata: {}
        data: {}
        target:
          entity_id: lock.l600137
    else:
      - if:
          - condition: state
            entity_id: lock.hk_lock
            state: locked
        then:
          - action: lock.lock
            metadata: {}
            data: {}
            target:
              entity_id: lock.l600137
mode: single

~ HomeKey MQTT Topic ~

alias: Homekey
description: ""
trigger:
  - platform: mqtt
    topic: topic/homekey/auth
condition:
  - condition: template
    value_template: "{{trigger.payload_json[\"issuerId\"] == \"0123456789ABCDEF\"}}"
action:
  - if:
      - condition: state
        entity_id: lock.l600137
        state: locked
    then:
      - action: lock.unlock
        metadata: {}
        data: {}
        target:
          entity_id: lock.l600137
    else:
      - action: lock.lock
        metadata: {}
        data: {}
        target:
          entity_id: lock.l600137
mode: restart

~ HomeKey HASS Tag ~

description: ""
mode: single
trigger:
  - platform: tag
    tag_id: 0123456789ABC
condition: []
action:
  - if:
      - condition: state
        entity_id: lock.l600137
        state: locked
    then:
      - action: lock.unlock
        metadata: {}
        data: {}
        target:
          entity_id: lock.l600137
    else:
      - action: lock.lock
        metadata: {}
        data: {}
        target:
          entity_id: lock.l600137
alias: Tag Red's Watch is scanned
Last updated on