Shelly 1/1PM/EM

Examples are without external sensor, document with examples and settings with sensors:

Fetch Status

Request URL:

POST /provider/fetch

Headers:

Content-Type: application/json
Authorization: Bearer {access_token}

Body:

{
"serial_number" : "{Shelly Serial Number}"
}

Response:

{
"provider": {
"online": true,
"isok": true,
"data": {
"online": true,
"device_status": {
"ram_free": 38924,
"has_update": true,
"wifi_sta": {
"connected": true,
"ssid": "",
"ip": "",
"rssi": -44
},
"update": {
"status": "pending",
"has_update": true,
"new_version": "",
"old_version": ""
},
"ext_sensors": [],
"actions_stats": {
"skipped": 0
},
"cfg_changed_cnt": 2,
"fs_free": 146333,
"getinfo": {
"fw_info": {
"device": "shelly1-E0*******33",
"fw": ""
}
},
"inputs": [
{
"input": 0,
"event": "",
"event_cnt": 0
}
],
"_updated": "2020-11-09 16:33:16",
"ram_total": 50736,
"fs_size": 233681,
"ext_humidity": [],
"relays": [
{
"ison": false,
"has_timer": false,
"timer_started": 0,
"timer_duration": 0,
"timer_remaining": 0,
"source": "input"
}
],
"mac": "E09*******33",
"meters": [
{
"power": 0,
"is_valid": true
}
],
"serial": 3,
"ext_temperature": [],
"unixtime": 1604946495,
"cloud": {
"enabled": true,
"connected": true
},
"time": "18:28",
"uptime": 108,
"mqtt": {
"connected": false
}
}
}
},
"_links": {
"self": {
"href": "/v1/provider/fetch"
}
}
}

*More information about device status response

Fetch Settings

Request URL:

POST /provider/fetch

Headers:

Content-Type: application/json
Authorization: Bearer {access_token}

Body:

{
"serial_number" : "{Shelly Serial Number}",
"settings":true
}

Response:

{
"provider": {
"coiot": {
"update_period": 15
},
"factory_reset_from_switch": true,
"wifi_sta": {
"enabled": true,
"ssid": "",
"ipv4_method": "dhcp",
"ip": null,
"gw": null,
"mask": null,
"dns": null
},
"timezone": "Europe/Sofia",
"fw": "20201102-092207/[email protected]",
"tz_dst_auto": true,
"wifi_ap": {
"enabled": false,
"ssid": "shelly1-E09*******33",
"key": ""
},
"_updated": "2020-11-09 16:28:13",
"longpush_time": 800,
"device": {
"type": "SHSW-1",
"mac": "E**********3",
"hostname": "shelly1-E***********3",
"num_outputs": 1
},
"sntp": {
"server": "time.google.com",
"enabled": true
},
"ext_humidity": [],
"mode": "relay",
"tz_utc_offset": 7200,
"build_info": {
"build_id": "20201102-092207/[email protected]",
"build_timestamp": "2020-11-02T09:22:07Z",
"build_version": "1.0"
},
"ext_switch": [
{
"relay_num": -1
}
],
"login": {
"enabled": false,
"unprotected": false,
"username": "admin"
},
"tz_dst": false,
"ext_temperature": [],
"unixtime": 1604946493,
"time": "18:28",
"wifi_sta1": {
"enabled": false,
"ssid": null,
"ipv4_method": "dhcp",
"ip": null,
"gw": null,
"mask": null,
"dns": null
},
"ext_sensors": [],
"ext_switch_enable": false,
"lng": 26.514299,
"actions": {
"active": false,
"names": [
"btn_on_url",
"btn_off_url",
"longpush_url",
"shortpush_url",
"out_on_url",
"out_off_url",
"lp_on_url",
"lp_off_url",
"ext_temp_over_url",
"ext_temp_under_url",
"ext_temp_over_url",
"ext_temp_under_url",
"ext_temp_over_url",
"ext_temp_under_url",
"ext_hum_over_url",
"ext_hum_under_url"
]
},
"tzautodetect": true,
"relays": [
{
"name": null,
"appliance_type": "General",
"ison": false,
"has_timer": false,
"default_state": "switch",
"btn_type": "toggle",
"btn_reverse": 0,
"auto_on": 0,
"auto_off": 0,
"power": 0,
"schedule": false,
"schedule_rules": []
}
],
"discoverable": false,
"lat": 43.525501,
"name": null,
"hwinfo": {
"hw_revision": "prod-191217",
"batch_id": 1
},
"cloud": {
"enabled": true,
"connected": true
},
"pin_code": "",
"mqtt": {
"enable": false,
"server": "192.168.33.3:1883",
"user": "",
"id": "shelly1-E09806963933",
"reconnect_timeout_max": 60,
"reconnect_timeout_min": 2,
"clean_session": true,
"keep_alive": 60,
"max_qos": 0,
"retain": false,
"update_period": 30
}
},
"_links": {
"self": {
"href": "/v1/provider/fetch"
}
}
}

*More information about device settings response

Fetch Statistics (1PM, EM)

Request URL:

POST /provider/fetch

Headers:

Content-Type: application/json
Authorization: Bearer {access_token}

Body:

{
"serial_number" : "{Shelly Serial Number}",
"statistics": true,
"channel":0, // optional
"value": {
"date_range": "custom", // day, week, month, year, custom
"date_from": "", // only if its custom
"date_to": "" // only if its custom
}
}

Response:

{
"provider": {
"isok": true,
"data": {
"history": [
{
"datetime": "2020-11-29 12:00:00",
"consumption": 0,
"available": false
},
{.....},
{
"datetime": "2020-11-30 11:00:00",
"consumption": 0,
"available": false
}
],
"timezone": "",
"history_interval": "hour",
"total": 0,
"units": {
"consumption": "Wh"
}
}
},
"_links": {
"self": {
"href": "/v1/provider/fetch"
}
}
}

Switch Shelly On/Off

Request URL:

POST /provider/send

Headers:

Content-Type: application/json
Authorization: Bearer {access_token}

Body:

{
"serial_number": “{Shelly Serial Number}”,
"command" : "switch_on_off",
"state" : "on" //receives values “on”/“off”
}

Response:

{
"provider": {
"isok": true,
"data": {
"device_id": "e***********3"
}
},
"_links": {
"self": {
"href": "/v1/provider/send"
}
}
}

Default State

Request URL:

POST /provider/send

Headers:

Content-Type: application/json
Authorization: Bearer {access_token}

Body:

{
"serial_number": “{Shelly Serial Number}”,
"command" : "relay_settings",
"setting" : "default_state",
"value" : "last" // Default power-on state on/off/last
}

Response:

{
"provider": {
"isok": true,
"data": {
"device_id": "e*********3"
}
},
"_links": {
"self": {
"href": "/v1/provider/send"
}
}
}

Button Type

Request URL:

POST /provider/send

Headers:

Content-Type: application/json
Authorization: Bearer {access_token}

Body:

{
"serial_number": “{Shelly Serial Number}”,
"command" : "relay_settings",
"setting" : "button_type",
"value" : "momentary" // momentary, edge, toggle
}

Response:

{
"provider": {
"isok": true,
"data": {
"device_id": "e*********3"
}
},
"_links": {
"self": {
"href": "/v1/provider/send"
}
}
}

Automatic Turn On/Off

Request URL:

POST /provider/send

Headers:

Content-Type: application/json
Authorization: Bearer {access_token}

Body:

{
"serial_number": “{Shelly Serial Number}”,
"command" : "relay_settings",
"setting": "auto_turn",
"channel": 0, // optional
"value": {
"timeout":20,// in seconds , 0 = OFF
"state": "on" // on/off
}
}

Response:

{
"provider": {
"isok": true,
"data": {
"device_id": "e*********3"
}
},
"_links": {
"self": {
"href": "/v1/provider/send"
}
}
}

Consumption Correction (1PM only)

Request URL:

POST /provider/send

Headers:

Content-Type: application/json
Authorization: Bearer {access_token}

Body:

{
"serial_number": “{Shelly Serial Number}”,
"command" : "relay_settings",
"setting": "power_correction",
"value": 1.05 // (0.85 - 1.15)
}

Response:

{
"provider": {
"isok": true,
"data": {
"device_id": "e*********3"
}
},
"_links": {
"self": {
"href": "/v1/provider/send"
}
}
}

Transformer Type (EM Only)

Request URL:

POST /provider/send

Headers:

Content-Type: application/json
Authorization: Bearer {access_token}

Body:

{
"serial_number": “{Shelly Serial Number}”,
"command" : "relay_settings",
"setting": "transformer_type",
"value": 50,
"channel":1
}

Response:

{
"provider": {
"isok": true,
"data": {
"device_id": "e*********3"
}
},
"_links": {
"self": {
"href": "/v1/provider/send"
}
}
}