From 56155740fe4391845ac75f4bab4ff9e3d4368787 Mon Sep 17 00:00:00 2001 From: Johann Kellerman Date: Mon, 17 Jun 2019 18:26:35 +0200 Subject: [PATCH] SMA sensor: Add optional path (#24558) --- homeassistant/components/sma/sensor.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/sma/sensor.py b/homeassistant/components/sma/sensor.py index 9f33e236186..0ef2926eb2d 100644 --- a/homeassistant/components/sma/sensor.py +++ b/homeassistant/components/sma/sensor.py @@ -8,7 +8,7 @@ import voluptuous as vol from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.const import ( CONF_HOST, CONF_PASSWORD, CONF_SCAN_INTERVAL, CONF_SSL, CONF_VERIFY_SSL, - EVENT_HOMEASSISTANT_STOP) + EVENT_HOMEASSISTANT_STOP, CONF_PATH) from homeassistant.helpers.aiohttp_client import async_get_clientsession import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity import Entity @@ -52,6 +52,7 @@ CUSTOM_SCHEMA = vol.Any({ vol.All(cv.string, vol.Length(min=13, max=15)), vol.Required(CONF_UNIT): cv.string, vol.Optional(CONF_FACTOR, default=1): vol.Coerce(float), + vol.Optional(CONF_PATH): vol.All(cv.ensure_list, [str]), }) PLATFORM_SCHEMA = vol.All(PLATFORM_SCHEMA.extend({ @@ -79,7 +80,8 @@ async def async_setup_platform( sensor_def = pysma.Sensors() # Sensor from the custom config - sensor_def.add([pysma.Sensor(o[CONF_KEY], n, o[CONF_UNIT], o[CONF_FACTOR]) + sensor_def.add([pysma.Sensor(o[CONF_KEY], n, o[CONF_UNIT], o[CONF_FACTOR], + o.get(CONF_PATH)) for n, o in config[CONF_CUSTOM].items()]) # Use all sensors by default