Help with actionable notifications

Hi,

I’m trying to set up some automations which give actionable notifications, but each time i get something wrong then restart hassio, the frontend won’t load, so i need some help on the configuration to get actionable notifications working how i want them.

I want a notification when my device leaves home with an option to turn all lights off (If any are still on)
I want a notification when my device arrives home with an option to turn all lights on
I want a notification if my usb webcam (using motion addon) detects movement with an option to raise an alarm (which will currently just be flashing my lights red), and I would like the notification to have the webcam stream as part of it’s content (i have seen on a hassio blog post that this is possible)

Thanks to anyone who can help!!

there are two videos one from burnsHa and another from DrZzs this videos will help you

I have had a look at these and tried using them as a template but I managed to mess up!

ios:
  push:
    categories:
      - name: ARRIVEDHOME
        identifier: 'arrivedhome'
        actions:
          - identifier: 'LIGHTS_ON'
            title: 'Lights On'
            activationMode: 'background'
            authenticationRequired: no
            destructive: no
            behavior: 'default'
            service: light.turn_on
            entity_id: light.bottom
            entity_id: light.middle
            entity_id: light.top
            entity_id: light.bridge
      - name: LEFTHOME
        identifier: 'lefthome'
        actions:
          - identifier: 'LIGHTS_OFF'
            title: 'Lights Off'
            activationMode: 'background'
            authenticationRequired: no
            destructive: yes
            behavior: 'default'
            service: light.turn_off
            entity_id: light.bottom
            entity_id: light.middle
            entity_id: light.top
            entity_id: light.bridge


automation old:
  - alias: Arrived home
    initial_state: True
    hide_entity: True
    trigger:
      - platform: zone
        event: enter
        zone: zone.home
        entity_id: device_tracker.iphone
    action:
        service: notify.ios_iphone
        data:
          title: "Arrived home" #customizable
          message: "Turn on lights" #customizable 
          data:
            push:
              badge: 0 # this will remove the badge/app icon number
              category: 'ARRIVEDHOME' #name matched in ios component
              
    - alias: Left home
    initial_state: False
    hide_entity: True
    trigger:
      - platform: zone
        event: leave
        zone: zone.home
        entity_id: device_tracker.iphone
    action:
        service: notify.ios_iphone
        data:
          title: "Left home" #customizable
          message: "Turn off lights" #customizable 
          data:
            push:
              badge: 0 # this will remove the badge/app icon number
              category: 'ARRIVEDHOME' #name matched in ios component

It’s probably something simple but I am new to all of this so would appreciate help
thank you so much, Billy

here is my configuration i hope it helps

ios:
  push:
    categories:
      - name: lights_on
        identifier: 'lights_on'        #this name has to match the category name
        actions:
          - identifier: 'LIGHT_ROOM_1'  
            title: 'light room 1'            
          - identifier: 'LIGHT_ROOM_2'
            title: 'light room 2'  
          - identifier: 'LIGHT_ROOM_3'
            title: 'light room 3'   
          - identifier: 'ALL_LIGHTS'
            title: 'all lights'                
####### THIS IS THE TRIGER #####
  - alias: leaving home
    trigger:
      platform: state
      entity_id: device_tracker.smekdjesiphone_2
      to: 'not_home'   
    action:
      service: notify.ios_kemuels_iphone
      data:
        message: "what lights do you want on !" 
        data:
          push:
            badge: 0 # this will remove the badge/app icon number
            category: 'lights_on'          #this has to match with identifier name
          
############ this is the action when you click on buttom ####  
#### buttom 1        
  - alias: turn on ligth 1
    trigger:
      platform: event
      event_type: ios.notification_action_fired
      event_data:
        actionName: LIGHT_ROOM_1
    action:
     service: homeassistant.turn_on 
     entity_id: light.mi_cuarto

### buttom 2    
  - alias: turn on ligth 2
    trigger:
      platform: event
      event_type: ios.notification_action_fired
      event_data:
        actionName: LIGHT_ROOM_2
    action:
     service: homeassistant.turn_on 
     entity_id: light.mi_cuarto_1  
####bottom3     
  - alias: turn on ligth 3
    trigger:
      platform: event
      event_type: ios.notification_action_fired
      event_data:
        actionName: LIGHT_ROOM_3
    action:
     service: homeassistant.turn_on 
     entity_id: light.pasillo           
####buttom4          
  - alias: turn on all lights 
    trigger:
      platform: event
      event_type: ios.notification_action_fired
      event_data:
        actionName: ALL_LIGHTS
    action:
     service: homeassistant.turn_on 
     entity_id: group.main_bedroom_lights      

nice. is this is all in your ios file though? It looks like some of it would go under automations?

I tried setting that up in ios and get an error about missing sequence so played with adding that but no luck.

Thanks!

The first part is under iOS
The second part goes under
automation old:
######## this is the trigger###

OK, I got it working and I get the options on my phone, however when I press the action nothing happes, and nothing in my log either…if you dont mind taking a look I would apprecaite it.

push:
  categories:
    - name: basement_lights
      identifier: 'basement_lights'        #this name has to match the category name
      actions:
        - identifier: 'Basement_ON'  
          title: 'Basement Lights On'            
        - identifier: 'Basement_Off'
          title: 'Basement Lights Off'

- alias: basement action
  trigger:
    platform: state
    entity_id: binary_sensor.basement_motion
  action:
    service: notify.ios_da
    data:
      message: "You need me to do somethin with the lights?"
      data:
        push:
          badge: 0
          category: "basement_lights"

- alias: 'basement lights on'
  trigger:
    platform: event
    event_type: ios.notification_action_fired
    event_data:
      actionName: 'Basement_On'
  action:
    - service: homeassistant.turn_on
      entity_id: light.bar
    - service: homeassistant.turn_on
      entity_id: light.game_room
    - service: homeassistant.turn_on
      entity_id: light.home_theater


- alias: basement lights off
  trigger:
    platform: event
    event_type: ios.notification_action_fired
    event_data:
      actionName: 'Basement_Off'
  action:
    - service: homeassistant.turn_off
      entity_id: light.bar
    - service: homeassistant.turn_off
      entity_id: light.game_room
    - service: homeassistant.turn_off
      entity_id: light.home_theater

try this

- alias: 'basement lights on'
  trigger:
    platform: event
    event_type: ios.notification_action_fired
    event_data:
      actionName: 'Basement_On'
  action:
    service: homeassistant.turn_on
    entity_id: 
      - light.bar
      - light.game_room
      - light.home_theater
          
- alias: basement lights off
  trigger:
    platform: event
    event_type: ios.notification_action_fired
    event_data:
      actionName: 'Basement_Off'
  action:
    service: homeassistant.turn_off
    entity_id:      
      - light.bar
      - light.game_room
      - light.home_theater

As a side note, you can combine things like this all in one file and place it under packages. I haven’t done it as much as I should but it will allow you to combine automation, scripts, etc. in one file to make it easier for troubleshooting.

1 Like

right so i’ve got this in my configuration.yaml

automation old:
####### THIS IS THE TRIGER #####
  - alias: leaving home
    trigger:
      - platform: zone
        entity_id: device_tracker.iphone
        event: enter
        zone: zone.home   
    action:
      service: notify.ios_iphone
      data:
        message: "You have left home, do you want to turn the lights off?" 
        data:
          push:
            badge: 0 # this will remove the badge/app icon number
            category: 'left_home'          #this has to match with identifier name
          
############ this is the action when you click on button ####  
#### button 1        
  - alias: turn off lights
    trigger:
      platform: event
      event_type: ios.notification_action_fired
      event_data:
        actionName: LIGHTS_OFF
    action:
     service: light.turn_off 
     entity_id: light.bottom

but in the app the ios component and notify platform say they have not been loaded (even after pressing save again and updating push settings in the app)

any suggestions? also what’s the best way to have multiple actions as a result of the pressed notification, e.g. turning off multiple lights at once

thanks

update i’ve got the app components loaded by restarting hassio, need to test it now

ios:
  push:
    categories:
      - name: left_home
        identifier: 'left_home'        #this name has to match the category name
        actions:
          - identifier: 'LIGHTS_OFF'
            title: 'Turn Lights Off'
            destructive: yes
      - name: arrived_home
        identifier: 'arrivedhome'        #this name has to match the category name
        actions:
          - identifier: 'LIGHTS_ON'
            title: 'Turn Lights On'

automation old:
####### THIS IS THE TRIGER #####
  - alias: leaving home
    trigger:
      #- platform: zone
        #entity_id: device_tracker.iphone
        #event: leave
        #zone: zone.home
        platform: state
        entity_id: light.bottom
    action:
      service: notify.ios_iphone
      data:
        message: "You have left home, do you want to turn the lights off?"
        data:
          push:
            badge: 0 # this will remove the badge/app icon number
            category: 'left_home'          #this has to match with identifier name

############ this is the action when you click on button ####
#### button 1
  - alias: turn off lights
    trigger:
      platform: event
      event_type: ios.notification_action_fired
      event_data:
        actionName: LIGHTS_OFF
    action:
     service: light.turn_off
     entity_id:
      - light.bottom
      - light.middle
      - light.top
      - light.bridge

  - alias: arriving home
    trigger:
      #- platform: zone
       # entity_id: device_tracker.iphone
        #event: enter
        #zone: zone.home
        platform: state
        entity_id: light.bridge
    action:
      service: notify.ios_iphone
      data:
        message: "You have arrived home, do you want to turn the lights on?"
        data:
          push:
            badge: 0 # this will remove the badge/app icon number
            category: 'arrivedhome'

  - alias: turn on lights
    trigger:
      platform: event
      event_type: ios.notification_action_fired
      event_data:
        actionName: LIGHTS_ON
    action:
     service: light.turn_on
     entity_id:
      - light.bottom
      - light.middle
      - light.top
      - light.bridge

right so i’m just using the state of different lights as a trigger for testing, and I’ve found that it works perfectly for leaving home, turning the lights off. However with the arrived home, the notification shows but the action option doesn’t

IF the fist is working just copy and paste it and make the necesary changes then restart home assistant and
update push notifications on the ios app

You don’t have the event trigger in your second arrived home block.

ok still haven’t tested with location as I haven’t left my house but both automations are now working using different triggers to test them!

thank you for the help!