From 39a520f552917582388d3a1766d514cc088355be Mon Sep 17 00:00:00 2001 From: Samuel Sieb Date: Tue, 12 Nov 2019 13:24:13 -0800 Subject: [PATCH] add position reporting to the template cover (#821) * add position reporting to the template cover * remove duplicate import * use config flag instead Co-authored-by: Samuel Sieb --- esphome/components/template/cover/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/esphome/components/template/cover/__init__.py b/esphome/components/template/cover/__init__.py index 13370d749c..7a60096d85 100644 --- a/esphome/components/template/cover/__init__.py +++ b/esphome/components/template/cover/__init__.py @@ -16,11 +16,14 @@ RESTORE_MODES = { 'RESTORE_AND_CALL': TemplateCoverRestoreMode.COVER_RESTORE_AND_CALL, } +CONF_HAS_POSITION = 'has_position' + CONFIG_SCHEMA = cover.COVER_SCHEMA.extend({ cv.GenerateID(): cv.declare_id(TemplateCover), cv.Optional(CONF_LAMBDA): cv.returning_lambda, cv.Optional(CONF_OPTIMISTIC, default=False): cv.boolean, cv.Optional(CONF_ASSUMED_STATE, default=False): cv.boolean, + cv.Optional(CONF_HAS_POSITION, default=False): cv.boolean, cv.Optional(CONF_OPEN_ACTION): automation.validate_automation(single=True), cv.Optional(CONF_CLOSE_ACTION): automation.validate_automation(single=True), cv.Optional(CONF_STOP_ACTION): automation.validate_automation(single=True), @@ -56,6 +59,7 @@ def to_code(config): cg.add(var.set_optimistic(config[CONF_OPTIMISTIC])) cg.add(var.set_assumed_state(config[CONF_ASSUMED_STATE])) cg.add(var.set_restore_mode(config[CONF_RESTORE_MODE])) + cg.add(var.set_has_position(config[CONF_HAS_POSITION])) @automation.register_action('cover.template.publish', cover.CoverPublishAction, cv.Schema({