Actionable Notification to Control Lights

Hi all

I have been trying to tackle an automation for a little while now. Its one of those that has evolved as I’ve used it more.

The setup is I have two doors in to my garage. When either door is opened, the lights in the garage turn on. Simple so far!
When BOTH doors are closed, but the lights are ON, the lights get turned off, and I get a notification to my phone stating as such. Also, pretty simple!

However, with winter coming, there will be times where I am in the garage, with the doors closed and want the lights to remain on.
What I would like is an actionable notification on my phone that asks if I want to keep the lights on or not.

If I say “Yes”, then the automation ends, no action is taken, the lights stay on (until the next time all the doors become “Closed” i.e. I have left the garage)
If I say “No” I would like the lights to turn off.

Then, to add further complication, I would also like a timeout on this so that if no response is recevied in 5minutes, the lights turn off anyway.

Any thoughts on how best to implement this?

Can you show the automation you already have in yaml so maybe someone can edit it for you, also it should show us whether your using iOS or Android for example?

The simplest way to allow for an occasional exception is to add an input_boolean which gives a toggle switch in the UI. This can then be added to automations so one toggle turns off actions.

  • Settings → Devices & Services → Helpers

Example - I have a toggle for night mode so that my lighting automation can be disabled or enabled at will:

  - condition: state
    entity_id: input_boolean.night_mode
    state: 'on'

Add a Garage Work Mode and disable the OFF as needed manually. I’d also add a timed automation to turn the lights OFF and Work Mode OFF when you forget! :slight_smile:
The same technique is really handy for things like morning alarm clocks - just disable them once when you’ve had a late night, and you get one sleep in. :zzz:

If this helps, :heart: this post!

Hi All

Thanks for the replies so far.
I am using Android. Yaml below:

alias: Garage Lights on Actionable Notification
description: ""
trigger:
  - type: not_opened
    platform: device
    device_id: 6d5c85e2f0679194964493cee3c3e251
    entity_id: binary_sensor.lumi_lumi_sensor_magnet_aq2_03765f07_on_off
    domain: binary_sensor
    for:
      hours: 0
      minutes: 0
      seconds: 30
  - type: not_opened
    platform: device
    device_id: 67587962dbffa3c81725d3a0abd7da48
    entity_id: binary_sensor.lumi_lumi_sensor_magnet_aq2_ea3e3908_on_off
    domain: binary_sensor
    for:
      hours: 0
      minutes: 0
      seconds: 30
  - type: not_opened
    platform: device
    device_id: a06ec059be6e06a35c9d898c1ecb31cf
    entity_id: binary_sensor.lumi_lumi_sensor_magnet_aq2_opening
    domain: binary_sensor
condition:
  - condition: or
    conditions:
      - condition: state
        entity_id: light.garage_light_1
        state: "on"
      - condition: state
        entity_id: light.garage_light_2
        state: "on"
  - type: is_not_open
    condition: device
    device_id: 6d5c85e2f0679194964493cee3c3e251
    entity_id: binary_sensor.lumi_lumi_sensor_magnet_aq2_03765f07_on_off
    domain: binary_sensor
  - type: is_not_open
    condition: device
    device_id: 67587962dbffa3c81725d3a0abd7da48
    entity_id: binary_sensor.lumi_lumi_sensor_magnet_aq2_ea3e3908_on_off
    domain: binary_sensor
  - type: is_not_open
    condition: device
    device_id: a06ec059be6e06a35c9d898c1ecb31cf
    entity_id: binary_sensor.lumi_lumi_sensor_magnet_aq2_opening
    domain: binary_sensor
action:
  - service: notify.mobile_app_sm_g781b
    data:
      title: GarageLightActionable
      message: The Garage Lights are ON but the Doors Are Closed!
      data:
        actions:
          - action: KEEP_LIGHTS_ON
            title: Keep Lights On
          - action: TURN_LIGHTS_OFF
            title: Turn Lights Off
  - wait_for_trigger:
      - platform: event
        event_type: mobile_app_notification_action
        event_data:
          action: TURN_LIGHTS_OFF
    timeout: "00:05:00"
  - service: light.turn_off
    data: {}
mode: single

At the moment I have the following behaviour:
Notification received if all the garage doors are shut and either of the lights are on
If I send “Turn Off The Lights” the lights turn off
If I do nothing, the lights turn off (Continue on Timeout: True, although not explicitly stated in the yaml)

I don’t have the creme de le creme action of “Do Nothing” when “Keep Lights On” is pressed.

I’m trying to work out how to automate the toggling of your suggestion @FloatingBloater from the “KEEP_LIGHTS_ON” response and use that as the qualifier. But however I cut it, there doesn’t seem to be a way to separate out the two potential outcomes.

Use a 2nd trigger and then a choose action based on the trigger received or no trigger after the 5 mins wait = turn off lights

Example taken from docs:

wait_for_trigger:
    - platform: event
      event_type: mobile_app_notification_action
      event_data:
        # waiting for the specific action avoids accidentally continuing
        # for another script/automation's notification action
        action: "{{ action_open }}"
    - platform: event
      event_type: mobile_app_notification_action
      event_data:
        action: "{{ action_close }}"
- alias: "Perform the action"
  choose:
    - conditions: "{{ wait.trigger.event.data.action == action_open }}"
      sequence:
        - service: cover.open_cover
          target:
            entity_id: cover.some_cover
    - conditions: "{{ wait.trigger.event.data.action == action_close }}"
      sequence:
        - service: cover.close_cover
          target:
            entity_id: cover.some_cover

This looks like it could be a solution, but I am not adept enough at yaml yet to understand how to make this work for my setup :frowning:

I don’t understand what all the " { { mean… do I keep them? Replace them?
HA isn’t liking the wait.trigger.event.data.action bit