OpenWonderLabs / SwitchBotAPI

SwitchBot Open API Documents
810 stars 68 forks source link

Keypad createKey return 190 Cannot read properties of undefined (reading 'type') #308

Open kostya-fr opened 1 month ago

kostya-fr commented 1 month ago

Analysis

Can't create a new pass code for Keypad. Here my request :

POST https://api.switch-bot.com/v1.1/devices/KEYPAD_ID/commands
body= {
    "commandType": "command",
    "command": "createKey",
    "parameters": {
        "name": "TEST 123",
        "type": "disposable",
        "password": "12345678",
        "startTime": 1716576575,
        "endTime": 1716580175
    }
}
headers={
    "Authorization": "...",
    "sign": "...=",
    "nonce": "94926fe7e26f931842d9548f62ff6649",
    "t": "1716577580988",
    "Content-Type": "application/json",
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3"
}

Response :

{
  statusCode: 190,
  body: {},
  message: "Cannot read properties of undefined (reading 'type')"
}

Expected Behavior

I'm pretty sure few months ago I could do this. I expect this output :

{
    "statusCode": 100,
    "body": {
        "commandId": "CMD..."
    },
    "message": "success"
}

Steps To Reproduce

  1. POST https://api.switch-bot.com/v1.1/devices/KEYPAD_ID/commands

Logs

No additional logs

Configuration

Here My keypad response on GET https://api.switch-bot.com/v1.1/devices/KEYPAD_ID/status:

{
  "data": {
    "statusCode": 100,
    "body": {
      "deviceId": "KEYPAD_ID",
      "deviceType": "Keypad",
      "hubDeviceId": "HUB_ID"
    },
    "message": "success"
  }
}

Environment

Keypad firmware V1.8

Additional Context

Looks similar to #307 but I'm using V1.1. No response

corasaniti commented 3 weeks ago

@kostya-fr @SwitchBot

Same error with the API 1.0 which I have always used correctly via cur and also with the contrib nodered contrib node-red-contrib-switchbot-api version 0.1.4

Now I am not able to use it via curl or even with nodered, there is a problem retrieving the device list.

curl -X GET https://api.switch-bot.com/v1.0/devices -H "Authorization: <your-api-token>" -H "Content-Type: application/json; charset=utf8"

Answer {"statusCode":190,"body":{},"message":"Cannot read properties of undefined (reading 'device_type')"}

Thanks in advance