PART ONE
應用總覽|適用場景與效益
空間: 主臥室
智慧應用: 冷氣溫度優化/暖床模式
智慧家庭類型: 智慧環控 + 智慧感測
應用概述: 根據室內溫度、外部天氣與您的睡眠模式,自動調整空調溫度。冬天睡前啟動暖床模式,夏天深夜自動升溫避免著涼,讓您整夜好眠
對人們幫助到的面向
健康
避免整夜吹冷氣導致著涼感冒,或過熱影響深層睡眠,維持最適睡眠溫度 24-26°C
節能
智慧溫控避免整晚低溫運轉,比傳統定溫運行節省 20-30% 電費,现境友善又省錢
舒適
冬天上床前被窩已預熱,不用再縮在冰冷的被子裡,立即感受溫暖舒適
智慧
系統學習您的睡眠習慣,自動優化溫度曲線,越用越懂您的喜好
PART TWO
```
所需的實體元件
1. 冷氣機 (climate domain)
entity_id: climate.master_bedroom_ac
屬性:
- temperature: 目標溫度(20-30°C)
- fan_mode: 風量模式(低/中/高/自動)
- swing_mode: 風向模式(上/中/下/掃風)
- hvac_mode: 運作模式(off/cool/heat/heat_cool/auto)
支援品牌:Daikin、Panasonic、Fujitsu、Midea 等(需具紅外線遙控整合或 WiFi 模組)
2. 溫濕度感測器 (sensor domain)
entity_id: sensor.master_bedroom_temperature
sensor.master_bedroom_humidity
屬性:
- unit_of_measurement: °C / %
- state: 當前數值
更新頻率: 每5分鐘或實時
推薦產品:Aqara、Tuya、Sonoff 溫濕度感測器
3. 電熱毯/電暖器 (switch domain)
entity_id: switch.electric_blanket_master_bedroom
(或: switch.bed_warmer_smart_plug)
屬性:
- state: on / off
- power (可選): 目前瓦數耗用
控制方式: 智慧插座(WiFi/Zigbee)
推薦產品:Sonoff Smart Plug、Tuya Smart Plug、Shelly Plug S
4. 人體/存在感測器(可選)(binary_sensor domain)
entity_id: binary_sensor.master_bedroom_occupancy
屬性:
- state: on (有人) / off (無人)
- last_changed: 最後變化時間
檢測方式: 紅外線動作感測器、毫米波存在感測器、手機定位
推薦產品:Aqara 人體感測器 (FP1-E 毫米波)、Sonoff SNZB-03 動作感測器
🛠️ 輔助元件設定
在 Home Assistant 中建立以下輔助元件,用於儲存使用者偏好與系統狀態:
Input Boolean - 開關類
# 舒眠模式總開關
input_boolean.sleep_comfort_mode:
name: "舒眠模式"
icon: mdi:bed
# 手動暖床啟動
input_boolean.manual_bed_warming:
name: "手動暖床啟動"
icon: mdi:thermometer-plus
# 溫度異常警報確認
input_boolean.temp_alert_acknowledged:
name: "溫度警報已確認"
Input Number - 數值調整
# 夏季目標溫度(初始值)
input_number.summer_initial_temp:
name: "夏季初始溫度"
unit_of_measurement: "°C"
min: 24
max: 28
step: 0.5
icon: mdi:thermometer
# 夏季最終溫度(深層睡眠時)
input_number.summer_deep_sleep_temp:
name: "夏季深層睡眠溫度"
unit_of_measurement: "°C"
min: 25
max: 28
step: 0.5
# 冬季暖床提前時間(分鐘)
input_number.winter_preheat_minutes:
name: "冬季提前暖床時間"
unit_of_measurement: "分鐘"
min: 15
max: 60
step: 5
# 入睡後關閉延遲(分鐘)
input_number.sleep_shutdown_delay:
name: "入睡後關閉延遲"
unit_of_measurement: "分鐘"
min: 20
max: 90
step: 5
# 室溫異常下限值
input_number.temp_alert_low:
name: "室溫警報下限"
unit_of_measurement: "°C"
min: 10
max: 20
step: 1
# 室溫異常上限值
input_number.temp_alert_high:
name: "室溫警報上限"
unit_of_measurement: "°C"
min: 28
max: 35
step: 1
Input Select - 模式選擇
# 季節模式
input_select.season_mode:
name: "季節模式"
options:
- "夏季模式"
- "冬季模式"
- "春秋模式"
- "自動模式"
initial: "自動模式"
icon: mdi:calendar-season
# 電熱毯功率模式
input_select.blanket_power_mode:
name: "電熱毯功率模式"
options:
- "關閉"
- "低溫保溫"
- "中溫"
- "高溫"
initial: "低溫保溫"
情境(Scene)設定
情境是「場景」,一鍵設定多個設備的狀態。
場景1:夏季舒眠啟動
scene.summer_sleep_start:
name: "夏季舒眠啟動"
entities:
climate.master_bedroom_ac:
temperature: 25 # 初始涼爽溫度
fan_mode: "medium"
swing_mode: "up"
hvac_mode: "cool"
switch.electric_blanket_master_bedroom:
state: "off"
場景2:夏季深夜調整(入睡60分鐘後)
scene.summer_sleep_deep:
name: "夏季深層睡眠調整"
entities:
climate.master_bedroom_ac:
temperature: 26.5 # 提高溫度
fan_mode: "low" # 降低風量
swing_mode: "up"
hvac_mode: "cool"
場景3:夏季起床準備
scene.summer_wake_up:
name: "夏季起床準備"
entities:
climate.master_bedroom_ac:
temperature: 26 # 逐漸降溫,提醒起床
fan_mode: "medium"
swing_mode: "up"
hvac_mode: "cool"
場景4:冬季暖床啟動
scene.winter_warm_bed_start:
name: "冬季暖床啟動"
entities:
switch.electric_blanket_master_bedroom:
state: "on"
climate.master_bedroom_ac:
hvac_mode: "off" # 不開冷氣/暖氣
場景5:冬季入睡後
scene.winter_sleep_deep:
name: "冬季入睡後調整"
entities:
switch.electric_blanket_master_bedroom:
state: "off" # 關閉電熱毯
climate.master_bedroom_ac:
hvac_mode: "off" # 保持關閉
場景6:緊急全關
scene.emergency_shutdown_climate:
name: "緊急溫控全關"
entities:
climate.master_bedroom_ac:
hvac_mode: "off"
switch.electric_blanket_master_bedroom:
state: "off"
自動化規則(Automation)
自動化是系統的「大腦」,根據條件自動執行動作。
自動化1:睡眠模式啟動 - 根據季節選擇情境
alias: "睡眠模式啟動 - 季節切換"
trigger:
- platform: state
entity_id: input_boolean.sleep_comfort_mode
to: "on"
action:
- choose:
# 夏季
- conditions:
- condition: state
entity_id: input_select.season_mode
state: "夏季模式"
sequence:
- service: scene.turn_on
target:
entity_id: scene.summer_sleep_start
- service: notify.mobile_app
data:
message: "🌞 夏季舒眠啟動 - 冷氣設定25°C,風量中"
# 冬季
- conditions:
- condition: state
entity_id: input_select.season_mode
state: "冬季模式"
sequence:
- service: scene.turn_on
target:
entity_id: scene.winter_warm_bed_start
- service: notify.mobile_app
data:
message: "❄️ 冬季暖床啟動 - 電熱毯已開啟"
自動化2:入睡30分鐘後自動調整(夏季深層睡眠)
alias: "夏季入睡30分鐘後深層睡眠調整"
trigger:
- platform: state
entity_id: input_boolean.sleep_comfort_mode
to: "on"
for:
minutes: 30
condition:
- condition: state
entity_id: input_select.season_mode
state: "夏季模式"
action:
- service: scene.turn_on
target:
entity_id: scene.summer_sleep_deep
- service: logbook.log
data:
name: "睡眠曲線調整"
message: "冷氣溫度提高至26.5°C,風量降至低檔"
自動化3:入睡30分鐘後自動關閉電熱毯(冬季)
alias: "冬季入睡後自動關閉電熱毯"
trigger:
- platform: state
entity_id: input_boolean.sleep_comfort_mode
to: "on"
for:
minutes: 30
condition:
- condition: state
entity_id: input_select.season_mode
state: "冬季模式"
action:
- service: switch.turn_off
target:
entity_id: switch.electric_blanket_master_bedroom
- service: notify.mobile_app
data:
message: "🛏️ 電熱毯已自動關閉(入睡後30分鐘)"
自動化4:凌晨自動微調溫度(夏季進一步升溫)
alias: "凌晨2點深層睡眠溫度最終調整"
trigger:
- platform: time
at: "02:00:00"
condition:
- condition: state
entity_id: input_boolean.sleep_comfort_mode
state: "on"
- condition: state
entity_id: input_select.season_mode
state: "夏季模式"
action:
- service: climate.set_temperature
target:
entity_id: climate.master_bedroom_ac
data:
temperature: 27
- service: climate.set_fan_mode
target:
entity_id: climate.master_bedroom_ac
data:
fan_mode: "low"
自動化5:起床前1小時預調溫度(夏季)
alias: "起床前1小時溫度預調"
trigger:
- platform: time
at: "06:00:00"
condition:
- condition: state
entity_id: input_boolean.sleep_comfort_mode
state: "on"
- condition: state
entity_id: input_select.season_mode
state: "夏季模式"
action:
- service: scene.turn_on
target:
entity_id: scene.summer_wake_up
- service: notify.mobile_app
data:
message: "🌅 起床準備中 - 冷氣已調整,30分鐘後可起床"
自動化6:室溫異常警報
alias: "室溫異常警報"
trigger:
- platform: numeric_state
entity_id: sensor.master_bedroom_temperature
below: 15 # 低於15°C
for:
minutes: 5
- platform: numeric_state
entity_id: sensor.master_bedroom_temperature
above: 32 # 高於32°C
for:
minutes: 5
action:
- service: notify.mobile_app
data:
message: "⚠️ 主臥室溫度異常!目前{{ states('sensor.master_bedroom_temperature') }}°C"
data:
importance: high
color: "red"
- service: switch.turn_off
target:
entity_id: switch.electric_blanket_master_bedroom
腳本(Script)
腳本1:手動啟動舒眠模式
script.activate_sleep_comfort_mode:
alias: "手動啟動舒眠模式"
sequence:
- service: input_boolean.turn_on
target:
entity_id: input_boolean.sleep_comfort_mode
- service: notify.mobile_app
data:
message: "✅ 舒眠模式已啟動"
腳本2:手動啟動暖床模式
script.activate_bed_warming:
alias: "手動啟動暖床模式"
sequence:
- service: switch.turn_on
target:
entity_id: switch.electric_blanket_master_bedroom
- service: notify.mobile_app
data:
message: "🔥 電熱毯已啟動"
腳本3:緊急關閉所有溫控設備
script.emergency_climate_shutdown:
alias: "緊急溫控全關"
sequence:
- service: climate.turn_off
target:
entity_id: climate.master_bedroom_ac
- service: switch.turn_off
target:
entity_id: switch.electric_blanket_master_bedroom
- service: input_boolean.turn_off
target:
entity_id: input_boolean.sleep_comfort_mode
- service: notify.mobile_app
data:
message: "🚨 緊急關閉 - 所有溫控設備已停止"
【注意事項】
1. 實體命名: 確保 entity_id 與實際整合一致。使用 HA 開發工具查詢可用實體。
2. 冷氣兼容性: 建議選擇原廠 WiFi 模組或紅外線遙控網關。
3. 電熱毯安全: 避免整夜開啟,選擇有過溫保護的產品。
4. 時間同步: 確保 HA 伺服器時間正確,否則定時自動化無法準確執行。
5. 通知渠道: 配置 Home Assistant 手機 App 或其他通知服務接收溫度警報。
【常見問題排除】
PART THREE
使用以下提示詞詢問 Claude 或其他 AI 助手,協助您逐步建立完整的 Home Assistant 配置。
使用以下提示詞詢問 Claude 或其他 AI 助手,協助您逐步建立完整的 Home Assistant 配置。
您是Home Assistant智慧家居配置專家。我需要為主臥室建立智慧溫控系統(夏季睡眠曲線 + 冬季暖床)。請按以下步驟協助我:
## 第1步:收集基本信息
1. 您的Home Assistant版本?
2. 您已經有哪些裝置(冷氣、溫濕度感測器、電熱毯/插座、人體感測器)?
3. 這些裝置如何與HA連接(MQTT、REST API、專用整合、紅外線網關)?
## 第2步:自動探測實體
根據您的設備回答,確認冷氣entity_id、溫度感測器、電熱毯/插座entity_id。
## 第3步:建立輔助元件
為您生成完整的input_boolean、input_number、input_select定義。
## 第4步:建立場景 ⚠️ 逐一詢問
逐個詢問您的偏好:
1. 夏季舒眠初始溫度?(建議24-26°C)
2. 夏季初始風量?(低/中/高)
3. 夏季風向設定?(上吹/掃風)
4. 夏季運作模式?(冷房/自動)
5. 夏季深層睡眠溫度?(建議26-27°C)
6. 冬季暖床提前時間?(建議30-60分鐘)
7. 冬季電熱毯溫度?(低溫35°C/中溫40°C/高溫45°C)
8. 冬季入睡後處理?(完全關閉或降低功率?延遲多久?)
## 第5步:建立自動化 ⚠️ 詳細詢問
詢問您的使用習慣與安全偏好:
1. 入睡判斷方式?
2. 入睡後調整延遲?(20-90分鐘)
3. 凌晨微調時間?(建議02:00或03:00)
4. 起床前預調時間?(建議1小時)
5. 室溫異常閾值?(建議<15°C、>32°C)
6. 警報通知方式?
## 第6步:生成完整YAML配置
基於回答生成configuration.yaml、automations.yaml、scenes.yaml、scripts.yaml。
## 第7步:驗證與排除故障
檢查語法錯誤、提供測試步驟、常見問題排除指南。
## 開始:請回答第1步的三個問題。
## 結語
主臥室的智慧溫控不僅是提升舒適度,更是對健康與能源效率的投資。透過本指南的三個部分——理論知識、技術配置、AI輔助——您現已擁有打造個人化睡眠環境的完整工具。
祝您好眠,並享受科技改善生活的實感。
最後提醒:每個家庭的環境不同,建議先以推薦值開始,根據實際睡眠體驗逐週微調,找出屬於自己最舒適的溫度曲線。
# 客廳篇|智慧家庭應用完整內容(7 篇)