Open abx360 opened 3 months ago
Based on feedback from a Home Assistant add-on user, it was found that the webhook is now being sent, but it differs from the specification. (Inside and outside of context, and only partial state values.)
expect:
{
"eventType": "changeReport",
"eventVersion": "1",
"context": {
"deviceType": "Robot Vacuum Cleaner S10",
"deviceMac": DEVICE_MAC_ADDR,
"workingStatus":"StandBy",
"onlineStatus": "online",
"battery": 100,// 0-100
"waterBaseBattery": 100,
"taskType": "explore",
"timeOfSample": 123456789
}
}
actual:
{
"eventType": "changeReport",
"eventVersion": "1",
"context": {
"deviceType": "Robot Vacuum Cleaner S10",
"deviceMac": "XXXXXXX",
"timeOfSample": 1725002665366
},
"onlineStatus": "online",
"taskType": "cleanAll"
}
@SwitchBot @SwitchBot-Wonderlabs @Minsheng Could you please either update the documentation or ensure that the webhook is sent as described in the documentation?
Analysis
Active polling is correctly working for the S10 Vacuum, but the API is not sending updates through webhooks.
Expected Behavior
If a webhook is configured in my own API account, I should receive active updates when something is changing in the device status.
Steps To Reproduce
Test that the webhook is correctly configured, asking the API the webhook details with the
queryDetails
command:curl -H "Content-Type: application/json" -H "Authorization":"XXmykeyXX" -X POST https://api.switch-bot.com/v1.1/webhook/queryWebhook -d '{"action":"queryDetails", "urls":"https://sbmqtt. xxmysitexx.it/webhook"}'
The following reply confirms the good setup:{"statusCode":100,"body":[{"deviceList":"ALL","createTime":1720015356692,"url":"https://sbmqtt.xxmysitexx.it/webhook","enable":true,"lastUpdateTime":1720015356692}],"message":"success"}
Test the device configuration, querying the device list with the
GET /v1.1/devices
command:curl -H "Content-Type: application/json" -H "Authorization: XXmykeyXX" -X GET https://api.switch-bot.com/v1.1/devices
The following reply confirms the good setup:{"statusCode":100,"body":{"deviceList":[{"deviceId":"XXsnXX","deviceName":"Signor Robot IV","deviceType":"Robot Vacuum Cleaner S10","enableCloudService":true,"hubDeviceId":""}],"infraredRemoteList":[]},"message":"success"}
Verify that my webserver, reverse proxy and firewall are correctly configured emulating a webhook from the SwitchBot API:
curl -H "Content-Type: application/json" -X POST https://sbmqtt.XXmysiteXX.it/webhook -d '{"eventType":"changeReport","eventVersion":"1","context":{"deviceMac":"XXsnXX","deviceType":"WoSweeperOrigin","workingStatus":"ChargeDone","onlineStatus":"online","battery":79,"waterBaseBattery":100,"taskType":"standBy","timeOfSample":1715158038876}}'
Check the server logs for incoming webhooks. The following log shows the dummy webhook is correctly received:switchbotmqtt | 16:03:50 info: SwitchBotMqttApp.Controllers.WebhookController[0] {"eventType":"changeReport","eventVersion":"1","context":{"deviceMac":"XXsnXX","deviceType":"WoSweeperOrigin","workingStatus":"ChargeDone","onlineStatus":"online","battery":79,"waterBaseBattery":100,"taskType":"standBy","timeOfSample":1715158038876}}
Logs
Configuration
Environment
Additional Context
I don't have any other Switchbot device to try.