> ## Documentation Index
> Fetch the complete documentation index at: https://docs.coreflux.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Shelly Gen2 Rpc

> Client-mode REST API connectors for Shelly Gen2+ devices (local RPC over HTTP) and the Shelly Cloud Control API v2: switch, cover, light, power and 3-phase energy meter status, energy history, webhooks, relay and cover control

Technical Preview

## Overview

Client-mode REST API connectors for Shelly Gen2+ devices (local RPC over HTTP) and the Shelly Cloud Control API v2: switch, cover, light, power and 3-phase energy meter status, energy history, webhooks, relay and cover control.

This is one of the templates in the Shelly (Gen2+ local RPC and Shelly Cloud) REST API app (`shelly`). Deploy it alongside the other connectors of that app when they depend on each other (for example a token connector plus an API connector).

> [!NOTE]
>
> Not yet verified against the live vendor API: No Shelly device reachable from the box and no Shelly Cloud auth key: the local connector needs a Gen2+ device on the LAN, and the cloud connector needs an account server uri + Authorization cloud key + a device id. The real cloud endpoint was probed (401 UNAUTHORIZED without a key); no authenticated live call could run.

## Auth

* **schemes**: \["none (local, device auth off)", "auth\_key query parameter (cloud)"]
* **secret**: SHELLY\_CLOUD\_AUTH\_KEY
* **note**: Local HTTP RPC uses SHA-256 Digest (RFC 7616) when auth is enabled; the REST\_API connector cannot answer the per-request nonce challenge, so protected devices return 401 except Shelly.GetDeviceInfo and /shelly. Use the device's native MQTT (\<shelly-id>/rpc) or the cloud connector for protected devices.

## Template parameters

| Placeholder | Type | Description | Required |
| - | - | - | - |
| `RouteName` | string | Name of the Shelly Gen2 Rpc connector | no |
| `BaseUrl` | string | Shelly Gen2 Rpc base URL without trailing slash (e.g. [http://192.168.33.1](http://192.168.33.1)) | yes |

`BASE_ADDRESS` default: `http://192.168.33.1`.

## Events

| Event | Method | Endpoint | Request topic | Response topic | Payload fields |
| - | - | - | - | - | - |
| `GetShellyIdentity` | GET | `/shelly` | `energy/shelly/identity/get` | `energy/shelly/identity/get/response` | none |
| `GetDeviceInfo` | GET | `/rpc/Shelly.GetDeviceInfo` | `energy/shelly/device-info/get` | `energy/shelly/device-info/get/response` | none |
| `GetStatus` | GET | `/rpc/Shelly.GetStatus` | `energy/shelly/status/get` | `energy/shelly/status/get/response` | none |
| `GetConfig` | GET | `/rpc/Shelly.GetConfig` | `energy/shelly/config/get` | `energy/shelly/config/get/response` | none |
| `ListMethods` | GET | `/rpc/Shelly.ListMethods` | `energy/shelly/methods/get` | `energy/shelly/methods/get/response` | none |
| `CheckForUpdate` | GET | `/rpc/Shelly.CheckForUpdate` | `energy/shelly/update/check` | `energy/shelly/update/check/response` | none |
| `SysGetStatus` | GET | `/rpc/Sys.GetStatus` | `energy/shelly/sys/status/get` | `energy/shelly/sys/status/get/response` | none |
| `SwitchGetStatus` | GET | `/rpc/Switch.GetStatus?id={value.json.id}` | `energy/shelly/switch/status/get` | `energy/shelly/switch/status/get/response` | `id` |
| `SwitchGetConfig` | GET | `/rpc/Switch.GetConfig?id={value.json.id}` | `energy/shelly/switch/config/get` | `energy/shelly/switch/config/get/response` | `id` |
| `InputGetStatus` | GET | `/rpc/Input.GetStatus?id={value.json.id}` | `energy/shelly/input/status/get` | `energy/shelly/input/status/get/response` | `id` |
| `CoverGetStatus` | GET | `/rpc/Cover.GetStatus?id={value.json.id}` | `energy/shelly/cover/status/get` | `energy/shelly/cover/status/get/response` | `id` |
| `LightGetStatus` | GET | `/rpc/Light.GetStatus?id={value.json.id}` | `energy/shelly/light/status/get` | `energy/shelly/light/status/get/response` | `id` |
| `Pm1GetStatus` | GET | `/rpc/PM1.GetStatus?id={value.json.id}` | `energy/shelly/pm1/status/get` | `energy/shelly/pm1/status/get/response` | `id` |
| `EmGetStatus` | GET | `/rpc/EM.GetStatus?id={value.json.id}` | `energy/shelly/em/status/get` | `energy/shelly/em/status/get/response` | `id` |
| `EmDataGetStatus` | GET | `/rpc/EMData.GetStatus?id={value.json.id}` | `energy/shelly/emdata/status/get` | `energy/shelly/emdata/status/get/response` | `id` |
| `EmDataGetData` | GET | `/rpc/EMData.GetData?id={value.json.id}&ts={value.json.ts}&end_ts={value.json.end_ts}` | `energy/shelly/emdata/data/get` | `energy/shelly/emdata/data/get/response` | `end_ts`, `id`, `ts` |
| `TemperatureGetStatus` | GET | `/rpc/Temperature.GetStatus?id={value.json.id}` | `energy/shelly/temperature/status/get` | `energy/shelly/temperature/status/get/response` | `id` |
| `WebhookList` | GET | `/rpc/Webhook.List` | `energy/shelly/webhook/list` | `energy/shelly/webhook/list/response` | none |
| `SwitchSet` | POST | `/rpc/Switch.Set` | `energy/shelly/switch/set` | `energy/shelly/switch/set/response` | `body` |
| `SwitchToggle` | POST | `/rpc/Switch.Toggle` | `energy/shelly/switch/toggle` | `energy/shelly/switch/toggle/response` | `body` |
| `CoverOpen` | POST | `/rpc/Cover.Open` | `energy/shelly/cover/open` | `energy/shelly/cover/open/response` | `body` |
| `CoverClose` | POST | `/rpc/Cover.Close` | `energy/shelly/cover/close` | `energy/shelly/cover/close/response` | `body` |
| `CoverStop` | POST | `/rpc/Cover.Stop` | `energy/shelly/cover/stop` | `energy/shelly/cover/stop/response` | `body` |
| `CoverGoToPosition` | POST | `/rpc/Cover.GoToPosition` | `energy/shelly/cover/position/set` | `energy/shelly/cover/position/set/response` | `body` |
| `LightSet` | POST | `/rpc/Light.Set` | `energy/shelly/light/set` | `energy/shelly/light/set/response` | `body` |
| `WebhookCreate` | POST | `/rpc/Webhook.Create` | `energy/shelly/webhook/create` | `energy/shelly/webhook/create/response` | `body` |
| `WebhookDelete` | POST | `/rpc/Webhook.Delete` | `energy/shelly/webhook/delete` | `energy/shelly/webhook/delete/response` | `body` |
| `Reboot` | POST | `/rpc/Shelly.Reboot` | `energy/shelly/reboot` | `energy/shelly/reboot/response` | `body` |
| `Rpc` | POST | `/rpc` | `energy/shelly/rpc` | `energy/shelly/rpc/response` | `body` |

## Deploy

Get the template card (JSON with `template` and `metadata`) from the broker, then deploy the connector:

```bash theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
mosquitto_pub -t '$SYS/Coreflux/Command' -m "-routeCode SHELLY_GEN2_RPC"
```

The deployable connector from the REST API app, with `BASE_ADDRESS` already filled in:

```lot theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
DEFINE ROUTE ShellyGen2Rpc WITH TYPE REST_API
    ADD REST_API_CONFIG
        WITH BASE_ADDRESS "http://192.168.33.1"
        WITH ENABLE_CLIENT "true"
        WITH USE_SSL "false"
        WITH REQUEST_TIMEOUT '10'
        WITH DEFAULT_CONTENT_TYPE "application/json"
    ADD EVENT GetShellyIdentity
        WITH SOURCE_TOPIC "energy/shelly/identity/get"
        WITH DESTINATION_TOPIC "energy/shelly/identity/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/shelly"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
    ADD EVENT GetDeviceInfo
        WITH SOURCE_TOPIC "energy/shelly/device-info/get"
        WITH DESTINATION_TOPIC "energy/shelly/device-info/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/rpc/Shelly.GetDeviceInfo"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
    ADD EVENT GetStatus
        WITH SOURCE_TOPIC "energy/shelly/status/get"
        WITH DESTINATION_TOPIC "energy/shelly/status/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/rpc/Shelly.GetStatus"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
    ADD EVENT GetConfig
        WITH SOURCE_TOPIC "energy/shelly/config/get"
        WITH DESTINATION_TOPIC "energy/shelly/config/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/rpc/Shelly.GetConfig"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
    ADD EVENT ListMethods
        WITH SOURCE_TOPIC "energy/shelly/methods/get"
        WITH DESTINATION_TOPIC "energy/shelly/methods/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/rpc/Shelly.ListMethods"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
    ADD EVENT CheckForUpdate
        WITH SOURCE_TOPIC "energy/shelly/update/check"
        WITH DESTINATION_TOPIC "energy/shelly/update/check/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/rpc/Shelly.CheckForUpdate"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
    ADD EVENT SysGetStatus
        WITH SOURCE_TOPIC "energy/shelly/sys/status/get"
        WITH DESTINATION_TOPIC "energy/shelly/sys/status/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/rpc/Sys.GetStatus"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
    ADD EVENT SwitchGetStatus
        WITH SOURCE_TOPIC "energy/shelly/switch/status/get"
        WITH DESTINATION_TOPIC "energy/shelly/switch/status/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/rpc/Switch.GetStatus?id={value.json.id}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
    ADD EVENT SwitchGetConfig
        WITH SOURCE_TOPIC "energy/shelly/switch/config/get"
        WITH DESTINATION_TOPIC "energy/shelly/switch/config/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/rpc/Switch.GetConfig?id={value.json.id}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
    ADD EVENT InputGetStatus
        WITH SOURCE_TOPIC "energy/shelly/input/status/get"
        WITH DESTINATION_TOPIC "energy/shelly/input/status/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/rpc/Input.GetStatus?id={value.json.id}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
    ADD EVENT CoverGetStatus
        WITH SOURCE_TOPIC "energy/shelly/cover/status/get"
        WITH DESTINATION_TOPIC "energy/shelly/cover/status/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/rpc/Cover.GetStatus?id={value.json.id}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
    ADD EVENT LightGetStatus
        WITH SOURCE_TOPIC "energy/shelly/light/status/get"
        WITH DESTINATION_TOPIC "energy/shelly/light/status/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/rpc/Light.GetStatus?id={value.json.id}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
    ADD EVENT Pm1GetStatus
        WITH SOURCE_TOPIC "energy/shelly/pm1/status/get"
        WITH DESTINATION_TOPIC "energy/shelly/pm1/status/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/rpc/PM1.GetStatus?id={value.json.id}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
    ADD EVENT EmGetStatus
        WITH SOURCE_TOPIC "energy/shelly/em/status/get"
        WITH DESTINATION_TOPIC "energy/shelly/em/status/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/rpc/EM.GetStatus?id={value.json.id}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
    ADD EVENT EmDataGetStatus
        WITH SOURCE_TOPIC "energy/shelly/emdata/status/get"
        WITH DESTINATION_TOPIC "energy/shelly/emdata/status/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/rpc/EMData.GetStatus?id={value.json.id}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
    ADD EVENT EmDataGetData
        WITH SOURCE_TOPIC "energy/shelly/emdata/data/get"
        WITH DESTINATION_TOPIC "energy/shelly/emdata/data/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/rpc/EMData.GetData?id={value.json.id}&ts={value.json.ts}&end_ts={value.json.end_ts}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
    ADD EVENT TemperatureGetStatus
        WITH SOURCE_TOPIC "energy/shelly/temperature/status/get"
        WITH DESTINATION_TOPIC "energy/shelly/temperature/status/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/rpc/Temperature.GetStatus?id={value.json.id}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
    ADD EVENT WebhookList
        WITH SOURCE_TOPIC "energy/shelly/webhook/list"
        WITH DESTINATION_TOPIC "energy/shelly/webhook/list/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/rpc/Webhook.List"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
    ADD EVENT SwitchSet
        WITH SOURCE_TOPIC "energy/shelly/switch/set"
        WITH DESTINATION_TOPIC "energy/shelly/switch/set/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/rpc/Switch.Set"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
            ADD "Content-Type" "application/json"
        WITH BODY "{value.json.body}"
    ADD EVENT SwitchToggle
        WITH SOURCE_TOPIC "energy/shelly/switch/toggle"
        WITH DESTINATION_TOPIC "energy/shelly/switch/toggle/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/rpc/Switch.Toggle"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
            ADD "Content-Type" "application/json"
        WITH BODY "{value.json.body}"
    ADD EVENT CoverOpen
        WITH SOURCE_TOPIC "energy/shelly/cover/open"
        WITH DESTINATION_TOPIC "energy/shelly/cover/open/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/rpc/Cover.Open"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
            ADD "Content-Type" "application/json"
        WITH BODY "{value.json.body}"
    ADD EVENT CoverClose
        WITH SOURCE_TOPIC "energy/shelly/cover/close"
        WITH DESTINATION_TOPIC "energy/shelly/cover/close/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/rpc/Cover.Close"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
            ADD "Content-Type" "application/json"
        WITH BODY "{value.json.body}"
    ADD EVENT CoverStop
        WITH SOURCE_TOPIC "energy/shelly/cover/stop"
        WITH DESTINATION_TOPIC "energy/shelly/cover/stop/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/rpc/Cover.Stop"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
            ADD "Content-Type" "application/json"
        WITH BODY "{value.json.body}"
    ADD EVENT CoverGoToPosition
        WITH SOURCE_TOPIC "energy/shelly/cover/position/set"
        WITH DESTINATION_TOPIC "energy/shelly/cover/position/set/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/rpc/Cover.GoToPosition"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
            ADD "Content-Type" "application/json"
        WITH BODY "{value.json.body}"
    ADD EVENT LightSet
        WITH SOURCE_TOPIC "energy/shelly/light/set"
        WITH DESTINATION_TOPIC "energy/shelly/light/set/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/rpc/Light.Set"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
            ADD "Content-Type" "application/json"
        WITH BODY "{value.json.body}"
    ADD EVENT WebhookCreate
        WITH SOURCE_TOPIC "energy/shelly/webhook/create"
        WITH DESTINATION_TOPIC "energy/shelly/webhook/create/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/rpc/Webhook.Create"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
            ADD "Content-Type" "application/json"
        WITH BODY "{value.json.body}"
    ADD EVENT WebhookDelete
        WITH SOURCE_TOPIC "energy/shelly/webhook/delete"
        WITH DESTINATION_TOPIC "energy/shelly/webhook/delete/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/rpc/Webhook.Delete"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
            ADD "Content-Type" "application/json"
        WITH BODY "{value.json.body}"
    ADD EVENT Reboot
        WITH SOURCE_TOPIC "energy/shelly/reboot"
        WITH DESTINATION_TOPIC "energy/shelly/reboot/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/rpc/Shelly.Reboot"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
            ADD "Content-Type" "application/json"
        WITH BODY "{value.json.body}"
    ADD EVENT Rpc
        WITH SOURCE_TOPIC "energy/shelly/rpc"
        WITH DESTINATION_TOPIC "energy/shelly/rpc/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/rpc"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
            ADD "Content-Type" "application/json"
        WITH BODY "{value.json.body}"
```

Deploy it with `-addRoute` (do not include `ADD METADATA`).

## Usage example

Call `GetShellyIdentity` by publishing a JSON payload to its request topic, and read the reply on the response topic:

```bash theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
mosquitto_sub -t 'energy/shelly/identity/get/response' &
mosquitto_pub -t 'energy/shelly/identity/get' -m '{}'
```

## Related

* [REST API Connectors](/latest/lot-language/routes/rest-api-routes)
* [REST API Apps catalog](/latest/lot-language/routes/rest-api-apps)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.