Shelly Door/Window Sensor 2

@markus7017
I installed the DEV Binding earlier today. Then re-included the DW2 device. It got included as DW2 this time. Also got a one-time update of the contact and battery states (at least I think so). When opening and closing the contact, this change in state did not get reflected in openhab.
I then started a DEBUG log and restarted the binding again. Please find attached the log entries. Even after this binding restart, and still in debug mode, no information was received by openhab (no log entry at all) when opening and closing the contact sensor.
It would be great if you could have a look and provide some help.
thanks,
FrankShelly DW2 log_200912.txt (47.8 KB)

ok, we have

2020-09-12 16:27:45.851 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellydw2-xxxxxxxxx: CoIoT Message from /192.168.x.xx:5683 (MID=30290): {"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}]}
2020-09-12 16:27:45.853 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellydw2-xxxxxxxxx: CoIoT Version 2 detected
2020-09-12 16:27:45.855 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellydw2-xxxxxxxxx: CoIoT Device Description for SHDW-2#xxxxxxxxx#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}]}
2020-09-12 16:27:45.856 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellydw2-xxxxxxxxx:    id=1: sensor_0
2020-09-12 16:27:45.857 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellydw2-xxxxxxxxx:    id=2: device
2020-09-12 16:27:45.859 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellydw2-xxxxxxxxx: Adding 11 sensor definitions
2020-09-12 16:27:45.860 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellydw2-xxxxxxxxx:    id 9103: cfgChanged, Type=EVC, Range=U16, Links=2
2020-09-12 16:27:45.861 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellydw2-xxxxxxxxx:    id 3108: dwIsOpened, Type=S, Range=0/1;-1, Links=1
2020-09-12 16:27:45.862 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellydw2-xxxxxxxxx:    id 3109: tilt, Type=S, Range=0/180;-1, Links=1
2020-09-12 16:27:45.863 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellydw2-xxxxxxxxx:    id 6110: vibration, Type=A, Range=0/1;-1, Links=1
2020-09-12 16:27:45.864 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellydw2-xxxxxxxxx:    id 3106: luminosity, Type=L, Range=U32;-1, Links=1
2020-09-12 16:27:45.865 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellydw2-xxxxxxxxx:    id 3110: luminosityLevel, Type=S, Range=dark/twilight/bright;unknown, Links=1
2020-09-12 16:27:45.866 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellydw2-xxxxxxxxx:    id 3101: extTemp, Type=T, Range=-55/125;999, Links=1
2020-09-12 16:27:45.867 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellydw2-xxxxxxxxx:    id 3102: extTemp, Type=T, Range=-67/257;999, Links=1
2020-09-12 16:27:45.868 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellydw2-xxxxxxxxx:    id 3115: sensorError, Type=S, Range=0/1, Links=1
2020-09-12 16:27:45.869 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellydw2-xxxxxxxxx:    id 3111: battery, Type=B, Range=0/100;-1, Links=2
2020-09-12 16:27:45.870 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellydw2-xxxxxxxxx:    id 9102: wakeupEvent, Type=EV, Range=battery/button/periodic/poweron/sensor/alarm;unknown, Links=2
2020-09-12 16:27:48.024 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellydw2-xxxxxxxxx: Updating sensor
2020-09-12 16:27:48.105 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellydw2-xxxxxxxxx: Updating DW state with close
2020-09-12 16:27:48.110 [DEBUG] [lly.internal.util.ShellyChannelCache] - shellydw2-xxxxxxxxx: Channel battery#batteryLevel updated with 100.0 % (type class org.eclipse.smarthome.core.library.types.QuantityType).
2020-09-12 16:27:51.226 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellydw2-xxxxxxxxx: Updating sensor
2020-09-12 16:27:51.331 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellydw2-xxxxxxxxx: Updating DW state with close
2020-09-12 16:27:51.334 [DEBUG] [lly.internal.util.ShellyChannelCache] - shellydw2-xxxxxxxxx: Channel battery#batteryLevel updated with 100.0 % (type class org.eclipse.smarthome.core.library.types.QuantityType).
2020-09-12 16:27:59.985 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellydw2-xxxxxxxxx: CoIoT Message from /192.168.x.xx:5683 (MID=56275): {"G":[[0,9103,0],[0,3108,0],[0,3109,-1],[0,6110,-1],[0,3106,15],[0,3110,"dark"],[0,3101,27.00],[0,3102,80.60],[0,3115,0],[0,3111,100],[0,9102,["button","sensor"]]]}
2020-09-12 16:27:59.987 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellydw2-xxxxxxxxx: CoIoT Sensor data {"G":[[0,9103,0],[0,3108,0],[0,3109,-1],[0,6110,-1],[0,3106,15],[0,3110,"dark"],[0,3101,27.00],[0,3102,80.60],[0,3115,0],[0,3111,100],[0,9102,["button","sensor"]]]} (serial=512)
2020-09-12 16:27:59.989 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellydw2-xxxxxxxxx: 11 CoAP sensor updates received
2020-09-12 16:27:59.993 [DEBUG] [lly.internal.util.ShellyChannelCache] - shellydw2-xxxxxxxxx: Channel battery#batteryLevel updated with 100.0 % (type class org.eclipse.smarthome.core.library.types.QuantityType).
2020-09-12 16:27:59.997 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellydw2-xxxxxxxxx: 1 channels updated from CoIoT status, serial=512
2020-09-12 16:28:15.036 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellydw2-xxxxxxxxx: CoIoT Message from /192.168.x.xx:5683 (MID=56276): {"G":[[0,9103,0],[0,3108,0],[0,3109,-1],[0,6110,-1],[0,3106,15],[0,3110,"dark"],[0,3101,27.00],[0,3102,80.60],[0,3115,0],[0,3111,100],[0,9102,["button","sensor"]]]}
2020-09-12 16:28:15.038 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellydw2-xxxxxxxxx: CoIoT Sensor data {"G":[[0,9103,0],[0,3108,0],[0,3109,-1],[0,6110,-1],[0,3106,15],[0,3110,"dark"],[0,3101,27.00],[0,3102,80.60],[0,3115,0],[0,3111,100],[0,9102,["button","sensor"]]]} (serial=512)
2020-09-12 16:28:15.040 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellydw2-xxxxxxxxx: 11 CoAP sensor updates received
2020-09-12 16:28:15.042 [DEBUG] [lly.internal.util.ShellyChannelCache] - shellydw2-xxxxxxxxx: Channel battery#batteryLevel updated with 100.0 % (type class org.eclipse.smarthome.core.library.types.QuantityType).
2020-09-12 16:28:15.044 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellydw2-xxxxxxxxx: 1 channels updated from CoIoT status, serial=512
2020-09-12 16:28:30.094 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellydw2-xxxxxxxxx: CoIoT Message from /192.168.x.xx:5683 (MID=56277): {"G":[[0,9103,0],[0,3108,0],[0,3109,-1],[0,6110,-1],[0,3106,15],[0,3110,"dark"],[0,3101,27.00],[0,3102,80.60],[0,3115,0],[0,3111,100],[0,9102,["button","sensor"]]]}
2020-09-12 16:28:30.095 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellydw2-xxxxxxxxx: CoIoT Sensor data {"G":[[0,9103,0],[0,3108,0],[0,3109,-1],[0,6110,-1],[0,3106,15],[0,3110,"dark"],[0,3101,27.00],[0,3102,80.60],[0,3115,0],[0,3111,100],[0,9102,["button","sensor"]]]} (serial=512)
2020-09-12 16:28:30.096 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellydw2-xxxxxxxxx: 11 CoAP sensor updates received
2020-09-12 16:28:30.099 [DEBUG] [lly.internal.util.ShellyChannelCache] - shellydw2-xxxxxxxxx: Channel battery#batteryLevel updated with 100.0 % (type class org.eclipse.smarthome.core.library.types.QuantityType).
2020-09-12 16:28:30.100 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellydw2-xxxxxxxxx: 1 channels updated from CoIoT status, serial=512
2020-09-12 16:28:45.340 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellydw2-xxxxxxxxx: Enabling channel cache (20 updates / 60s)
2020-09-12 16:33:23.200 [DEBUG] [discovery.ShellyDiscoveryParticipant] - ServiceInfo [ServiceInfoImpl@11364983 name: 'shellydw2-xxxxxxxxx._http._tcp.local.' address: '(null):80' status: 'DNS: JmDNS-/192.168.y.yy [/192.168.y.yy] state: probing 1 task: null', has NO data, empty]

I see incoming CoAP messages, but only indicating sensor status = false
id 3108: dwIsOpened, Type=S, Range=0/1;-1, Links=1
when you search for 3108, you’ll only find “[0,3108,0]” - this indicates sensor closed

Do you see CoAP messages when opening and closing the window?
run tail -f openhan.log and watch what happens when you open/close the window multiple times

The binding will not indicate “sensor open” unless you see “[0,3108,1]”

You could also check http://<device-ip>/status when the window is open.
For this you need to wake up the device by pressing the button

Both http status and the shelly app report the sensor as open, when it is open.
When opening and closing the door, no messages at all get to openhab (in Debug logging).
The entries above only came through when I woke the device up.

I found the log entry below, though …

2020-09-12 17:53:23.264 [DEBUG] [discovery.ShellyDiscoveryParticipant] - ServiceInfo [ServiceInfoImpl@3063325 name: 'shellydw2xxxxx._http._tcp.local.' address: '(null):80' status: 'DNS: JmDNS-/192.168.y.yyy [/192.168.y.yyy] state: probing 1 task: null', has NO data, empty]

that sounds like a firmware bug

you could try action urls:

  • go to the binding config (not the thing config)
  • disable AutoCoIoT
  • go to the thing config and enable Sensor events

Do I have to restart the binding or re-inlcude the device?
Does this have any impact in other shelly devices?

OK just, did what you suggested. Interesting output:

it showed the close messages in the log, but the open messages did not appear at at all

2020-09-12 18:43:47.049 [DEBUG] [elly.internal.api.ShellyEventServlet] - CallbackServlet: HTTP/1.1 Request from 192.168.n.nn:57198/shelly/event/shellydw2-xxxxx/report?{type=[close]}

hmm, what should I say?
If there is no event, the binding can’t act on that

what happens when you press the button while the window is open?
does that generate an event with state = open?

This is what happens when I open, and close the sensor:

2020-09-13 10:51:51.261 [INFO ] [clipse.smarthome.model.script.System] - Shelly logging: DEBUG
2020-09-13 10:51:51.275 [INFO ] [lipse.smarthome.io.net.exec.ExecUtil] - executed commandLine 'sudo /usr/bin/ssh -p 8101 -i /home/openhabian/openhab.id_rsa 
        openhab@localhost log:set DEBUG org.openhab.binding.shelly'
2020-09-13 10:53:08.041 [DEBUG] [elly.internal.api.ShellyEventServlet] - CallbackServlet: HTTP/1.1 Request from 192.168n.nn:63920/shelly/event/shellydw2-xxxxx/report?{type=[dark]}
2020-09-13 10:53:08.044 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellydw2-xxxxx: Event received: class=report, index=, parameters={type=dark}
2020-09-13 10:53:08.047 [DEBUG] [lly.internal.api.ShellyDeviceProfile] - shellydw2-xxxxx: Invalid index -1 for getControlGroup()
2020-09-13 10:53:08.049 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellydw2-xxxxx: Unsupported event class: report
2020-09-13 10:54:00.871 [DEBUG] [elly.internal.api.ShellyEventServlet] - CallbackServlet: HTTP/1.1 Request from 192.168n.nn:58639/shelly/event/shellydw2-xxxxx/report?{type=[close]}
2020-09-13 10:54:00.877 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellydw2-xxxxx: Event received: class=report, index=, parameters={type=close}
2020-09-13 10:54:00.880 [DEBUG] [lly.internal.api.ShellyDeviceProfile] - shellydw2-xxxxx: Invalid index -1 for getControlGroup()
2020-09-13 10:54:00.882 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellydw2-xxxxx: Unsupported event class: report
2020-09-13 10:54:14.127 [DEBUG] [elly.internal.api.ShellyEventServlet] - CallbackServlet: HTTP/1.1 Request from 192.168n.nn:61489/shelly/event/shellydw2-xxxxx/report?{type=[dark]}
2020-09-13 10:54:14.128 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellydw2-xxxxx: Event received: class=report, index=, parameters={type=dark}
2020-09-13 10:54:14.129 [DEBUG] [lly.internal.api.ShellyDeviceProfile] - shellydw2-xxxxx: Invalid index -1 for getControlGroup()
2020-09-13 10:54:14.130 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellydw2-xxxxx: Unsupported event class: report
2020-09-13 10:54:23.434 [DEBUG] [elly.internal.api.ShellyEventServlet] - CallbackServlet: HTTP/1.1 Request from 192.168n.nn:50401/shelly/event/shellydw2-xxxxx/report?{type=[close]}
2020-09-13 10:54:23.437 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellydw2-xxxxx: Event received: class=report, index=, parameters={type=close}
2020-09-13 10:54:23.441 [DEBUG] [lly.internal.api.ShellyDeviceProfile] - shellydw2-xxxxx: Invalid index -1 for getControlGroup()

whenever I open the sensor, I see an entry for type=dark in openhab

try the updated build

Ok. Will do. Where do I find the latest build?
Can you indicate what you changed with this new Bild?

index should be 0 instead of -1
setting action url for open was missing


Latest DEV build - README - Installation - Firmware Index - Firmware Archive - API Doc

just tested the new binding with event URL first - worked.
Then switched back to CoIot - worked. Can you please have a look in the log below, if the switch back to CoIoT actually worked. I changed the THING config in PaperUI to disable Event URL and activate CoIoT.

great! thanks a lot!
I still get an INDEX -1 for ControlGroup. Is this an issue?

Log is attached:

openhab_200914.log (25.1 KB)

I seem to have a similar problem with my Shelly dw2 not receiving updates in the binding. Have the changes made it into the official release (which I have) or do I need to download the dev release?

I acually run my DW2s with MQTT, as I could not get them to work consistently with the Shelly Binding.

1 Like

Okay, thanks or saving me countless hours of trying all kinds of things. I was going to wait another while before I learn MQTT and switch my shellies over, but I’ll take this as an incentive to start learning MQTT and start using it with the shelly DW2. Anything special I should be aware of? (My impression is that at least part of the trouble is due to the DW2 being asleep most of the time. Not sure if that is a challenge with MQTT too?)

https://community.openhab.org/t/shelly-dw2-does-not-trigger/112698/15?u=ffr

You can find some additional info here

1 Like

Up to you, but the wrong direction from my PoV. Please be more specific. There were changes around the tilt status/event, and they SHOULD be part of the 3.1 release, but verify the latest DEV build (even showing 3.1-SNAPSHOT). Would be interesting to see if there are differences. I know from people successfully using the DW2 with the binding. If there are issues we could work on this.

Do mean it is wrong to use MQTT instead of the shelly-binding? I guess one doesn’t exclude the other, does it? Or does the binding need the shelly cloud?

One disadvantage with MQTT seems to be that you don’t get access to all the data (I have not yet found how to get the wifi signal strength), but while I was able to get the DW2 to work via MQTT, I could not get it to work with the binding. I also suspect that MQTT may be faster and more energy efficient, but I’m not sure.

What information do you need?

Solved by just waiting some time…

Hi @tophee and @markus7017,

the topic is a little bit old but I’m acutally wondering why I can’t link items to the Windows open/closed status. Is there any specific thing I have to do. In the Shelly ap it works fine and I can see the actual status.

Thanks in advance
Christian

I’m not sure what you mean by that. I’m not fluent in the openHAB terminology, but I wouldn’t know what it would mean to link an item to a status. In my mind, an item has a status. In my model, it looks like this:

Hi,

It seems that it just took some time. Now everything is there as expected…

chr1s