Unit Step16 组件提供 16 定位旋转编码器数值读取、数码管亮度和 RGB 灯光控制功能。
| 项目 | 信息 |
|---|---|
| 产品名称 | Unit Step16 |
| SKU | U198 |
| 主要功能 | 16 定位旋转编码器、数码管和 RGB 灯光控制 |
| 通信接口 | I2C |
| 默认 I2C 地址 | 0x48 |
| ESPHome 组件 | unit_step16(外部组件) |
| ESPHome 版本要求 | / |
添加 External 组件:
external_components:
- source: github://m5stack/esphome-yaml/components
components: [unit_step16]
refresh: 0s
unit_step16:
id: my_step16
i2c_id: bsp_iic
address: 0x48
led_brightness: 50
led_enabled: true
rgb_brightness: 50
rgb_enabled: true
rgb_red: 0
rgb_green: 255
rgb_blue: 0 Hub 组件可设置 LED 刻度灯与 RGB 灯的初始启用状态、亮度和颜色。led_brightness、rgb_brightness 的范围为 0 至 100,RGB 颜色通道的范围为 0 至 255。
添加 Sensor 组件:
sensor:
- platform: unit_step16
unit_step16_id: my_step16
name: "Encoder Value"
update_interval: 100ms 默认轮询间隔为 60s;用于实时交互时可根据需要缩短 update_interval。
添加 Output 组件:
output:
- platform: unit_step16
id: led_brightness_output
unit_step16_id: my_step16
channel: led_brightness
- platform: unit_step16
id: rgb_brightness_output
unit_step16_id: my_step16
channel: rgb_brightness
- platform: unit_step16
id: rgb_red_output
unit_step16_id: my_step16
channel: rgb_red
- platform: unit_step16
id: rgb_green_output
unit_step16_id: my_step16
channel: rgb_green
- platform: unit_step16
id: rgb_blue_output
unit_step16_id: my_step16
channel: rgb_blue 添加 Light 组件:
light:
- platform: rgb
id: step16_rgb_light
name: "Step16 RGB Light"
red: rgb_red_output
green: rgb_green_output
blue: rgb_blue_output
restore_mode: ALWAYS_ON
default_transition_length: 0s
- platform: monochromatic
id: step16_led_display
name: "Step16 LED Display"
output: led_brightness_output
restore_mode: ALWAYS_ON
default_transition_length: 0s 添加 Number 组件:
number:
- platform: template
name: "RGB Brightness"
min_value: 0
max_value: 100
step: 1
optimistic: true
initial_value: 50
on_value:
then:
- output.set_level:
id: rgb_brightness_output
level: !lambda "return x / 100.0;" 完整示例包含 Unit Step16 外部组件、I2C 总线、编码器 Sensor、灯光 Output 和亮度 Number 配置: