自用esphome yaml配置文件。论坛找了一圈,没有完整版本的,自带我家加湿器红外控制的使用示例。这个计量芯片采集的读数来回跳动,比如电压有时候220v,有时候150v,因此电压、电流等传感器均添加中值过滤器去抖动
解压附件的5个yaml配置,到esphome的conf目录下,然后编译,刷机。适配cmcc_x12、电信小翼管家、希智空调伴侣等类似的设备
esphome配置:
x12空调伴侣.zip
(9.69 KB, 下载次数: 71)
substitutions:
current_res: "0.001"
current_multiply: "0.943"
voltage_div: "1745" # 2351
hlw8012_sel_pin: GPIO12
hlw8012_cf_pin: GPIO4
hlw8012_cf1_pin: GPIO5
ir_receiver_pin: GPIO13
ir_transmitter_pin: GPIO14
button_pin: GPIO0
led_status_pin: GPIO15
node_name: "irremote-room1"
node_name_friendly: ${node_name}
node_name_add_mac_suffix: "false"
#可选填
node_project_name: "cmcc.x12-AcPartner"
node_project_version: "tywe3s-v1.0.0-webserver2.0"
node_build_min_version: "2023.12.0"
packages:
common: !include 1-common-esp8266-1m.yaml
common-component: !include 1-common-component.yaml
debug-component: !include 1-debug-component.yaml
webserver-component: !include 1-webserver-component.yaml
esphome:
on_boot:
- priority: 0
then:
- lambda: |-
//配网模式,led快速闪烁;
if(nullptr != esphome::captive_portal::global_captive_portal)
{
//配网模式,蓝色led闪烁
if(esphome::captive_portal::global_captive_portal->is_active() && !id(id_wifi).is_connected())
{
id(id_led_status).turn_off().perform();
id(id_led_status).turn_on().set_effect("fast").perform();
}
}
wifi:
reboot_timeout: 0s
on_connect:
- light.turn_off: id_led_status
logger:
level: INFO
baud_rate: 0
time:
- platform: homeassistant
id: id_homeassistant_time
timezone: "Asia/Shanghai"
output:
- platform: esp8266_pwm
id: id_pin_led_status
pin: ${led_status_pin}
inverted: false
light:
#连接状态指示灯
- platform: status_led
name: "API Link Led"
id: id_led_api_link
output: id_pin_led_status
internal: true
#配网状态指示灯
- platform: monochromatic
name: "StatusLed"
id: id_led_status
output: id_pin_led_status
default_transition_length: 0s
internal: true
effects:
- pulse:
name: "fast"
transition_length: 0ms
update_interval: 100ms
sensor:
- platform: hlw8012
model: BL0937
sel_pin:
number: ${hlw8012_sel_pin}
inverted: true
cf_pin: ${hlw8012_cf_pin}
cf1_pin: ${hlw8012_cf1_pin}
current_resistor: ${current_res}
voltage_divider: ${voltage_div}
current:
name: "energy-Current"
id: id_sensor_current
filters:
- multiply: ${current_multiply}
- median:
window_size: 5
send_every: 3
send_first_at: 3
voltage:
name: "energy-Voltage"
id: id_sensor_voltage
filters:
- median:
window_size: 5
send_every: 3
send_first_at: 3
power:
name: "energy-Power"
id: id_sensor_power
energy:
name: "energy-Energy"
id: id_sensor_energy
update_interval: 3s
initial_mode: CURRENT
#change_mode_every: 4294967295
- platform: copy
name: energy-MedianPower
id: id_energy_median_power
source_id: id_sensor_power
filters:
- median:
window_size: 5
send_every: 3
send_first_at: 3
- platform: total_daily_energy
name: "energy-DailyEnergy"
id: id_total_daily_energy_median
power_id: id_energy_median_power
accuracy_decimals: 2
device_class: "energy"
state_class: "total_increasing"
icon: "mdi:counter"
restore: true
unit_of_measurement: Wh
remote_receiver:
pin:
number: ${ir_receiver_pin}
inverted: true
#dump: nec
dump: all
remote_transmitter:
pin:
number: ${ir_transmitter_pin}
carrier_duty_percent: 50%
binary_sensor:
- platform: gpio
#name: button-Power Key Real
id: id_power_key
internal: true
pin:
number: ${button_pin}
inverted: true
mode:
input: true
pullup: true
on_multi_click:
#长按5s以上,重置为出厂模式,进入配网状态
- timing:
- ON for at least 5s
then:
- switch.turn_on: id_factoryreset
invalid_cooldown: 0s
- timing:
- ON for at most 0.5s
- OFF for at least 0.01s
then:
- logger.log: "power button pressed!"
invalid_cooldown: 0s
#双击(启动/关闭空调)
#- timing:
# - ON for at most 0.5s
# - OFF for at most 0.5s
# - ON for at most 0.5s
# - OFF for at least 0.2s
# then:
# - logger.log: "double click."
# -
# invalid_cooldown: 0s
#单击(启动/关闭加湿器)
- timing:
- ON for at most 0.3s
- OFF for at least 0.2s
then:
- logger.log: "single click."
- button.press: id_button_humidifier_power
invalid_cooldown: 0s
##加湿器红外键值
##电源 Received NEC: address=0xFF00, command=0xB946 command_repeats=1
##恒湿 Received NEC: address=0xFF00, command=0xF807 command_repeats=1
##档位 Received NEC: address=0xFF00, command=0xF609 command_repeats=1
##定时 Received NEC: address=0xFF00, command=0xF30C command_repeats=1
##睡眠 Received NEC: address=0xFF00, command=0xA15E command_repeats=1
##UV灯 Received NEC: address=0xFF00, command=0xAD52 command_repeats=1
button:
#加湿器-电源
- platform: template
name: Humidifier Power
id: id_button_humidifier_power
on_press:
then:
- remote_transmitter.transmit_nec:
address: 0xFF00
command: 0xB946
#加湿器-档位
- platform: template
name: Humidifier Speed
id: id_button_humidifier_speed
on_press:
then:
- remote_transmitter.transmit_nec:
address: 0xFF00
command: 0xF609
#加湿器-定时
- platform: template
name: Humidifier Timer
id: id_button_humidifier_timer
on_press:
then:
- remote_transmitter.transmit_nec:
address: 0xFF00
command: 0xF30C
#加湿器-睡眠
- platform: template
name: Humidifier Sleep
id: id_button_humidifier_sleep
on_press:
then:
- remote_transmitter.transmit_nec:
address: 0xFF00
command: 0xA15E
#空调组件
#climate:
# - platform: gree
# name: "AC"
# sensor: room_temperature
# model: yan
复制代码