Know the state of tilt and turn Windows/doors

Hello.
In my house i have tilt and turn windows and doors( acess to balcony) that i always wanted to make it possible to HA know the real state of them (opened,closed or tilted ) with the minimum hardware possible.

I want to know the real state of them for several reasons:

  • If they are tilted or closed the automations for the shutters can run, if they are opened they can,t.

  • If they are tilted i want to be advised if i turn on the air conditioner, or if it is too cold/warm outside…

I used door/window zigbee sensors in them already for a long time, but i didn,t had the tilt state. I could just put another sensor just for the tilt position, but that would be one more battery to track, one more sensor in the network etc…

  • So i came up with an idea when i bought an cheap ( arround 4 $ ) zigbee sensor from aliexpress that exposes the window/door state but also the tamper state of the sensor ( it have an switch that will trigger the tamper sensor if someone tries to take of the sensor of it,s position). The idea is to take off the switch and put another reed sensor in it,s place , and now i have two reed sensors in the same zigbee device !

the sensor is this .



but has up for today this sensor only appears in zigbee2mqtt , not in ZHA.

reedeesgiif

Then i make an template sensor, using the state of the 2 entities created by the device:

template:
  sensor:

    - name: "window state"
      state: >
        {% if is_state("binary_sensor.porta_varanda_escritorio_contact", "on") and is_state("binary_sensor.porta_varanda_escritorio_bascula", "on") %}
         open
        {% elif is_state("binary_sensor.porta_varanda_escritorio_contact", "off") and is_state("binary_sensor.porta_varanda_escritorio_bascula", "on") %}
         tilt
        {% elif is_state("binary_sensor.porta_varanda_escritorio_contact", "off") and is_state("binary_sensor.porta_varanda_escritorio_bascula", "off") %}
         close
        {% else %}
         offline
        {% endif %}
      icon: >
        {% if is_state("binary_sensor.porta_varanda_escritorio_contact", "on") and is_state("binary_sensor.porta_varanda_escritorio_bascula", "on") %}
         phu:double-window-open
        {% elif is_state("binary_sensor.porta_varanda_escritorio_contact", "off") and is_state("binary_sensor.porta_varanda_escritorio_bascula", "on") %}
         phu:lift-in-window-open1
        {% elif is_state("binary_sensor.porta_varanda_escritorio_contact", "off") and is_state("binary_sensor.porta_varanda_escritorio_bascula", "off") %}
         phu:double-window-closed
        {% else %}
         phu:window-sensor
        {% endif %}

I think HA don,t have an icon good enought for tilt windows, so i used this component from hacs.

In the picture below i have the state of my shutter and window.

Screenshot 2023-08-31 155254

And that,s just it.

If you like the idea and want more info please ask here and i will edit this post.

1 Like

This is why i always tell people, “Read the documentation” You didn’t need to come up with an “idea” or reinvent the wheel here, This is already a baked in feature of HA and has been for a long time. This is a “cover” and it’s how you integrate windows, blinds, shades, garage doors. gates etc… it works for all of them to track the state and position and a quick trip to the search box would have saved you a lot of time. Template Cover - Home Assistant

Also, if you are finally realizing how little sense it makes to put multiple battery operated sensors on one door or window or you finally figured out that theses things cant accurately track the battery state and the values it does give you are way off, it’s time you learn how to use esp boards and esphome. 1 battery powered esp board could track the states of multiple sensors, control the motor for open/close, monitor the temperature, a motion sensor or vibration sensor for part of a security system and it would only require one device needing powered and only one device on the network instead of 3 or 4 individual ones that all need batteries tracked just to monitor a single door.

one device for multiple sensors

Like @Fallingaway24 says, it sounds like you could use an ESP device with ESPHome to get to the custom solution you need instead of hacking pre-made products to do the trick. Yes, you might have to do a bit of soldering but ESP’s and ESPHome are very solid, probably more so than a generic Aliexpress product that probably won’t be around when you want to do this again in the future.

using esp boards opens soooo many doors that just arent practical with whats available online and everything being a single purpose device with 1 sensor. You could build out a comprehensive home automation system/security system with a handful of esp boards or the other option is 40+ single purpose battery operated sensors that cost 40x more $$. Throw in even a cheap 3d printer and the sky is the limit and that’s no joke.

Thank you very mutch for your opinion. I am very aware of what am i doing, and very satisfied with the result. I love esphome but for me makes no sense to put wires arround the window to have this state.

Just sharing what i came up with, if it,s hepfull for somebody.

3 Likes

you’ve already got wires going up the side of it so i’m not sure what the difference is. Not having wires is everyone’s excuse but, that’s exactly what it is, an excuse. You can hide wires but, most people just aren’t interested in putting in the work or they aren’t capable pulling wires in a wall and making things look professional. If you knew what you were doing then you would have known this is just a simple cover. It’s already there for you to use and you didn’t come up with something new. You made a cover instead of using the cover platform that’s already available.

Well you don,t really want to help i see, just trash talk about someone else work and ideas.

I really enjoy seeing you loving esphome, i love it too, probably already using it for a while when you discover it.

But hey !! You saw my tags ?? I,m using zigbee2mqtt , templates and a dashboard card, so not using esphome . Already said that i am pretty satisfied what i came up with, and really didn,t wanna do it diferently OK ? This is the way i did it , i had a nice ideia in my point of view ( yes i said IDEA , you don,t have to put cotes , it is realy an IDEA)

  • I share it because i thing is a good ideia and if you google it ( just use the search box and paste " tilt windows in home assistant" ) and see how many are trying to do similar things, most of them are using 2 window/door sensors, so is best using just one (no i don,t use 2 or 3 like you said), so you google it and you can too go to all that threads with your trash and hate talk and that " esphome is the only way…" kid talk of yours.

  • I,m pretty sure you still doesn,t get all of what i posted, and that template cover thing , ok i could do it, but if you see i just wan,t to know the state of the window, didn,t want to end up with an cover that in fact i don,t gonna use the controls, just the state… and has i wanted to use personalize icons, i would had to use templates anyway.

    • Hope you like your role of going to threads just poiting at someone else work without even really understand it, with your 3 or 4 posts you didnt say anything usefull and just killed all my work , but hey go ahead with your quest , i have better things to do ( thank god )…
4 Likes

I have tilt and turn windows. On some of them I’m using simple zigbee contact sensor for a window status. I didn’t go as far as @finipini. My sensors report only if the window is open or closed no matter if it is in tilt or fully opened.
This is how it looks on my window

But his post gave me and idea. Well maybe there is some zigbee conatact sensor that has proximity option build in. Didn’t check this out, just an idea. With that there will be no need for two sensors to determinate is window open of tilt.

Yes, i had it like that for some time too, but didnt like that window to show has closed on ha when it was tilted.

Whell maybe with an tilt sensor you could know that too, i tryed One from aqara ( the vibration sensor) , but didnt seem realible, and it stated only the tilt position, have to have too the Open/close one.

Shelly came up now with an ble sensor that have the reed sensor and detects tilt too, bit its a bit expensive and i thing that zigbee is more realible.

I installed mine sensor in upper frame of the window and had never any problems with detecting open/close. I had made myself third gasket and installed it in window frame. Sensor is attached to that gasket if you look a little bit closer.
Now, tilt and turn windows have three positions, open, close and tilt. It is not possible to detect tilt or open window without two contact sensor. I have siegenia window hardware. They made some device on their own to detect is window open or closed but it’s cost a lot for that kind a device, it’s closed source and it require hub to operate.
If there is some simple proximity sensor it will be possible to detect if window is open or tilt by position of window, if we install that kind of sensor inside window frame. And than one sensor will be enough.

Yes, i never had problems too with the function of the sensor.

Back then i choose to put the sensor in the lower frame because i wanted to make automations to my shutters this way:

If the window are closed or tilted the Shutters can close . If the window are Open the Shutter can not close from automations.

But now i have the 3 states, it,s even better for me.

Btw @ddaniel you seem to have the same sensor i had in my Windows, that ones i,m removing now to put the ones with 2 reed sensors. But they are good too, got to use it in other place.

If you wanted to do just that you should put it in upper part of the frame. This part is always open no matter if the window is open or tilt.
But maybe in your frame when you close the window it doesnt close the sensor. But, as I said, I have third gasket I installed in my window frame and I attached sensor to it.

No, that was not my point. If the window is tilted is the same has the window are closed in closing the Shutter point of view. If the window are open there could be someone até the window, of something hang in there to get fresh air só the Shutter cant close.

If the window is tilted ir closed in my case for sure body is at the window nor is nothing hang in there to block the Shutter.

I did it this way mostly because the Windows are often tilted, and that way if i had the sensor in the upper frame the Shutters would never close when they supposed to, when in fact was no problem for them to close.

Oh, ok. Well then you will need two sensors and the setup you done. If it works, than keep it. Don’t mind what other people said. It’s your house and your setup and if it works for you than this is all that matters.

2 Likes

I thing that this could be usefull to someone else too, thats why i posted.

I really posted mostly because after doing that thing to the sensor i was searching for a good icon to use that best represents the tilt window position, and then i saw that was some people asking for the better way to know this 3 positions of the windows, and ohter people using other methods, só i thought that it would help someone posting this.

Other usefull thing about this is that in my case i have not only Windows but also door with Open/tilt position on the acess to balcony , so in that case is even more important to know the right position: if it,s tilted or close then nobody its outside, if they are opened can be someone else outside…but has i said in the first post i want to know either if is entering air from outside… so i really wanted this 3 states.

2 Likes

The fact i used an template sensor do not excuse your trash talk, it was even not the most important thing of my post. One simple " you could instead use template cover" would make your point…

Edit: and for conclusion of this talk, your " help" has you call it doesn,t even work… :yawning_face: , you need at least one action to create an cover template , and i don,t have any action for this because i don,t have nothing to control the window, i just need to know the state… i could make an " fake" script just to pass this has cover , but whats the point in that ?

Conclusion: has always all the trash talk that you are trying to cover as “help” ends up in nothing , and really shows what was your target.

That really is a Classic from “helpers” like you.

1 Like

Like i said in one of the posts, you didnt even understand what i,ve made🤦.

I said i invented the template sensor ? :joy:… i know nothing about code, zero . All templates i use is copy/past of others .

Read carefully for once the post you are replying to since yesterday.

I understand exactly what you did and what I keep saying is, it isn’t “your idea”. You combined 2 sensors…This isn’t something new and it isn’t something unique or special. You may think it is because you failed to do any due diligence but, it isn’t. You are trying to pass off an idea as your own and it’s not new and it’s not your idea. That’s whT I keep saying.

There is no mods in here ?? Why it is allowed all this spam an anger from the same guy in various threads ?

Go fall away ( far away) please !

1 Like