"""
Class for communicating with the GrovePi ultrasonic ranger.

Here we treat it as a binary sensor.
"""

import logging
logging.basicConfig()
LOGGER = logging.getLogger(__name__)
LOGGER.setLevel(logging.getLevelName('INFO'))
try:
    from grovepi import ultrasonicRead
except ImportError:
    LOGGER.warning("GrovePi lib unavailable. Using dummy.")
    from drivers.dummy_grovepi_interface import ultrasonicRead


class GrovePiUltrasonicRangerBinary:
    """A module to read from the GrovePi Ultrasonic as a binary sensor."""

    def __init__(self, port, binary_threshold):
        """Create a GrovePi Ultrasonic Ranger (Binary) driver module."""
        self.port = int(port)
        self.binary_threshold = binary_threshold
        print(f"Setting up GrovePi Ultrasonic Ranger (Binary) on port {port}")

    def is_high(self):
        """HIGH, meaning "not seeing something"."""
        # to match the old GPIO sensors, we'll make this sensor active low
        # False output means object detected
        # True output means no object detected
        return ultrasonicRead(self.port) > self.binary_threshold

@@ -855,12 +855,8 @@
 ng %22
-not 
 seei
@@ -877,83 +877,8 @@
 %22%22%22%0A
-        # to match the old GPIO sensors, we'll make this sensor active low%0A
     
@@ -902,16 +902,19 @@
 t means 
+no 
 object d
@@ -941,35 +941,32 @@
 ue output means 
-no 
 object detected%0A
@@ -1010,9 +1010,9 @@
 rt) 
-%3E
+%3C
  sel

Fix sensor to be active high