companion-module-requests icon indicating copy to clipboard operation
companion-module-requests copied to clipboard

Shelly Cloud Components

Open Suenee opened this issue 2 years ago • 7 comments

Hi

I found you have had implemented TP-Link smart components already. So I hope it would be simple to make the same for Shelly components. Please take a look at https://shelly-api-docs.shelly.cloud/gen2/ It would be really nice, because I have these components in my live streaming studio.

What would I like to do about it? The absolute minimum that would be nice a lot:

  • switch the relay on / off / toggle
  • switch the light on / off / toggle
  • set the color of the light
  • Feedback when relay/light is ON / OFF
  • Turn on / off the whole scene (nice to have)
  • Amount of energy consumption (nice to have)

Thank you! :-)

Have a nice day! Sueneé

Suenee avatar Apr 03 '22 16:04 Suenee

Hi Sueneé,

I just got some Shelly1 switches, and you can make them work just fine with the HTTP integration:

In the Connection, select HTTP, and use the base URL like that: http://192.168.2.171/relay/0

I even used the feedback to get the state of the switch. Save the GET request with the base URL into a custom variable, and compare the output with the content below blow: Compare variable:

{ ison: false, has_timer: false, timer_started: 0, timer_duration: 0, timer_remaining: 0, overpower: false, overtemperature: false, is_valid: true, source: "http" }

Sure it could be a lot nicer and more fancy, as you can not really parse the output of the JSON data...

Therefore I would support your request above! roman p.s. I did not use the cloud connected API, just the local REST API

duplicate of https://github.com/bitfocus/companion-module-requests/issues/668

rgischig avatar Apr 03 '22 18:04 rgischig

@rgischig, could you elaborate how you got the Shelly State feedback working using the local REST API? I am just getting familiar with the BitCompanion Custom Variables.

Thanks, Philipp

philip-p avatar Apr 06 '22 01:04 philip-p

Hi Philip,

Well it's not the best way to do it but it get's the job done in my case:

A) create a custom variable for each shelly: $(internal:custom_shelly1_01_state) B) Create a separate "connection" for each shelly with the base URL likt that: http://192.168.2.171/relay/0 C) create a button with the following actions: Action1: Shelly1-01: POST Action1: URL: ?turn=on Action1: delay 1000 Action2: Shelly1-01: GET Action2: delay 5000 Action2: wite the output into the variable we created: JSON Response Data Variable > shelly1_01_state

Feedback: Action: internal: Check variable value Variable: internal:custom_shelly1_01_state Operation: = Value: {"ison":true,"has_timer":false,"timer_started":0,"timer_duration":0,"timer_remaining":0,"source":"http"}

the key is "ison":true > I know this is not the most beautiful way, but it works..

And then I set the background color of the button acordingly: green = on, red = off I'll document this on my website a bit nicer.. www.gischig.com

roman

rgischig avatar Apr 06 '22 06:04 rgischig

Hi guys,

I found another work around solution with cURL command:

curl --output nul -s -d "turn=on&channel=0&auth_key=******&id=Ab8f21" https://shelly-26-eu.shelly.cloud/device/relay/control/

and it works well. Thx for support and the idea about feedback detection. :)

Suenee avatar Apr 07 '22 08:04 Suenee

http://192.168.2.171/relay/0

when you make connection BF, what type of connection you use, please?

Suenee avatar Apr 07 '22 08:04 Suenee

I used this reference: https://shelly.cloud/documents/developers/ddd_communication.pdf

Press Action

the POST URL: http://192.168.2.171/relay/0?turn=toggle (or on/off) Body: {} Content Type: text/plain

And make a 5s delay if you make a 2nd request.

Ahh and I'm not using the cloud here, all local! https://shelly.cloud/documents/developers/ddd_communication.pdf

roman Tutorial on how to inplment it: https://gischig.com/shelly-remote-wifi-switches/

rgischig avatar Apr 07 '22 09:04 rgischig

If there's anyone thinking about writing a module for this, it could also support the RGBW version of the Shelly, including a color-picker for the RGB values. It works fine with HTTP requests as stated, but I may give this a go if I can sort out the specifics of writing a module. It would be nice to have feedbacks as well for at least on/off.

joshua-wyatt avatar Sep 16 '22 16:09 joshua-wyatt

TIP: As someone suggested here, shells can be controlled via HTTP in local network. I used cURL and using triggers in companion set the light to change color depending on whether the studio is recording (purple color) or broadcasting (red color) or paused (white color).

Suenee avatar Dec 11 '22 07:12 Suenee

https://github.com/bitfocus/companion-module-shelly-http is now in Beta testing.

leonreucher avatar Aug 11 '23 07:08 leonreucher