mirror of
https://github.com/esphome/esphome.git
synced 2024-12-02 11:44:13 +01:00
8e75980ebd
* Cleanup dashboard JS * Add vscode * Save start_mark/end_mark * Updates * Updates * Remove need for cv.nameable It's a bit hacky but removes so much bloat from integrations * Add enum helper * Document APIs, and Improvements * Fixes * Fixes * Update PULL_REQUEST_TEMPLATE.md * Updates * Updates * Updates
26 lines
1.1 KiB
Python
26 lines
1.1 KiB
Python
import esphome.codegen as cg
|
|
import esphome.config_validation as cv
|
|
from esphome import pins
|
|
from esphome.components import remote_base
|
|
from esphome.const import CONF_CARRIER_DUTY_PERCENT, CONF_ID, CONF_PIN
|
|
|
|
AUTO_LOAD = ['remote_base']
|
|
remote_transmitter_ns = cg.esphome_ns.namespace('remote_transmitter')
|
|
RemoteTransmitterComponent = remote_transmitter_ns.class_('RemoteTransmitterComponent',
|
|
remote_base.RemoteTransmitterBase,
|
|
cg.Component)
|
|
|
|
MULTI_CONF = True
|
|
CONFIG_SCHEMA = cv.Schema({
|
|
cv.GenerateID(): cv.declare_id(RemoteTransmitterComponent),
|
|
cv.Required(CONF_PIN): pins.gpio_output_pin_schema,
|
|
cv.Required(CONF_CARRIER_DUTY_PERCENT): cv.All(cv.percentage_int, cv.Range(min=1, max=100)),
|
|
}).extend(cv.COMPONENT_SCHEMA)
|
|
|
|
|
|
def to_code(config):
|
|
pin = yield cg.gpio_pin_expression(config[CONF_PIN])
|
|
var = cg.new_Pvariable(config[CONF_ID], pin)
|
|
yield cg.register_component(var, config)
|
|
|
|
cg.add(var.set_carrier_duty_percent(config[CONF_CARRIER_DUTY_PERCENT]))
|