From b4ec84030e9d35d388463824a4fd10f7e2ce1d54 Mon Sep 17 00:00:00 2001 From: Otto Winter Date: Thu, 30 May 2019 20:01:16 +0200 Subject: [PATCH] Fix validation TypeError (#574) --- esphome/py_compat.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/esphome/py_compat.py b/esphome/py_compat.py index 53c38fbb24..6833a55801 100644 --- a/esphome/py_compat.py +++ b/esphome/py_compat.py @@ -78,8 +78,12 @@ def indexbytes(buf, i): if IS_PY2: def decode_text(data, encoding='utf-8', errors='strict'): # type: (str, str, str) -> unicode + if isinstance(data, unicode): + return data return unicode(data, encoding=encoding, errors=errors) else: def decode_text(data, encoding='utf-8', errors='strict'): # type: (bytes, str, str) -> str + if isinstance(data, str): + return data return data.decode(encoding=encoding, errors=errors)