Switchbot Cloud - Water Leak device support

Please add water leak device support with the switchbot cloud integration. Thanks

Some of the Switchbot devices are made with Tuya components. You might want to try with the Tuya integration to talk to it.
This should be available in the Integration as you mentioned, but this might get your devices working.

I have tose on the way as well. As per the spec sheet they seem to support Bluetooth and Wifi. Please let me know if I can be of assistance developing the extension, for example providing logging data.

I also recently purchased a water leak detector, unfortunately, I was disappointed to see that the homeassistant couldn’t detect my new water leak sensors :frowning: I will be following up on the update here!

I looked through the Switchbot bluetooth integration and it seems like whenever it gets dev attention, it shouldn’t be a hard fix.

In the meantime I was able to set up automations from the sensor triggering with the Switchbot API because the water sensor doesn’t need a hub to use cloud features. It’s definitely the long way: it works over the internet, and I don’t know how reliable their cloud service is. I would be quite careful if the automation not working for some reason would cost you lots of money! Instructions below are based on the docs here which won’t be challenging if you’re familiar with REST APIs. You should just need to do this once:

  1. Create an automation with a webhook trigger, set it to be triggered from the internet and test that it works with a curl command.

  2. Obtain your Switchbot account secret key and token from the app by navigating to Preferences > About > [Tap the App Version 7-15 times] > Developer Options. You’ll use these to craft a header for authentication and signing the API call in the next step.

  3. [See below for some help doing this] Send a POST request to the Switchbot API to configure a webhook - you want to submit the webhook URL Home Assistant generated for you in the body. You should get a success message in the response.

  4. Test and set up the rest of the automation. Switchbot should POST to your webhook whenever an event happens across any of your cloud-connected devices. So, you should use templated conditions to check that the message is about a leak, and then take action with the automation.

I put together a python script to help you create the webhook, you’ll just need your token and secret.

And here’s a sample alert that triggered my webhook, you would parse this to guide your automations:

            "trigger": {
              "platform": "webhook",
              "webhook_id": "webhook-test-switchbot-XXXXXXXXXX",
              "json": {
                "eventType": "changeReport",
                "eventVersion": "new-open-api",
                "context": {
                  "battery": 100,
                  "detectionState": 0,
                  "deviceMac": "DEAD0BEEF",
                  "deviceType": "Water Detector",
                  "timeOfSample": 1729876774313
                }

EDIT: A couple of weeks later and it seems to be working reliably so far for my needs. This is the value template I use in the automation (replace the device MAC address):
{{ trigger.json.context.deviceMac == 'DEAD0BEEF' and trigger.json.context.detectionState == 1 }}

Switchbot will trigger the webhook again when the alert clears (detectionState == 0).

Can believe that people have problems with this. I have a water leak sensor. Zigbee one that runs on battery. I don’t think that is particularly smart idea to make a water leakage sensor that is connected to the main electricity. :roll_eyes:
Anyway I use mine to turn on all lights in bathroom when shower is on and brightness is below some threshold.

@pj1115 HI Can you possibly help me out with this I got as far as step 3 but I can seem to prove out in step 4 that HA is getting the POST and how I can buld the template … Thanks in advance