diff --git a/esphomeyaml/espota2.py b/esphomeyaml/espota2.py index f329c07949..d70dbb929d 100755 --- a/esphomeyaml/espota2.py +++ b/esphomeyaml/espota2.py @@ -7,7 +7,7 @@ import time from esphomeyaml.core import EsphomeyamlError from esphomeyaml.helpers import resolve_ip_address, is_ip_address -from esphomeyaml.py_compat import IS_PY2 +from esphomeyaml.py_compat import IS_PY2, char RESPONSE_OK = 0 RESPONSE_REQUEST_AUTH = 1 @@ -68,7 +68,7 @@ def recv_decode(sock, amount, decode=True): data = sock.recv(amount) if not decode: return data - return [ord(x) for x in data] + return [char(x) for x in data] def receive_exactly(sock, amount, msg, expect, decode=True): @@ -136,6 +136,8 @@ def send_check(sock, data, msg): data = bytes(data) elif isinstance(data, int): data = bytes([data]) + elif isinstance(data, str): + data = data.encode('utf8') sock.sendall(data) except socket.error as err: