Shelly DW2 does not trigger

@markus7017

OH 2.5.11
I have a strange case here with my second DW2.
It works completely fine with the Shelly App. Sensor reports OPEN/CLOSE flawlessly. It is ONLINE in Openhab, channels are defined.
When triggering a configuration change in PaperUI, all the channels report back.
When opening or closing the sensor, no push activity in Openhab - no entry in the DEBUG logs.
When comparing the config parameters of the non-working DW2 with the working DW2, I can see no difference. I like to add though, that the “working” DW2 does not consistantly work. Every now and then, the channels do not report open and close. What is the optimal configuration for DW2s to work with Opanhab?

Any help or idea is appreciated.

Debug log of the faulty device:

2021-01-03 14:45:03.311 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellydw2-483fda81f2cf: Initializing device shellydw2-483fda81f2cf, type SHDW-2, Hardware: Rev: , batch ; Firmware: v1.9.3 / 20201228-092556 (ad2bb4e3)

2021-01-03 14:45:03.314 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellydw2-483fda81f2cf: Shelly settings info for shellydw2-483fda81f2cf: {"device":{"type":"SHDW-2","mac":"MAC","hostname":"shellydw2-483FDA81F2CF","sleep_mode":true},"wifi_ap":{"enabled":false,"ssid":"shellydw2-483FDA81F2CF","key":""},"wifi_sta":{"enabled":true,"ssid":"SSID","ipv4_method":"static","ip":"<IP>","gw":"<GATEWAY>","mask":"255.255.255.0","dns":"<DNS>"},"wifi_sta1":{"enabled":false,"ssid":null,"ipv4_method":"dhcp","ip":null,"gw":null,"mask":null,"dns":null},"mqtt": {"enable":false,"server":"<IP>","user":"","id":"shellydw2-483FDA81F2CF","reconnect_timeout_max":60.000000,"reconnect_timeout_min":2.000000,"clean_session":true,"keep_alive":60,"max_qos":0,"retain":false,"update_period":30},"coiot": {"update_period":15},"sntp":{"server":"time.google.com","enabled":true},"login":{"enabled":false,"unprotected":false,"username":"ID"},"pin_code":"++(vtn","name":null,"fw":"20201228-092556/v1.9.3@ad2bb4e3","discoverable":false,"build_info":{"build_id":"20201228-092556/v1.9.3@ad2bb4e3","build_timestamp":"2020-12-28T09:25:56Z","build_version":"1.0"},"cloud":{"enabled":false,"connected":false},"timezone":"Europe/Berlin","lat":0.000000,"lng":0.000000,"tzautodetect":false,"tz_utc_offset":0,"tz_dst":true,"tz_dst_auto":true,"time":"","unixtime":0,"led_status_disable":false,"actions":{"active":false,"names":["dark_url","twilight_url","open_url","close_url","vibration_url","temp_over_url","temp_under_url"]},"dark_threshold":100,"twilight_threshold":300,"sleep_mode":{"period":6,"unit":"h"},"led_status_disable":false,"tilt_enabled":false,"tilt_calibrated":false,"vibration_enabled":false,"reverse_open_close":false,"lux_wakeup_enable":false,"sensors":{"temperature_threshold":1.0,"temperature_unit":"C"},"temperature_offset":0.0}

2021-01-03 14:45:03.316 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellydw2-483fda81f2cf: Device hasRelays:false (numRelays=0),isRoller:false (numRoller=0),isDimmer:false,numMeter=0,isEMeter:false),isSensor:true,isDS:true,hasBattery:true (low battery threshold=20%),isSense:false,isLight:false,isBulb:false,isDuo:false,isRGBW2:false,inColor:false,updatePeriod:21660sec

2021-01-03 14:45:03.452 [DEBUG] [lly.internal.util.ShellyChannelCache] - shellydw2-483fda81f2cf: Channel device#uptime updated with 106 s (type class org.eclipse.smarthome.core.library.types.QuantityType).

2021-01-03 14:45:03.456 [DEBUG] [lly.internal.util.ShellyChannelCache] - shellydw2-483fda81f2cf: Channel device#wifiSignal updated with 3 (type class org.eclipse.smarthome.core.library.types.DecimalType).

2021-01-03 14:45:03.459 [DEBUG] [lly.internal.util.ShellyChannelCache] - shellydw2-483fda81f2cf: Channel device#internalTemp updated with 22 °C (type class org.eclipse.smarthome.core.library.types.QuantityType).

2021-01-03 14:45:03.462 [DEBUG] [lly.internal.util.ShellyChannelCache] - shellydw2-483fda81f2cf: Channel device#updateAvailable updated with OFF (type class org.eclipse.smarthome.core.library.types.OnOffType).

2021-01-03 14:45:03.463 [DEBUG] [lly.internal.util.ShellyChannelCache] - shellydw2-483fda81f2cf: Channel device#alarm updated with NONE (type class org.eclipse.smarthome.core.library.types.StringType).

2021-01-03 14:45:03.465 [DEBUG] [ng.shelly.internal.api.ShellyHttpApi] - shellydw2-483fda81f2cf: Set Sensor Reporting URL

2021-01-03 14:45:03.468 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellydw2-483fda81f2cf: Starting CoIoT (autoCoIoT=false/false)

2021-01-03 14:45:03.470 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellydw2-483fda81f2cf: Stopping CoAP Listener

2021-01-03 14:45:03.472 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellydw2-483fda81f2cf: CoAP Request was canceled

2021-01-03 14:45:03.474 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellydw2-483fda81f2cf: Starting CoAP Listener

2021-01-03 14:45:03.478 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellydw2-483fda81f2cf: Thing successfully initialized.

2021-01-03 14:45:03.480 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellydw2-483fda81f2cf: Update status job started, interval=300*3=900sec.

2021-01-03 14:45:03.507 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellydw2-483fda81f2cf: CoIoT Message from /<IP>:5683 (MID=58131): {"blk":[{"I":1,"D":"sensor_0"},{"I":2,"D":"device"}],"sen":[{"I":9103,"T":"EVC","D":"cfgChanged","R":"U16","L":2},{"I":3108,"T":"S","D":"dwIsOpened","R":["0/1","-1"],"L":1},{"I":3109,"T":"S","D":"tilt","U":"deg","R":["0/180","-1"],"L":1},{"I":6110,"T":"A","D":"vibration","R":["0/1","-1"],"L":1},{"I":3106,"T":"L","D":"luminosity","U":"lux","R":["U32","-1"],"L":1},{"I":3110,"T":"S","D":"luminosityLevel","R":["dark/twilight/bright","unknown"],"L":1},{"I":3101,"T":"T","D":"extTemp","U":"C","R":["-55/125","999"],"L":1},{"I":3102,"T":"T","D":"extTemp","U":"F","R":["-67/257","999"],"L":1},{"I":3115,"T":"S","D":"sensorError","R":"0/1","L":1},{"I":3111,"T":"B","D":"battery","R":["0/100","-1"],"L":2},{"I":9102,"T":"EV","D":"wakeupEvent","R":["battery/button/periodic/poweron/sensor/alarm","unknown"],"L":2}]}

2021-01-03 14:45:03.510 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellydw2-483fda81f2cf: CoIoT Version 2 detected

2021-01-03 14:45:03.513 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellydw2-483fda81f2cf: CoIoT Device Description for SHDW-2#483FDA81F2CF#2: {"blk":[{"I":1,"D":"sensor_0"},{"I":2,"D":"device"}],"sen":[{"I":9103,"T":"EVC","D":"cfgChanged","R":"U16","L":2},{"I":3108,"T":"S","D":"dwIsOpened","R":["0/1","-1"],"L":1},{"I":3109,"T":"S","D":"tilt","U":"deg","R":["0/180","-1"],"L":1},{"I":6110,"T":"A","D":"vibration","R":["0/1","-1"],"L":1},{"I":3106,"T":"L","D":"luminosity","U":"lux","R":["U32","-1"],"L":1},{"I":3110,"T":"S","D":"luminosityLevel","R":["dark/twilight/bright","unknown"],"L":1},{"I":3101,"T":"T","D":"extTemp","U":"C","R":["-55/125","999"],"L":1},{"I":3102,"T":"T","D":"extTemp","U":"F","R":["-67/257","999"],"L":1},{"I":3115,"T":"S","D":"sensorError","R":"0/1","L":1},{"I":3111,"T":"B","D":"battery","R":["0/100","-1"],"L":2},{"I":9102,"T":"EV","D":"wakeupEvent","R":["battery/button/periodic/poweron/sensor/alarm","unknown"],"L":2}]}

2021-01-03 14:45:03.518 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellydw2-483fda81f2cf:    id=1: sensor_0

2021-01-03 14:45:03.520 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellydw2-483fda81f2cf:    id=2: device

2021-01-03 14:45:03.522 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellydw2-483fda81f2cf: Adding 11 sensor definitions

2021-01-03 14:45:03.524 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellydw2-483fda81f2cf:    id 9103: cfgChanged, Type=EVC, Range=U16, Links=2

2021-01-03 14:45:03.525 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellydw2-483fda81f2cf:    id 3108: dwIsOpened, Type=S, Range=0/1;-1, Links=1

2021-01-03 14:45:03.527 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellydw2-483fda81f2cf:    id 3109: tilt, Type=S, Range=0/180;-1, Links=1

2021-01-03 14:45:03.529 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellydw2-483fda81f2cf:    id 6110: vibration, Type=A, Range=0/1;-1, Links=1

2021-01-03 14:45:03.531 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellydw2-483fda81f2cf:    id 3106: luminosity, Type=L, Range=U32;-1, Links=1

2021-01-03 14:45:03.532 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellydw2-483fda81f2cf:    id 3110: luminosityLevel, Type=S, Range=dark/twilight/bright;unknown, Links=1

2021-01-03 14:45:03.534 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellydw2-483fda81f2cf:    id 3101: extTemp, Type=T, Range=-55/125;999, Links=1

2021-01-03 14:45:03.536 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellydw2-483fda81f2cf:    id 3102: extTemp, Type=T, Range=-67/257;999, Links=1

2021-01-03 14:45:03.538 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellydw2-483fda81f2cf:    id 3115: sensorError, Type=S, Range=0/1, Links=1

2021-01-03 14:45:03.539 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellydw2-483fda81f2cf:    id 3111: battery, Type=B, Range=0/100;-1, Links=2

2021-01-03 14:45:03.541 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellydw2-483fda81f2cf:    id 9102: wakeupEvent, Type=EV, Range=battery/button/periodic/poweron/sensor/alarm;unknown, Links=2

2021-01-03 14:45:05.814 [DEBUG] [lly.internal.util.ShellyChannelCache] - shellydw2-483fda81f2cf: Channel device#heartBeat updated with 2021-01-03T14:45:05.000+0100 (type class org.eclipse.smarthome.core.library.types.DateTimeType).

2021-01-03 14:45:05.816 [DEBUG] [lly.internal.util.ShellyChannelCache] - shellydw2-483fda81f2cf: Channel device#deviceName updated with  (type class org.eclipse.smarthome.core.library.types.StringType).

2021-01-03 14:45:05.817 [DEBUG] [lly.internal.util.ShellyChannelCache] - shellydw2-483fda81f2cf: Channel device#statusLed updated with OFF (type class org.eclipse.smarthome.core.library.types.OnOffType).

2021-01-03 14:45:05.818 [DEBUG] [lly.internal.util.ShellyChannelCache] - shellydw2-483fda81f2cf: Channel device#powerLed updated with OFF (type class org.eclipse.smarthome.core.library.types.OnOffType).

2021-01-03 14:45:05.821 [DEBUG] [lly.internal.util.ShellyChannelCache] - shellydw2-483fda81f2cf: Channel device#uptime updated with 108 s (type class org.eclipse.smarthome.core.library.types.QuantityType).

2021-01-03 14:45:05.822 [DEBUG] [lly.internal.util.ShellyChannelCache] - shellydw2-483fda81f2cf: Channel device#wifiSignal updated with 4 (type class org.eclipse.smarthome.core.library.types.DecimalType).

2021-01-03 14:45:05.895 [DEBUG] [lly.internal.util.ShellyChannelCache] - shellydw2-483fda81f2cf: Channel device#wakeupReason updated with button (type class org.eclipse.smarthome.core.library.types.StringType).

2021-01-03 14:45:05.896 [INFO ] [y.internal.handler.ShellyBaseHandler] - shellydw2-483fda81f2cf: Event triggered: BUTTON

2021-01-03 14:45:05.898 [DEBUG] [lly.internal.util.ShellyChannelCache] - shellydw2-483fda81f2cf: Channel device#alarm updated with BUTTON (type class org.eclipse.smarthome.core.library.types.StringType).

2021-01-03 14:45:05.900 [DEBUG] [lly.internal.util.ShellyChannelCache] - shellydw2-483fda81f2cf: Channel sensors#state updated with CLOSED (type class org.eclipse.smarthome.core.library.types.OpenClosedType).

2021-01-03 14:45:05.902 [DEBUG] [lly.internal.util.ShellyChannelCache] - shellydw2-483fda81f2cf: Channel sensors#lastError updated with  (type class org.eclipse.smarthome.core.library.types.StringType).

2021-01-03 14:45:05.905 [INFO ] [y.internal.handler.ShellyBaseHandler] - shellydw2-483fda81f2cf: Event triggered: 

2021-01-03 14:45:05.907 [DEBUG] [lly.internal.util.ShellyChannelCache] - shellydw2-483fda81f2cf: Channel device#alarm updated with  (type class org.eclipse.smarthome.core.library.types.StringType).

2021-01-03 14:45:05.910 [DEBUG] [lly.internal.util.ShellyChannelCache] - shellydw2-483fda81f2cf: Channel sensors#temperature updated with 22.4 °C (type class org.eclipse.smarthome.core.library.types.QuantityType).

2021-01-03 14:45:05.912 [DEBUG] [lly.internal.util.ShellyChannelCache] - shellydw2-483fda81f2cf: Channel sensors#lux updated with 763 lx (type class org.eclipse.smarthome.core.library.types.QuantityType).

2021-01-03 14:45:05.914 [DEBUG] [lly.internal.util.ShellyChannelCache] - shellydw2-483fda81f2cf: Channel sensors#illumination updated with bright (type class org.eclipse.smarthome.core.library.types.StringType).

2021-01-03 14:45:05.916 [DEBUG] [lly.internal.util.ShellyChannelCache] - shellydw2-483fda81f2cf: Channel sensors#tilt updated with -1 ° (type class org.eclipse.smarthome.core.library.types.QuantityType).

2021-01-03 14:45:05.918 [DEBUG] [lly.internal.util.ShellyChannelCache] - shellydw2-483fda81f2cf: Channel sensors#vibration updated with OFF (type class org.eclipse.smarthome.core.library.types.OnOffType).

2021-01-03 14:45:05.920 [DEBUG] [lly.internal.util.ShellyChannelCache] - shellydw2-483fda81f2cf: Channel battery#batteryLevel updated with 98.0 % (type class org.eclipse.smarthome.core.library.types.QuantityType).

2021-01-03 14:45:05.922 [DEBUG] [lly.internal.util.ShellyChannelCache] - shellydw2-483fda81f2cf: Channel battery#lowBattery updated with OFF (type class org.eclipse.smarthome.core.library.types.OnOffType).

2021-01-03 14:45:05.923 [DEBUG] [lly.internal.util.ShellyChannelCache] - shellydw2-483fda81f2cf: Channel sensors#motion updated with OFF (type class org.eclipse.smarthome.core.library.types.OnOffType).

2021-01-03 14:45:05.925 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellydw2-483fda81f2cf: Unable to refresh status: Unable to update status

check out the latest DEV build

Latest DEV build: 2.5.12 - 3.1.0 - README - Installation - Bugs/Features - Firmware Index - Firmware Archive - API Doc
Note: The binding version included in the final OH 3.0 distro is significantly older than the DEV build. I can’t make it in-time. Make sure you deleted older versions of the binding when installing the 2.5.12-SNAPSHOT or 3.1.0-SNAPSHOT if you are already on OH 3.

Hello Markus,
I deleted the DW2 thing from PaperUI
Then uninstalled Shelly Binding 2.11.
Then installed the DEV binding via JAR file
Then rediscovered the DW2, checked the channel (defined via files)
But still, there is no push message from the device to Openhab.
The Shelly App shows open and close of the DW2 correctly.

When I CLOSE the contact, I get the following message in the log:

2021-01-05 12:38:20.485 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellydw2-d8bfc01a854e: Event received: class=report, index=, parameters={type=close}

2021-01-05 12:38:20.487 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellydw2-d8bfc01a854e: Device is not yet initialized, event triggers initialization

When I OPEN the contact, there is no log entry at all.
The channels never fire.

Is the device discovery not completed? What do I need to do?

Have you disabled CoIoT events?
the log you are showing indicates an http action event, I would prefer CoIoT, see README

ColoT is activated and sensor events are disabled for the thing.
Auto-ColoT is deactivated for the binding.
In the first post, you see the debug log for the discovery of the DW2.

@markus7017
I enabled AutoColoT and rediscovered the DW2. The device is still not functioning correctly. I get a lot of API Timeouts. In some rare cases, I get a few channels updated, but not all of them. In most cases, I do not get the STATE channel updated. Sometimes when I close the Contact, the device log shows a rediscovery. This is absolutely weird to me.
I am on the latest firmware release for the DW2 and on the snapshot 12 for the shelly binding.
And as I mentioned earlier, the Shelly App functions absolutely flawlessly all the time.
As a sidenote, all other Shelly devices (Shelly 1 and Shelly 2.5) work flawlessly with Openhab.
Any help is appriciated.
Looks like @Sulu is having similar problems:

how should I analyse your problem if you are not providing detailed log information?
DEBUG log for full initialization and around events.
Did you checked with tcpdump/Wireshark that your OH system is receiving the CoAP packets?

Hello Markus,
appologize … I sent you a private message with the DEBUG log.

thanks

Hello Markus,
Did you get my private message? Is the data I provided sufficient or can I get more info for you?
Thanks for helping me out.

@markus7017
I did some further test with the DW2.
I can confirm that the CLOSE gets pushed back to openhab from the device. The channel gets updated.
An OPEN does not get pushed back to openhab from the sensor at all. (Shelly App works fine here.)
When I change the config of the device though (just minor change, i.e. changing the name) and subsequent rediscovery of the device, an OPEN sensor gets reported back at that time.

@markus7017

some further testing today.
It looks like ColoT communication is much more sensitive to magnet strength / positioning than the Shelly internal communication. When I used magnets with lower strength, the OPEN/CLOSE came still through to the Shelly app, but did not make it to Openhab. Does Shelly use a different communication protocoll internally?
After optimal positioning of the Shelly magnet, I ran a number of OPEN/CLOSE tests. The CLOSE did always make it to openhab, the OPEN did sometimes not make it to openhab. (see attached log, which was filtered for “dw2” and commented by myself).

Question: Can the sensor be made more reliable from the openhab side, or does Allterco need to improve the sensitivity level for the ColoT communication.

Or am I on a wrong track here?

Any idea / suggestion from the experts?
openhab_Shelly DW2 (filter)_210116.log (17.1 KB)

I gave up.
Two days ago, I switched my Shelly DW2 to the MQTT binding. No issue so far. OPEN and CLOSE get detected correctly all the time.

Hey, is it still working with the MQTT binding?

Yes, still working fine with the MQTT binding. Not one single false detection or miss.

1 Like

Can you show me your settings? I tried it by myself but can’t get it to work. :confused:

First, I installed the MQTT Binding & created an MQTT Broker Thing.

Then, I created a Generic MQTT Thing with the Bridge and added the Open/Close Contact Channel with the state topic like this: “shellies/shellydw-[deviceid]/sensor/state”. I inserted the deviceID which is shown in the Shelly-App.

As last step, i added the Channel into the .items file & .sitemap file.

Did you do something different from these steps?
Greetz Sulu

Did you install the Mosquitto Broker First?

Yes i did. In my openhabian config.

Could you make a photo of your MQTT Bridge?

You mean the Mqtt Broker Thing?
I did not make any changes to the defaults.
Did you check that Mosquitto is indeed up and running?
Initially, my configuration did not work because Mosquitto was not running.

Additional potential problem:
The shellies provide open and close in small letters. You need to add custom On/Open and Off/Close into the channel definitions.
For OPEN you need to add : open
For CLOSE you need to add: close

Ok, my Mosquitto is running. I edited to open & close.

I also did log:set DEBUG org.openhab.mqtt for more information but I can’t see some errors. Did you use the deviceid which is shown in the Shelly-App? At the MQTT State Topic, did you take shellydw or shellydw2?

As Broker Hostname/IP I used “openhabiandevice”.

I used the device ID from the shelly app.
For the State topic, I used shellydw2.

When you installed Mosquitto, you entered a userid and password for the broker.
Did you enter those credentials into the Broker thing?

This YouTube tutorial in German may help: