fbpx

Get started quickly!Now you can control SPM units via HTTP API.

by | Nov 22, 2021 | Product Insight

DIY mode is a function specially designed for IoT home automation users and developers that allows them to control SONOFF devices via existing home automation open-source platform or local HTTP client instead of eWeLink App. BASICR3, RFR3, MINIR2 and D1 support the DIY mode which is well received by users. Now SPM units also support DIY mode and have more functions. Let’s enter the DIY mode!

Entering the DIY Mode

Power on SPM-Main and long press the button on it for 5s until the SIGNAL indicator flashes, which means SPM-Main entered the pairing mode.

Then connect SPM-Main to the router using an Ethernet cable, and choose one of the following methods to connect the router to the computer.

Type the ip address in the browser on your computer and access. Then access the “DIY WEB” webpage and click “WIFI SETTING”.

Next, enter the WiFi SSID and password that the device needs to be connected with, then wait for the device to connect to the WiFi network (WiFi configuration).

When WiFi configuration is completed, the SIGNAL light will remain double blinking continuously. Done. SPM-Main is in the DIY Mode!

After entering the DIY mode, you can send requests to enable SPM-Main to execute different functions, such as sub-device list obtaining and overload protection setting. You can view more details in SPM-Main HTTP API via this link: http://developers.sonoff.tech/spm-main-http-api.html

Now, let’s try to get the list of sub-device now.

1. Obtain the list of SPM-4RELAY

Before obtaining, check whether the COMM light of SPM-4RELAY is blinking. If the COMM light is off, you need to whether the RS485 communication cable is connected to the SPM-Main and SPM-4RELAY. If connected correctly, press the button on SPM-Main once and you will see the COMM light on SPM-4RELAY flashes continuously.

Open the Postman application and create a new HTTP Request, and select POST–Body–raw.

Next, type http://[ip]:[port]/zeroconf/subDevList in the browser.

[ip] is the ip address of SPM-Main. [port] is fixed to 8081.

For example, http://192.168.1.103:8081/zeroconf/subDevList

Enter the request in the Body:

1
2
3
4
{ 
    "deviceid": "100000140e", 
    "data": {} 
 }

Attribute

Type

Optional

Description

deviceid

String

Yes

The device ID for this request.

data

Object

No

Object type, Specific device information setting when controlling the device. Empty object when check the device information.

Send the request then you will obtain the information about sub-device in the “response”.

2. Turn on all switches

Good job. Now we get the sub-device id that SPM-4RELAY can be controlled.

Enter the following “URL and Body” info to turn on the on/off of each channel on SPM-4RELAY.

URL: http://[ip]:[port]/zeroconf/switches

Body:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{
  "deviceid": "100000140e",
  "data": {
    "subDevId": "123456",
    "switches": [
      {
        "switch": "on",
        "outlet": 0
      },
      {
        "switch": "on",
        "outlet": 1
      },
      {
        "switch": "on",
        "outlet": 2
      },
      {
        "switch": "on",
        "outlet": 3
      }
    ]
  }
}

Attribute

Type

Optional

Description

switch

String

No

on: turn the switch on, off: turn the switch off

outlet

Number

No

Channel Number, [0,3]

Send the request, then the channel on SPM-4RELAY will be turned on. Seems very simple, right?

Well. It seems that you can now access and use more functions of SPM units by yourself. Start more features setup and experience on SPM units according to the guide in SPM-Main HTTP API.

BASICR2

SONOFF BASICR2 is a cost effective WiFi wireless smart switch that lets you automate or remotely control lighting and appliances.

Read More

ZBMINI

SONOFF ZBMINI is a ZigBee-enabled two-way smart switch that is compatible SONOFF ZBBridge & other ZigBee 3.0 hub

Read More

DW2-RF

SONOFF DW2-RF windows door alarm sensor can work with SONOFF RF Bridge 433 that can detect the opening status and sends alarm notification

Read More

B02/B05-B

Smart LED bulbs are even smarter ones in home automation. You can remote control ON & OFF, dim the light and adjust the color as it can.

Read More

SNZB-02

SONOFF SNZB-02 ZigBee 3.0 Mini Indoor Temperature and Humidity Sensor for Checking the Room Climate.

Read More

SNZB-03

SONOFF SNZB-03 ZigBee Motion Sensor, Wireless Motion Detector Get Alerts or Trigger Lights to Turn on

Read More
Loading

Related Posts

Get started quickly!Now you can control SPM units via HTTP API.
Get started quickly!Now you can control SPM units via HTTP API.
The complete guide to set up Philips Hue Bulbs on SONOFF NSPanel: get the perfect Hue lighting on a panel
The complete guide to set up Philips Hue Bulbs on SONOFF NSPanel: get the perfect Hue lighting on a panel
How to Control Your Home on SONOFF NSPanel Smart Scene Wall Switch?
How to Control Your Home on SONOFF NSPanel Smart Scene Wall Switch?
Alexa Routine: How to use SONOFF WiFi door sensor to trigger Philips Hue bulbs?
Alexa Routine: How to use SONOFF WiFi door sensor to trigger Philips Hue bulbs?
How to add Zigbee devices to Home Assistant via SONOFF Zigbee 3.0 USB Dongle Plus? How to flash firmware to Cc2652P?
How to add Zigbee devices to Home Assistant via SONOFF Zigbee 3.0 USB Dongle Plus? How to flash firmware to Cc2652P?

Subscribe To Our Newsletter

Join our mailing list to receive the latest news and updates from our team.

You have Successfully Subscribed!

Pin It on Pinterest

Share This