HomeAssistant ESPHome设备YAML

拷贝你在闲鱼上购买设备的对应YAML

车库控制(5路不带状态检测)

esphome:
  name: garage
  on_boot:
    priority: -100
    then:
      - output.turn_off: out_io5
      - output.turn_off: out_io4
      - output.turn_off: out_io14
      - output.turn_off: out_io12

esp8266:
  board: esp01_1m

logger:

api:
  encryption:
    key: "你的key"

ota:
  - platform: esphome
    password: "你的password"

wifi:
  ssid: "wifi ssid"
  password: "wifi 密码"
  ap:
    ssid: "Garage Fallback Hotspot"
    password: "QXIAoLa5kGo9"

captive_portal:

# ───────────  继电器输出  ───────────
output:
  - platform: gpio
    id: out_io5          # 关门
    pin: GPIO5
  - platform: gpio
    id: out_io4          # 开门
    pin: GPIO4
  - platform: gpio
    id: out_io14         # 停止
    pin: GPIO14
  - platform: gpio
    id: out_io12         # 锁
    pin: GPIO12

# ───────────  卷帘 cover 实体  ───────────
cover:
  - platform: template
    name: "Garage Door"
    id: garage_cover
    optimistic: true       # 无位置传感器
    assumed_state: true    # HA 同时显示开/关按钮

    open_action:
      - lambda: |-
          id(garage_cover).current_operation = COVER_OPERATION_OPENING;
          id(garage_cover).publish_state();
      - output.turn_on: out_io4
      - delay: 500ms
      - output.turn_off: out_io4
      - lambda: |-
          id(garage_cover).current_operation = COVER_OPERATION_IDLE;
          id(garage_cover).publish_state();

    close_action:
      - lambda: |-
          id(garage_cover).current_operation = COVER_OPERATION_CLOSING;
          id(garage_cover).publish_state();
      - output.turn_on: out_io5
      - delay: 500ms
      - output.turn_off: out_io5
      - lambda: |-
          id(garage_cover).current_operation = COVER_OPERATION_IDLE;
          id(garage_cover).publish_state();

    stop_action:
      - lambda: |-
          id(garage_cover).current_operation = COVER_OPERATION_IDLE;   
          id(garage_cover).publish_state();
      - output.turn_on: out_io14
      - delay: 500ms
      - output.turn_off: out_io14

# ───────────  锁定开关(可选)  ───────────
switch:
  - platform: template
    name: "Lock"
    id: lock_switch
    optimistic: true
    turn_on_action:
      - output.turn_on: out_io12
      - delay: 500ms
      - output.turn_off: out_io12
      - switch.turn_off: lock_switch

车库控制(3路带状态检测)

esphome:
  name: garageplus
  on_boot:
    priority: -100
    then:
      - output.turn_off: out_io5
      - output.turn_off: out_io4
      - output.turn_off: out_io12
      - lambda: |-
          id(last_action) = 2;  // 初始状态为停止/未知

esp8266:
  board: esp01_1m

logger:

api:
  encryption:
    key: "你的key"

ota:
  - platform: esphome
    password: "你的password"

wifi:
  ssid: "wifi ssid"
  password: "wifi 密码"
  ap:
    ssid: "Garage Fallback Hotspot"
    password: "QXIAoLa5kGo9"

captive_portal:

globals:
  - id: last_action
    type: int
    restore_value: true
    initial_value: '2'  # 0=关, 1=开, 2=停止/未知

# ─────────── 继电器输出 ───────────
output:
  - platform: gpio
    id: out_io5
    pin: GPIO5  # 关门
  - platform: gpio
    id: out_io4
    pin: GPIO4  # 开门
  - platform: gpio
    id: out_io12
    pin: GPIO12 # 停止

# ─────────── 限位开关(可选) ───────────
binary_sensor:
  - platform: gpio
    id: open_pin
    pin:
      number: GPIO14
      mode: INPUT_PULLUP
      inverted: true
    filters:
      - delayed_on: 50ms
      - delayed_off: 50ms
    on_state:
      - component.update: garage_state_text

  - platform: gpio
    id: close_pin
    pin:
      number: GPIO13
      mode: INPUT_PULLUP
      inverted: true
    filters:
      - delayed_on: 50ms
      - delayed_off: 50ms
    on_state:
      - component.update: garage_state_text

# ─────────── cover ───────────
cover:
  - platform: template
    name: "车库门"
    id: garage_cover
    device_class: garage

    open_action:
      - lambda: |-
          id(last_action) = 1;  // 标记正在开门
      - output.turn_on: out_io4
      - delay: 500ms
      - output.turn_off: out_io4
      - lambda: |-
          id(last_action) = 1;  // 动作结束,已打开
      - component.update: garage_state_text

    close_action:
      - lambda: |-
          id(last_action) = 0;  // 标记正在关门
      - output.turn_on: out_io5
      - delay: 500ms
      - output.turn_off: out_io5
      - lambda: |-
          id(last_action) = 0;  // 动作结束,已关闭
      - component.update: garage_state_text

    stop_action:
      - lambda: |-
          id(last_action) = 2;  // 标记停止
      - output.turn_on: out_io12
      - delay: 500ms
      - output.turn_off: out_io12
      - component.update: garage_state_text

    lambda: |-
      if (id(open_pin).state && !id(close_pin).state) {
        return COVER_OPEN;
      } else if (id(close_pin).state && !id(open_pin).state) {
        return COVER_CLOSED;
      } else {
        return id(last_action) == 1 ? COVER_OPEN : COVER_CLOSED;
      }

text_sensor:
  - platform: template
    id: garage_state_text
    name: "车库门状态"
    update_interval: never
    lambda: |-
      if (id(open_pin).state && !id(close_pin).state) {
        return {"已打开"};
      } else if (id(close_pin).state && !id(open_pin).state) {
        return {"已关闭"};
      } else {
        if (id(last_action) == 1) {
          return {"正在开门…"};
        } else if (id(last_action) == 0) {
          return {"正在关门…"};
        } else {
          return {"已停止"};
        }
      }

机柜散热风扇(esp8266版)

esphome:
  name: cabinetfan
  friendly_name: CabinetFanESP8266

esp8266:
  board: esp01_1m

logger:

api:
  encryption:
    key: "你的 key"

ota:
  - platform: esphome
    password: "你的password"

wifi:
  ssid: "wifi ssid"
  password: "wifi密码"
  ap:
    ssid: "Cabinetfan Fallback Hotspot"
    password: "21z8fDtaLbNL"

output:
  - platform: esp8266_pwm
    id: fan1_pwm
    pin: GPIO5
    frequency: 25000 Hz
    inverted: true
    zero_means_zero: true

  - platform: esp8266_pwm
    id: fan2_pwm
    pin: GPIO4
    frequency: 25000 Hz
    inverted: true
    zero_means_zero: true

  - platform: esp8266_pwm
    id: fan3_pwm
    pin: GPIO14
    frequency: 25000 Hz
    inverted: true
    zero_means_zero: true

  - platform: esp8266_pwm
    id: fan4_pwm
    pin: GPIO12
    frequency: 25000 Hz
    inverted: true
    zero_means_zero: true

fan:
  - platform: speed
    output: fan1_pwm
    name: "风扇1(io5)"

  - platform: speed
    output: fan2_pwm
    name: "风扇2(io4)"

  - platform: speed
    output: fan3_pwm
    name: "风扇3(io14)"

  - platform: speed
    output: fan4_pwm
    name: "风扇4(io12)"

机柜散热风扇(esp32版)

esphome:
  name: cabinetfan
  friendly_name: CabinetFanESP32

esp32:
  board: esp32dev

wifi:
  ssid: "wifi ssid"
  password: "wifi 密码"
  ap:
    ssid: "Cabinetfan Fallback Hotspot"
    password: "21z8fDtaLbNL"

api:
  encryption:
    key: "你的key"

ota:
  - platform: esphome
    password: "你的password"

logger:

output:
  - platform: ledc
    pin: GPIO16
    frequency: 25000 Hz
    id: fan1_pwm
    inverted: true
  - platform: ledc
    pin: GPIO17
    frequency: 25000 Hz
    id: fan2_pwm
    inverted: true
  - platform: ledc
    pin: GPIO18
    frequency: 25000 Hz
    id: fan3_pwm
    inverted: true
  - platform: ledc
    pin: GPIO19
    frequency: 25000 Hz
    id: fan4_pwm
    inverted: true

fan:
  - platform: speed
    output: fan1_pwm
    name: "Fan1"
    on_turn_off:
      - output.set_level:
          id: fan1_pwm
          level: 0.0
  - platform: speed
    output: fan2_pwm
    name: "Fan2"
    on_turn_off:
      - output.set_level:
          id: fan2_pwm
          level: 0.0
  - platform: speed
    output: fan3_pwm
    name: "Fan3"
    on_turn_off:
      - output.set_level:
          id: fan3_pwm
          level: 0.0
  - platform: speed
    output: fan4_pwm
    name: "Fan4"
    on_turn_off:
      - output.set_level:
          id: fan4_pwm
          level: 0.0

sensor:
  - platform: pulse_counter
    pin: GPIO32
    name: "Fan1 RPM"
    unit_of_measurement: "rpm"
    accuracy_decimals: 0
    update_interval: 5s
    filters:
      - multiply: 0.5
  - platform: pulse_counter
    pin: GPIO33
    name: "Fan2 RPM"
    unit_of_measurement: "rpm"
    accuracy_decimals: 0
    update_interval: 5s
    filters:
      - multiply: 0.5
  - platform: pulse_counter
    pin: GPIO25
    name: "Fan3 RPM"
    unit_of_measurement: "rpm"
    accuracy_decimals: 0
    update_interval: 5s
    filters:
      - multiply: 0.5
  - platform: pulse_counter
    pin: GPIO26
    name: "Fan4 RPM"
    unit_of_measurement: "rpm"
    accuracy_decimals: 0
    update_interval: 5s
    filters:
      - multiply: 0.5

light:
  - platform: neopixelbus
    type: GRB
    variant: WS2812
    pin: GPIO27
    num_leds: 12     
    name: "Fan RGB"
    id: fan_rgb
    default_transition_length: 300ms
    effects:
      - random:
      - strobe:
      - flicker:
      - pulse:
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇