Shelly Door Window 2 - State changes

  • Hi all,

    Just bought a couple of Shelly Door Window 2 sensors. I configured both of them via Shelly integration (official). They work good with Open and Close events (they change their state from off to on and viceversa).

    The strange thing comes when the device performs some “automatic” action like waking up for “temperature” monitoring, “periodical” or something called “sensor” under the Event Log page of the Shelly app:


    [Blockierte Grafik: https://community-assets.home-assistant.io/optimized/3X/1/c/1cbbe375b62fe4a3a8d37863be452af807e35777_2_690x270.png]

    As you can see in the Shelly Event Log, there are different “events” regarding “SENSOR GARAJE” related with “temperature” and “sensor” in the INFO field. These events are not related with the Open or Close actions of the door but they arrive to my Home Assistant as state changes (from “off” to “on” and viceversa) that only have 1 second or 2 seconds of duration (as far as I checked it). This is the binary sensor which manages the state:


    [Blockierte Grafik: https://community-assets.home-assistant.io/optimized/3X/8/a/8aada483a0d4b572d2e0418ee0e04ec9ccaabe08_2_690x236.png]

    So, I tried to align magnet with sensor, check batteries and so on. I think it is realated with the Shelly HA integration.

    Do you have some experience handling this device?, I do not know how t avoid this kind of behaviour.

    Thanks a lot!

    P.S: I have configured CoIoT in the shelly battery devices as recommended in addition to static ip. Not related but I wanted to specify it.

  • I'm trying to troubleshoot the same problem. I haven't found and confirmed the solution (or even the culprit for that matter) yet, but my findings may help someone else.

    I'm using the native Shelly integration in Home Assistant (not MQTT).

    Using the mechanism Home Assistant uses for listening for status updates from Shelly devices, I found out that when there are these open+close state changes in HA, the Shelly DW2 sensor sends a strange update (or multiple) to the COAP server with dwIsOpened parameter set to -1 followed up by another message with a correct value (0/1).

    This seems to be always immediately before a normal wakeup event (like "sensor", "temperature", or "button").

    Example one - this happened automatically, looks like due to temperature sensor state change.

    pasted-from-clipboard.png

    Example two - this happened when I pressed the button on the device.

    pasted-from-clipboard.png


    I don't know if this behavior is normal for DW2 and should be handled by the automation system (here Home Assistant) or not, but I know there was a recent large-scope code change in the Shelly integration in Home Assistant - https://github.com/home-assistant/core/pull/52544.

    I don't have any proof yet (the Pull Request is really large), but the description suggests it was a change in the integration's internal data types, which in case a boolean type (true/false) was used for the state of the DW2 sensor, a value of -1 could be cast to true an cause exactly what we're seeing. I'll be taking a closer look at this change.


    The tool I used to troubleshoot it comes from aioshelly Python package (https://github.com/home-assistant-libs/aioshelly) used by HA to communicate with Shelly devices.

    I ran it on the Home Assistant server itself, inside the "homeassistant" Docker container using the following command: python3 example.py -ip 192.168.1.211 .

    Please note that in order to run the above I needed to unlock HA debugging and download example.py script from GitHub manually.

  • I'm seeing the same behaviour with DW2 added using ShellyForHass (the custom integration from HACS) and communicating through CoAP. In my case the sensors also report temperatures of 999°C followed by the detected temperature and -1° tilt followed by the correct tilt. I've opened a support case with Shelly and here's their reply after reviewing the debug logs:

    The problem which you are observing with enormous values and after that, they are getting normal that was reported before and right now our devs are working on a solution.

    That is happening on mqtt topic messages.

    We will check what is happening and reach you back with additional information.

    In the meantime, please try using some of the devices without HA and only with Shelly Cloud APP to check if the problem is coming from HA integration.

    Looks like the issue comes from the way DW2 reports values after wake-up, which HA is not able to handle, while the Shelly Cloud APP is able to.

    There is a test firmware which is supposed to fix these issues: 20210820-121213/v1.11.4-rc2-gcc41d4b

    If you want try it: http://<DEVICE_IP>/ota?url=http://repo.shelly.cloud/firmware/rc/SHDW-2.zip

    I've updated my devices with this version and will revert with a status update.

    Einmal editiert, zuletzt von mihsu81 (22. August 2021 um 11:21)

  • Thanks for the info about the upcoming firmware fix! It worked for me as well.

    Meanwhile, I did more Home Assistant testing and confirmed that this problem was not introduced in the Pull Request I mentioned in my previous post. Looks like HA has never supported these incorrect values, but for some reason it wasn't a problem until recently (at least for me).

    Regardless of the firmware fix, -1 still remains an acceptable value for dwIsOpened as listed the API specification, so I prepared and submitted a patch for Home Assistant Shelly integration - https://github.com/home-assistant/core/pull/55042. I hope it gets accepted and included in one of upcoming HA updates.