-
-
Notifications
You must be signed in to change notification settings - Fork 35.8k
Add support for action buttons to ntfy integration #152014
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
cr7pt0gr4ph7
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, @tr4nt0r!
Code looks generally good to me 👍 See code review comments for a small nitpick + an open design question.
8d396b5 to
540f59c
Compare
4c32be0 to
5310d4f
Compare
|
hassfest CI failure seems unrelated, something about apt cache. Locally hassfest runs without issues. |
cr7pt0gr4ph7
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a small rewording suggestion. LGTM otherwise 👍 Thank you, @tr4nt0r!
b788f97 to
dedc1ca
Compare
dedc1ca to
729ec83
Compare
729ec83 to
6e5ea86
Compare
|
really waiting for this, this is the only big feature missing in the core integration |
|
I'm wondering what the real-world use cases for these new actions will be. I think the most common use case will be triggering a notification (e.g. door is open), then displaying a button that will then perform an action in Home Assistant (e.g. close door). How can this be achieved? Should we use a webhook trigger, or is there another, better way to handle this use case? |
|
I think same as for the companion app's actionable notifications: https://companion.home-assistant.io/docs/notifications/actionable-notifications |
|
@tr4nt0r Thanks for the tip. I checked how this integration is implemented, and it registers a webhook, and doesn't rely on the user having a defined webhook. I wonder if we should implement similar functionality in our integration. In this case, we can also rely on the queue event, but we would probably need to consider what would work better in our case and add recommendations to the documentation. I think that I personally would have a problem implementing the user case that I presented earlier, because we have several paths and several blocks need to be connected to each other to achieve what I think is a common use case. How can we simplify this? The simplest solution is documentation, but there are other solutions. |
|
I managed to get these buttons working using two topics. One for communication from the HA to the phone, and the other from the phone to the HA, but it took longer than it should have. alias: New automation
description: ""
triggers: []
conditions: []
actions:
- alias: Set up variables for the actions
variables:
action_open: "{{ 'OPEN_' ~ context.id }}"
action_close: "{{ 'CLOSE_' ~ context.id }}"
- action: ntfy.publish
target:
entity_id: notify.display_name
data:
title: TEST
actions:
- action: http
label: Open
url: https://ntfy.sh/axwgvRGbLMh1hIMl_response
body: "{{ action_open }}"
- action: http
label: Close
url: https://ntfy.sh/axwgvRGbLMh1hIMl_response
body: "{{ action_close }}"
- wait_template: >
{{
(state_attr('event.axwgvrgblmh1himl_response', 'message') == action_open)
or
(state_attr('event.axwgvrgblmh1himl_response', 'message') == action_close)
}}
mode: restartI have a feeling this should also be possible to do with a webhook trigger, but it would be a bit more complicated because I would have to set up my instance to be accessible from the internet. |
|
Oh, that's pretty clever, using a ntfy topic as callback route 😯 |
|
I double-checked and Android actually uses a webhook to handle buttons. |
Proposed change
Extends the
ntfy.publishaction with support for defining action buttons.Type of change
Additional information
Checklist
ruff format homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all.To help with the load of incoming pull requests: