From 3cc88327073e1651e01516b195a452be79522b67 Mon Sep 17 00:00:00 2001 From: Florian Derzbach Date: Sun, 14 Feb 2021 13:25:39 +0100 Subject: [PATCH 1/2] add sleep to _write_cmd Without the sleep the commands are sent too fast to the USB-Device, so map and toggle won't work, neither from cli nor Homeassistant. --- pylacrosse/lacrosse.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pylacrosse/lacrosse.py b/pylacrosse/lacrosse.py index 5cd4316..f467bd8 100644 --- a/pylacrosse/lacrosse.py +++ b/pylacrosse/lacrosse.py @@ -19,6 +19,7 @@ import logging import re import threading +import time _LOGGER = logging.getLogger(__name__) @@ -78,6 +79,8 @@ def start_scan(self): def _write_cmd(self, cmd): """Write a cmd.""" self._serial.write(cmd.encode()) + """ensure there is enough time between commands""" + time.sleep(0.5) @staticmethod def _parse_info(line): From f04fe06f51da728a64304e88c00314b9a41842c0 Mon Sep 17 00:00:00 2001 From: Florian Derzbach Date: Sun, 14 Feb 2021 16:33:18 +0100 Subject: [PATCH 2/2] Update lacrosse.py --- pylacrosse/lacrosse.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pylacrosse/lacrosse.py b/pylacrosse/lacrosse.py index f467bd8..12495c9 100644 --- a/pylacrosse/lacrosse.py +++ b/pylacrosse/lacrosse.py @@ -77,10 +77,11 @@ def start_scan(self): self._start_worker() def _write_cmd(self, cmd): - """Write a cmd.""" - self._serial.write(cmd.encode()) """ensure there is enough time between commands""" time.sleep(0.5) + """Write a cmd.""" + self._serial.write(cmd.encode()) + @staticmethod def _parse_info(line):