#Actionable notifications on iphone

39 messages · Page 1 of 1 (latest)

grand light
#

Hi all,
I would like an automation that notifies me on my iPhone that the coffee machine has been on for too long (for example 2 hours) and that allows me to turn it off directly from the notification. Thanks in advance

clever scaffold
grand light
#

I saw this documentation, but I can understand how to build an automation that allow me to turn off a switch

clever scaffold
#

You use the notify service with actions (which have kind of an ID - e.g. OFF and IGNORE), add a wait for trigger (event - mobile_app_notification_action and the action's ID) and continue with a switch turn off action.
Here is an example of an automation reminding to arm the alarm when away.

#
alias: Alarm away
description: ""
trigger:
  - platform: numeric_state
    entity_id: zone.home
    below: 1
condition:
  - condition: not
    conditions:
      - condition: or
        conditions:
          - condition: state
            entity_id: alarm_control_panel.master
            state: armed_custom_bypass
          - condition: state
            entity_id: alarm_control_panel.master
            state: armed_away
          - condition: state
            entity_id: alarm_control_panel.master
            state: triggered
          - condition: state
            entity_id: alarm_control_panel.master
            state: pending
action:
  - data:
      title: Alarm
      message: >-
        Alarm is inaktive. So you want to activate it?
      data:
        color: "#FF0000"
        clickAction: noAction
        persistent: true
        tag: persistent
        actions:
          - action: ARM_ALARM
            title: Arm
          - action: IGNORE_ALARM
            title: Ignore
    action: notify.mobile_app_phone
  - wait_for_trigger:
      - platform: event
        event_type: mobile_app_notification_action
        event_data:
          action: ARM_ALARM
      - platform: event
        event_type: mobile_app_notification_action
        event_data:
          action: IGNORE_ALARM
      - platform: event
        event_type: mobile_app_notification_cleared
        event_data:
          action_1_key: ARM_ALARM
  - choose:
      - conditions:
          - condition: template
            value_template: "{{ wait.trigger.event.data.action == 'ARM_ALARM' }}"
        sequence:
          - data:
              mode: away
              skip_delay: true
              entity_id: alarm_control_panel.master
            enabled: true
            action: alarmo.arm
      - conditions:
          - condition: template
            value_template: "{{ wait.trigger.event.data.action == 'IGNORE_ALARM' }}"
        sequence:
          - stop: Ignored
            enabled: true
      - conditions:
          - condition: template
            value_template: >-
              {{ wait.trigger.event.event_type ==
              'mobile_app_notification_cleared' }}
        sequence:
          - stop: Ignored
mode: single
grand light
#

Ok, sorry but I am a beginner

#

Here my code:

alias: Macchina caffè long
description: ""
trigger:

  • platform: device
    type: turned_on
    device_id: 7f2f1450e0853c7bbf50aa8fbed29ad8
    entity_id: dd68fa8c51ca77bbc19ba61f06f98e63
    domain: switch
    for:
    hours: 2
    minutes: 0
    seconds: 0
    condition: []
    action:
  • action: notify.mobile_app_iphone_11_di_marco
    metadata: {}
    data:
    title: Notify from Home Assistant
    message: Coffee machine is ON for too long!!!
    mode: single

How I can integrate?

clever scaffold
#

By adding the actions to the nofify action first

grand light
#

Ok, I wish only a button to turn off the machine

halcyon eagleBOT
#

@sturdy pendant To format your text as code, enter three backticks on the first line, press Enter for a new line, paste your code, press Enter again for another new line, and lastly three more backticks.
```yaml
example: here
```
Don't forget you can edit your post rather than repeatedly posting the same thing.

clever scaffold
#

Then add one action to the notify data part.

grand light
#

alias: Macchina caffè long
description: ""
trigger:

  • platform: device
    type: turned_on
    device_id: 7f2f1450e0853c7bbf50aa8fbed29ad8
    entity_id: dd68fa8c51ca77bbc19ba61f06f98e63
    domain: switch
    for:
    hours: 2
    minutes: 0
    seconds: 0
    condition: []
    action:
  • action: notify.mobile_app_iphone_11_di_marco
    metadata: {}
    data:
    title: Notifica da Home Assistant
    message: La macchina del caffè è accesa da troppo!!!
    data:
    actions:
    - action: OFF_MACHINE
    title: Spegni macchina
    mode: single
clever scaffold
#

And now you have to build the wait for trigger part

grand light
#

alias: Macchina caffè long
description: ""
trigger:

  • platform: device
    type: turned_on
    device_id: 7f2f1450e0853c7bbf50aa8fbed29ad8
    entity_id: dd68fa8c51ca77bbc19ba61f06f98e63
    domain: switch
    for:
    hours: 2
    minutes: 0
    seconds: 0
    condition: []
    action:
  • action: notify.mobile_app_iphone_11_di_marco
    metadata: {}
    data:
    title: Notifica da Home Assistant
    message: La macchina del caffè è accesa da troppo!!!
    data:
    actions:
    - action: OFF_MACHINE
    title: Spegni macchina
    mode: single
halcyon eagleBOT
#

To format your text as code, enter three backticks on the first line, press Enter for a new line, paste your code, press Enter again for another new line, and lastly three more backticks.
```yaml
example: here
```
Don't forget you can edit your post rather than repeatedly posting the same thing.

grand light
clever scaffold
#

It is in my example.
The event trigger mobile_app_notification_action is the one reacting to the action, and mobile_app_notification_cleared is when the notification is swiped away without action press.

grand light
#
alias: Macchina caffè long
description: ""
trigger:
  - platform: device
    type: turned_on
    device_id: 7f2f1450e0853c7bbf50aa8fbed29ad8
    entity_id: dd68fa8c51ca77bbc19ba61f06f98e63
    domain: switch
    for:
      hours: 2
      minutes: 0
      seconds: 0
condition: []
action:
  - action: notify.mobile_app_iphone_11_di_marco
    metadata: {}
    data:
      title: Notifica da Home Assistant
      message: La macchina del caffè è accesa da troppo!!!
      data:
        actions:
          - action: OFF_MACHINE
            title: Spegni macchina
mode: single
clever scaffold
#

2 parts missing.

  1. the waiting
  2. the action with a condition
grand light
#
alias: Macchina caffè long
description: ""
trigger:
  - platform: device
    type: turned_on
    device_id: 7f2f1450e0853c7bbf50aa8fbed29ad8
    entity_id: dd68fa8c51ca77bbc19ba61f06f98e63
    domain: switch
    for:
      hours: 2
      minutes: 0
      seconds: 0
condition: []
action:
  - action: notify.mobile_app_iphone_11_di_marco
    metadata: {}
    data:
      title: Notifica da Home Assistant
      message: La macchina del caffè è accesa da troppo!!!
      data:
        actions:
          - action: TURN_OFF_COFFEE_MACHINE
            title: Spegni macchina
  - wait_for_trigger:
      - platform: event
        event_type: mobile_app_notification_action
        event_data:
          action: TURN_OFF_COFFEE_MACHINE
      - platform: device
        type: turned_off
        device_id: 7f2f1450e0853c7bbf50aa8fbed29ad8
        entity_id: dd68fa8c51ca77bbc19ba61f06f98e63
        domain: switch
mode: single
clever scaffold
#

I would do this for the wait part

- wait_for_trigger:
  - platform: event
    event_type: mobile_app_notification_action
    event_data:
    action: TURN_OFF_COFFEE_MACHINE
  - platform: event
    event_type: mobile_app_notification_cleared
    event_data:
    action_1_key: TURN_OFF_COFFEE_MACHINE
grand light
#

If I paste this code

alias: Macchina caffè long
description: ""
trigger:
  - platform: device
    type: turned_on
    device_id: 7f2f1450e0853c7bbf50aa8fbed29ad8
    entity_id: dd68fa8c51ca77bbc19ba61f06f98e63
    domain: switch
    for:
      hours: 2
      minutes: 0
      seconds: 0
condition: []
action:
  - action: notify.mobile_app_iphone_11_di_marco
    metadata: {}
    data:
      title: Notifica da Home Assistant
      message: La macchina del caffè è accesa da troppo!!!
      data:
        actions:
          - action: TURN_OFF_COFFEE_MACHINE
            title: Spegni macchina
  - wait_for_trigger:
  - platform: event
    event_type: mobile_app_notification_action
    event_data:
    action: TURN_OFF_COFFEE_MACHINE
  - platform: event
    event_type: mobile_app_notification_cleared
    event_data:
    action_1_key: TURN_OFF_COFFEE_MACHINE
mode: single
#

I get this error: Message malformed: extra keys not allowed @ data['action'][2]['platform']

clever scaffold
#

And then a condition, to just turn off, if the action is pressed

- condition: template
  value_template: "{{ wait.trigger.event.data.action == 'TURN_OFF_COFFEE_MACHINE' }}"
clever scaffold
#

And at last you just add a switch turn off for your coffee machine

grand light
#

Could you post the code complete? Please I beg you, just to understand how to works

clever scaffold
#
alias: Macchina caffè long
description: ""
trigger:
  - platform: device
    type: turned_on
    device_id: 7f2f1450e0853c7bbf50aa8fbed29ad8
    entity_id: dd68fa8c51ca77bbc19ba61f06f98e63
    domain: switch
    for:
      hours: 2
      minutes: 0
      seconds: 0
condition: []
action:
  - action: notify.mobile_app_iphone_11_di_marco
    metadata: {}
    data:
      title: Notifica da Home Assistant
      message: La macchina del caffè è accesa da troppo!!!
      actions:
        - action: TURN_OFF_COFFEE_MACHINE
          title: Spegni macchina
  - wait_for_trigger:
    - platform: event
      event_type: mobile_app_notification_action
      event_data:
        action: TURN_OFF_COFFEE_MACHINE
    - platform: event
      event_type: mobile_app_notification_cleared
      event_data:
        action_1_key: TURN_OFF_COFFEE_MACHINE
  - condition: template
    value_template: "{{ wait.trigger.event.data.action == 'TURN_OFF_COFFEE_MACHINE' }}"
  - action: switch.turn_off
    metadata: {}
    data: {}
    target:
      entity_id: switch.coffee_machine
mode: single
#

Or whatever you use to turn off the coffee machine

grand light
#

Ok I paste the code

#

Message malformed: expected dict for dictionary value @ data['event_data']

clever scaffold
#

Ah, my fault. I corrected that

#

Typing on mobile 🫣

grand light
#

I'm trying

#

The notify appears but there is not button to switch off

clever scaffold
#

I just copied your notify action, assuming it would already have worked. Found the mistake and edited it above

grand light
#

Update: when the notify shows up and I keep press show the button to switch off

#

Sorry for my english, and thank you so much for the help 🙏

clever scaffold
#

If it is working now, please add the tag "✅Resolved" in the ... menu of this post