def valid_reading(reading, previous_reading):
    """ Check if a reading is valid.

        The SmartThings API may return zero or the reading may go backwards, which confuses things.
        Ensure that we have a valid, increasing reading here.
    """
    return (
        reading is not None
        and reading > 0
        and (previous_reading is None or reading >= previous_reading)
    )