Integrating the Shelly flood sensor with Home Assistant is easy, but unfortunately only the temperature and battery sensors work as expected. The flood sensor itself does not work out of the box; it sticks to the state “Dry”. This can be overcome by using the MQTT protocol.
For adding the flood sensor to Home Assistant the following is required:
- Shelly Flood sensor & IP address of this sensor
- MQTT broker working within Home Assistant & it’s username and password
- An MQTT explorer, for example for windows.
3. Integrating the Shelly Flood sensor with Home Assistant
Perform the following steps to integrate the sensor with Home Assistant:
- Within Home Assistant select Settings from the sidebar
- Select Devices & services
- At bottom left click the button Add integration
- In the search box enter shelly to search for the Shelly integration
- Open your flood sensor and press once on the reset button to get the sensor out of sleep state.
- Enter the IP address of the flood sensor (can for example be found in your router) and click SUBMIT.
- The flood sensor configuration has now been created. Enter the area of the flood sensor and click on Finish.
- The Home Assistant integrations overview will show in the Shelly integratie the newly added flood sensor. Clicking on it will show the device details.
- One device with 3 entities will be shown. Click on the device link.
- The flood, temperature and battery sensor will be shown.
4. Configuring MQTT for the flood sensor
The last step for integrating the flood sensor with Home Assistant is implementing a connection via MQTT protocol to get the flood sensor working. This is divided into 2 steps:
- Enable the MQTT protocol in the flood sensor
- Create a Home Assistant Automation for the flood sensor
4.1 Enable the MQTT protocol in the Shelly Flood sensor
Execute the following steps:
- Awake the flood sensor by pressing the reset button once.
- Open it’s interface by entering the IP address in the browser address bar
- Go to Internet & Security > Advanced – Developer Settings > Enable MQTT
- Additional fields will be shown. Enter the username/password of the MQTT broker, the Home Assistant server IP address and if you want a custom MQTT prefix. Assure the flood sensor is still awake and click on the Save button.
- At the top of the browser screen the button Reboot now will be displayed. Click it.
4.2 Create a Home Assistant Automation for the flood sensor
A Home Assistant automation will be created to monitor the Shelly Flood MQTT topic for changes and will inform us if there is any. Execute the following steps:
- Open the automations.yaml file via the Home Assistant File Editor add-in
- Paste the following YAML code:
YAML123456789101112alias: MQTT flood detectiondescription: ''trigger:- platform: mqtttopic: shellies/shellyflood-B035E2/sensor/floodpayload: 'true'condition: action:- service: persistent_notification.createdata:message: flood is detected thanks to MQTT and the subscribe buttonmode: single
- Use the MQTT explorer to find the correct topic. I used the MQTT Explorer for Windows. After making connection to my Home Assistant I awakened the flood Sensor by pressing it’s reset button once. The explorer will show the flood sensor info. Select the flood sensor. The correct topic will be shown. Update the automation.yaml code w.r.t. the topic.
- Test it works by setting the flood sensor in water. Within Home Assistant a notification should be available.