Custom Component: Room Presence

Hi folks,

I’d like to share my first ever HA component: Room Presence / Room. It manages the presence status of your home’s rooms by monitoring the sensors you configure into it. No more manually creating / modifying your automations for each room and motion sensor in your house!

image

This component lets you define rooms in your house and assign sensors that will trigger the presence occupied status (and clear when they are clear). A switch called “Presence Hold” will be created for each room you add that will prevent the occupancy status to change. This is really useful when you are watching TV sitting still and you don’t want the room to be marked clear when your motion sensor stops detecting you, or when you’re sleep and you don’t want your lights coming up when you move. There’s a parameter that defines which sensors will trigger/clear “Presence Hold” automatically.

I’ve added the hacs.json file so you SHOULD be able to install it through HACS by manually adding the repository (not tested).

The setup is pretty straightforward, you define in your configuration.yaml your room definitions, including which sensors will trigger occupancy and which will be responsible for presence_hold. The default clear_timeout (how long to wait on marking the room clear when the last presence sensor is cleared.) is 5 seconds but you can configure that too.

Below an example configuration which has a media_player and a template binary sensor from my smart outlet responsible for both occupancy and presence_hold at the same time (yes, it’s possible!):

room:
  living_room:
    name: "Living Room"
    presence_sensors:
      - binary_sensor.motion_living_room
      - media_player.living_room_alexa
      - binary_sensor.door_living_room
      - binary_sensor.tv_living_room
    presence_hold_sensors:
      - binary_sensor.tv_living_room
      - media_player.living_room_alexa
    icon: 'mdi:sofa'
    on_states:
      - on
      - playing
      - home
    clear_timeout: 30

Please check out the GitHub repository and let me know your opinion!

8 Likes

Impressive, thanks!

1 Like

really nice idea
tried to install it myself but no luck. I don’t find it in the HACS :roll_eyes: :roll_eyes:

It’s not on HACS official repo yet. You have to add my repository into HACS first.

To install manually, download the repo and copy the folder room in custom_components to your custom_components folder.