# HearthNodes recipe 07 - daylight harvesting
alias: "Light - daylight harvesting on the work plane"
id: hn_light_daylight_harvest
description: "Hold 500 lx on the work plane, clamp the ceiling circuit to 12-100 percent"
mode: single
max_exceeded: silent
trigger:
- platform: numeric_state
entity_id: sensor.office_workplane_lux
below: "{{ state_attr('sensor.office_workplane_lux','last_setpoint') | float(500) - 60 }}"
- platform: numeric_state
entity_id: sensor.office_workplane_lux
above: "{{ state_attr('sensor.office_workplane_lux','last_setpoint') | float(500) + 60 }}"
variables:
target_lx: 500
daylight_share: >-
{{ (states('sensor.office_daylight_only_lux') | float(0) / target_lx * 100) | round(0) }}
harvested_pct: >-
{{ [[(100 - daylight_share | float(0)) | round(0), 12] | max, 100] | min }}
condition:
- condition: state
entity_id: binary_sensor.office_occupied
state: "on"
- condition: state
entity_id: input_boolean.harvest_hold
state: "off"
- condition: template
value_template: >-
{{ (now() - states.sensor.office_workplane_lux.last_updated).total_seconds() < 600 }}
action:
- service: light.turn_on
target:
entity_id: light.office_ceiling
data:
brightness_pct: "{{ harvested_pct }}"
transition: 8
- service: input_number.set_value
target:
entity_id: input_number.ceiling_last_level
data:
value: "{{ harvested_pct }}"
# Photosensor failure -> fixed 70 percent plus a maintenance flag. Daylight is
# never inferred from a weather API. Manual dimmer presses always suspend the
# loop for 15 minutes through input_boolean.harvest_hold.
触发器 · numeric_state
sensor.office_workplane_lux
工作面照度相对当前调光档位对应的照度值变化超过 60 lx。
分步说明
- light.office_ceiling把顶灯设为计算出的档位,限制在 12 %–100 % 之间,使用 8 秒过渡,让人看不出台阶感。
turn_on · brightness_pct {{ harvested }} · transition 8s - sensor.office_lighting_power每 5 分钟记录该回路的平均功率,以便与基线周做诚实的节能量报告。
log · 5min mean - input_boolean.harvest_hold任何人碰过物理调光旋钮后,暂停日光采集 15 分钟。
on for 15 min after any manual dimmer press
用真实照度计标定顶棚传感器
调试时把经过校准的照度计放在工作面,调节顶棚传感器的增益,直到两者读数相差不超过 10 %。要在两种日照水平下各做一次——一次阴天、一次晴天——因为传感器的余弦响应在低角度下会失真,且误差不是线性的。
下限设在 12 % 而不是零
调到零会脱离无频闪区间,并且恢复时的跳变很明显。12 % 还能让驱动保持在工作温度、高于最小导通角。如果房间确实不需要电光,就显式关闭回路,而不是把它调到零。
先完整测量一周基线
开启功率记录,让回路以固定 100 % 运行一个工作周,然后才启用日光采集。没有这个基线,你报出的任何节能量都只是估算,而估算会被所有读到它的人打折。
硬件
| 型号 | 协议 | 连接 | 在本链路中的作用 |
|---|---|---|---|
| DALI or 0-10 V dimmable driver with a Matter bridge | matter |
有线 | 这里必须用有线控制:廉价驱动在 12 % 的 Zigbee 调光下容易闪烁,无法稳定维持在低档位。 |
| Ceiling-mounted closed-loop photosensor (0-10 V) | matter |
有线 | 读取工作面上「日光 + 电光」的合成照度,这正是闭环需要保持恒定的量。 |
| Desk-level lux reference (Zigbee, for calibration only) | zigbee |
无线 | 调试时用于把顶棚传感器的读数与真实工作面测量值对齐。 |
失效时怎么办
如果光电传感器失效,回路回退到固定 70 % 并抛出维护标记;系统绝不从天气 API 去猜日照,因为猜错会让人在黑暗里工作。物理调光旋钮始终优先,并始终暂停闭环。