Create custom Windows sensor (from tilt sensor)

Hi there,

i have a tilt sensor attached to my roof window.
The sensor gives me values for the x/y/z axis and changes with the opening state of the window.

Now i want to have a custom window sensor that show me two (or three) states: open (and a little bit open for air flow) and closed.

What is the simplest way to achieve this?

I looked into templates, Helper, automations and i am lost…

Create a template sensor. Something like this:

  - binary_sensor:
      unique_id: MYID
      name: "roof_window_open"
      state: > 
          states("sensor.tilt_axes") |int(0) > 5 
      - platform: state
        entity_id: sensor.tilt_axes

Where 5 is the axes where you want to report it as open

1 Like


I got something similar to work:


  • trigger:
    • platform: state
      entity_id: sensor.fenstersensordg_kiz_x_axis
      name: “roof_window”
      state: ‘{{is_state(“sensor.fenstersensordg_kiz_y_axis”) |int(0) > 700 and is_state(“sensor.fenstersensordg_kiz_z_axis”) |int(0) < -300 }}’
      device_class: window

But the last thing, the device_class is not working (with templates)

Any solution to that, because i would like to have a “Window” device /entity