From 6959407dfdf726edd8488dec39830c1d657cdd4d Mon Sep 17 00:00:00 2001 From: David-Leon Pohl <pohl@physik.uni-bonn.de> Date: Tue, 13 Sep 2016 03:28:11 +0200 Subject: [PATCH] Bugfix pilight component (#3355) * BUG Message data cannot be changed thus use voluptuous to ensure format * Pilight daemon expects JSON serializable data Thus dict is needed and not a mapping proxy. * Add explanation why dict as message data is needed * Use more obvious voluptuous validation scheme * Pylint: Trailing whitespace --- homeassistant/components/pilight.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/pilight.py b/homeassistant/components/pilight.py index 764b972d393..3475a6be65a 100644 --- a/homeassistant/components/pilight.py +++ b/homeassistant/components/pilight.py @@ -10,7 +10,6 @@ import socket import voluptuous as vol import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.config_validation import ensure_list from homeassistant.const import ( EVENT_HOMEASSISTANT_START, EVENT_HOMEASSISTANT_STOP, CONF_HOST, CONF_PORT, CONF_WHITELIST) @@ -29,7 +28,10 @@ EVENT = 'pilight_received' # The pilight code schema depends on the protocol # Thus only require to have the protocol information -RF_CODE_SCHEMA = vol.Schema({vol.Required(ATTR_PROTOCOL): cv.string}, +# Ensure that protocol is in a list otherwise segfault in pilight-daemon +# https://github.com/pilight/pilight/issues/296 +RF_CODE_SCHEMA = vol.Schema({vol.Required(ATTR_PROTOCOL): + vol.All(cv.ensure_list, [cv.string])}, extra=vol.ALLOW_EXTRA) SERVICE_NAME = 'send' @@ -71,12 +73,9 @@ def setup(hass, config): def send_code(call): """Send RF code to the pilight-daemon.""" - message_data = call.data - - # Patch data because of bug: - # https://github.com/pilight/pilight/issues/296 - # Protocol has to be in a list otherwise segfault in pilight-daemon - message_data['protocol'] = ensure_list(message_data['protocol']) + # Change type to dict from mappingproxy + # since data has to be JSON serializable + message_data = dict(call.data) try: pilight_client.send_code(message_data) -- GitLab