From 8424f9c34b8fac2362670d391869a808eac46497 Mon Sep 17 00:00:00 2001 From: Otto Winter Date: Fri, 18 Jan 2019 11:16:53 +0100 Subject: [PATCH] Fix expire_after requires MQTT (#354) Fixes https://github.com/OttoWinter/esphomelib/issues/372 --- esphomeyaml/components/sensor/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/esphomeyaml/components/sensor/__init__.py b/esphomeyaml/components/sensor/__init__.py index 5f8f52152f..f19571c457 100644 --- a/esphomeyaml/components/sensor/__init__.py +++ b/esphomeyaml/components/sensor/__init__.py @@ -100,7 +100,8 @@ SENSOR_SCHEMA = cv.MQTT_COMPONENT_SCHEMA.extend({ vol.Optional(CONF_UNIT_OF_MEASUREMENT): cv.string_strict, vol.Optional(CONF_ICON): cv.icon, vol.Optional(CONF_ACCURACY_DECIMALS): vol.Coerce(int), - vol.Optional(CONF_EXPIRE_AFTER): vol.Any(None, cv.positive_time_period_milliseconds), + vol.Optional(CONF_EXPIRE_AFTER): vol.All(cv.requires_component('mqtt'), + vol.Any(None, cv.positive_time_period_milliseconds)), vol.Optional(CONF_FILTERS): FILTERS_SCHEMA, vol.Optional(CONF_ON_VALUE): automation.validate_automation({ cv.GenerateID(CONF_TRIGGER_ID): cv.declare_variable_id(SensorStateTrigger),