mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-06-01 10:38:27 +02:00
7b9c2d2978
* Added options to control pulse duration on Climate_IR_LG Component. This is usefull as some equipment from LG (Tested in Brazil AC unit) use different pulse durations in their protocol. * Fixed C++ linting issues * Fixed Python linting issues * fixed spaces on parameters linting issue * fixed spacing clint * Removed unused constants * Removed wrong spacing * Changed int to time period in all new fields Changed cv._int to cv.positive_time_period_microseconds in the time definitions for the new options * Fixed the time defaults Time defaults fixed for Climate_IR_LG.
36 lines
1.4 KiB
Python
36 lines
1.4 KiB
Python
import esphome.codegen as cg
|
|
import esphome.config_validation as cv
|
|
from esphome.components import climate_ir
|
|
from esphome.const import CONF_ID
|
|
|
|
AUTO_LOAD = ['climate_ir']
|
|
|
|
climate_ir_lg_ns = cg.esphome_ns.namespace('climate_ir_lg')
|
|
LgIrClimate = climate_ir_lg_ns.class_('LgIrClimate', climate_ir.ClimateIR)
|
|
|
|
CONF_HEADER_HIGH = 'header_high'
|
|
CONF_HEADER_LOW = 'header_low'
|
|
CONF_BIT_HIGH = 'bit_high'
|
|
CONF_BIT_ONE_LOW = 'bit_one_low'
|
|
CONF_BIT_ZERO_LOW = 'bit_zero_low'
|
|
|
|
CONFIG_SCHEMA = climate_ir.CLIMATE_IR_WITH_RECEIVER_SCHEMA.extend({
|
|
cv.GenerateID(): cv.declare_id(LgIrClimate),
|
|
cv.Optional(CONF_HEADER_HIGH, default='8000us'): cv.positive_time_period_microseconds,
|
|
cv.Optional(CONF_HEADER_LOW, default='4000us'): cv.positive_time_period_microseconds,
|
|
cv.Optional(CONF_BIT_HIGH, default='600us'): cv.positive_time_period_microseconds,
|
|
cv.Optional(CONF_BIT_ONE_LOW, default='1600us'): cv.positive_time_period_microseconds,
|
|
cv.Optional(CONF_BIT_ZERO_LOW, default='550us'): cv.positive_time_period_microseconds,
|
|
})
|
|
|
|
|
|
def to_code(config):
|
|
var = cg.new_Pvariable(config[CONF_ID])
|
|
yield climate_ir.register_climate_ir(var, config)
|
|
|
|
cg.add(var.set_header_high(config[CONF_HEADER_HIGH]))
|
|
cg.add(var.set_header_low(config[CONF_HEADER_LOW]))
|
|
cg.add(var.set_bit_high(config[CONF_BIT_HIGH]))
|
|
cg.add(var.set_bit_one_low(config[CONF_BIT_ONE_LOW]))
|
|
cg.add(var.set_bit_zero_low(config[CONF_BIT_ZERO_LOW]))
|