From e21382cd3e810e152f5f3191fa4fd407d84b3213 Mon Sep 17 00:00:00 2001 From: rubund Date: Mon, 5 Dec 2016 17:15:36 +0100 Subject: [PATCH] Fix broken EnOcean support (#4710) * ensure_list * CONF_ID is not required configuration for enocean lights * Use vol.All(cv.ensure_list, [vol.Coerce(int)]) as suggested in pull request review * Fix line too long --- homeassistant/components/binary_sensor/enocean.py | 2 +- homeassistant/components/light/enocean.py | 5 +++-- homeassistant/components/sensor/enocean.py | 2 +- homeassistant/components/switch/enocean.py | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/binary_sensor/enocean.py b/homeassistant/components/binary_sensor/enocean.py index 631ed0021e1..bd68a232f22 100644 --- a/homeassistant/components/binary_sensor/enocean.py +++ b/homeassistant/components/binary_sensor/enocean.py @@ -20,7 +20,7 @@ DEPENDENCIES = ['enocean'] DEFAULT_NAME = 'EnOcean binary sensor' PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ - vol.Required(CONF_ID): cv.string, + vol.Required(CONF_ID): vol.All(cv.ensure_list, [vol.Coerce(int)]), vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, vol.Optional(CONF_SENSOR_CLASS, default=None): SENSOR_CLASSES_SCHEMA, }) diff --git a/homeassistant/components/light/enocean.py b/homeassistant/components/light/enocean.py index ce65d8cc041..e24aca4902d 100644 --- a/homeassistant/components/light/enocean.py +++ b/homeassistant/components/light/enocean.py @@ -26,8 +26,9 @@ DEPENDENCIES = ['enocean'] SUPPORT_ENOCEAN = SUPPORT_BRIGHTNESS PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ - vol.Required(CONF_ID): cv.string, - vol.Required(CONF_SENDER_ID): cv.string, + vol.Optional(CONF_ID, default=[]): vol.All(cv.ensure_list, + [vol.Coerce(int)]), + vol.Required(CONF_SENDER_ID): vol.All(cv.ensure_list, [vol.Coerce(int)]), vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, }) diff --git a/homeassistant/components/sensor/enocean.py b/homeassistant/components/sensor/enocean.py index e998b5c9c46..009718dd720 100644 --- a/homeassistant/components/sensor/enocean.py +++ b/homeassistant/components/sensor/enocean.py @@ -20,7 +20,7 @@ DEFAULT_NAME = 'EnOcean sensor' DEPENDENCIES = ['enocean'] PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ - vol.Required(CONF_ID): cv.string, + vol.Required(CONF_ID): vol.All(cv.ensure_list, [vol.Coerce(int)]), vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, }) diff --git a/homeassistant/components/switch/enocean.py b/homeassistant/components/switch/enocean.py index 71bd180ad10..ead5d789bbd 100644 --- a/homeassistant/components/switch/enocean.py +++ b/homeassistant/components/switch/enocean.py @@ -20,7 +20,7 @@ DEFAULT_NAME = 'EnOcean Switch' DEPENDENCIES = ['enocean'] PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ - vol.Required(CONF_ID): cv.string, + vol.Required(CONF_ID): vol.All(cv.ensure_list, [vol.Coerce(int)]), vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, })