Internal Automations
Prepare some internal automations!
Advanced Automation with Multi-Click
For more advanced control, you can use ESPHome's on_multi_click feature. This allows you to assign different actions to short and long presses of a momentary switch, giving you full control over movement and tilt with just two buttons.
Here is a recommended configuration that provides intuitive control:
binary_sensor:
# UP Button
- platform: gpio
name: 'IN_01'
id: in_01
pin:
pcf8574: pcf_inputs_1to14
number: 0
mode:
input: true
inverted: true
on_multi_click:
- timing:
- ON for at least 2s # Long press
then:
- lambda: |
auto call = id(cover_01).make_call();
if(id(cover_01).current_operation == COVER_OPERATION_IDLE){
call.set_command_open();
}
else {
call.set_command_stop();
}
call.perform();
- timing:
- ON for at most 0.4s # Short press
- OFF for at least 0.1s
then:
- lambda: |
auto call = id(cover_01).make_call();
if (id(cover_01).current_operation == COVER_OPERATION_IDLE){
if (id(cover_01).tilt < 1.0){
float new_tilt = std::min(id(cover_01).tilt + 0.1f, 1.0f);
call.set_tilt(new_tilt);
}
}
else {
call.set_command_stop();
}
call.perform();
# DOWN Button
- platform: gpio
name: 'IN_02'
id: in_02
pin:
pcf8574: pcf_inputs_1to14
number: 1
mode:
input: true
inverted: true
on_multi_click:
- timing:
- ON for at least 2s # Long press
then:
- lambda: |
auto call = id(cover_01).make_call();
if(id(cover_01).current_operation == COVER_OPERATION_IDLE){
call.set_command_close();
}
else {
call.set_command_stop();
}
call.perform();
- timing:
- ON for at most 0.4s # Short press
- OFF for at least 0.1s
then:
- lambda: |
auto call = id(cover_01).make_call();
if (id(cover_01).current_operation == COVER_OPERATION_IDLE){
if (id(cover_01).tilt > 0.0){
float new_tilt = std::max(id(cover_01).tilt - 0.1f, 0.0f);
call.set_tilt(new_tilt);
}
}
else {
call.set_command_stop();
}
call.perform();How It Works:
This configuration uses two buttons (IN_01 for UP and IN_02 for DOWN) to control a single cover (cover_01).
-
Long Press (Up/Down Button):
- If the cover is idle, it starts moving up or down.
- If the cover is already moving, it stops.
-
Short Press (Up/Down Button):
- If the cover is idle, it adjusts the tilt of the slats (lamellas) in 10% increments. This is perfect for Venetian blinds.
- If the cover is moving, it stops.