With the fix in HA 0.54 we can now send a camera stream and actions to an IOS device. A limitation of this is the actions must be the same no matter what camera stream you send.
With the below config I attempted to make a more dynamic approach. I can now send a camera stream with two generic action buttons. and HA will interpret my answer based on the entity ID and button pressed.
In the IOS conf.
ios:
push:
categories:
- name: camera
identifier: 'camera'
actions:
- identifier: 'ALLINONE_TRUE'
title: 'On/True/Open/Lock'
authenticationRequired: no
- identifier: 'ALLINONE_FALSE'
title: 'Off/False/Close/Unlock'
authenticationRequired: no
To send a message I am using the following message config.
- alias: IOS - Chicken camera actions
trigger:
action:
service: notify.ios_ryans_iphone_app
data:
message: "What should I do with the chicken door?"
data:
push:
category: 'camera'
entity_id: camera.d239
action_data:
entity_id: cover.chicken_door
Finally HA listens for the event to come back into Home assistant does interprets the correct action to take.
- alias: IOS - All In one camera
trigger:
platform: event
event_type: ios.notification_action_fired
condition:
condition: template
value_template: "{{(trigger.event.data.actionName.split('_')[0] == 'ALLINONE')}}"
action:
- service_template: >-
{% set domain = (trigger.event.data['action_data']['entity_id'].split('.')[0]) %}
{% set function = (trigger.event.data.actionName.split('_')[1]) %}
{% set entity_id = (trigger.event.data['action_data']['entity_id']) %}
{% if (function == 'TRUE') -%}
{% if (domain == 'cover') -%}
cover.open_cover
{% elif (domain in ['light', 'switch', 'script', 'automation', 'input_boolean', 'group']) -%}
homeassistant.turn_on
{% elif (domain == 'lock') -%}
lock.lock
{% else -%}
Invalid Domain:{{domain}} Function: {{function}} or entity:{{entity_id}}
{% endif -%}
{% elif (function == 'FALSE') -%}
{% if (domain == 'cover') -%}
cover.close_cover
{% elif (domain in ['light', 'switch', 'script', 'automation', 'input_boolean', 'group']) -%}
homeassistant.turn_off
{% elif (domain == 'lock') -%}
lock.unlock
{% else -%}
Invalid Domain:{{domain}} Function: {{function}} or entity:{{entity_id}}
{% endif -%}
{% else -%}
Invalid Domain:{{domain}} Function: {{function}} or entity:{{entity_id}}
{% endif -%}
data_template:
entity_id: "{{trigger.event.data['action_data']['entity_id']}}"
HI, been a long while
I want to try and use it to switch on an espresso machine, and don’t use cameras, but like to try proximity as trigger.
hence i renamed the iOS and automation like this, would that be ok (for starters, figure out the trigger of proximity later on…)?
al, that is happening now is the message on my phone, whithout any buttons with actions. (yes, i did update the push notifications in the app)
Also, Somehow I cant enable this automation. it switches back to off whenever I switch it on. I can trigger it in the dev-service tools.
maybe thats because there’s no trigger (yet)?
guess i found it: had to hold/push on my iPhone to see the actionable buttons> hadn’t read about that, and thought it would show up with the message notification itself…
anyt thoughts on how to get a local image file to show up in the action_data: ?