mirror of
https://github.com/esphome/esphome.git
synced 2024-12-04 12:38:17 +01:00
69879920eb
* Add black Update pre commit Update pre commit add empty line * Format with black
30 lines
1 KiB
Python
30 lines
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]))
|