跳转至

ESPHome进阶

《HomeAssistant智能家居实战篇》视频

固定IP地址

wifi:
  ssid: MyHomeNetwork
  password: VerySafePassword

  # Optional manual IP
  manual_ip:
    static_ip: 192.168.3.123
    gateway: 192.168.3.1
    subnet: 255.255.255.0

wifi连接失败的补救

wifi:
  ssid: MyHomeNetwork
  password: VerySafePassword

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esp32 Aaa Fallback Hotspot"
    password: "eriZWbg2Ebdq"

captive_portal:

网络日志与串口日志

# Enable logging
logger:

WEB服务

web_server:

调用HomeAssistant中的服务

light:
  - platform: binary
    # ...
    on_turn_on:
      then:
        - homeassistant.service:
            service: tts.google_translate_say
            data:
              entity_id: all
              message: 开发板上的灯被打开了
    on_turn_off:
      then:
        - homeassistant.service:
            service: tts.google_translate_say
            data:
              entity_id: all
              message: 开发板上的灯被关闭了

生成HomeAssistant中可调用的服务

api:
  services:
    - service: flash_light
      variables:
        duration: float
      then:
        - light.turn_on: my_led
        - delay: !lambda 'return duration;'
        - light.turn_off: my_led

返回课程目录↩