Two Obstacle Sensors on a feedback cover

We are working on a pet door design. I’d like to include two closing obstacle sensors. One for a current based threshold sensor and another for an IR beam sensor.

Is there an easy way to have both sensors? Do I somehow have to have a binary sensor that ORs the two values together?

Any ideas will be appreciated.

Joel

Personally I’d export the sensors separately and use a group in HA to combine them. But you could do the same in the esp using a template binary sensor:

Here’s an AND example.

For OR I use ||.

https://en.cppreference.com/w/cpp/language/operator_logical

My preference is to do things on the ESPHome side where possible.

binary_sensor:
#Someone is sitting? Sit dection using a multi-pronged approach.
  - platform: template
    id: someone_is_sitting
    name: Someone Is Sitting
    icon: "mdi:seat-recline-normal"   
    #Motion is detected, ToF is in range, keyboard drawer is open, desk height is in range
    lambda: |-
      return
      id(desky_motion_detected_processed).state &&
      id(desky_tof_seems_occupied).state &&
      id(desky_keyboard_drawer_endstop).state &&
      (id(desky_current_sit_stand_position).state == "Sitting")
      ;

Thank you for the suggestion. I haven’t used a group in HA. I will study up on that.

Thank you for the example! You are saying that replacing && with || would logically OR all the binary sensors together?

Appreciate the fast feedback!

1 Like

Yes, switch the && to || to get OR.