
The Shelly Door/Window 2 (SHDW-2) is a battery-powered (2x CR123A) Wi-Fi contact sensor. TapHome communicates with the device over MQTT — the recommended protocol for battery-operated Shelly devices, since the sensor sleeps most of the time and publishes data only on wake-up events (magnet state change, vibration, brightness change, or periodic timer).
The template supports up to 5 Shelly Door/Window sensors per module. Each sensor instance is distinguished by a sensorN_topic custom variable pointing to the device’s MQTT Client ID.
Configuration
Device ID
Each Shelly Door/Window 2 sensor has a unique MQTT Device ID in the format shellydw2-<MAC6>, where <MAC6> is the last 6 characters of the MAC address in lowercase hex (e.g., shellydw2-A1B2C3).
The Device ID can be found:
- On the device label (MAC address)
- In the Shelly web UI: Settings → Device Info
- Via API:
GET http://<device-ip>/settings→device.hostnamefield
This device supports mDNS discovery. You can use the hostname
shellydw2-{MAC}.localinstead of an IP address when configuring TapHome. Replace{MAC}with the last 6 characters of the device’s MAC address in lowercase hex (e.g.,shellydw2-A1B2C3.local). Using a hostname prevents connectivity issues when the device’s IP address changes.
Template setup
After importing the template in TapHome:
- Open the Shelly Door/Window MQTT module
- Set the MQTT Broker IP and Port (default
1883) - For each sensor instance, set the
sensorN_topiccustom variable to the Device ID of the corresponding Shelly Door/Window 2 (e.g.,shellydw2-A1B2C3)
The module subscribes to shellies/# and the listener scripts filter messages by the configured topic prefix.
Only configure the sensor slots you actually use. Unconfigured slots (with the default
shellydw2-deviceidvalue) will show an error message prompting you to set the correct topic.
Device capabilities
Open/close detection
Each sensor instance is mapped as a Reed Contact device in TapHome. The door/window state is read from the shellies/<id>/sensor/state topic:
open→ Alarm (door/window open)close→ OK (door/window closed)
The sensor wakes up and publishes its state when the magnet moves (door or window opens or closes), and also during periodic reporting intervals (default every 3 minutes).
Battery, temperature and luminance monitoring
Each sensor instance exposes three service attributes:
- Battery — battery level percentage read from
shellies/<id>/sensor/battery. A low battery warning is triggered when the level drops below 20%. - Temperature — ambient temperature in °C read from
shellies/<id>/sensor/temperature. - Luminance — ambient light level in lux read from
shellies/<id>/sensor/lux.
All attributes are read-only and update whenever the sensor wakes up and publishes data.
Additional capabilities (not implemented)
The Shelly Door/Window 2 also publishes tilt angle (0–180 degrees) and vibration detection via MQTT, as well as an online/offline status via the LWT topic. These capabilities are available in the device’s MQTT output but are not mapped in the current TapHome template. They can be added in a future template update.
Troubleshooting
Sensor not reporting data
- Verify the Shelly Door/Window 2 is connected to Wi-Fi and MQTT is enabled in the device settings
- Check that the
sensorN_topiccustom variable matches the Device ID exactly (e.g.,shellydw2-A1B2C3) - If the MQTT broker address changed, try using the mDNS hostname (
shellydw2-A1B2C3.local) to verify the sensor is reachable on the network - Use an MQTT client (e.g., MQTT Explorer) to subscribe to
shellies/#and verify the sensor publishes messages on wake-up
Open/close state not updating
- Make sure the magnet is properly aligned with the main unit — when the door/window is closed, the magnet should be within 15 mm of the sensor
- If the sensor was recently moved, use the calibration endpoint (
GET http://<device-ip>/calibrate?opened=1) with the door/window in the open position to recalibrate - Check TapHome for the Reed Contact device state — 1 = open (alarm), 0 = closed (OK)
Battery draining quickly
- Shelly Door/Window 2 uses 2x CR123A batteries (not rechargeable) with typical battery life of approximately 18 months
- Frequent wake-ups (e.g., due to unstable Wi-Fi requiring repeated reconnection or a very short sleep period) can drain the battery faster
- The default sleep period is 3 minutes — increasing it via
sleep_mode.periodin the device settings reduces power consumption - Ensure strong Wi-Fi signal at the sensor location
Gen1 Shelly devices do not support MQTT over TLS. Communication between the sensor and the MQTT broker is unencrypted (plain MQTT, port 1883). Ensure the MQTT broker is on a trusted local network.