I have a script that listens for state changes on some door sensors, and when a change is detected causes an update function to run. The update function in turn checks the states of all the sensors, looking for any that are in state on. The problem is, even though I explicitly see a transition from off to on, every once in a while the actual state of the sensor when queried is still off.
Is there a known issue with the AppDaemon entity values not updating immediately on transition? Do I need to add a delay? It seems odd that it would know about the change and inform my script about it without updating the internal state first - am I just doing something wrong?
Some code snippets to clarify, starting with init:
for sensor in self._sensors:
    sensor.listen_state(self.sensor_update)
The listener code is:
def sensor_update(self, entity, attribute, old, new, **kwargs):
    self.log(f"{entity} has transitioned from {old} to {new}")
    self.update_lights()
And finally the top of update_lights is:
def update_lights(self):
        if any(sensor.get_state() == "on" for sensor in self._sensors):
            ...