If the sensor changes state (on/off), then when it is flipped on, we should only consider the time ranges in which it has been on. We should overwrite the last_completed_time field that is passed through to the context.
We should also consider renaming last_completed_time to something else... maybe just since_time?