Lyr3x / Roode

A reliable smart home people counter based on VL53L1X and ESPHome
The Unlicense
149 stars 41 forks source link

FR: Count person in door frame #119

Closed noxhirsch closed 1 year ago

noxhirsch commented 2 years ago

Is your feature request related to a problem? Please describe. When you use Roode to control the light, the light only comes on when you are already in the room - so you walk into the darkness.

Describe the solution you'd like Here a config option "count_person_in_doorframe" or "count_presence_detection" would be handy, which also counts up if a person is only standing in the doorframe and nobody else is in the room.

Describe alternatives you've considered This is my current workaround. The presence sensor needs an off-delay, because otherwise it can happen that after passing through the door the counter goes from 1 to 0 and back to 1. The off-delay must be on an extra sensor, so that the normal count process is not delayed. The workaround works, but is IMHO relatively complicated for such an easy and useful feature and can probably be solved more efficiently internally in Roode.

binary_sensor:
  - platform: roode
    presence_sensor:
      name: $friendly_name presence
      id:  presence_sensor
      internal: true
  - platform: template
    id: presence_sensor_delay_off
    internal: true
    lambda: 'return id(presence_sensor).state;'
    filters:
      - delayed_off: 100ms
    on_state:
      then:
        - component.update: number_peoplecounter

number:
  - platform: roode
    people_counter:
      id: master_peoplecounter
      internal: true
      on_value:
        then:
          - component.update: number_peoplecounter
  - platform: template
    name: $friendly_name
    id: number_peoplecounter
    min_value: 0
    max_value: 1000
    icon: "mdi:counter"
    step: 1
    lambda: |-
      if(id(presence_sensor_delay_off).state && id(master_peoplecounter).state == 0) { return 1; } 
      else{ return id(master_peoplecounter).state; }
    set_action:
      then:
        - number.set:
            id: master_peoplecounter
            value: !lambda "return x;"

Additional context Add any other context or screenshots about the feature request here.

diplix commented 2 years ago

this is how i use the roode sensor:

the presence (in the door) snesor works for me like a photo sensor („lichtschrake“), so that i never walk into a dark room.

noxhirsch commented 2 years ago

Of course, you can do it that way. But I think if Roode could solve this internally it would be a handy little feature that could simplify automation for many user.

For me, it doesn't make sense to add this to my room automation in Home Assistant - it is already very complicated. This is why I created this workaround in ESPHome.

This is all one automation (split in 6 screenshots) to control lights, dashboard, computer etc in one room: (click here to open) Screenshot 2022-02-15 140354 Screenshot 2022-02-15 140418 Screenshot 2022-02-15 140449 Screenshot 2022-02-15 140508 Screenshot 2022-02-15 140527 Screenshot 2022-02-15 140544
roc634 commented 1 year ago

Thanks for your idea. I now use presence sensor as a trigger to turn on lights and I never walk into darkness any more. Cheers!

this is how i use the roode sensor:

  • to trigger occupancy (turn on the light) i use the „presence“ sensor (somebody stands/walks in the door)
  • i use the people count to hold occupancy (not to trigger it). so as long as > 0 people are in a room, the light stays on
  • to trigger occupancy-off i do use the people count with a delay (depending on the room usage)

the presence (in the door) snesor works for me like a photo sensor („lichtschrake“), so that i never walk into a dark room.