mirror of
https://github.com/home-assistant/core.git
synced 2025-07-12 07:47:08 +00:00
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
This commit is contained in:
parent
71aa1a2f3c
commit
dd4611064f
@ -10,7 +10,6 @@ import socket
|
|||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.config_validation import ensure_list
|
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
EVENT_HOMEASSISTANT_START, EVENT_HOMEASSISTANT_STOP, CONF_HOST, CONF_PORT,
|
EVENT_HOMEASSISTANT_START, EVENT_HOMEASSISTANT_STOP, CONF_HOST, CONF_PORT,
|
||||||
CONF_WHITELIST)
|
CONF_WHITELIST)
|
||||||
@ -29,7 +28,10 @@ EVENT = 'pilight_received'
|
|||||||
|
|
||||||
# The pilight code schema depends on the protocol
|
# The pilight code schema depends on the protocol
|
||||||
# Thus only require to have the protocol information
|
# 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)
|
extra=vol.ALLOW_EXTRA)
|
||||||
SERVICE_NAME = 'send'
|
SERVICE_NAME = 'send'
|
||||||
|
|
||||||
@ -71,12 +73,9 @@ def setup(hass, config):
|
|||||||
|
|
||||||
def send_code(call):
|
def send_code(call):
|
||||||
"""Send RF code to the pilight-daemon."""
|
"""Send RF code to the pilight-daemon."""
|
||||||
message_data = call.data
|
# Change type to dict from mappingproxy
|
||||||
|
# since data has to be JSON serializable
|
||||||
# Patch data because of bug:
|
message_data = dict(call.data)
|
||||||
# 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'])
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
pilight_client.send_code(message_data)
|
pilight_client.send_code(message_data)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user