Skip to content

Commit

Permalink
Update station.py
Browse files Browse the repository at this point in the history
  • Loading branch information
EdLeckert authored Oct 12, 2024
1 parent 1586170 commit 6cf159e
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions pyopensprinkler/station.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,22 @@ def _bit_check(self, bit_property):
return bool(bits[position])

async def _bit_set(self, bit_property, bit_update_name, value):
bits = self._controller._state["stations"][bit_property]
_LOGGER.debug(f"Station {self.name}, _bit_set before: {bits}; type={type(bits)}")
bit_list = self._controller._state["stations"][bit_property]
_LOGGER.debug(f"Station {self.name}, _bit_set before: {bit_list}; type={type(bit_list)}")
bank = math.floor(self._index / 8)
bits = list(reversed([int(x) for x in list("{0:08b}".format(bits[bank]))]))
bits = list(reversed([int(x) for x in list("{0:08b}".format(bit_list[bank]))]))
_LOGGER.debug(f"bits1: {bits})
position = self._index % 8
value = int(value)
bits[position] = value
_LOGGER.debug(f"bits[position]: {bits[position]})
bits = list(reversed(bits))
_LOGGER.debug(f"bits2: {bits})
bits = "".join(map(str, bits))
_LOGGER.debug(f"bits3: {bits})
bits = int(bits, 2)
self._controller._state["stations"][bit_property] = bits
_LOGGER.debug(f"bits4: {bits})
self._controller._state["stations"][bit_property] = list(bits)
_LOGGER.debug(f"Station {self.name}, _bit_set after: {bits}")
return await self._set_attribute(bit_update_name + str(bank), bits)

Expand Down

0 comments on commit 6cf159e

Please sign in to comment.