Homeassistant - Detecting tilted windows
Introduction
One of my main requests for my Smarthome was and is detection of tilted windows, as I quite also window for for a longer period of time and before I go, want to know which windows are open and which tilted as I tilted windows due to let the built-in fuse open...
I looked forward to solutions, but it was I'm only very limited, because tilted windows are more of a German? Things seem to be...
There are certainly solutions that can see how the ELV Homematic IP window sensor. This would also be the most visually beautiful solution. Since I don't have a Homematic I want to use IP, according to favorable and reliable solutions searched and finally on the AEOTEC Zigbee Multipurpose Sensor which I then bought directly 15x... Price of approx. 30€ per sensor, they are priced in the reasonable framework and continue to have a few nice extensions, like a gyroscope, a vibration sensor and a thermometer.
Facility in Homeassistant
The setup is quite simple via the ZigBee Addon in HASS, but you only get 3 sensors
- Thermometer (temperature)
- IAS Zone (magnetic sensor)
- Accelormeter (Boolean -> Named with isMoving)
These values can show me if a window is on or too, but not whether it's tilted. Accordingly, we need the values of the gyro and we do as follows:
Setup Helpers:
First we need 2 Helper -> We create this under SETTINGS > DEVICES & SERVICES > Helpers
- Helper for Tiltvalue from sensor (This helper will include the value of the sensor)
TYPE:
MIN: 0
MAX: 200
INFO: In the normal case, these values can range from -1400 to +1400, but with “normal” fenterns these ranges - Helper for isTilted boolean value
defines and shows whether the window is tilted or not (toward
Use in a Picture Elements Dashboard – if this is not
need not be added to the sensor)
Type: Toggle
Toggle Sensor - Shows if the window is tilted or not (only needed for lovelace picture elements dashboard)
- Numeric Sensor - This sensor holds the gyro value from the sensor
Setup Automation
Next, we need to create an automation that has the values
from the sensor to the helpers, we create a new automation
SETTINGS > Automations & Scenes > Automations
Small
Info: Automation can be executed automatically unlike a script
a script must be started manually, e.g. by a
Button on the dashboard. Therefore, we need to use automation here.
Automation in YAML:
alias: GetTiltFromFensterKontaktBad
description: Setzt den FensterKippWert (X Achse) vom Bad
trigger:
- platform: event
#under this event the data are send (may vary when you use another sensor
event_type: zha_event
event_data:
#your device ID -> under Setings > devices
device_ieee: 28:6d:97:00:01:xx:xx:xx
condition: []
action:
- service: input_number.set_value
data:
value: '{{ trigger.event.data.args.value }}'
#change this ID to your helper ID
entity_id: input_number.fensterkontaktbadneigungx
- choose:
- conditions:
- condition: numeric_state
#change this ID to your helper ID
entity_id: input_number.fensterkontaktbadneigungx
above: '0'
below: '100'
sequence:
- service: input_boolean.turn_off
data: {}
target:
#change this ID to your helper ID
entity_id: input_boolean.fensterkontaktbadistgekippt
- conditions:
- condition: numeric_state
#change this ID to your helper ID
entity_id: input_number.fensterkontaktbadneigungx
above: '100'
below: '200'
sequence:
- service: input_boolean.turn_on
data: {}
target:
#change this ID to your helper ID
entity_id: input_boolean.fensterkontaktbadistgekippt
default: []
mode: single
Finally, you can still integrate this data into a dashboard, so you can see the following article [Link]
Back…