REST Switch to enable/disable Cloud connection in Shellys

Hi,
After adding a Google Home Nest in every room, I needed a way to quickly disable Google Home ability to operate my roller shutters (to avoid that someone standing right out of the window could open the cover just asking Google...).
Since the native Shelly integration provides only a sensor for Cloud connection, I wrote two RESTful switch, one for Gen 1 devices and the other for Gen 2+:

switch:
  # Gen 1
  - platform: rest
    name: "Gen 1 Cloud Enable"
    unique_id: <gen1 GUID>
    resource: http://<gen1 IP>/settings/cloud
    body_on: "enabled=true"
    body_off: "enabled=false"
    is_on_template: "{{ value_json.enabled == true }}"
    headers:
      Content-Type: application/x-www-form-urlencoded
  # Gen 2
  - platform: rest
    name: "Gen 2+ Cloud Enable"
    unique_id: <gen2 GUID>
    resource: http://<gen2 IP>/rpc/Cloud.SetConfig
    state_resource: http://<gen2 IP>/rpc/Cloud.GetConfig
    body_on: '{"config":{"enable":true}}'
    body_off: '{"config":{"enable":false}}'
    is_on_template: "{{ value_json.enable == true }}"
    headers:
      Content-Type: application/json

Flipping these switches immediatly cuts the devices out of the Cloud, rendering the respective instances unavailable to Google Home.

I hope this can be useful to someone else.

/ML

2 Likes