跳转到内容

基于电流的罩盖

current_based 罩盖平台允许你通过使用电流 传感器检测完全开启和完全关闭状态,来创建具有位置控制的罩盖。这在搭配带有 集成机械限位开关的电机时非常有用。在罩盖运行期间,组件会监控电流消耗 以检测电机何时停止。

当请求完全开启或关闭时,相应的继电器将保持开启,直到电机消耗的 电流降至某个阈值以下。电流阈值需要在配置中指定。

可以指定开启和关闭持续时间,以允许 ESPHome 近似罩盖的当前位置。

这种类型的罩盖还提供安全功能,如基于电流的障碍物检测(带自动可配置 回滚)以及继电器故障检测:如果在相反操作电路中检测到电流 (通常由焊接继电器引起),则取消操作。

WARNING

根据罩盖和电机类型,障碍物可能在被检测到之前就已经对罩盖造成物理损坏。 请验证你的设置,确保电流消耗增加足够以被检测到,而不造成 任何物理损坏。使用此功能风险自负。

# 配置示例
cover:
- platform: current_based
name: "Current Based Cover"
open_sensor: open_current_sensor
open_moving_current_threshold: 0.5
open_obstacle_current_threshold: 0.8
open_duration: 12s
open_action:
- switch.turn_on: open_cover_switch
close_sensor: close_current_sensor
close_moving_current_threshold: 0.5
close_obstacle_current_threshold: 0.8
close_duration: 10s
close_action:
- switch.turn_on: close_cover_switch
stop_action:
- switch.turn_off: close_cover_switch
- switch.turn_off: open_cover_switch
obstacle_rollback: 30%
start_sensing_delay: 0.8s
  • open_sensor (必填,ID):开启电流传感器。

  • open_action (必填,Action):当远程请求罩盖开启时应执行的 动作。

  • open_duration (必填,Time):罩盖从 完全关闭状态开启所需的时间。

  • open_moving_current_threshold (必填,浮点数):电机应消耗的以安培为单位的电流量, 用于判断罩盖正在开启。

  • open_obstacle_current_threshold (可选,浮点数):电机应消耗的以安培为单位的电流量, 用于判断罩盖在开启过程中被卡住。

  • close_sensor (必填,ID):关闭电流传感器。

  • close_action (必填,Action):当远程请求罩盖关闭时应执行的 动作。

  • close_duration (必填,Time):罩盖从 完全开启状态关闭所需的时间。

  • close_moving_current_threshold (必填,浮点数):电机应消耗的以安培为单位的电流量, 用于判断罩盖正在关闭。

  • close_obstacle_current_threshold (可选,浮点数):电机应消耗的以安培为单位的电流量, 用于判断罩盖在关闭过程中被卡住。

  • stop_action (必填,Action):应执行以 停止罩盖的动作。

  • max_duration (可选,Time):罩盖开启 或关闭的最大持续时间。用于防止因电机集成限位开关故障而导致的损坏。

  • start_sensing_delay (可选,Time):电机开始移动时电流检测被 禁用的时间。电机可能需要一些时间才能达到其平均功耗。 较低的值可能会因为首次电流读数发生在电流上升阶段而立即停止。 默认为 500ms。

  • obstacle_rollback (可选,百分比):检测到障碍物时罩盖将回滚的百分比。默认为 10%。

  • malfunction_detection (可选,布尔值):启用以检测故障(通常是焊接继电器)。默认为 True。

  • malfunction_action (可选,Action):检测到继电器故障时应执行的 动作。故障可能需要维修设备。你可以使用此动作 通知其他系统有关此情况。

  • Cover 中的所有其他选项。

Shelly 2.5 是此平台的理想硬件。它具有两个带电流监控的输出 (得益于内置的 ADE7953),外形非常小巧(39mm x 36mm x 17 mm)。 它还具有 NTC 温度传感器。

这些设备通常运行温度较高(20°C 室温下约 55°C)。长期重载(接近其额定极限)可能导致设备过热。 强烈建议使用 NTC 温度传感器监控设备温度,如果超过 90°C 则关闭设备。 此安全功能也存在于原始固件中。

WARNING

ADE7953 的 IRQ 线连接到 GPIO16。ADE7953 的 irq_pin 参数必须 设置为 GPIO16,以防止设备过热(>70°C 闲置)。

配置示例:

esphome:
name: Shelly 2.5
esp8266:
board: esp01_1m
restore_from_flash: true
i2c:
sda: GPIO12
scl: GPIO14
sensor:
- platform: ade7953_i2c
irq_pin: GPIO16
voltage:
name: Shelly 2.5 Mains Voltage
internal: true
filters:
- throttle: 5s
current_a:
name: Shelly 2.5 Open Current
id: open_current
internal: true
current_b:
name: Shelly 2.5 Close Current
id: close_current
internal: true
update_interval: 0.5s
# NTC 温度
- platform: ntc
sensor: temp_resistance_reading
name: Shelly 2.5 Temperature
unit_of_measurement: "°C"
accuracy_decimals: 1
calibration:
b_constant: 3350
reference_resistance: 10kOhm
reference_temperature: 298.15K
on_value_range:
above: 90
then: # 因过热进行安全关闭
- switch.turn_on: _shutdown
- platform: resistance
id: temp_resistance_reading
sensor: temp_analog_reading
configuration: DOWNSTREAM
resistor: 32kOhm
internal: true
- platform: adc
id: temp_analog_reading
pin: A0
update_interval: 30s
internal: true
binary_sensor:
- platform: gpio
pin:
number: GPIO13
name: Shelly 2.5 Open Button
on_press:
then:
cover.open: blind
- platform: gpio
pin:
number: GPIO5
name: Shelly 2.5 Close Button
on_press:
then:
cover.close: blind
switch:
- platform: shutdown
id: _shutdown
name: Shelly 2.5 Shutdown
- platform: gpio
id: open_relay
name: Shelly 2.5 Open Relay
pin: GPIO15
restore_mode: RESTORE_DEFAULT_OFF
interlock: &interlock [open_relay, close_relay]
interlock_wait_time: 200ms
- platform: gpio
id: close_relay
name: Shelly 2.5 Close Relay
pin: GPIO4
restore_mode: RESTORE_DEFAULT_OFF
interlock: *interlock
interlock_wait_time: 200ms
# 配置示例
cover:
- platform: current_based
name: Blind
id: blind
open_sensor: open_current
open_moving_current_threshold: 0.5
open_duration: 12s
open_action:
- switch.turn_on: open_relay
close_sensor: close_current
close_moving_current_threshold: 0.5
close_duration: 10s
close_action:
- switch.turn_on: close_relay
stop_action:
- switch.turn_off: close_relay
- switch.turn_off: open_relay
obstacle_rollback: 30%
start_sensing_delay: 0.8s
malfunction_detection: true
malfunction_action:
then:
- logger.log: "Malfunction detected. Relay welded."
status_led:
pin:
number: GPIO0
inverted: yes