Input
The Input component handles external digital or analog input terminals of a device. Input components are identified with input:<id>
in objects containing multiple component payloads. Inputs can trigger webhooks, control switches and optionally perform factory reset.
Inputs can support one of two modes:
- Digital inputs sense a discrete HIGH / LOW input states and can be configured to work with attached momentary buttons or toggle switches.
- Analog inputs can be configured to work as discrete inputs, but also support reading the analog value of the input, represented as a range between 0 and 100 %. Whether an input is analog capable is reflected on the page of each device model.
The Input component uses Input
as RPC namespace and implements the minimal component interface:
Input.GetConfig
to obtain the component's configurationInput.SetConfig
to update the component's configurationInput.GetStatus
to obtain the component's status
Factory reset by input is a way to roll back any changes made to the device and return it to its factory configuration. This action is possible only in the first 60 seconds after boot. The user should toggle the input 5 times and the device will be reset to its factory settings. Factory reset can also be done using an RPC call.
Methods
Input.SetConfig
Property | Type | Description |
---|---|---|
| number | Id of the Input component instance |
| object | Configuration that the method takes |
Find more about the config properties in config section
Input.GetConfig
Properties:
Property | Type | Description |
---|---|---|
| number | Id of the Input component instance |
Find the Input.GetConfig response properties in config section
Input.GetStatus
Properties:
Property | Type | Description |
---|---|---|
| number | Id of the Input component instance |
Find more about the status response properties in status section
Configuration
The configuration of the Input component contains information about the type, invert and factory reset settings of the chosen input instance. To Get/Set the configuration of the Input component its id
must be specified.
Properties:
Property | Type | Description |
---|---|---|
| number | Id of the Input component instance |
| string or null | Name of the input instance |
| string | Type of associated input. Range of values |
| boolean | True if the logical state of the associated input is inverted, false otherwise. For the change to be applied, the physical switch has to be toggled once after |
| boolean | (only for type |
| number | (only for type |
| array or null | (only for type |
Status
The status of the Input component contains information about the state of the chosen input instance. To obtain the status of the Input component its id
must be specified.
Property | Type | Description |
---|---|---|
| number | Id of the Input component instance |
| boolean or null | (only for type |
| number or null | (only for type |
| array of type string | Shown only if at least one error is present. May contain |
Webhook Events
Currently, depending on the type of Input component different events that can trigger webhooks are available:
- for Input instances of type switch:
input.toggle_on
- produced when the input instance is toggled fromoff
toon
stateinput.toggle_off
- produced when the input instance is toggled fromon
tooff
state
- for Input instances of type button:
input.button_push
- produced when the button is pushed onceinput.button_longpush
- produced when the button is pushed once for longer timeinput.button_doublepush
- produced when the button is pushed two consecutive timesinput.button_triplepush
- produced when the button is pushed three consecutive times
- for Input instances of type analog:
input.analog_change
- produced when analog value percent delta between two measurements is greater thanreport_thr
input.analog_measurement
- produced on a monotonic measurement period (60s)
input.analog_change
and input.analog_measurement
support one attribute, that can be used to compose conditional webhooks:
Property | Type | Description |
---|---|---|
| number | New analog value in percent |
Notifications
This section describes notifications for events specific to the Input component. For general information please see this page.
Instances of the Input component can send notifications for the following events:
btn_down
btn_up
single_push
double_push
triple_push
long_push
Rate Limit for Notifications
In certain cases the Input component generates excessive amount of event or status change notifications which may cause degraded performance or even outages in certain scenarios. To mitigate this, a rate limiting algorithm (sliding time window) is applied to the generated notifications. If the limit is reached event notifications will be dropped, while status changes will accumulate until the rate limit is no longer enforced. At the end of the time period an event notification is sent with the counts of missed event and status change notifications, as well as a status change notification if changes were accumulated during the time the rate limiter was active. The limit applied is 80 notifications for a period of 60 seconds.
Examples
Input.GetConfig example
- Input.GetConfig HTTP GET Request
- Input.GetConfig Curl Request
- Input.GetConfig Mos Request
http://192.168.33.1/rpc/Input.GetConfig?id=0
curl -X POST -d '{"id":1,"method":"Input.GetConfig","params":{"id":0}}' http://${SHELLY}/rpc
mos --port ${PORT} call Input.GetConfig '{"id":0}'
Response
- Input.GetConfig HTTP GET Response
- Input.GetConfig Curl Response
- Input.GetConfig Mos Response
{
"id": 0,
"name": "name",
"type": "switch",
"invert": false
}
{
"id": 1,
"src": "shellypro1-84cca87c1f90",
"params": {
"id": 0,
"name": "name",
"type": "switch",
"invert": false
}
}
{
"id": 0,
"name": "name",
"type": "switch",
"invert": false
}
Input.SetConfig example
- Input.SetConfig HTTP GET Request
- Input.SetConfig Curl Request
- Input.SetConfig Mos Request
http://192.168.33.1/rpc/Input.SetConfig?id=0&config={"name":"Input0"}
curl -X POST -d '{"id":1,"method":"Input.SetConfig","params":{"id":0,"config":{"name":"Input0"}}}' http://${SHELLY}/rpc
mos --port ${PORT} call Input.SetConfig '{"id":0,"config":{"name":"Input0"}}'
Response
- Input.SetConfig HTTP GET Response
- Input.SetConfig Curl Response
- Input.SetConfig Mos Response
{
"restart_required": false
}
{
"id": 1,
"src": "shellypro1-84cca87c1f90",
"params": {
"restart_required": false
}
}
{
"restart_required": false
}
Input.GetStatus example
- Input.GetStatus HTTP GET Request
- Input.GetStatus Curl Request
- Input.GetStatus Mos Request
http://192.168.33.1/rpc/Input.GetStatus?id=0
curl -X POST -d '{"id":1,"method":"Input.GetStatus","params":{"id":0}}' http://${SHELLY}/rpc
mos --port ${PORT} call Input.GetStatus '{"id":0}'
Response
- Input.GetStatus HTTP GET Response
- Input.GetStatus Curl Response
- Input.GetStatus Mos Response
{
"id": 0,
"state": false
}
{
"id": 1,
"src": "shellypro1-84cca87c1f90",
"params": {
"id": 0,
"state": false
}
}
{
"id": 0,
"state": false
}
Notifications example
- Button press (only when Input
type
=button
):
Example 1:
Notify that a button press event has occurred.{
"src": "shellypro4pm-f008d1d8b8b8",
"dst": "user_1",
"method": "NotifyEvent",
"params": {
"ts": 1631266595.43,
"events": [
{
"component": "input:0",
"id": 0,
"event": "btn_down",
"ts": 1631266595.43
}
]
}
}
- Button release (only when Input
type
=button
):
Example 2:
Notify that a button release event has occurred.{
"src": "shellypro4pm-f008d1d8b8b8",
"dst": "user_1",
"method": "NotifyEvent",
"params": {
"ts": 1631266564.64,
"events": [
{
"component": "input:0",
"id": 0,
"event": "btn_up",
"ts": 1631266564.64
}
]
}
}
- Single button push (only when Input
type
=button
):
Example 3:
Notify that a button single push event has occurred.{
"src": "shellypro4pm-f008d1d8b8b8",
"dst": "user_1",
"method": "NotifyEvent",
"params": {
"ts": 1631266595.44,
"events": [
{
"component": "input:0",
"id": 0,
"event": "single_push",
"ts": 1631266595.44
}
]
}
}
- Double button push (only when Input
type
=button
):
Example 4:
Notify that a button double push event has occurred.{
"src": "shellypro4pm-f008d1d8b8b8",
"dst": "user_1",
"method": "NotifyEvent",
"params": {
"ts": 1631266647.44,
"events": [
{
"component": "input:0",
"id": 0,
"event": "double_push",
"ts": 1631266647.44
}
]
}
}
- Triple button push (only when Input
type
=button
):
Example 5:
Notify that a button triple push event has occurred.{
"src": "shellypro4pm-f008d1d8b8b8",
"dst": "user_1",
"method": "NotifyEvent",
"params": {
"ts": 1631266647.44,
"events": [
{
"component": "input:0",
"id": 0,
"event": "triple_push",
"ts": 1631266647.44
}
]
}
}
- Long button push (only when Input
type
=button
):
Example 6:
Notify that a button long push event has occurred.{
"src": "shellypro4pm-f008d1d8b8b8",
"dst": "user_1",
"method": "NotifyEvent",
"params": {
"ts": 1631266629.79,
"events": [
{
"component": "input:0",
"id": 0,
"event": "long_push",
"ts": 1631266629.79
}
]
}
}