Infostripe
使用Neopixel(WS2812B)灯带显示传感器状态的当前状态是一种向用户传达状态简单方法。与仪表盘屏幕相比,信息灯带只能像二进制传感器一样传达信息。
- 颜色(例如,红色=错误/警告,橙色=警告,绿色=正常,蓝色=活动)
- 亮度(关闭,亮度缩放)
- 模式(连续与闪烁,闪烁或频闪不建议使用)
- 灯带上的位置

ESPHome配置
uart:
rx_pin: GPIOXX
tx_pin: GPIOXX
baud_rate: 9600
sensor:
- platform: mhz19
co2:
name: "MH-Z19 CO2值"
temperature:
name: "MH-Z19温度"
update_interval: 30s
# 监控Wifi连接状态
binary_sensor:
- platform: status
name: "Infostripe状态"
# 将每个像素配置为单个灯(注意内存消耗)
light:
- platform: fastled_clockless
chipset: WS2812B
id: light_fastled
pin: GPIOXX
num_leds: 4
rgb_order: GRB
name: "Infostripe"
effects:
- strobe:
- random:
- platform: partition
name: "PL0"
segments:
- id: light_fastled
from: 0
to: 0
effects:
- strobe:
- platform: partition
name: "PL1"
segments:
- id: light_fastled
from: 1
to: 1
effects:
- strobe:
- platform: partition
name: "PL2"
segments:
- id: light_fastled
from: 2
to: 2
effects:
- strobe:
- platform: partition
name: "PL3"
segments:
- id: light_fastled
from: 3
to: 3
effects:
- strobe:
⚠️ Warning
考虑Light Partition中关于内存使用增加的警告。
Home Assistant配置
在Home Assistant中显示CO2警告灯(例如,如果CO2 > 1000 ppm则为红色)的自动化,但也可以使用ESPHome 自动化实现。
# 使用相关颜色打开灯
automation:
- id: '1601241280015'
alias: CO2灯开启
description: ''
trigger:
- platform: numeric_state
entity_id: sensor.mh_z19_co2_value
above: 1000
condition: []
action:
- action: light.turn_on
data:
color_name: red
entity_id: light.pl2
mode: single
- id: '1601241280016'
alias: CO2灯关闭
description: ''
trigger:
- platform: numeric_state
entity_id: sensor.mh_z19_co2_value
below: 800
condition: []
action:
- action: light.turn_off
entity_id: light.pl2
mode: single
- alias: "状态灯映射"
trigger:
platform: time_pattern
# 你也可以匹配间隔。这将匹配每5分钟一次
minutes: "/5"
action:
- action: light.turn_on
data_template:
entity_id: light.pl1
brightness_pct: 30
color_name: >
{% set map = {'on': 'green', 'off': 'red'} %}
{% set state = states('binary_sensor.bad_status') %}
{{ map[state] if state in map else 'white' }}
