按照度自适应的百叶:维持桌面 300 lx,而不是固定开合比例
闭环控制器每 90 秒读一次桌面照度,把百叶移动到让桌面维持在 250–400 lx 的位置。阴天时全开,2 月正午强光时只开到 22 %。
# HearthNodes recipe 06 - lux adaptive blinds
alias: "Light - closed loop blinds holding 300 lx"
id: hn_light_lux_adaptive_blinds
description: "Desk illuminance loop, 90 s cycle, 12 point maximum step"
mode: single
max_exceeded: silent
trigger:
- platform: numeric_state
entity_id: sensor.desk_illuminance
below: 250
for: "00:01:30"
- platform: numeric_state
entity_id: sensor.desk_illuminance
above: 400
for: "00:01:30"
variables:
target_lx: 300
deadband_lx: 60
measured: "{{ states('sensor.desk_illuminance') | float(300) }}"
current: "{{ state_attr('cover.study_blind','current_position') | int(50) }}"
error: "{{ measured - target_lx }}"
raw_step: "{{ (-error / 18) | round(0) }}"
clamped_step: "{{ [[raw_step, -12] | max, 12] | min }}"
computed_position: "{{ [[current + clamped_step, 0] | max, 100] | min }}"
condition:
- condition: numeric_state
entity_id: sun.sun
attribute: elevation
above: 5
- condition: state
entity_id: binary_sensor.blind_manual_override
state: "off"
- condition: state
entity_id: binary_sensor.study_window_contact
state: "off"
- condition: template
value_template: "{{ (measured - target_lx) | abs > deadband_lx }}"
action:
- service: cover.set_cover_position
target:
entity_id: cover.study_blind
data:
position: "{{ computed_position }}"
- service: counter.increment
target:
entity_id: counter.blind_moves_today
# Stale lux (>20 min without a report) hands the loop to a sun-position model.
# A manual wall-switch press suppresses the loop for 45 minutes via
# binary_sensor.blind_manual_override, which matters more than any tuning value.
触发器 · numeric_state
sensor.desk_illuminance
桌面照度离开 250–400 lx 区间,并持续 90 秒。
分步说明
- cover.study_blind把百叶移动到计算位置,单次循环最多改变 12 %,避免叶片出现可见的来回摆动。
set_cover_position · {{ computed_position }} - input_number.blind_deadband在 300 lx 目标周围保留 60 lx 死区,避免飘过的云边就让百叶动一次。
hold at 60 lx - counter.blind_moves_today统计每日移动次数;超过 25 次说明死区或采样周期设置不对。
increment
把照度传感器对准你真正在读的表面
把传感器装在你坐下时眼睛的高度,略微朝上指向天花板。平放在桌面上的传感器在冬天会读到直射阳光,在你面前的纸面只有 200 lx 时报出 900 lx。让传感器的视场对齐任务面,而不是对齐窗户。
每 90 秒采样一次,并限制单次步长
采样太快,百叶会跟着云边来回摆动;采样太慢,房间会暗上好几分钟。90 秒配合最大 12 % 步长是一个折中:叶片看上去是静止的,同时仍能跟随太阳移动。先记录一周的移动次数再判断是否调好。
给墙面开关 45 分钟的优先权
任何亲手移动过百叶的人都已经表达了明确意愿。手动操作后 45 分钟内暂停闭环,是让自动化显得有帮助而不是在跟你抬杠的关键。
硬件
| 型号 | 协议 | 连接 | 在本链路中的作用 |
|---|---|---|---|
| Somfy Sonesse 30 with a Matter bridge | matter |
有线 | 市电供电的百叶电机;Matter 提供真实的百分比位置,而不是仅射频电机那种靠按键计时的近似。 |
| Aqara T1 illuminance sensor | zigbee |
无线 | 桌面高度照度传感器,朝向天花板,读取反射光而不是直射阳光。 |
| Window contact (any reed sensor) | zigbee |
无线 | 窗户开启时阻断闭环,因为此时百叶会撞到窗框。 |
失效时怎么办
如果照度传感器超过 20 分钟没有更新,闭环交给太阳位置模型(高度角与方位角)接管,用近似值维持同一目标。若该模型也给出不合理值,百叶保持原位,并发送通知指明是哪个传感器失效,而不是在大中午把百叶全开。