Running
Pytomation on a Pi v3 Raspbian GNU/Linux 10 (buster) with Python 3.8.11.
I implemented a NamedPipe interface and determined that ha_interface.py raised a silent exception in _readInterface.
The exception that occurred was: can only concatenate str (not "bytes") to str
As a quick fix, I added .decode('utf-8') to the result in named_pipe.py
diff --git a/pytomation/interfaces/named_pipe.py b/pytomation/interfaces/named_pipe.py
index a86e9b0..3793836 100644
--- a/pytomation/interfaces/named_pipe.py
+++ b/pytomation/interfaces/named_pipe.py
@@ -31,7 +31,7 @@ class NamedPipe(Interface):
def read(self, bufferSize=1024):
result = ''
try:
- result = os.read(self._pipe, bufferSize)
+ result = os.read(self._pipe, bufferSize).decode('utf-8')
except OSError as ex:
self._logger.debug('Nothing to read in pipe: %s' % ex)
except Exception as ex:
I referenced this guide to learn about the differences in File I/O in Python 2 vs 3.
A better solution may be to open the pipe in a mode that returns a str instead of bytes.
Thoughts?