Skip to content

Conversation

@tr4nt0r
Copy link
Contributor

@tr4nt0r tr4nt0r commented Sep 10, 2025

Proposed change

Extends the ntfy.publish action with support for defining action buttons.

image

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.

To help with the load of incoming pull requests:

Copy link
Contributor

@cr7pt0gr4ph7 cr7pt0gr4ph7 left a 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.

@tr4nt0r
Copy link
Contributor Author

tr4nt0r commented Sep 15, 2025

hassfest CI failure seems unrelated, something about apt cache. Locally hassfest runs without issues.

Copy link
Contributor

@cr7pt0gr4ph7 cr7pt0gr4ph7 left a 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!

@tr4nt0r tr4nt0r force-pushed the ntfy_button_actions branch from 729ec83 to 6e5ea86 Compare October 24, 2025 17:28
@tr4nt0r tr4nt0r marked this pull request as draft October 28, 2025 15:51
@tr4nt0r tr4nt0r marked this pull request as ready for review October 28, 2025 15:55
@an0Nym0us63
Copy link

really waiting for this, this is the only big feature missing in the core integration

@mik-laj
Copy link
Contributor

mik-laj commented Nov 8, 2025

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?

@tr4nt0r
Copy link
Contributor Author

tr4nt0r commented Nov 8, 2025

I think same as for the companion app's actionable notifications: https://companion.home-assistant.io/docs/notifications/actionable-notifications

@mik-laj
Copy link
Contributor

mik-laj commented Nov 8, 2025

@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.

@mik-laj
Copy link
Contributor

mik-laj commented Nov 8, 2025

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: restart

I 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.

@tr4nt0r
Copy link
Contributor Author

tr4nt0r commented Nov 8, 2025

Oh, that's pretty clever, using a ntfy topic as callback route 😯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants