智能家居实战:用 Home Assistant 打造自动化灯光系统

智能家居实战:用 Home Assistant 打造自动化灯光系统

为什么你需要智能灯光?

想象一下:早上 7 点,卧室灯光自动亮起,色温从暖黄渐变到冷白,模拟日出唤醒你;晚上看电影时,客厅灯光自动调暗到 20% 亮度;离家时一键关闭所有灯光。这就是智能家居的魅力。

硬件准备清单

搭建这套系统,你需要:

  • 网关主机: 树莓派 4B(约 300 元)或旧笔记本
  • 智能灯泡: Yeelight 彩光版(约 80 元/个)或 Philips Hue(约 200 元/个)
  • 传感器: 人体传感器(约 50 元)、门窗传感器(约 40 元)
  • 开关: 无线开关(约 60 元)用于场景触发

Home Assistant 安装

在树莓派上安装 Home Assistant OS:

# 下载镜像
wget https://github.com/home-assistant/operating-system/releases/download/11.5/haos_rpi4-64-11.5.img.xz

# 写入 SD 卡
xzcat haos_rpi4-64-11.5.img.xz | sudo dd of=/dev/mmcblk0 bs=4M conv=fsync

核心自动化配置

configuration.yaml 中添加:

automation:
  - alias: "早晨唤醒灯光"
    trigger:
      platform: time
      at: "07:00:00"
    action:
      - service: light.turn_on
        target:
          entity_id: light.bedroom
        data:
          brightness_pct: 30
          color_temp: 400
      - delay: "00:05:00"
      - service: light.turn_on
        target:
          entity_id: light.bedroom
        data:
          brightness_pct: 80
          color_temp: 250

  - alias: "离家关闭所有灯光"
    trigger:
      platform: state
      entity_id: person.home
      to: "not_home"
    action:
      - service: light.turn_off
        target:
          entity_id: all

进阶玩法:存在检测

使用毫米波雷达传感器(如 Aqara FP1)实现更精准的人员检测,避免传统红外传感器”静止即离开”的误判。配置示例:

automation:
  - alias: "有人自动开灯"
    trigger:
      platform: state
      entity_id: binary_sensor.living_room_occupancy
      to: "on"
    action:
      - service: light.turn_on
        target:
          entity_id: light.living_room
        data:
          brightness_pct: 70

成本对比

方案 成本 灵活性 学习曲线
小米米家
Philips Hue
Home Assistant 极高

总结

Home Assistant 虽然学习曲线陡峭,但一旦掌握,你可以实现任何你能想象的自动化场景。从简单的灯光控制到复杂的”回家模式”(自动开灯、开空调、播放音乐),一切皆有可能。

Comments

No comments yet. Why don’t you start the discussion?

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注