From 38e7b597d6212dd8b0e2efa4429d394b51c0b923 Mon Sep 17 00:00:00 2001 From: mtl010957 Date: Tue, 26 Feb 2019 12:35:45 -0500 Subject: [PATCH] Add handling for min power output setting (#448) * Add handling for min power output setting * Fix line length error --- esphome/components/output/__init__.py | 6 +++++- esphome/const.py | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/esphome/components/output/__init__.py b/esphome/components/output/__init__.py index fde09ab321..a79a88ff04 100644 --- a/esphome/components/output/__init__.py +++ b/esphome/components/output/__init__.py @@ -3,7 +3,8 @@ import voluptuous as vol from esphome.automation import ACTION_REGISTRY, maybe_simple_id from esphome.components.power_supply import PowerSupplyComponent import esphome.config_validation as cv -from esphome.const import CONF_ID, CONF_INVERTED, CONF_LEVEL, CONF_MAX_POWER, CONF_POWER_SUPPLY +from esphome.const import CONF_ID, CONF_INVERTED, CONF_LEVEL, CONF_MAX_POWER, \ + CONF_MIN_POWER, CONF_POWER_SUPPLY from esphome.core import CORE from esphome.cpp_generator import Pvariable, add, get_variable, templatable from esphome.cpp_types import Action, esphome_ns, float_ @@ -21,6 +22,7 @@ BINARY_OUTPUT_PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(BINARY_OUTPUT_SCHEMA.sche FLOAT_OUTPUT_SCHEMA = BINARY_OUTPUT_SCHEMA.extend({ vol.Optional(CONF_MAX_POWER): cv.percentage, + vol.Optional(CONF_MIN_POWER): cv.percentage, }) FLOAT_OUTPUT_PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(FLOAT_OUTPUT_SCHEMA.schema) @@ -47,6 +49,8 @@ def setup_output_platform_(obj, config, skip_power_supply=False): add(obj.set_power_supply(power_supply)) if CONF_MAX_POWER in config: add(obj.set_max_power(config[CONF_MAX_POWER])) + if CONF_MIN_POWER in config: + add(obj.set_min_power(config[CONF_MIN_POWER])) def setup_output_platform(obj, config, skip_power_supply=False): diff --git a/esphome/const.py b/esphome/const.py index 7cb3376d4a..0a82539a84 100644 --- a/esphome/const.py +++ b/esphome/const.py @@ -414,6 +414,7 @@ CONF_USE_ADDRESS = 'use_address' CONF_FROM = 'from' CONF_TO = 'to' CONF_SEGMENTS = 'segments' +CONF_MIN_POWER = 'min_power' ALLOWED_NAME_CHARS = u'abcdefghijklmnopqrstuvwxyz0123456789_' ARDUINO_VERSION_ESP32_DEV = 'https://github.com/platformio/platform-espressif32.git#feature/stage'