Supereg / homebridge-http-switch

Powerful http switch for Homebridge: https://github.com/homebridge/homebridge
ISC License
218 stars 36 forks source link

HowTo: Sending JSON via ntfy.sh #113

Closed Write closed 1 year ago

Write commented 1 year ago

Here's a working example to send JSON body trough ntfy.sh, as I had much issue to do it.

       {
            "accessory": "HTTP-SWITCH",
            "name": "JSONTest",
            "switchType": "stateless",
            "serialNumber": "SW002",
            "timeout": 1000,
            "debug": true,
            "method": "POST",
            "onUrl":
            {
                "url": "https://ntfy.sh/",
                "method": "POST",
                "headers":
                {
                    "Content-Type": "application/json"
                },
                "body":
                {
                    "topic": "your_topic",
                    "title": "🔥  NAS is running hot 🔥",
                    "message": "temperature is over 95",
                    "attach": "https://sflanders.net/wp-content/uploads/2015/11/synology-150x150.png"
                }
            }
        }

Remember: As per ntfy.sh doc : When sending a JSON notification, it must be sent to the root URL, and the topic in the body under "topic".

Thanks to https://github.com/Supereg/homebridge-http-switch/issues/103#issuecomment-999190364 / @mbierman's message which helped me a lot.

gandalfk7 commented 1 year ago

thanks, this helped me a lot!!

Supereg commented 1 year ago

I included your example in https://github.com/Supereg/homebridge-http-switch/wiki/Community-supplied-examples