pycirculate
pycirculate copied to clipboard
Doesn't work properly with python3
I was looking into using this for home-assistant. In the process I noticed that it doesn't work properly with python3.
Traceback (most recent call last):
File "anova.py", line 13, in <module>
print(anova.read_unit())
File "/srv/hass/lib/python3.4/site-packages/pycirculate/anova.py", line 74, in read_unit
return self.send_command_async("read unit")
File "/srv/hass/lib/python3.4/site-packages/pycirculate/anova.py", line 64, in send_command_async
self._send_command(command)
File "/srv/hass/lib/python3.4/site-packages/pycirculate/anova.py", line 54, in _send_command
self.characteristic.write(command)
File "/srv/hass/lib/python3.4/site-packages/bluepy/btle.py", line 148, in write
self.peripheral.writeCharacteristic(self.valHandle, val, withResponse)
File "/srv/hass/lib/python3.4/site-packages/bluepy/btle.py", line 458, in writeCharacteristic
self._writeCmd("%s %X %s\n" % (cmd, handle, binascii.b2a_hex(val).decode('utf-8')))
TypeError: 'str' does not support the buffer interface
Making this change appears to fix it (although I don't know what it does to python2)
diff --git a/pycirculate/anova.py b/pycirculate/anova.py
index 3d39c25..b863a83 100644
--- a/pycirculate/anova.py
+++ b/pycirculate/anova.py
@@ -59,7 +59,7 @@ class AnovaController(object):
def _send_command(self, command):
command = "{0}\r".format(command)
- self.characteristic.write(command)
+ self.characteristic.write(bytes(command, 'UTF-8'))
def _read(self):
#self.characteristic.read()
Pull requests welcome. Maybe use https://pypi.python.org/pypi/six for Python 2/3 compatibility.
@superm1 Did you get it into Home Assistant?
No I didn't. I ran into other troubles that were taking longer to debug so I got distracted.
Please tell us when/if you get this to work