Add-on endpoints or how to communicate with add-on properly, RESTful switch

Need some help on the handling POST request in add-on, please!

What is the proper way of getting POST information inside of the add-on? Are there any global variables defined for the add-on, or how can I handle request in the code, e.g. a python file? Do I need to setup a web server to handle requests, or can it be done in easy way?

…spend days on searching for this simple thing, will appreciate any useful information… Thanks in advance!

The goal is to have switch entities in HA, handle their switching in the add-on, and send a responses back to HA. From what I read in the documentation, RESTful switch can do that. But there is no info on how to create an ‘endpoint’ that REST api has to ‘consume’ in the add-on.

If there’s easier way of doing this, please let me know!