This is a slightly modified version of a post I originally made on the Home Assistant forums.
When a Shelly 2.5 is controlling roller shutters, there exists the ability to set the “Input buttons” mode of the Shelly. This allows for the possibility of the shutters to be controlled with two separate buttons – one for up, one for down-- OR one button.
In the case of “one button” mode, every time the button is pressed, the roller will go in the next sequence step. For example, a button press would start the opening the roller, the next would stop the rolling, the next would start closing the roller, the next press would stop it, etc.
As I have two physical buttons to control my roller, I wanted to use both buttons to control the roller however I wanted to emulate this one button mode using Home Assistant. With the Shelly integrated as a cover
, this was relatively straightforward: I needed to keep track of the last state of the roller and either open or close the roller based on the last state of the roller or if currently moving ('closing' or 'opening') then stop the roller.
To do this, I created one automation with an action to store the cover's last state in an input_select
(an input_text
would have worked as well) that was triggered every time there was a state_changed event for the cover. I then created a second automation that, when triggered, would either call cover.open_cover
or cover.close_cover
depending on the last state of the cover which is stored in the input_select
as an option/value or cover.stop_cover
if it is currently moving.
With a two-button Aqara Oppolo Zigbee switch, I get to have my 'one button' mode while still having my existing roller buttons work as marked.
Here are the two automations:
# Automation to keep the last state of the cover
alias: Set Bedroom Shutters Last State
description: Used to keep track of Bedroom Shutters’ last state
trigger:
- platform: event
event_type: state_changed
condition:
- condition: template
value_template: |
{{ trigger.event.data.entity_id == "cover.bedroom_shutters" }}
action:
- service: input_select.select_option
data:
option: |
{% if trigger.event.data.old_state.state == 'opening' %}
{{ trigger.event.data.old_state.state }}
{% elif trigger.event.data.old_state.state == 'closing' %}
{{ trigger.event.data.old_state.state }}
{% endif %}
entity_id: input_select.bedroom_shutter_last_state
mode: single
# The one button automation
alias: Toggle Bedroom Shutters
description: 'Enables a single button to cycle through the open/stop/close/stop sequence. '
trigger:
- device_id: 6124f02a20f611eb8f2d55764adf7b07
domain: zha
platform: device
type: remote_button_alt_short_press
subtype: button_1
condition: []
action:
- choose:
- conditions:
- condition: state
entity_id: cover.bedroom_shutters
state: closing
sequence:
- service: cover.stop_cover
entity_id: cover.bedroom_shutters
- conditions:
- condition: state
entity_id: cover.bedroom_shutters
state: opening
sequence:
- service: cover.stop_cover
entity_id: cover.bedroom_shutters
- conditions:
- condition: state
entity_id: input_select.bedroom_shutter_last_state
state: closing
sequence:
- service: cover.open_cover
entity_id: cover.bedroom_shutters
- conditions:
- condition: state
entity_id: input_select.bedroom_shutter_last_state
state: opening
sequence:
- service: cover.close_cover
entity_id: cover.bedroom_shutters
- conditions:
- condition: state
entity_id: input_select.bedroom_shutter_last_state
state: closed
sequence:
- service: cover.open_cover
target:
entity_id: cover.bedroom_shutters
- conditions:
- condition: state
entity_id: input_select.bedroom_shutter_last_state
state: open
sequence:
- service: cover.close_cover
target:
entity_id: cover.bedroom_shutters
default:
- service: cover.stop_cover
entity_id: cover.bedroom_shutters
mode: single