How do I use the "REST Server Provider"?

Hi there,

I just started a home project trying to pimp my HomeAutomation / SmartHome installation using StreamSheets running on a RasPi.

I hoped to be able to use a StreamMachine as a REST Server that will receive “calls” from a Shelly Plug S, Shelly 1 (or any other of the Shelly products) when the button is pressed.
The Shelly offers the possibility to call an URL once this happens. Like what is also called a “Webhook” in other environments.

Unfortunately documentation and information on the REST Server Provider and it’s usage is very limited (so far). So I tried some things that I figured might work, but simply did not manage to get any message/information into my inbox. (To avoid my issues resulting from the Shelly not working or being misconfigured I also tried sending/calling different requests/URLs using “Postman” ).

Has anyone a running example for me how to do that?

By the way:
I managed to get the REST to MQTT tutorial to run and adjust to and get current status information from my Shelly, but I would rather have a “push” approach here than a “pull”. I don’t want to flush my network with REST-calls to all my Shellies every second, just to see, whether potentially the status changed because the button was pressed.
Also the Shellys do offer the publication of MQTTs out of the box, but unfortunately the press of the button is not among the things being published (only the resulting relay status - on/off).
So the only way of receiving information about the button press itself is (currently) the “action” mentioned above.

Any help would be highly appreciated :slight_smile:

Hi ThomasP,

Nice use case, thanks for posting!! I agree, pushing only one request does make a lot of sense!
You were very close. The URL to be hit looks something like this:
http://192.168.2.221:8083/api/v1.0/cedalo/shellies/shellyplug-s-6A5833/button/on

So the root URL is: localhost:8083/api/v1.0/
And you can define the other URL parts in the Connector and the Consumer.
We have not yet documented the webhooks/api, but it is on our to-do list. :construction_worker_man:

I have added an example Stream Machine. Webhook Example.json (7.5 KB)

Let me know, if this works out for you! :slight_smile:

Cheers

Tizian

Hi Tizian,

thanks for the immediate and perfect answer.
I downloaded your example and it instantaneously worked perfect :+1:.

For my Shelly Plug-S I have defined my “Action URLs” like this now:
http://[ip]:8083/api/v1.0/cedalo/shellies/shellyplug-s-[plug-id]?action=button_pressed&index=0&status=toggled
http://[ip]:8083/api/v1.0/cedalo/shellies/shellyplug-s-[plug-id]?action=output_switched&index=0&status=on
http://[ip]:8083/api/v1.0/cedalo/shellies/shellyplug-s-[plug-id]?action=output_switched&index=0&status=off

The index only being there for compatibility with other Shelly products that have more than one input/output.
Now I am using topics like

  • shellies/shellyplug-s-[plug-id]
  • shellies/shellydimmer-[dimmer-id]

And with your cool IF-column I filter out the different Shellys by topic, and the events by actions.

From here I will have fun experimenting further with StreamSheets for my lights at home :slight_smile:

Thanks Again
ThomasP

1 Like

Awesome,
Have fun playing around. :slight_smile: