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

Accept priority as string #642

Open
lezruk opened this issue Mar 25, 2024 · 6 comments
Open

Accept priority as string #642

lezruk opened this issue Mar 25, 2024 · 6 comments
Labels
a:feature New feature or request

Comments

@lezruk
Copy link

lezruk commented Mar 25, 2024

Is your feature request related to a problem? Please describe.
Home-Assistant notify service with POST_JSON type always sends priority as sting in resulting JSON due to templating engine (similar how ansible jinja templating works), that is not accepted by gotify server with 400 bad requests, as it accepts strict integer value for priority only

Describe the solution you'd like
gotify server to accept priority as string, and throw an error only if string value is not castable to integer

Describe alternatives you've considered
No real alernativies found so far, only hardcoding particular value/default priority which doesn't serve the purpose of prioirty differentiation within single app messages

Additional context
N/A

@lezruk lezruk added the a:feature New feature or request label Mar 25, 2024
@LaurenceJJones
Copy link
Contributor

Hey 👋🏻

Looking at home assistant docs they provide a link to -> https://jinja.palletsprojects.com/en/latest/templates/#jinja-filters.int

I dont know what the template look like but I guess you should be able to type conversion?

@lezruk
Copy link
Author

lezruk commented Apr 1, 2024

All these filters are fine, but problem is that POST_JSON result is ALWAYS sent in quotes, which is interpreted as string. Thus gotify rejects it.

@jmattheis
Copy link
Member

You can set the priority like this in home assistent (also included markdown support):

notify:
  - name: gotify_high
    platform: rest
    resource: https://gotify.example.org/message
    method: POST_JSON
    headers:
      X-Gotify-Key: AsQHYA96LH90.RT
    message_param_name: message
    title_param_name: title
    data:
      priority: 10
      extras:
        client::display:
          contentType: "text/markdown"

@lezruk
Copy link
Author

lezruk commented Apr 3, 2024

Appreciate your answer, hardcoding value in data.extras works. Idea though is to avoid hardcoding and send priority as a value for individual message call within same service. Therefore I opened this request for evaluation.

@jmattheis
Copy link
Member

How do I manually trigger an alert with priority in home assistant? developer-tools/service doesn't have a priority.

@lezruk
Copy link
Author

lezruk commented Apr 10, 2024

How do I manually trigger an alert with priority in home assistant? developer-tools/service doesn't have a priority.

There is target parameter for notification service, that you can map to priority for gotify call. But again internally that is sent in JSON in quotes and doesn't work. Other option would be sending payload as fields in POST call, yet in this case markdown is lost as gotify doesn't support extras parameters without json. I saw somewhere here request to implement extras fields params i gotify but that was not done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:feature New feature or request
Development

No branches or pull requests

3 participants