I just released the brand new Web API for Pushcut, and my intention is to offer everything that is needed to integrate Pushcut with Home Assistant the right way.
Here is the documentation. <- You can even play around with the API through the web UI.
The primary use is to send smart notifications with dynamic content and automation actions to your iOS devices.
However, I think the coolest part is the possibility to register you own (local network) webhooks as “online actions” in Pushcut.
This way we could trigger Home Assistant as a response - directly from the notification action - on your local network.
I understand the the HA iOS app has a feature like this, but Pushcut has more power when it comes to notification actions - like running shortcuts or online integrations like Zapier.
So, you could send a notification asking: “Should I turn off the lights?” and there could be dynamic Yes/Dim/No options that actually do it. Or you could say “TV was turned on, should I open the remote app?”, or open a web dashboard or something like that.
I believe there are many situations where fully automatic is not feasible, but a “quick action” on your phone at the right time is the best experience. This type of interaction is the reason I created Pushcut: for “semi-automation”, where you are given the right options at the right time.
To be honest, for my “production” home automation I have settled on openHAB years ago and only played around with hass.io occasionally. So, at the moment I am no where near ready to develop for it.
Is anyone willing to help me create this integration?
Best I can do for you is a poor man’s configuration based integration that I wrote for myself before work this morning.
Nice app by the way. Found it and subscribed this morning. I hope I’m late to this party with home assistant but I didn’t find anyone else mentioning any integrations or plugins they’ve made.
I’ll be modifying these settings slightly when I decide to add my wife into this mix. So probably still keep two rest_command options but instead pass in the pushcut_api_key from a script or automation like I’m doing with pushcut_secret and then my secret file will have like pushcut_api_key_ben and pushcut_api_key_wife
EDIT:
Would love to specify notification in the body rather than URL
Thanks for the app. Does exactly what I needed and I’m sad I just realized it existed today. Up until now I was doing everything via a Telegram Bot which is fun and all but that limited me to the actions being handled all in Home Assistant. And the notification from telegram is just the message. Much better just to execute on the notification and move on.
Installing this on my wife’s phone and having her be able to respond to notifications seems very very doable. Not so much signing her up for a chat platform and convincing her to respond to chat messages from some bot I wrote. That will just make her roll her eyes at me.
I have written a (dirty) script for my own use and just want to share it here.
The main intent of this script is to avoid having to write extensively the “payload” data (this script refers to the script provided by @benisntfunny)
notify_pushcut_smart:
alias: Smart call of a specified Pushcut notification
sequence:
- service: rest_command.pushcut_smart_notify
data:
notification: "{{ notification }}"
payload: >
{% if da_text is defined %}
{% set pda_url = '"url": "' ~ da_url ~ '"' if da_url is defined else '' %}
{% set pda_homekit = '"homekit": "' ~ da_homekit ~ '"' if da_homekit is defined else '' %}
{% set pda_shortcut = '"shortcut": "' ~ da_shortcut ~ '"' if da_shortcut is defined else '' %}
{% set pdaction = ',"defaultAction": { "name": "' ~ da_text ~ '",' ~ pda_url ~ pda_homekit ~ pda_shortcut ~ ' }' %}
{% endif %}
{% if a_text is defined %}
{% set pa_url = '"url": "' ~ a_url ~ '"' if a_url is defined else '' %}
{% set pa_homekit = '"homekit": "' ~ a_homekit ~ '"' if a_homekit is defined else '' %}
{% set pa_shortcut = '"shortcut": "' ~ a_shortcut ~ '"' if a_shortcut is defined else '' %}
{% set pactions = ',"actions": [{ "name": "' ~ a_text ~ '",' ~ pa_url ~ pa_homekit ~ pa_shortcut ~ ' }]' %}
{% endif %}
{% set pdevices = ',"devices": "' ~ devices ~ '"' if devices is defined else '' %}
{% set psound = ',"sound": "' ~ sound ~ '"' if sound is defined else '' %}
{% set pimage = ',"image": "' ~ image ~ '"' if image is defined else '' %}
{% set pdata = '{ "text": "' ~ message ~ '","title": "' ~ title ~ '"' ~ psound ~ pimage ~ pdevices ~ pdaction ~ pactions ~ ' }' %}
{{ pdata }}
example of calling the script:
action:
- service: script.notify_pushcut_smart
data:
notification: 'my notification in Pushcut'
title: 'my title'
message: 'my message'
a_text: 'name of action to launch'
a_homekit: 'homekit action'
the data to be passed in the call are the following:
notification: name of the Pushcut notification. required title: title. optional message: message. optional sound: sound. optional image: image. optional (note that this should be an url with explicit mention of image type in the extension, dixit @sliemeobn) devices: devices to which notification is sent. optional
da_text: name of the default action. optional, but required in case you want to specify a default action to be launched by the notification when you tap on it on your mobile phone da_url: url that will be open. optional da_homekit: homekit scene that will be set. optional da_shortcut: shortcut to be run. optional. Note that one and only one out of the 3 last data is required; but my script does not test that
a_text: name of an additional action. optional, but required in case you want to specify an additional action to be launched by the notification when you open it on your mobile phone a_url: url that will be open. optional a_homekit: homekit scene that will be set. optional a_shortcut: shortcut to be run. optional. Note that one and only one out of the 3 last data is required; but my script does not test that.
Please excuse my ignorance. From my little knowledge (I’m only a fortnight into HA) I can use this Web API to trigger a Pushcut Action from HA. I have no idea where to start and can’t find any info to read about triggering a Web API from HA. If you could please point me in the right direction, I am more than happy to read and learn but can’t find anything. Maybe I am using all the incorrect terminology?
Thank you in advance and thank you the developer/s!!!
Then create in scripts.yaml the script notify_pushcut_smart as shown in my previous post.
Finally you call the script as shown in the example in my previous post.
See also the documentation WebAPI for Pushcut.
Indeed if you go through all the previous posts in this thread you will get all the needed instructions on how to setup things. This is what I did.