Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
cmonicob committed Dec 18, 2023
1 parent 4553d07 commit 28f7eb0
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions hardware/io_expander.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def load_hardware(self):
loaded_hardware = self._load_device(address)
if loaded_hardware is not None:
# All off is all True
loaded_hardware.port = self.INITIAL_STATE
loaded_hardware.states = self.INITIAL_STATE
self.__hardware_cache.set_data(hardware_key, loaded_hardware, -1)

return loaded_hardware
Expand All @@ -83,7 +83,9 @@ def close(self):
@property
def state(self):
try:
return not self.__device.port[self.port] if self.active_high else self.__device.port[self.port]
state = self.__device.port[self.port]
self.__device.states[self.port] = state
return not state if self.active_high else state
except Exception as ex:
logger.error(f"Got an error reading {self}: {ex}")
return None
Expand All @@ -93,7 +95,8 @@ def state(self, state):
try:
state = terrariumUtils.is_true(state)
state = not state if self.active_high else state
self.__device.port[self.port] = state
self.__device.states[self.port] = state
self.__device.port = self.__device.states

return True
except Exception as ex:
Expand Down

0 comments on commit 28f7eb0

Please sign in to comment.