mirror of
https://github.com/esphome/esphome.git
synced 2024-11-27 09:18:00 +01:00
Add Switch power_on_value option
This commit is contained in:
parent
6a24145be6
commit
94f4f3e239
4 changed files with 13 additions and 4 deletions
|
@ -3,14 +3,15 @@ import voluptuous as vol
|
||||||
from esphomeyaml import pins
|
from esphomeyaml import pins
|
||||||
import esphomeyaml.config_validation as cv
|
import esphomeyaml.config_validation as cv
|
||||||
from esphomeyaml.components import output
|
from esphomeyaml.components import output
|
||||||
from esphomeyaml.const import CONF_ID, CONF_PIN
|
from esphomeyaml.const import CONF_ID, CONF_PIN, CONF_POWER_ON_VALUE
|
||||||
from esphomeyaml.helpers import App, Pvariable, gpio_output_pin_expression
|
from esphomeyaml.helpers import App, Pvariable, gpio_output_pin_expression, add
|
||||||
|
|
||||||
GPIOBinaryOutputComponent = output.output_ns.GPIOBinaryOutputComponent
|
GPIOBinaryOutputComponent = output.output_ns.GPIOBinaryOutputComponent
|
||||||
|
|
||||||
PLATFORM_SCHEMA = output.BINARY_OUTPUT_PLATFORM_SCHEMA.extend({
|
PLATFORM_SCHEMA = output.BINARY_OUTPUT_PLATFORM_SCHEMA.extend({
|
||||||
vol.Required(CONF_ID): cv.declare_variable_id(GPIOBinaryOutputComponent),
|
vol.Required(CONF_ID): cv.declare_variable_id(GPIOBinaryOutputComponent),
|
||||||
vol.Required(CONF_PIN): pins.gpio_output_pin_schema,
|
vol.Required(CONF_PIN): pins.gpio_output_pin_schema,
|
||||||
|
vol.Optional(CONF_POWER_ON_VALUE): cv.boolean,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,6 +21,8 @@ def to_code(config):
|
||||||
yield
|
yield
|
||||||
rhs = App.make_gpio_output(pin)
|
rhs = App.make_gpio_output(pin)
|
||||||
gpio = Pvariable(config[CONF_ID], rhs)
|
gpio = Pvariable(config[CONF_ID], rhs)
|
||||||
|
if CONF_POWER_ON_VALUE in config:
|
||||||
|
add(gpio.set_power_on_value(config[CONF_POWER_ON_VALUE]))
|
||||||
output.setup_output_platform(gpio, config)
|
output.setup_output_platform(gpio, config)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,14 +3,15 @@ import voluptuous as vol
|
||||||
import esphomeyaml.config_validation as cv
|
import esphomeyaml.config_validation as cv
|
||||||
from esphomeyaml import pins
|
from esphomeyaml import pins
|
||||||
from esphomeyaml.components import switch
|
from esphomeyaml.components import switch
|
||||||
from esphomeyaml.const import CONF_MAKE_ID, CONF_NAME, CONF_PIN
|
from esphomeyaml.const import CONF_MAKE_ID, CONF_NAME, CONF_PIN, CONF_POWER_ON_VALUE
|
||||||
from esphomeyaml.helpers import App, Application, gpio_output_pin_expression, variable
|
from esphomeyaml.helpers import App, Application, gpio_output_pin_expression, variable, add
|
||||||
|
|
||||||
MakeGPIOSwitch = Application.MakeGPIOSwitch
|
MakeGPIOSwitch = Application.MakeGPIOSwitch
|
||||||
|
|
||||||
PLATFORM_SCHEMA = cv.nameable(switch.SWITCH_PLATFORM_SCHEMA.extend({
|
PLATFORM_SCHEMA = cv.nameable(switch.SWITCH_PLATFORM_SCHEMA.extend({
|
||||||
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeGPIOSwitch),
|
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeGPIOSwitch),
|
||||||
vol.Required(CONF_PIN): pins.gpio_output_pin_schema,
|
vol.Required(CONF_PIN): pins.gpio_output_pin_schema,
|
||||||
|
vol.Optional(CONF_POWER_ON_VALUE): cv.boolean,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,6 +21,8 @@ def to_code(config):
|
||||||
yield
|
yield
|
||||||
rhs = App.make_gpio_switch(config[CONF_NAME], pin)
|
rhs = App.make_gpio_switch(config[CONF_NAME], pin)
|
||||||
gpio = variable(config[CONF_MAKE_ID], rhs)
|
gpio = variable(config[CONF_MAKE_ID], rhs)
|
||||||
|
if CONF_POWER_ON_VALUE in config:
|
||||||
|
add(gpio.Pgpio.set_power_on_value(config[CONF_POWER_ON_VALUE]))
|
||||||
switch.setup_switch(gpio.Pswitch_, gpio.Pmqtt, config)
|
switch.setup_switch(gpio.Pswitch_, gpio.Pmqtt, config)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -340,6 +340,7 @@ CONF_MONTHS = 'months'
|
||||||
CONF_DAYS_OF_WEEK = 'days_of_week'
|
CONF_DAYS_OF_WEEK = 'days_of_week'
|
||||||
CONF_CRON = 'cron'
|
CONF_CRON = 'cron'
|
||||||
CONF_POWER_SAVE_MODE = 'power_save_mode'
|
CONF_POWER_SAVE_MODE = 'power_save_mode'
|
||||||
|
CONF_POWER_ON_VALUE = 'power_on_value'
|
||||||
|
|
||||||
ALLOWED_NAME_CHARS = u'abcdefghijklmnopqrstuvwxyz0123456789_'
|
ALLOWED_NAME_CHARS = u'abcdefghijklmnopqrstuvwxyz0123456789_'
|
||||||
ARDUINO_VERSION_ESP32_DEV = 'https://github.com/platformio/platform-espressif32.git#feature/stage'
|
ARDUINO_VERSION_ESP32_DEV = 'https://github.com/platformio/platform-espressif32.git#feature/stage'
|
||||||
|
|
|
@ -522,6 +522,7 @@ output:
|
||||||
id: gpio_26
|
id: gpio_26
|
||||||
power_supply: atx_power_supply
|
power_supply: atx_power_supply
|
||||||
inverted: False
|
inverted: False
|
||||||
|
power_on_value: True
|
||||||
- platform: ledc
|
- platform: ledc
|
||||||
pin: 19
|
pin: 19
|
||||||
id: gpio_19
|
id: gpio_19
|
||||||
|
@ -688,6 +689,7 @@ switch:
|
||||||
icon: "mdi:restart"
|
icon: "mdi:restart"
|
||||||
inverted: True
|
inverted: True
|
||||||
command_topic: custom_command_topic
|
command_topic: custom_command_topic
|
||||||
|
power_on_value: True
|
||||||
- platform: remote_transmitter
|
- platform: remote_transmitter
|
||||||
name: "Panasonic TV Off"
|
name: "Panasonic TV Off"
|
||||||
nec:
|
nec:
|
||||||
|
|
Loading…
Reference in a new issue