Combining Room Assistant and Person Entities

Home Assistant Template

Home assistant’s Person entity can be used to show if some one is home or away and room assistant can then show which room someone (or at least someone’s BLE device is).

In order to get a single feedback on where someone is I created a template sensor to show a Room if they are detected in one or Home/Not home based on the the person sensor, which in our case is currently controlled by pinging our phones.

    jane_location:
      friendly_name: "Jane Location"
      value_template: >
        {% set id = states('person.jane') %}
        {% if states('sensor.jane_watch_room_presence') != 'not_home' %}
        {% set id = states('sensor.jane_watch_room_presence') %}
        {% endif %}
        {{ id[0]|upper}}{{id[1:]|replace('_',' ') }}
      attribute_templates:
        short_name: "Jane"
        type: "location"
      icon_template: >
        {% set loc = states('sensor.jane_location') %}
        {% if loc == 'Office' %}
        mdi:desk
        {% elif loc == 'Living Room' %}
        mdi:sofa
        {% elif loc == 'Bedroom' %}
        mdi:bed
        {% elif loc == 'Kitchen' %}
        mdi:chef-hat
        {% elif loc == 'Home' %}
        mdi:home
        {% else %}
        mdi:earth
        {% endif %}

The above returns a Room name or Home or Not Home with an appropriate icon for the room we are in. It sets the value from Room Assistant unless it is reporting “not_home” , otherwise it uses the value from the person entity, tidying the result to a nice capitalised field. One of the reasons for this is that we only have 4 RA devices currently so some rooms are not covered.

{{ states('binary_sensor.office_motion') == 'on' or states.sensor|selectattr('state','eq','Office')|selectattr('attributes.type','eq','location')| list| count > 0}}

The above is used in a Room Occupied Binary Sensor, which is then use to detect requirements for lighting or heating. The advantage with this method is the type and state filters mean adding additional people is just a case of adding an additional location type sensor as shown above.