If you want to add a button to your dashboard that will trigger an automation once clicked, but you don't like the fact that by default the state will be always on, you can add an additional input_boolean. Below are the steps how to do this.
To define an input_boolean in Home Assistant, you can add it to your configuration.yaml
file. Here’s how to do it:
Open your
configuration.yaml
file in Home Assistant.Add the Input Boolean definition under the
input_boolean
section. If the section doesn’t exist yet, you can create it.rain_water_pump_button
: This is the entity ID for your input boolean.name
: This is the name that will appear in the UI.initial
: Setting this tooff
means the button will be off each time Home Assistant restarts.
Save the Configuration and Restart Home Assistant:
- After saving your changes, go to Settings > System > Restart to apply the new configuration.
Create a Combined Automation: This automation will:
- Turn the
rain_water_pump_button
“on” for 2 seconds to confirm the button press. - Trigger
switch.rain_water_pump
for 3 minutes, then turn it off.
- Turn the
Update the Dashboard Button: Here’s the updated configuration for the dashboard button to trigger the
input_boolean
instead of the automation directly. This way, pressing the button will activate the whole process:- The dashboard button will change to "on" for 2 seconds when pressed.
- The
input_boolean
state change triggers theswitch.rain_water_pump
to turn on for 3 minutes and then turn off automatically.
With this setup:
No comments:
Post a Comment