Replies: 1 comment
-
I haven't tried it yet, but maybe it would be easier to do something like this in a scripting language like Python?
I guess that is something that we could add 👍 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I use the json-rpc implementation (with @haberda addon), and I would like to send events to Home Assistant to get the messages.
I tried many combinations of commands and the best thing I managed to get is this one liner.
wscat -c 10.0.0.9:8080/v1/receive/+XXXXXXXX --slash | jq --unbuffered -c -r '.envelope | select( .dataMessage != null)' | sed -u "s/^/'/;s/$/'/" | xargs -I{} curl -N -d '{}' -H "Content-Type: application/json" -X POST http://10.0.0.9:8123/api/webhook/-XXXXXXXXXXXXXXXXX
select( .dataMessage != null)
is used to exclude "Start typing / Stop typing" messages.It mainly works but because of xargs, it fails for specific cases like the presence of unmatching single quote. I didn't manage to find a proper way to fully escape the messages.
So, I can get the messages as events in HA, parse them and do what I want with them:
{{ trigger.json.sourceName }} says "{{ trigger.json.dataMessage.message }}"
Any idea to have a better / easiest way to do it?
Would it make sense to have such JSON forwarder implemented in this project as an advanced option? The minimal implementation would be to specify the webhook endpoint. The filtering of messages would be the responsibility of the receiving client.
Beta Was this translation helpful? Give feedback.
All reactions