I’m trying to get my owntracks mqtt notification to be forwarded to the Nextcloud app Phone Track but am having a heck of a time getting the notify.rest component to work.
It first was complaining message wasn’t defined even though it’s not mentioned in the doc, after confirming it wouldn’t matter if I had a junk field I just threw in test to test it. Then it was complaining that I had extra keys not allowed in @ data
I feel like I’m missing something obvious.
configuration.yml
notify:
- name: track_james
platform: rest
resource: "https://example.tld/apps/phonetrack/logGet/################################/dugite"
method: GET
Invalid service data for notify.track_dugite: extra keys not allowed @ data['bat']. Got '52'
extra keys not allowed @ data['lat']. Got '##'
extra keys not allowed @ data['lon']. Got '##'
extra keys not allowed @ data['timestamp']. Got '##'
What I expected get url should look like: https://example.tld/apps/phonetrack/logGet/################################/dugite?message=test&bat=52&lat=##&lon=##×tamp=##
It’s just an owntracks payload. {"_type":"location", "lat":##, "lon":## and you can see it’s read correctly in the log it just isn’t passing it as a url parameter as I expected it to.
That’s not the problem. If i don’t use paylod_json the error extra keys not allowed @ data['bat']. Got '52' becoms extra keys not allowed @ data['bat']. Got ''
Right, but from what I’ve read, you just want the url to pass through. So if that’s the case, treat the payload as a string and feed it through to the message.
Your other option is to just make the URL, you have the format concatenate the string and pass it through to the message.
After struggling with it myself, I figured out how the Restful Notification works. Extra parameters (as called by the doc) should be declared in the entity definition, not when calling the service. Unfortunately the rest platform does not seem to support extended data functionality when calling the notify service, so we only have title, message and target available. In a similar case like yours, one could feed the incoming data into an MQTT sensor with attributes and trigger notifications when that sensor changes state.
As an alternative one could also use the title, message or target service parameters to pass data to the notification directly, but that involves some jinja trickery (there are more than 3 parameters needed for this notification).
Sorry, I know this is an old post but I just came across this and I am in a similar situation as the original poster.
Would anyone be able to further elaborate on Petro’s suggestion of the URL and how to format concatenate the string to pass it through to the message? Maybe with an example of how it would be written? Would really appreciate that! Thank you!
UPDATE: I went with the shell command approach mentioned by dugite-code in the end. That seems to be the most straightforward way.