Skip to content
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

Custom notifications with Home Assistant #1235

Open
Clam58 opened this issue Nov 9, 2024 · 2 comments
Open

Custom notifications with Home Assistant #1235

Clam58 opened this issue Nov 9, 2024 · 2 comments

Comments

@Clam58
Copy link

Clam58 commented Nov 9, 2024

💡 The Idea

The current notification for HA uses the service persistent_notification/create and works really well.
However within HA it is possible to create custom notifications that are sent to various devices e.g. TV, phone etc. as popups. This can be done using these devices services, and notifications groups.

it is simple to call these using for example curl with the long-lived token but calling a different url e.g.

http://homeassistant.local:8123/api/services/notify/servicename

This is so similar to the existing code, I thought it might be possible to add this in by allowing a custom path to be given in the configuration that would bypass the persistent_notification/create path.

I think it would be a great addition but appreciate you may not think so, but thanks for taking the time to read this.

if I can provide anything else to support this enhancement let me know.

🔨 Breaking Feature

@caronc
Copy link
Owner

caronc commented Dec 7, 2024

Sure, can you share with me what the payload looks like? Is it truely the same except for just the URL itself?

Here is what we support now:

  • {schema}://{host}/{accesstoken}
  • {schema}://{host}:{port}/{accesstoken}
  • {schema}://{user}@{host}/{accesstoken}
  • {schema}://{user}@{host}:{port}/{accesstoken}
  • {schema}://{user}:{password}@{host}/{accesstoken}
  • {schema}://{user}:{password}@{host}:{port}/{accesstoken}

Perhaps additionally supporting (keeping backwards compatibility)::

  • {schema}://{host}/{accesstoken}/{servicename}
  • {schema}://{host}:{port}/{accesstoken}/{servicename}
  • {schema}://{user}@{host}/{accesstoken}/{servicename}
  • {schema}://{user}@{host}:{port}/{accesstoken}/{servicename}
  • {schema}://{user}:{password}@{host}/{accesstoken}/{servicename}
  • {schema}://{user}:{password}@{host}:{port}/{accesstoken}/{servicename}

I can also add more then one service name in the URL too if the access token is always the same:

  • {schema}://{host}/{accesstoken}/{servicename1}/{servicename2}/{servicenameN}
  • {schema}://{host}:{port}/{accesstoken}/{servicename1}/{servicename2}/{servicenameN}
  • {schema}://{user}@{host}/{accesstoken}/{servicename1}/{servicename2}/{servicenameN}
  • {schema}://{user}@{host}:{port}/{accesstoken}/{servicename1}/{servicename2}/{servicenameN}
  • {schema}://{user}:{password}@{host}/{accesstoken}/{servicename1}/{servicename2}/{servicenameN}
  • {schema}://{user}:{password}@{host}:{port}/{accesstoken}/{servicename1}/{servicename2}/{servicenameN}

@Clam58
Copy link
Author

Clam58 commented Dec 13, 2024

Thanks for your reply.

To call any of the notify services only requires you know its service name. Everything else is the same

So whereas just now the url called is

http://homeassistant.local:8123/api/services/persistent_notification/create?

which create a persistent notification. To call one of the other notify services for example my-servicename, requires you call

http://homeassistant.local:8123/api/services/notify/my-servicename?

so only the url is changed. The same bearer token works in both cases.

In your example, this would be servicename1=notify and servicename2=my-servicename.

or you could restrict this to only hitting the notify endpoints by accepting a single service name and appending it to

http://homeassistant.local:8123/api/services/notify/

which might be safer.

Hope this helps - if you need anything else let me know.

Thanks again for the great project!

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

No branches or pull requests

2 participants