Determine if an area is occupied

With ESPresence being the new hotness in room detection I decided to start looking into room occupancy. I set up a test ESPresence unit to see what all of the entities look like. I was able to add my phone and it now tells me I am in the “test” room.

The thing I can’t figure out is how to indicate that an “area” is occupied. ESPresence, or any of the presence software ie. room-assistant, can tell me where a person is, but doesn’t tell me that a space is occupied. I don’t really care who is in a particular space, just that someone is in the space.

I can’t find any type of occupancy sensor for a given area to trigger an automation off of. The room detection seems to be based on a particular person. In the case of ESPresence, it’s a sensor that is associated with a specific BLE radio and its current location, either indicating one of the areas or not home.

This all seems backwards to me. Like I mentioned I don’t care who walked into the master bedroom. I just want the lights to turn on when someone walks in there. I know that I can accomplish this with a motion sensor, but when the motion clears the occupancy is cleared also. The advantage of a BLE tracker is along as the device is present, the area is occupied. It doesn’t depend continued motion.

I’m sure there is a way to create some kind of template sensor that uses all of the BLE sensor states, but that seems overly complicated to me. HA has the concept of area but it’s only a logical grouping of devices/entities. An area doesn’t have occupancy associated with it.

What am I missing? This seems like a simple problem, is it just a matter of getting ESPpresence to publish an MQTT topic for an occupancy sensor for each area? Or is this just some core functionality missing in Home Assistant?

Suggestions?

Hi Barry,

I have not yet tried this sensor type but maybe this is a starting point.

Alternatively, you could consider turning on an input Boolean when any of your room sensors are ‘on’ & only turning it off when all of the sensors are ‘off’.

Cheers

I know this thread is quite old, but it may still help you or others :slight_smile:

I was wondering the exact same. I find it weird that ESPresence does not provide that by default.

However, I did it very easy by defining template sensors :slight_smile:

# Basic ESPresence sensor per device. Tells you in which room a device is.
sensor:
  - platform: mqtt_room
    device_id: "iTrack:xxxxxxxxxxxx"
    name: 'iPhone BLE'
    state_topic: 'espresense/devices/iTrack:xxxxxxxxxxxx'
    timeout: 5
    away_timeout: 60
  - platform: mqtt_room
    device_id: "iBeacon:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx-3-58241"
    name: 'Pixel6 BLE'
    state_topic: 'espresense/devices/iBeacon:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx-3-58241'
    timeout: 5
    away_timeout: 60


# Vice versa: Is a room occupied? Match your device sensors against your room topics set in ESPresence/MQTT
template:
  - binary_sensor:
      - name: Living Room occupied
        state: >
          {{ is_state('sensor.iphone_ble', 'livingroom')
             or is_state('sensor.pixel6_ble', 'livingroom') }}
  - binary_sensor:
      - name: Kitchen occupied
        state: >
          {{ is_state('sensor.iphone_ble', 'kitchen')
             or is_state('sensor.pixel6_ble', 'kitchen') }}
1 Like

I just started with ESPresense and once I got it working came to the same thought. Thank you!
/I’m terrible with templating.