mirror of
https://github.com/esphome/esphome-docs.git
synced 2024-12-25 17:17:54 +01:00
Add endstop cover guide
This commit is contained in:
parent
7929a73e59
commit
0ad211f102
@ -31,13 +31,13 @@ for some motors.
|
||||
.. code-block:: yaml
|
||||
|
||||
esphome:
|
||||
name: cover
|
||||
platform: ESP8266
|
||||
board: esp01_1m
|
||||
name: cover
|
||||
platform: ESP8266
|
||||
board: esp01_1m
|
||||
|
||||
wifi:
|
||||
ssid: '***'
|
||||
password: '***'
|
||||
ssid: '***'
|
||||
password: '***'
|
||||
|
||||
api:
|
||||
|
||||
@ -48,7 +48,7 @@ for some motors.
|
||||
binary_sensor:
|
||||
- platform: gpio
|
||||
pin:
|
||||
number: 10
|
||||
number: GPIO10
|
||||
inverted: true
|
||||
id: button
|
||||
on_press:
|
||||
@ -75,10 +75,10 @@ for some motors.
|
||||
|
||||
switch:
|
||||
- platform: gpio
|
||||
pin: 12
|
||||
pin: GPIO12
|
||||
id: open
|
||||
- platform: gpio
|
||||
pin: 5
|
||||
pin: GPIO5
|
||||
id: close
|
||||
|
||||
cover:
|
||||
@ -102,7 +102,8 @@ for some motors.
|
||||
stop_action:
|
||||
- switch.turn_off: open
|
||||
- switch.turn_off: close
|
||||
optimistic: true
|
||||
optimistic: True
|
||||
assumed_state: True
|
||||
|
||||
See Also
|
||||
--------
|
||||
|
113
cookbook/endstop-cover.rst
Normal file
113
cookbook/endstop-cover.rst
Normal file
@ -0,0 +1,113 @@
|
||||
Template Cover with Endstops
|
||||
============================
|
||||
|
||||
.. seo::
|
||||
:description: An example of how to integrate covers with endstops in ESPHome.
|
||||
:image: window-open.jpg
|
||||
|
||||
The following is an example configuration for controlling covers (like window blinds etc)
|
||||
with ESPHome. This guide assumes that the cover is set up with two endstops at the top
|
||||
and the bottom. When these endstops are reached, the cover will automatically stop.
|
||||
|
||||
To protect the motors from spinning indefinitely (in case an endstop fails) the motors
|
||||
also have a maximum run time - after 3 minutes they will automatically turn off even if the
|
||||
endstop is not reached.
|
||||
|
||||
ESPHome uses Home Assistant's cover architecture model which has two states: "OPEN" or
|
||||
"CLOSED". We will map OPEN to "cover is at the top endstop" and CLOSE to "cover is at the bottom".
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
switch:
|
||||
# The switch that turns the UP direction on
|
||||
- platform: gpio
|
||||
pin: D1
|
||||
id: up_pin
|
||||
# Use interlocking to keep at most one of the two directions on
|
||||
interlock: &interlock_group [up_pin, down_pin]
|
||||
# If ESP reboots, do not attempt to restore switch state
|
||||
restore_mode: always off
|
||||
|
||||
# The switch that turns the DOWN direction on
|
||||
- platform: gpio
|
||||
pin: D2
|
||||
id: down_pin
|
||||
interlock: *interlock_group
|
||||
restore_mode: always off
|
||||
|
||||
|
||||
binary_sensor:
|
||||
# The top endstop
|
||||
- platform: gpio
|
||||
pin: D4
|
||||
id: top_endstop
|
||||
on_press:
|
||||
# Acknowledge that the cover is open
|
||||
- cover.template.publish:
|
||||
id: my_cover
|
||||
state: OPEN
|
||||
# Stop the cover motors
|
||||
- cover.stop: my_cover
|
||||
|
||||
- platform: gpio
|
||||
pin: D5
|
||||
id: bottom_endstop
|
||||
on_press:
|
||||
# Acknowledge that the cover is closed
|
||||
- cover.template.publish:
|
||||
id: my_cover
|
||||
state: CLOSED
|
||||
# Stop the cover motors
|
||||
- cover.stop: my_cover
|
||||
|
||||
cover:
|
||||
- platform: template
|
||||
name: "My Endstop Cover"
|
||||
id: my_cover
|
||||
open_action:
|
||||
- switch.turn_on: up_pin
|
||||
# Failsafe: Turn off motors after 3min if endstop not reached.
|
||||
- delay: 3 min
|
||||
- cover.stop: my_cover
|
||||
close_action:
|
||||
- switch.turn_on: down_pin
|
||||
- delay: 3 min
|
||||
- cover.stop: my_cover
|
||||
stop_action:
|
||||
- switch.turn_off: up_pin
|
||||
- switch.turn_off: down_pin
|
||||
optimistic: True
|
||||
assumed_state: True
|
||||
|
||||
You can then optionally also add manual controls to the cover with three buttons:
|
||||
open, close, and stop.
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
binary_sensor:
|
||||
# [...] - Previous binary sensors
|
||||
- platform: gpio
|
||||
id: open_button
|
||||
pin: D3
|
||||
on_press:
|
||||
- cover.open: my_cover
|
||||
- platform: gpio
|
||||
id: close_button
|
||||
pin: D6
|
||||
on_press:
|
||||
- cover.close: my_cover
|
||||
- platform: gpio
|
||||
id: stop_button
|
||||
pin: D7
|
||||
on_press:
|
||||
- cover.stop: my_cover
|
||||
|
||||
See Also
|
||||
--------
|
||||
|
||||
- :doc:`/guides/automations`
|
||||
- :doc:`/components/cover/template`
|
||||
- :doc:`dual-r2-cover`
|
||||
- :ghedit:`Edit`
|
||||
|
||||
.. disqus::
|
@ -9,8 +9,6 @@ The following is a possible configuration file for garage doors that are control
|
||||
One for opening and another one for closing the garage door. When either one of them is turned on
|
||||
for a short period of time, the close/open action begins.
|
||||
|
||||
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
switch:
|
||||
|
@ -278,7 +278,7 @@ Cookbook
|
||||
|
||||
.. imgtable::
|
||||
|
||||
Garage Door, cookbook/garage-door, window-open.svg
|
||||
Endstop Cover, cookbook/endstop-cover, window-open.svg
|
||||
PIR Sensor, cookbook/pir, pir.jpg
|
||||
Relay, cookbook/relay, relay.jpg
|
||||
BRUH Multisensor, cookbook/bruh, bruh.png
|
||||
@ -290,6 +290,7 @@ Cookbook
|
||||
H801 LED Controller, cookbook/h801, h801.jpg
|
||||
Time & Temperature on OLED Display, cookbook/display_time_temp_oled, display_time_temp_oled_2.jpg
|
||||
Mirabella Genio Bulb, cookbook/mirabella-genio-bulb, cookbook-mirabella-genio-b22-rgbw.jpg
|
||||
Garage Door, cookbook/garage-door, window-open.svg
|
||||
|
||||
Do you have other awesome automations or cool setups? Please feel free to add them to the
|
||||
documentation for others to copy. See :doc:`Contributing </guides/contributing>`.
|
||||
|
Loading…
Reference in New Issue
Block a user