2021-09-27 22:23:50 +02:00
|
|
|
Current Based Cover
|
|
|
|
===================
|
|
|
|
|
|
|
|
.. seo::
|
|
|
|
:description: Instructions for setting up current-based covers in ESPHome.
|
2021-11-16 03:19:33 +01:00
|
|
|
:image: window-open.svg
|
2021-09-27 22:23:50 +02:00
|
|
|
|
|
|
|
The ``current_based`` cover platform allows you to create covers with position control by using current
|
2021-11-16 03:19:33 +01:00
|
|
|
sensors to detect the fully-open and fully-closed states. This is pretty useful when using motors with
|
|
|
|
integrated mechanical endstops. During cover operation, the component monitors the current consumption
|
|
|
|
to detect when the motor has stopped.
|
2021-09-27 22:23:50 +02:00
|
|
|
|
2021-11-16 03:19:33 +01:00
|
|
|
When fully open or close is requested, the corresponding relay will stay on until the current the motor is
|
2021-09-27 22:23:50 +02:00
|
|
|
consuming goes below a certain amount. The amount of current needs to be specified in the configuration.
|
|
|
|
|
|
|
|
Open and close durations can be specified to allow ESPHome to approximate the current position of the cover.
|
|
|
|
|
|
|
|
.. figure:: images/more-info-ui.png
|
|
|
|
:align: center
|
|
|
|
:width: 75.0%
|
|
|
|
|
2021-11-16 03:19:33 +01:00
|
|
|
This type of cover also provides safety features like current-based obstacle detection with automatic configurable
|
|
|
|
rollback as well as relay malfunction detection: operation cancels if there's a current flowing in the opposite
|
|
|
|
operation circuit (typically caused by welded relays).
|
2021-09-27 22:23:50 +02:00
|
|
|
|
|
|
|
.. warning::
|
|
|
|
|
2021-11-16 03:19:33 +01:00
|
|
|
Depending on the cover and motor type, obstacles can physically damage the cover before being detectable.
|
|
|
|
Verify your setup to ensure the current consumption will increase enough to be detectable before causing
|
2021-09-27 22:23:50 +02:00
|
|
|
any physical damage. Use it at your own risk.
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
# Example configuration entry
|
|
|
|
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
|
2021-11-16 03:19:33 +01:00
|
|
|
|
2021-09-27 22:23:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
Configuration variables:
|
|
|
|
------------------------
|
|
|
|
|
|
|
|
- **name** (**Required**, string): The name of the cover.
|
|
|
|
- **open_sensor** (**Required**, :ref:`config-id`): The open current sensor.
|
|
|
|
- **open_action** (**Required**, :ref:`Action <config-action>`): The action that should
|
|
|
|
be performed when the remote requests the cover to be opened.
|
|
|
|
- **open_duration** (**Required**, :ref:`config-time`): The amount of time it takes the cover
|
|
|
|
to open up from the fully-closed state.
|
2021-11-16 03:19:33 +01:00
|
|
|
- **open_moving_current_threshold** (**Required**, float): The amount of current in Amps the motor
|
|
|
|
should drain to consider the cover is opening.
|
|
|
|
- **open_obstacle_current_threshold** (**Required**, float): The amount of current in Amps the motor
|
2021-09-27 22:23:50 +02:00
|
|
|
should drain to consider the cover is blocked during opening.
|
|
|
|
- **close_sensor** (**Required**, :ref:`config-id`): The close current sensor.
|
|
|
|
- **close_action** (*Optional*, :ref:`Action <config-action>`): The action that should
|
|
|
|
be performed when the remote requests the cover to be closed.
|
|
|
|
- **close_duration** (**Required**, :ref:`config-time`): The amount of time it takes the cover
|
|
|
|
to close from the fully-open state.
|
2021-11-16 03:19:33 +01:00
|
|
|
- **close_moving_current_threshold** (**Required**, float): The amount of current in Amps the motor
|
2021-09-27 22:23:50 +02:00
|
|
|
should drain to consider the cover is closing.
|
2021-11-16 03:19:33 +01:00
|
|
|
- **close_obstacle_current_threshold** (**Required**, float): The amount of current in Amps the motor
|
2021-09-27 22:23:50 +02:00
|
|
|
should drain to consider the cover is blocked during closing.
|
|
|
|
- **stop_action** (**Required**, :ref:`Action <config-action>`): The action that should
|
|
|
|
be performed to stop the cover.
|
|
|
|
- **max_duration** (*Optional*, :ref:`config-time`): The maximum duration the cover should be opening
|
|
|
|
or closing. Useful for protecting from dysfunctional motor integrated endstops.
|
2021-11-16 03:19:33 +01:00
|
|
|
- **start_sensing_delay** (*Optional*, :ref:`config-time`): The amount of time the current sensing will be
|
|
|
|
disabled when the movement starts. Motors can take some time before reaching their average consumption.
|
|
|
|
Low values can cause an immediate stop because of the first current reading happening in the current-rising period.
|
2021-09-27 22:23:50 +02:00
|
|
|
Defaults to ``500ms``.
|
2021-11-16 03:19:33 +01:00
|
|
|
- **obstacle_rollback** (*Optional*, percentage): The percentage of rollback the cover will perform in case of
|
2021-09-27 22:23:50 +02:00
|
|
|
obstacle detection. Defaults to ``10%``.
|
|
|
|
- **malfunction_detection** (*Optional*, boolean): Enable to detect malfunction detection (Tipically welded realys). Defaults to ``True``.
|
|
|
|
- **malfunction_action** (*Optional*, :ref:`Action <config-action>`): The action that should
|
2021-11-16 03:19:33 +01:00
|
|
|
be performed when relay malfunction is detected. Malfunction may require device servicing. You can use this action
|
2021-09-27 22:23:50 +02:00
|
|
|
to notify other systems about this situation
|
|
|
|
- **id** (*Optional*, :ref:`config-id`): Manually specify the ID used for code generation.
|
|
|
|
- All other options from :ref:`Cover <config-cover>`.
|
|
|
|
|
|
|
|
Use with Shelly 2.5
|
|
|
|
-------------------
|
|
|
|
|
|
|
|
The Shelly 2.5 is the perfect hardware for this platform. It features two outputs with current monitoring
|
2021-11-16 03:19:33 +01:00
|
|
|
(thanks to an embedded :doc:`ADE7953 </components/sensor/ade7953>`) in a very small form factor (39mm x 36mm x 17 mm).
|
2021-09-27 22:23:50 +02:00
|
|
|
It also features an :doc:`NTC temperature sensor </components/sensor/ntc>`.
|
|
|
|
|
|
|
|
.. figure:: images/shelly2.5.png
|
|
|
|
:align: center
|
|
|
|
:width: 30.0%
|
|
|
|
|
2021-11-16 03:19:33 +01:00
|
|
|
These devices typically run hot (~55Cº at 20ºC room temperature). Long-term heavy loads (near to its rated limit) can overheat the device.
|
|
|
|
It is strongly recommended to monitor the device temperature using the NTC temperature sensor, shutting down the device if it exceeds 90ºC.
|
2021-09-27 22:23:50 +02:00
|
|
|
This safety feature is also present in the original firmware.
|
|
|
|
|
|
|
|
.. warning::
|
|
|
|
|
2021-11-16 03:19:33 +01:00
|
|
|
The ADE7953 IRQ line is connected to the GPIO16. The ``irq_pin`` parameter for the :doc:`ADE7953 </components/sensor/ade7953>` MUST be
|
2021-09-27 22:23:50 +02:00
|
|
|
set to GPIO16 to prevent device overheat (>70ºC idling).
|
|
|
|
|
|
|
|
Configuration example:
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
esphome:
|
|
|
|
name: Shelly 2.5
|
2022-02-10 23:10:43 +01:00
|
|
|
|
|
|
|
esp8266:
|
2021-09-27 22:23:50 +02:00
|
|
|
board: esp01_1m
|
2022-02-10 23:10:43 +01:00
|
|
|
restore_from_flash: true
|
2021-09-27 22:23:50 +02:00
|
|
|
|
|
|
|
i2c:
|
|
|
|
sda: GPIO12
|
|
|
|
scl: GPIO14
|
2021-11-16 03:19:33 +01:00
|
|
|
|
2021-09-27 22:23:50 +02:00
|
|
|
sensor:
|
|
|
|
- platform: ade7953
|
|
|
|
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
|
2021-11-16 03:19:33 +01:00
|
|
|
|
2021-09-27 22:23:50 +02:00
|
|
|
# NTC Temperature
|
|
|
|
- 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
|
2021-11-16 03:19:33 +01:00
|
|
|
on_value_range:
|
2021-09-27 22:23:50 +02:00
|
|
|
above: 90
|
|
|
|
then: # Security shutdown by overheating
|
|
|
|
- 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:
|
2021-11-16 03:19:33 +01:00
|
|
|
- platform: gpio
|
2021-09-27 22:23:50 +02:00
|
|
|
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
|
|
|
|
|
|
|
|
# Example configuration entry
|
|
|
|
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:
|
2021-11-16 03:19:33 +01:00
|
|
|
- logger.log: "Malfunction detected. Relay welded."
|
|
|
|
|
2021-09-27 22:23:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
status_led:
|
|
|
|
pin:
|
|
|
|
number: GPIO0
|
|
|
|
inverted: yes
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
See Also
|
|
|
|
--------
|
|
|
|
|
|
|
|
- :doc:`index`
|
|
|
|
- :doc:`/components/cover/template`
|
|
|
|
- :doc:`/components/sensor/ade7953`
|
|
|
|
- :ref:`automation`
|
|
|
|
- :apiref:`current_based/current_based_cover.h`
|
|
|
|
- :ghedit:`Edit`
|