Using Ultrasonic sensor HC-SR04 in 3-wire mode

Thanks, this is helpful. I didn’t know you could customise it with custom C code (but I’m also not surprised given the quality of this project).

I’ve since decided just to stick to the 4-wire solution because I already had the sensors.

You can create your binary sensor in the YAML from the sensor you now have. This is what I’ve done:

  - platform: template
    name: "Garage Occupied"
    lambda: |-
      if (id(garage_ultrasonic_sensor).state < 1) {
        return true;
      } else {
        return false;
      }

Note: The 1 is one meter.