Anonym-tsk / zigbee2mqtt-extensions

Create simple automations directly in zigbee2mqtt
MIT License
52 stars 9 forks source link

Stop an automation? #17

Open iantait opened 11 months ago

iantait commented 11 months ago

Do you think its possible to stop an automation?

Use case - a motion sensor detects motion and turns on some lights, there is also a rule to turn the lights off after a couple of mins. Say its a room that today you're going to be in a while, it would be nice to cancel the lights off automation rule if a switch or similar turns the lights on.

Anonym-tsk commented 10 months ago

How to stop automation? By automation id? Look at my solution:

kitchen_workspace_on_by_motion:
  trigger:
    platform: state
    entity: Motion Kitchen
    attribute: occupancy
    state: true
  action:
    - entity: Kitchen Workspace
      service: custom
      data:
        state: 'ON'
        brightness: 250

kitchen_workspace_off_no_motion:
  trigger:
    platform: state
    entity: Motion Kitchen
    attribute: occupancy
    state: false
    for: 120
  condition:
    platform: state
    entity: Light Kitchen
    state: 'OFF'
  action:
    - entity: Kitchen Workspace
      service: turn_off

Kitchen Workspace light turns on by motion sensor and turns off if no motion for 120 seconds but only if Kitchen light (base light) disabled.