Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 95468

Automation to check multiple entities every x minutes and notify about triggered entity

$
0
0

@jarrah wrote:

I would like to create a single automation that sends me an alert notification every 10 mins that my car has one of its sensors open or unlocked.

There are nine entities I wish to monitor. One working solution would be to create 9 separate automations, but I wondered if it’s possible to create a more elegant single automation solution that involves templates please?

Here are two out of nine automations I’m using. The key thing I need is for a notification to be sent every 10 mins until I’ve either locked the car or disabled the notification, so I thought I needed a time_pattern trigger rather than an entity state change trigger.

  - alias: Car unlocked
    initial_state: 'on'
    trigger:
      - platform: time_pattern
        minutes: '/10'
    condition:
      - condition: state
        entity_id: binary_sensor.audi_doors_lock
        state: 'on'
        for:
          minutes: 20
      - condition: state
        entity_id: device_tracker.audi_position
        state: 'home'
      - condition: state
        entity_id: input_boolean.car_disable_notification
        state: 'off'
    action:
      - service: notify.mobile_app_iphone
        data:
          title: "Car is Unlocked!"
          message: "Lock the car you fool!"
          data:
            push:
              sound:
                name: default
                critical: 1
                volume: 1.0

  - alias: Window Open
    initial_state: 'on'
    trigger:
      - platform: time_pattern
        minutes: '/10'
    condition:
      - condition: state
        entity_id: binary_sensor.audi_windows
        state: 'on'
        for:
          minutes: 20
      - condition: state
        entity_id: device_tracker.audi_position
        state: 'home'
      - condition: state
        entity_id: input_boolean.car_disable_notification
        state: 'off'
    action:
      - service: notify.mobile_app_iphone
        data:
          title: "Car Window Open!"
          message: "You've left a window open!"
          data:
            push:
              sound:
                name: default
                critical: 1
                volume: 1.0 

If it wasn’t for the time_pattern trigger requirement, I could specify all my entities within trigger and refer to the triggered entity in the notification, but the constant nagging to lock the car is more important.

I’ve thought about using another time_pattern automation to trigger another automation, but I’ve read that conditions are ignored if you do that so would be no use for me.

I could create multiple OR conditions, but then I wouldn’t be able to send a message relating to a specific entity, eg window left open, or door unlocked, or boot open, etc.

Thanks in advance.

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 95468

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>