Skip to main content
Version: 1.0

Component Concept

General

A component is an encapsulated functional unit which exposes methods for communication with the outside world. Each component has a status and a configuration. Hence, each component supports the methods: <component>.GetStatus, <component>.GetConfig, <component>.SetConfig. The behavior of these methods is identical, they only differ in the format of the configuration and status structures.

Status

The status contains all static characteristics of a component. To get the status of a component, the method <component>.GetStatus can be used. Alternatively, to see the status of all components in your device in one place, you can use Shelly.GetStatus. As the status characteristics are static, they cannot be set and that's the reason why Shelly Gen2+ devices support only <component>.GetStatus method (but not a <component>.SetStatus one).

The <component>.GetStatus method returns an object specific to the chosen component. Hence, a parameter id is needed in case the device has more than one instance of this component. Otherwise, <component>.GetStatus takes no parameters. For example, a Shelly Pro4PM device has 4 instances of the switch component and only one instance of the cloud component. To get the status of the switch instance with id=2, the request frame should be:

http://192.168.33.1/rpc/Switch.GetStatus?id=2

On the other hand, for getting the status of the only cloud instance, the request frame should be:

http://192.168.33.1/rpc/Cloud.GetStatus

Configuration

The configuration contains all component's configuration parameters. Here, the method <component>.GetConfig is provided to return the configuration of a component and <component>.SetConfig can be used to update configuration parameters of a component. A shorthand for obtaining the configuration of all the components in your device in one place, you can use Shelly.GetConfig.

<component>.GetConfig

Analogically to <component>.GetStatus, the method <component>.GetConfig takes a parameter id in case the device has more than one instance of a component. Otherwise, it takes no parameters. Response will contain the configuration structure

http://192.168.33.1/rpc/Sys.GetConfig

<component>.SetConfig

Configuration of a component can be set through the method <component>.SetConfig. Once again, it takes as parameter the id of the component, if needed. Additionally, it takes the required parameter config - JSON object, containing the configuration to be applied. This object should be identical in structure to the JSON payload returned by <component>.GetConfig, containing only the keys that need to be modified. The response of <component>.SetConfig is a JSON object, which contains only one attribute:

  • restart_required: boolean, true if restart is required to apply the changes, false otherwise.
Disable ethernet connection for this device.
curl -X POST -d '{"id":1, "method":"Eth.SetConfig",
"params":{"config":{"enable":false}}}' http://${SHELLY}/rpc
Change the configuration of the input with id=0 setting its name to my-Shelly-One and its type to switch.
curl -X POST -d '{"id":1, "method":"Input.SetConfig",
"params":{"id":0, "config":{"name":"my-Shelly-One", "type":"switch"}}}' http://${SHELLY}/rpc