X as occupancy sensor

Hello

I would like certain sensors such as door or window sensors to be used as occupancy sensors. If, for example, a window opens or closes, that is indicative that someone is in that room. I think it could be a good complement to motion sensors since these only detect movement if it is evident and could be complemented with other sensors that, although they are not motion sensors, their use necessarily implies that there is someone in that room. I am currently doing it by hand, I leave you an example:

- trigger:
    - platform: state
      entity_id: binary_sensor.lumi_lumi_sensor_magnet_aq2_06a64e04_on_off
      from: 'on'
      to: 'off'
    - platform: state
      entity_id: binary_sensor.lumi_lumi_sensor_magnet_aq2_06a64e04_on_off
      from: 'off'
      to: 'on'
  binary_sensor:
    - name: "Puerta terraza occupancy"
      unique_id: "puerta_terraza_occupancy"
      device_class: "occupancy"
      auto_off: 10
      state: "true"

You can do this in Magic Areas(via HACs) integration.
I understand you may be looking for a simpler “built-in” solution.
It offers the option for defining various types of devices like media players as well as the type of trigger like play, pause etc. There’s a lot available there.