I have a self made wlan push button. So I can configure the url where the request should be send.
I used the binary sensor component to handle the request. The binary sensor has an on/off state. But pressing the push button is just an event and not an on/off switch. Is there another more appropriate component?
Of course I could send two request. An “on” and immediatly after that an “off” - but this is only a temporary solution.
You could have the button run a script. That’ll save you a bit of code since you won’t have to add an automation that watches the state of the binary sensor. Also - if your script contains delays, you can test for it’s state being on or off in other automations if you don’t want to load everything into that one script. For example if you had a script that’s only sequence item was a one second delay, then the state would be “on” for a second, then return to off. Saves you a second call from your wlan button.
When you’re working out how to use the API, the services dev tool (left icon at bottom of sidebar) is handy. That way you can get things ironed out there before you put the logic in your button. Some things to remember: content type should be application/json, HTTP verb is POST, and you can pass your API variable in the URL.