itead / Sonoff_Devices_DIY_Tools

BSD 3-Clause "New" or "Revised" License
558 stars 166 forks source link

Cannot change switch to on/off - on Sonoff minir3 from DIY mode. How to change the switch? #123

Open IurieGaitur opened 2 years ago

IurieGaitur commented 2 years ago

Bought recently a Sonoff minir3. Did the configuration, found out that in order to get info, the deviceid should not be sent as it would return status 422. So without it - on the info call /zeroconf/info with

{ 
    "data": {
    } 
 }

device returns multiple switches which is strange, should be only one :?. Response:

{
    "seq": 15,
    "error": 0,
    "data": {
        "switches": [
            {
                "switch": "off",
                "outlet": 0
            },
            {
                "switch": "off",
                "outlet": 1
            },
            {
                "switch": "off",
                "outlet": 2
            },
            {
                "switch": "off",
                "outlet": 3
            }
        ],
        "configure": [
            {
                "startup": "off",
                "outlet": 0
            },
            {
                "startup": "off",
                "outlet": 1
            },
            {
                "startup": "off",
                "outlet": 2
            },
            {
                "startup": "off",
                "outlet": 3
            }
        ],
        "pulses": [
            {
                "pulse": "off",
                "switch": "on",
                "outlet": 0,
                "width": 0
            },
            {
                "pulse": "off",
                "switch": "on",
                "outlet": 1,
                "width": 0
            },
            {
                "pulse": "off",
                "switch": "on",
                "outlet": 2,
                "width": 0
            },
            {
                "pulse": "off",
                "switch": "on",
                "outlet": 3,
                "width": 0
            }
        ],
        "sledOnline": "on",
        "fwVersion": "1.2.0",
        "rssi": -62,
        "bssid": "ac:22:5:56:63:bd"
    }
}

When I want to to on, using zeroconf/switch .

{ 
    "data": {
        "switch": "on"
    } 
 }

It returns

{
    "seq": 16,
    "error": 400
}

Any ideas how I can switch on/off the switch? at least the first one

oeildefeu commented 2 years ago

Hello, The answer is here: https://sonoff.tech/sonoff-diy-developer-documentation-minir3-http-api/

So you have to use such curl line for instance: curl -v -d '{"deviceid":"XXXXXXXX","data":{"switches": [{ "switch": "on", "outlet": 0 },{"switch": "off", "outlet": 1 },{ "switch": "off", "outlet": 2 },{ "switch": "off", "outlet": 3 }]}}' POST http://192.168.0.XX:8081/zeroconf/switches