Modify Multipurpose Sensor Device Handler for 2 way opened windows?

Hello All, i am not a developer , but i would really need your help. I have a Multipurpose Sensor , problem is my windows are european windows which you can tilt and turn, you can open the window in 2 modes, i have attached also a picture.

What i actually need is to modify a device handler from Multipurpose sensor, in order to show me in which state is the window, meaning closed, Open based on the actual function of the sensor open/closed in swing, and the third option would be based on the 3 axis that is hopper open. Can anybody help ? i want to mention that i searched the forum but found nothing. Problem is that i am not a developer so i don`t understand what to change in the device handler in order to obtain this.
So far i have managed to have on my screen the 3 axis state.


Maybe I’m missing something - but it seems to me that if the sensor were on the upper right corner of the window it would work with normal open or close in either swing or hopper mode without needing to deal with the axis tilt…again, am I missing something?


The ideea is to know when the window is open in hopper or tilt. With the axis i know that is hopper

The default handler has a garage tilt option. You should be able to borrow that code for the tilt (and you may need to adjust the values at which it trips depending on orientation and how soon you want it to show as open). You can probably just have it post the event generated from the garageEvent function to a new attribute.

Yes, i was thinking of that but to be honest, I don’t know how to do it exactly :frowning: that is why i ask for help.

One way you can do without custom device handler is to install 2 sensors, 1 at the top part of window and 1 at the bottom.

If both opened then you know it’s swing position, if top is open but bottom still close, then at tilt position.

You can deploy the much cheaper contact sensor for this.

You still need to test to see if the bottom contact work at tilt position.

You can find multiple post on this forum from users with this request. I thought of it this weekend: why is that difficult to implement?
The Smarthings code of smartsense-multi-sensor.groovy DTH uses a variable to manage events based on the sensor is set garage door usage (positioning only rather than magnet open/close).
You can see the code is conditioned by such if (garageSensor == “Yes”) tests.

So basically, you would have to modify the DTH to keep the magnet and XYZevents management.

Now the problem is the way you want to consider the window is open. I give you an example: for your SHM, I understand you would consider the window is an issue if it is in “swing” of your picture but not of “hopper”. So you would have the DTH sending the “Open” event only in swing.
Now you consider your heating system: whether the window is in “hopper” or “swing”, you would want to have it lower temperature or something. So I hope you see now the difficulty: what will be the “open” state seems to depend on the usage and this is not how SmartThings is using events, except if you want to rewrite all the smartapps around.
So I think you should have 2 Devices based on different DTH: one would react to open/close magnet. One would be set as garage door but with an adaptation of the garageEvent(xyzResults) you have in the original DTH.
Note that you will certainly have to pass the whole set of x,y and z (at least 2 of them) and make your tests on what is the right set of values when the window is “hopper”.
Current code is:

List garageEvent(zValue) {
284 List results =
285 def absValue = zValue.abs()
286 def contactValue = null
287 def garageValue = null
288 if (absValue > 900) {
289 contactValue = ‘closed’
290 garageValue = ‘garage-closed’
291 } else if (absValue < 100) {
292 contactValue = ‘open’
293 garageValue = ‘garage-open’
294 }

These 100, 900 thresholds have to be set for the 2 dimensions (x and z or y and z depending how you mount your sensor).

Hope it helps.

This helped a lot, i will try to do this in the weekend probably when i will have a little time. Thank you verry much