Alert MQTT Proxy creates a very simple HTTP API that proxies MQTT messages.
Messages are sent to http://localhost:3001/alert/topic?msg=Hello
where topic
is the MQTT subtopic you want to post to, and msg=
is suffixed by the URL encoded message you want to send in that topic.
- Topics must be 128 characters or less.
- Topics may only contain a-z, 0-9, as well as hypen and underscore.
- There must be a topic.
- All topics are forced into lowercase.
- Messages must be 512 characters or less.
- There must be a message.
Messages are dispatched to the MQTT broker configured in the .env
file and can be prefixed with a topic path, for example MQTT_TOPIC=av
would mean that all proxied messages will end up inside av/
, for example a HTTP request like http://localhost:3001/alert/hh_302?msg=There%20is%20no%20sound.
would send the message "There is no sound." to av/hh_302
.
On successfully proxying a message the HTTP server will respond with ok
in plain text.
If there is an error you will still get a 200 status code, but a plain text message as follows:
error - invalid topic
– This means the topic has failed one of the above listed topic validation rules.error - no message
- This means there was nomsg
query string parameter, or it was empty.error - message too long
– This means the message was too long.error – server side
– This means the server was unable to send the message, probably because MQTT was down.
If you get any other message than these error codes something else is wrong.