def is_on(self) -> bool | None:
        """Return true if sensor is active."""
        if self._data_point.is_valid:
            return self._data_point.value
        if (
            self.is_restored
            and self._restored_state
            and (restored_state := self._restored_state.state) not in (STATE_UNKNOWN, STATE_UNAVAILABLE)
        ):
            return restored_state == STATE_ON
        return cast(bool | None, self._data_point.default)
Return true if sensor is active.
custom_components/homematicip_local/binary_sensor.py