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.
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.
And that,s just it.
If you like the idea and want more info please ask here and i will edit this post.