Added missing check to ensure a sensor is active before querying it.