Added hoermann_door.stop_polling and .start_polling as automations should that need arise somehow!
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
from esphome import pins
|
||||
from esphome import pins, automation
|
||||
from esphome.components import uart
|
||||
from esphome.const import (
|
||||
CONF_ID
|
||||
@@ -11,6 +11,8 @@ DEPENDENCIES=["uart"]
|
||||
|
||||
hoermann_door_ns = cg.esphome_ns.namespace('hoermann_door')
|
||||
HoermannDoor = hoermann_door_ns.class_('HoermannMainComponent', cg.Component)
|
||||
StopPolling = hoermann_door_ns.class_('StopPollingAction', automation.Action)
|
||||
StartPolling = hoermann_door_ns.class_('StartPollingAction', automation.Action)
|
||||
|
||||
CONF_UART_ENTRY = "uart_connection"
|
||||
CONF_TX_PIN = "tx_pin"
|
||||
@@ -43,19 +45,29 @@ CONFIG_SCHEMA = cv.All(
|
||||
validate_config
|
||||
)
|
||||
|
||||
ACTION_SCHEMA = automation.maybe_simple_id({
|
||||
cv.GenerateID(): cv.use_id(HoermannDoor)
|
||||
})
|
||||
|
||||
@automation.register_action("hoermann_door.stop_polling", StopPolling, ACTION_SCHEMA)
|
||||
async def stop_polling(config, action_id, template_arg, args):
|
||||
parent = await cg.get_variable(config[CONF_ID])
|
||||
return cg.new_Pvariable(action_id, template_arg, parent)
|
||||
|
||||
@automation.register_action("hoermann_door.start_polling", StartPolling, ACTION_SCHEMA)
|
||||
async def start_polling(config, action_id, template_arg, args):
|
||||
parent = await cg.get_variable(config[CONF_ID])
|
||||
return cg.new_Pvariable(action_id, template_arg, parent)
|
||||
|
||||
async def to_code(config):
|
||||
var = cg.new_Pvariable(config[CONF_ID])
|
||||
await cg.register_component(var, config)
|
||||
#yield mqtt.register_mqtt_component(var, config)
|
||||
|
||||
#btnReset = yield cg.gpio_pin_expression(config[CONF_SENSOR_PIN])
|
||||
#cg.add(var.set_input_pin(btnReset))
|
||||
|
||||
code = await cg.get_variable(config[CONF_UART_ENTRY])
|
||||
cg.add(var.set_seriel_connection(code))
|
||||
|
||||
code2 = await cg.gpio_pin_expression(config[CONF_TX_PIN])
|
||||
cg.add(var.set_tx_on_pin(code2)) # Needs be configured before sensor
|
||||
cg.add(var.set_tx_on_pin(code2))
|
||||
|
||||
log_level = config[CONF_LOG_LEVEL]
|
||||
cg.add(var.set_log_level(log_level))
|
Reference in New Issue
Block a user