Skip to content

Commit

Permalink
Refactor JA-80T confirm
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsaxon committed Mar 20, 2022
1 parent c6c0186 commit bbdf43f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions custom_components/jablotron80/jablotron.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,12 @@ def is_connected(self) -> bool:

def add_command(self, command: JablotronCommand) -> None:
LOGGER.debug(f'Adding command {command}')

# for JA-80T, when putting in key presses, these are not echoed back, just an \xff
if self._type == CABLE_MODEL_JA80T:
if command.code == command.confirm_prefix:
command.confirm_prefix = b'\xff'

self._cmd_q.put(command)

def _get_command(self) -> Union[JablotronCommand,None]:
Expand Down Expand Up @@ -769,9 +775,7 @@ def read_send_packet_loop(self) -> None:
records_tmp = self._read_data()
self._forward_records(records_tmp)
for record in records_tmp:
if (self._type == CABLE_MODEL_JA82T and record[:len(send_cmd.confirm_prefix)] == send_cmd.confirm_prefix) \
or (self._type == CABLE_MODEL_JA80T and (send_cmd.confirm_prefix == send_cmd.code or \
record[:len(send_cmd.confirm_prefix)] == send_cmd.confirm_prefix)):
if record[:len(send_cmd.confirm_prefix)] == send_cmd.confirm_prefix:
LOGGER.info(
f"confirmation for command {send_cmd} received")
confirmed=True
Expand Down

0 comments on commit bbdf43f

Please sign in to comment.