hsakoh / switchbot-mqtt

SwitchBot MQTT Home Assistant add-on
MIT License
40 stars 1 forks source link

S10 vacuum: Not receiving webhooks from API #27

Closed abx360 closed 1 month ago

abx360 commented 3 months ago

First of all thank you for your work, which is making almost perfect my S10 vacuum 🤗

Anyway, I'm not receiving any updates from the webhooks, only active polling is working.

This is my configuration:

This is my Compose config:

  switchbotmqtt:
    container_name: switchbotmqtt
    image: ghcr.io/hsakoh/switchbotmqtt-amd64:1.0.18
    networks:
      - domotica_network
    ports:
      - "8098:8098"
      - "8199:8099" #8099 port used
    volumes:
      - ./switchbotmqtt:/data
    restart: unless-stopped

And this the webhook configuration:

    "WebhookService": {
      "UseWebhook": true,
      "UseNgrok": false,
      "NgrokAuthToken": "NA",
      "HostUrl": "https://sbmqtt.xxmysitexx.it"
    }

Of course also the webhook is ticked in the device configuration, and the webhook service started.

If I call the webook with curl or even https://reqbin.com/, I see that the service and the configuration are fine, since I can change the shown values (eg battery%) in home assistant: curl -H "Content-Type: application/json" -X POST https://sbmqtt.xxmysitexx.it/webhook -d '{"eventType":"changeReport","eventVersion":"1","context":{"deviceMac":"123456789","deviceType":"WoSweeperOrigin","workingStatus":"ChargeDone","onlineStatus":"online","battery":100,"waterBaseBattery":100,"taskType":"standBy","timeOfSample":1715158038876}}' The values are changing and in the logs I can see: switchbotmqtt | 13:07:10 info: SwitchBotMqttApp.Controllers.WebhookController[0] {"eventType":"changeReport","eventVersion":"1","context":{"deviceMac":"123456789","deviceType":"WoSweeperOrigin","workingStatus":"ChargeDone","onlineStatus":"online","battery":100,"waterBaseBattery":100,"taskType":"standBy","timeOfSample":1715158038876}}

I also verified the SwitchBot API configuration, and it seems ok. If i send this command to check the webhook configuration: curl -H "Content-Type: application/json" -H "Authorization: XXmykeyXX" -X POST https://api.switch-bot.com/v1.0/webhook/queryWebhook -d '{"action":"queryDetails", "urls":"https://sbmqtt.xxmysitexx.it/webhook"} The API replies: {"statusCode":100,"body":[{"deviceList":"ALL","createTime":1719941450906,"url":"https://sbmqtt.xxmysitexx.it/webhook","enable":true,"lastUpdateTime":1719941450906}],"message":"success"}

Am I missing something? 🤔

hsakoh commented 3 months ago

From the provided settings and the details you’ve confirmed, it appears that nothing has been overlooked.

Do you own any other SwitchBot devices? If the webhook from other devices can be received, we can definitively declare that the configuration is not the issue.

In #17, a user with an S10 hasn't received an actual webhook even once. It’s possible that SwitchBot might not have implemented the webhook for the S10 yet.

Additionally, as discovered in #25 (written in Japanese), some devices like Color Bulb and Ceiling Light exhibit a behavior where webhooks do not trigger when operated via the SwitchBot API, but do trigger when operated through the app.

Trying multiple methods to trigger the webhook event might reveal something.

Ultimately, it might be best to raise an issue in the API repository or contact SwitchBot's support. SwitchBotAPI

Sorry I couldn't be of more help.

abx360 commented 3 months ago

Unfortunately I don't have any other Switchbot device to try... At this point I think that for the S10 the webhooks are still missing in the API. I'll try with Switchbot support and let you know then, thanks!

zalmael commented 2 months ago

Hi guys, Just to let you know that I have multiple switchbot devices, and after playing with the add-on (thanx again hsakoh), I can say that I have myself some questions about how the webhooks work on switchbot side.

My config is ok, I can send webhooks myself, no problem.

But some devices (like the S10 vacuum, or meter and water leak detector) seem to not sending anything. I don't really know how to trigger it, changing settings in the app doesn't work on those devices. I will have to manually trigger the water leak under my Kitchen sink to see if it changes :)

I also have a Hub2 and a Tilt Cam, and I can see traces of webhhooks received in the logs.

But the others, nothing. I'm sure this is on their side, but I have read some issue already closed and they don't seem to take care a lot about it (often marked as stale then closed due to no activities).

I also have the issue on the sound setting (https://github.com/hsakoh/switchbot-mqtt/issues/17#issuecomment-2118793338) and self-cleaning (https://github.com/hsakoh/switchbot-mqtt/issues/17#issuecomment-2118773017) for the S10 by the way.

I will be happy to test or open issues on their side if needed to help !

Thanks again for the great work !

hsakoh commented 2 months ago

Thank you for the feedback.

It does seem like the issue might be on SwitchBot's side rather than with the Webhook configuration.

abx360 has raised an issue here: https://github.com/OpenWonderLabs/SwitchBotAPI/issues/321 If you have any additional information, it would be helpful to add it there.

As it appears to be an issue on SwitchBot's side, there isn’t much more we can try at the moment. The best course of action is to encourage SwitchBot to make improvements through support channels and issue reports.

https://github.com/OpenWonderLabs/SwitchBotAPI/issues/303

hsakoh commented 1 month ago

I have just released version v1.0.24. Support for the undocumented webhook payload format of the Robot Vacuum Cleaner S10.

See also #40.