本帖最后由 dscao 于 2022-12-15 14:17 编辑
以前备份的,刚刚测试最新版ESPHome2022.12.0可以编辑成功,不过自己没有实际刷过。
esphome:
name: air-conditioner
platformio_options:
platform_packages:
- framework-arduinoespressif32 @ https://github.com/pauln/arduino-esp32.git#solo-no-mac-crc/1.0.6
platform:
- [email protected]
on_loop: # 示例,如果开启蓝牙,需要加入一定的延迟避免触发看门狗(自行测试)
- lambda: |
vTaskDelay(10/portTICK_PERIOD_MS);
esp32:
board: esp32doit-devkit-v1
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Air-conditioner Fallback Hotspot"
password: "XXXXXXX"
captive_portal:
ota:
logger:
# Enable Home Assistant API
api:
services: #示例,可删除
- service: send_ir_nec #示例发送学习好的红外遥控信号
variables:
address: int
command: int
repeat: int
then:
- remote_transmitter.transmit_nec:
address: !lambda 'return address;'
command: !lambda 'return command;'
repeat:
times: !lambda 'return repeat;'
- service: send_ir_raw #示例发送任意红外信号,可与smartir等搭配实现空调遥控
variables:
command: int[]
then:
- remote_transmitter.transmit_raw:
code: !lambda 'return command;'
carrier_frequency: 38k
light: #rgb灯,配合output
- platform: rgb
id: "indicateor"
name: "Light"
red: led_red
green: led_green
blue: led_blue
output: #rgb灯相关引脚
- platform: ledc
id: led_red
pin:
number: GPIO4
- platform: ledc
id: led_green
pin:
number: GPIO0
inverted: True
- platform: ledc
id: led_blue
pin:
number: GPIO2
remote_transmitter: #红外发射引脚
pin:
number: GPIO23
carrier_duty_percent: 50%
remote_receiver:
pin:
number: GPIO17
inverted: True
mode: INPUT_PULLUP
dump: nec #红外解码示例,适用大多数遥控。
binary_sensor: #按键相关引脚
- platform: gpio
pin:
number: GPIO5
filters:
invert:
name: "Button"
sensor: #功率芯片及相关引脚,电路上限制了只能测电压、功率
- platform: hlw8012
current_resistor: 0.002
voltage_divider: 2138 #影响220v电压测量结果,可根据实际情况调整校准
sel_pin: GPIO16
cf_pin: GPIO26
cf1_pin: GPIO18
voltage:
name: "Voltage"
power:
name: "Power"
energy:
name: "Energy"
update_interval: 3s
initial_mode: VOLTAGE
change_mode_every: 4294967295
esp32_ble_tracker: #开启小米蓝牙设备支持,温湿度计,牙刷等
|