Keypad createKey return 190 Cannot read properties of undefined (reading 'type')
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
- 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
@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
Having same issue with Switchbot Bot, api v1.1, GET queries for devices run ok as well as /status/ get queries, but sending commands with POST return
{"statusCode":190,"body":{},"message":"Cannot read properties of undefined (reading '0')"}
request is
base_url = 'https://api.switch-bot.com'
endpoint = f'/v1.1/devices/{button_1}/commands/'
data = {
'command': 'press',
'parameter': 'default',
"commandType": "command",
'deviceType': 'Bot'
}
r = requests.request("POST",base_url + endpoint, headers=apiHeader, json=data)
headers
{'Authorization': '...', 'Content-Type': 'application/json', 'charset': 'utf8', 't': '1723237137278', 'sign': '...', 'nonce': '...'}
if its not a bug, what could possibly be the problem?