"""
Defined states:
- * 0: The device is inactive.
- * ST_ACTIVE|ST_TRANSITION: The device is transitioning from inactive to active.
- * ST_ACTIVE: The device is active.
- * ST_TRANSITION: The device is transitioning from active to inactive.
+ - 0: The device is inactive.
+ - ST_ACTIVE|ST_TRANSITION: The device is transitioning from inactive to active.
+ - ST_ACTIVE: The device is active.
+ - ST_TRANSITION: The device is transitioning from active to inactive.
"""
import logging
if self.desired_state == 0 and self.transition is not None:
logger.debug("cancelling pending deactivation")
self._cancel_transition()
+ curstate = self.device.state
+ if curstate == ST_ACTIVE:
+ self.desired_state = ST_ACTIVE
+ OnoffDevice.changestate(self, ST_ACTIVE)
+ return
+ logger.warn("device should be active during delayed deactivation" +
+ ", but is in state %d", curstate)
self.desired_state = ST_ACTIVE
self.device.activate()
self.changestate(self.device.state)