From 1dab1314ffbeab76bc3f6aa7f416a8e2fdd7c335 Mon Sep 17 00:00:00 2001 From: Otto Winter Date: Sat, 30 Mar 2019 15:47:12 +0100 Subject: [PATCH 1/5] Upgrade ESPAsyncTCP to 1.2.0 (#497) --- esphome/components/api.py | 2 +- esphome/writer.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/esphome/components/api.py b/esphome/components/api.py index 86e77bb4c6..544d0e418b 100644 --- a/esphome/components/api.py +++ b/esphome/components/api.py @@ -86,7 +86,7 @@ def lib_deps(config): if CORE.is_esp32: return 'AsyncTCP@1.0.3' if CORE.is_esp8266: - return 'ESPAsyncTCP@1.1.3' + return 'ESPAsyncTCP@1.2.0' raise NotImplementedError diff --git a/esphome/writer.py b/esphome/writer.py index 953680e467..9c2bc8fbd8 100644 --- a/esphome/writer.py +++ b/esphome/writer.py @@ -290,7 +290,7 @@ def gather_lib_deps(): lib_deps.add('AsyncTCP@1.0.1') lib_deps.add('ESPmDNS') elif CORE.is_esp8266: - lib_deps.add('ESPAsyncTCP@1.1.3') + lib_deps.add('ESPAsyncTCP@1.2.0') lib_deps.add('ESP8266mDNS') # avoid changing build flags order From 5859d4b01f523a6a1357c720dfe2592e113ebca8 Mon Sep 17 00:00:00 2001 From: Otto Winter Date: Sun, 31 Mar 2019 11:04:41 +0200 Subject: [PATCH 2/5] Fix dashboard wizard unicode (#494) * Fix dashboard wizard unicode Fixes https://github.com/esphome/issues/issues/169 * Fix password md5 --- esphome/dashboard/dashboard.py | 6 +++--- esphome/espota2.py | 2 +- esphome/py_compat.py | 10 ++++++++++ esphome/wizard.py | 2 +- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/esphome/dashboard/dashboard.py b/esphome/dashboard/dashboard.py index a70fe2add2..6c1d9f2616 100644 --- a/esphome/dashboard/dashboard.py +++ b/esphome/dashboard/dashboard.py @@ -28,7 +28,7 @@ import tornado.websocket from esphome import const from esphome.__main__ import get_serial_ports from esphome.helpers import mkdir_p, get_bool_env, run_system_command -from esphome.py_compat import IS_PY2 +from esphome.py_compat import IS_PY2, decode_text from esphome.storage_json import EsphomeStorageJSON, StorageJSON, \ esphome_storage_path, ext_storage_path, trash_storage_path from esphome.util import shlex_quote @@ -223,8 +223,8 @@ class WizardRequestHandler(BaseHandler): def post(self): from esphome import wizard - kwargs = {k: ''.join(v) for k, v in self.request.arguments.items()} - destination = os.path.join(CONFIG_DIR, kwargs['name'] + '.yaml') + kwargs = {k: u''.join(decode_text(x) for x in v) for k, v in self.request.arguments.items()} + destination = os.path.join(CONFIG_DIR, kwargs['name'] + u'.yaml') wizard.wizard_write(path=destination, **kwargs) self.redirect('/?begin=True') diff --git a/esphome/espota2.py b/esphome/espota2.py index dbe7e94313..ac0dd33ebc 100755 --- a/esphome/espota2.py +++ b/esphome/espota2.py @@ -195,7 +195,7 @@ def perform_ota(sock, password, file_handle, filename): send_check(sock, cnonce, 'auth cnonce') result_md5 = hashlib.md5() - result_md5.update(password.encode()) + result_md5.update(password.encode('utf-8')) result_md5.update(nonce.encode()) result_md5.update(cnonce.encode()) result = result_md5.hexdigest() diff --git a/esphome/py_compat.py b/esphome/py_compat.py index 16a4d27ebf..4b48aa0f88 100644 --- a/esphome/py_compat.py +++ b/esphome/py_compat.py @@ -69,3 +69,13 @@ def indexbytes(buf, i): return buf[i] else: return ord(buf[i]) + + +if IS_PY2: + def decode_text(data, encoding='utf-8', errors='strict'): + # type: (str, str, str) -> unicode + return unicode(data, encoding='utf-8', errors=errors) +else: + def decode_text(data, encoding='utf-8', errors='strict'): + # type: (bytes, str, str) -> str + return data.decode(encoding='utf-8', errors=errors) diff --git a/esphome/wizard.py b/esphome/wizard.py index a2401584a1..abc2270235 100644 --- a/esphome/wizard.py +++ b/esphome/wizard.py @@ -79,7 +79,7 @@ def wizard_write(path, **kwargs): kwargs['platform'] = 'ESP8266' if board in ESP8266_BOARD_PINS else 'ESP32' platform = kwargs['platform'] - with codecs.open(path, 'w') as f_handle: + with codecs.open(path, 'w', 'utf-8') as f_handle: f_handle.write(wizard_file(**kwargs)) storage = StorageJSON.from_wizard(name, name + '.local', platform, board) storage_path = ext_storage_path(os.path.dirname(path), os.path.basename(path)) From 5b0d30bc0920c509215e2aedcc571b83a60dcad2 Mon Sep 17 00:00:00 2001 From: Otto Winter Date: Sun, 31 Mar 2019 11:04:57 +0200 Subject: [PATCH 3/5] Fix text sensor MQTT settings (#495) Fixes https://github.com/esphome/issues/issues/170 --- esphome/components/text_sensor/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/components/text_sensor/__init__.py b/esphome/components/text_sensor/__init__.py index a4a6caec26..1aff0c1e3b 100644 --- a/esphome/components/text_sensor/__init__.py +++ b/esphome/components/text_sensor/__init__.py @@ -46,7 +46,7 @@ def setup_text_sensor_core_(text_sensor_var, config): trigger = Pvariable(conf[CONF_TRIGGER_ID], rhs) automation.build_automations(trigger, [(std_string, 'x')], conf) - setup_mqtt_component(text_sensor_var.get_mqtt(), config) + setup_mqtt_component(text_sensor_var.Pget_mqtt(), config) def setup_text_sensor(text_sensor_obj, config): From 0272048899af4da65e7392988cb1d7a5568bb45e Mon Sep 17 00:00:00 2001 From: Otto Winter Date: Sun, 31 Mar 2019 12:25:44 +0200 Subject: [PATCH 4/5] Upgrade docker base image to 1.4.3 (#499) --- .gitlab-ci.yml | 4 ++-- docker/Dockerfile | 2 +- docker/Dockerfile.hassio | 2 +- docker/hooks/build | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0cc29416c9..f4e2fa40af 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -41,11 +41,11 @@ stages: - | if [[ "${IS_HASSIO}" == "YES" ]]; then - BUILD_FROM=esphome/esphome-hassio-base-${BUILD_ARCH}:1.4.1 + BUILD_FROM=esphome/esphome-hassio-base-${BUILD_ARCH}:1.4.3 BUILD_TO=esphome/esphome-hassio-${BUILD_ARCH} DOCKERFILE=docker/Dockerfile.hassio else - BUILD_FROM=esphome/esphome-base-${BUILD_ARCH}:1.4.1 + BUILD_FROM=esphome/esphome-base-${BUILD_ARCH}:1.4.3 if [[ "${BUILD_ARCH}" == "amd64" ]]; then BUILD_TO=esphome/esphome else diff --git a/docker/Dockerfile b/docker/Dockerfile index 2568ef37f3..0416f2496e 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,4 +1,4 @@ -ARG BUILD_FROM=esphome/esphome-base-amd64:1.4.1 +ARG BUILD_FROM=esphome/esphome-base-amd64:1.4.3 FROM ${BUILD_FROM} COPY . . diff --git a/docker/Dockerfile.hassio b/docker/Dockerfile.hassio index 95888739bd..eaa7d9d504 100644 --- a/docker/Dockerfile.hassio +++ b/docker/Dockerfile.hassio @@ -1,4 +1,4 @@ -ARG BUILD_FROM=esphome/esphome-hassio-base-amd64:1.4.1 +ARG BUILD_FROM=esphome/esphome-hassio-base-amd64:1.4.3 FROM ${BUILD_FROM} # Copy root filesystem diff --git a/docker/hooks/build b/docker/hooks/build index 083c5c50a8..60879aaa88 100755 --- a/docker/hooks/build +++ b/docker/hooks/build @@ -16,11 +16,11 @@ echo "PWD: $PWD" if [[ ${IS_HASSIO} = "YES" ]]; then docker build \ - --build-arg "BUILD_FROM=esphome/esphome-hassio-base-${BUILD_ARCH}:1.4.1" \ + --build-arg "BUILD_FROM=esphome/esphome-hassio-base-${BUILD_ARCH}:1.4.3" \ --build-arg "BUILD_VERSION=${CACHE_TAG}" \ -t "${IMAGE_NAME}" -f ../docker/Dockerfile.hassio .. else docker build \ - --build-arg "BUILD_FROM=esphome/esphome-base-${BUILD_ARCH}:1.4.1" \ + --build-arg "BUILD_FROM=esphome/esphome-base-${BUILD_ARCH}:1.4.3" \ -t "${IMAGE_NAME}" -f ../docker/Dockerfile .. fi From cb9f36a15373466e59e97ebeec64e19cd5f50fd5 Mon Sep 17 00:00:00 2001 From: Michiel van Turnhout Date: Sun, 31 Mar 2019 19:00:39 +0200 Subject: [PATCH 5/5] TTP229-LSF i2c device support (#489) * setting up non i2c ttp229 * add component * fixed const and multiconf * fixed issues with i2c address (it is fixed for this device renamed component and platform to ttp229_lsf => i2c device. There is another ttp229_bsf device that uses a proprietary bus protocol * max channels is 0 to 15 * folow up on code review * fixed Component ttf229_lsf --- .../components/binary_sensor/ttp229_lsf.py | 24 ++++++++++++++++++ esphome/components/ttp229_lsf.py | 25 +++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 esphome/components/binary_sensor/ttp229_lsf.py create mode 100644 esphome/components/ttp229_lsf.py diff --git a/esphome/components/binary_sensor/ttp229_lsf.py b/esphome/components/binary_sensor/ttp229_lsf.py new file mode 100644 index 0000000000..76ea5091ed --- /dev/null +++ b/esphome/components/binary_sensor/ttp229_lsf.py @@ -0,0 +1,24 @@ +import voluptuous as vol + +from esphome.components import binary_sensor +from esphome.components.ttp229_lsf import TTP229LSFComponent, CONF_TTP229_ID +import esphome.config_validation as cv +from esphome.const import CONF_CHANNEL, CONF_NAME +from esphome.cpp_generator import get_variable + +DEPENDENCIES = ['ttp229_lsf'] +TTP229Channel = binary_sensor.binary_sensor_ns.class_( + 'TTP229Channel', binary_sensor.BinarySensor) + +PLATFORM_SCHEMA = cv.nameable(binary_sensor.BINARY_SENSOR_PLATFORM_SCHEMA.extend({ + cv.GenerateID(): cv.declare_variable_id(TTP229Channel), + cv.GenerateID(CONF_TTP229_ID): cv.use_variable_id(TTP229LSFComponent), + vol.Required(CONF_CHANNEL): vol.All(vol.Coerce(int), vol.Range(min=0, max=15)) +})) + + +def to_code(config): + for hub in get_variable(config[CONF_TTP229_ID]): + yield + rhs = TTP229Channel.new(config[CONF_NAME], config[CONF_CHANNEL]) + binary_sensor.register_binary_sensor(hub.add_channel(rhs), config) diff --git a/esphome/components/ttp229_lsf.py b/esphome/components/ttp229_lsf.py new file mode 100644 index 0000000000..e945066a59 --- /dev/null +++ b/esphome/components/ttp229_lsf.py @@ -0,0 +1,25 @@ +from esphome.components import binary_sensor +import esphome.config_validation as cv +from esphome.const import CONF_ID +from esphome.cpp_generator import Pvariable +from esphome.cpp_helpers import setup_component +from esphome.cpp_types import App, Component + +DEPENDENCIES = ['i2c'] + +CONF_TTP229_ID = 'ttp229_id' +TTP229LSFComponent = binary_sensor.binary_sensor_ns.class_('TTP229LSFComponent', Component) + +CONFIG_SCHEMA = cv.Schema({ + cv.GenerateID(): cv.declare_variable_id(TTP229LSFComponent), +}).extend(cv.COMPONENT_SCHEMA.schema) + + +def to_code(config): + rhs = App.make_ttp229_lsf() + var = Pvariable(config[CONF_ID], rhs) + + setup_component(var, config) + + +BUILD_FLAGS = '-DUSE_TTP229_LSF'