Automation

Home Assistant Toggle Switch: Complete Guide 2026

AliExpress
TL;DR: Create a Home Assistant toggle switch by combining an input_boolean helper (the toggle), two scripts (on/off actions), and an automation that links them. The toggle appears on your dashboard. When tapped, the automation reads its new state and calls the matching script. Works for any device, even ones without a native HA integration, by sending IR/RF commands via a Broadlink or similar remote.

Updated for 2026. This guide covers the input_boolean toggle helper, toggle switch automations, the toggle helper, and switch button creation – all in one place.

Home Assistant Toggle Switch: Complete Guide

Sometimes you need to control a “dumb” device from Home Assistant – a fan, AC, TV – that has no smart integration. The trick is combining three pieces: an input_boolean helper (the toggle), scripts that send the actual on/off commands, and an automation that links them. This guide walks through the full setup with working YAML, then shows the variations: toggle helper vs toggle switch vs toggle button, switch automations, and how to bind everything to a single dashboard control.

What is a Home Assistant Toggle Switch?

In Home Assistant, “toggle switch” can mean a few different things:

  • Toggle Helper / input_boolean: a virtual on/off switch that lives in HA. No physical hardware. Used to track state and trigger automations.
  • Physical switch (switch entity): a real device integrated into HA, like a Shelly relay or Z-Wave switch.
  • Toggle button: a dashboard card that toggles any switchable entity when tapped.

This guide focuses on the most useful pattern: using a toggle helper plus scripts to control a device that HA can’t directly turn on or off. The Bedroom Fan example uses a Broadlink RF remote, but the same pattern works for IR remotes, REST commands, MQTT messages, or anything else you can script.

Prerequisites

  1. A working Home Assistant setup
  2. The device you want to control, integrated via a remote (Broadlink, Tuya IR, ESPHome IR transmitter, etc.) or any other method that can send commands
  3. Basic understanding of YAML in configuration.yaml, scripts.yaml, and automations.yaml

Step 1: Create the On and Off Scripts

Scripts are the action layer. They contain the actual command to turn the device on or off. Add these to scripts.yaml (or via Settings > Automations & Scenes > Scripts):

bedroom_fan_on:
  alias: "Turn On Bedroom Fan"
  icon: hass:fan
  mode: single
  sequence:
    - service: remote.send_command
      target:
        entity_id: remote.broadlink_pro_remote
      data:
        command: b64:sgYyAAoYFgwWDAoYChgWDAoYFgwWCxYMChgKGBYMFgwKGBYMChgWDAoYChgWDBYMChcWDArcAAAAAAAA

bedroom_fan_off:
  alias: "Turn Off Bedroom Fan"
  icon: hass:fan-off
  mode: single
  sequence:
    - service: remote.send_command
      target:
        entity_id: remote.broadlink_pro_remote
      data:
        command: b64:sgYyAAoXFgsWCwoXChcKFxYLChgXCxYMChcKFxYLChcWCwoYChcWCwoXChcWCwoXChcKFwrcAAAAAAAA

Replace remote.broadlink_pro_remote with your actual remote entity. The command values are the Base64-encoded RF codes captured by your Broadlink during the learning process.

Step 2: Create the Toggle Switch Helper (input_boolean)

The toggle helper is the virtual switch that appears on your dashboard. It’s just a state container – “on” or “off” – that triggers your automation when changed.

Option A: Via the UI

Go to Settings > Devices & Services > Helpers > Create Helper > Toggle. Give it a name like “Bedroom Fan”.

Creating a toggle helper in Home Assistant UI

Option B: Via configuration.yaml

input_boolean:
  bedroom_fan_switch:
    name: Bedroom Fan
    initial: off
    icon: mdi:fan

Restart Home Assistant after editing configuration.yaml. The new toggle now exists as the entity input_boolean.bedroom_fan_switch.

Step 3: Create the Toggle Switch Automation

The automation is the glue. It watches the toggle helper for state changes and calls the matching script.

Toggle switch automation in Home Assistant

automation:
  - alias: "Bedroom Fan Control"
    trigger:
      - platform: state
        entity_id: input_boolean.bedroom_fan_switch
    action:
      - choose:
          - conditions:
              - condition: state
                entity_id: input_boolean.bedroom_fan_switch
                state: 'on'
            sequence:
              - service: script.bedroom_fan_on
          - conditions:
              - condition: state
                entity_id: input_boolean.bedroom_fan_switch
                state: 'off'
            sequence:
              - service: script.bedroom_fan_off

How the Automation Works

  1. Trigger: any state change on input_boolean.bedroom_fan_switch fires the automation
  2. Action with choose: evaluates two conditions in order
  3. If the new state is on, run script.bedroom_fan_on
  4. If the new state is off, run script.bedroom_fan_off

That’s the complete loop: tap toggle → state changes → automation triggers → script runs → device responds.

Home Assistant Toggle Helper vs Toggle Switch Automation

A common confusion: do you need the automation if you have the toggle helper? Yes. The toggle helper by itself does nothing – it’s just a tracked state. The automation is what makes the toggle actually do something. Three pieces, all required:

  • Toggle helper (input_boolean): the on/off state
  • Scripts: the commands sent to the device
  • Automation: links state changes to script calls

Home Assistant Switch Toggle: Adding It to Your Dashboard

To use the toggle from the HA dashboard, add a card pointing to the input_boolean. The simplest is a tile card:

type: tile
entity: input_boolean.bedroom_fan_switch
name: Bedroom Fan
icon: mdi:fan
tap_action:
  action: toggle

For a bigger button-style control, use a button card:

type: button
entity: input_boolean.bedroom_fan_switch
name: Bedroom Fan
icon: mdi:fan
tap_action:
  action: toggle
show_state: true

Both render as tappable controls that flip the toggle, which triggers the automation, which fires the script.

Home Assistant Toggle Button vs Switch Button

Functionally they’re identical for this use case. The difference is visual:

  • Toggle button: a slider-style on/off control with clear on/off positions
  • Switch button: a tappable button that toggles state, often with an icon change to reflect state

Both call tap_action: toggle under the hood, so pick whichever matches your dashboard aesthetic.

Home Assistant Automation Toggle Switch: Common Variations

Toggle by voice (Alexa, Google Assistant)

Expose the input_boolean to your voice assistant, then “Alexa, turn on bedroom fan” toggles it, triggering the automation. Configure exposure under Settings > Voice assistants.

Toggle on schedule

automation:
  - alias: "Bedroom Fan On at Bedtime"
    trigger:
      - platform: time
        at: "22:00:00"
    action:
      - service: input_boolean.turn_on
        target:
          entity_id: input_boolean.bedroom_fan_switch

Toggle on sensor trigger

automation:
  - alias: "Fan on when room is warm"
    trigger:
      - platform: numeric_state
        entity_id: sensor.bedroom_temperature
        above: 26
    action:
      - service: input_boolean.turn_on
        target:
          entity_id: input_boolean.bedroom_fan_switch

Why Not Just Use a Template Switch?

Good question. A template switch can wrap the on/off scripts directly without an input_boolean. The downside: template switches don’t always sync state correctly if the device is also controlled externally (via the original remote). The input_boolean + automation pattern is more robust because the state is owned entirely by Home Assistant.

If your device is fully under HA’s control (no manual remote use), a template switch is cleaner:

switch:
  - platform: template
    switches:
      bedroom_fan:
        friendly_name: "Bedroom Fan"
        value_template: "{{ is_state('input_boolean.bedroom_fan_switch', 'on') }}"
        turn_on:
          service: script.bedroom_fan_on
        turn_off:
          service: script.bedroom_fan_off

Need to Control IR/RF Devices?

For controlling fans, ACs, TVs, and other IR/RF-only devices, you need a learning remote that integrates with Home Assistant. The Broadlink RM4 Pro is the most popular option – works with HA natively, learns almost any IR or RF command, and costs under $50. Once it’s set up, you capture the original remote’s button presses and replay them via the remote.send_command service exactly as shown in the scripts above.

Conclusion

The toggle helper + script + automation pattern unlocks Home Assistant control over any device, even ones with zero smart features. Once you understand the three-piece structure, you can build toggle switches for fans, ACs, projectors, blinds, anything controllable by IR, RF, REST, MQTT, or any other Home Assistant service. The toggle becomes your unified dashboard control regardless of what’s behind it.

Frequently Asked Questions

How do I create a Home Assistant toggle switch?

You need three components: an input_boolean helper (the toggle), on/off scripts that send the actual commands to your device, and an automation that triggers the right script when the toggle state changes. Create the helper via Settings > Devices & Services > Helpers > Create Helper > Toggle, write your scripts in scripts.yaml, and link them with an automation that uses the choose action.

What is a toggle helper in Home Assistant?

A toggle helper, technically called input_boolean, is a virtual on/off switch in Home Assistant that has no physical hardware. It just stores an “on” or “off” state. The value of a toggle helper is that automations can watch it for changes and trigger actions, making it the bridge between dashboard taps and scripts that control real devices.

What’s the difference between a toggle switch and an automation toggle switch in Home Assistant?

A toggle switch (input_boolean) is just the state container – it does nothing on its own. An automation toggle switch refers to the full pattern: the toggle plus the automation that listens for its state changes and runs corresponding actions. You need both for the toggle to actually do something.

Can I use a toggle helper without an automation?

Yes, if you only need to track state for other automations to read. For example, an “Away Mode” toggle that other automations check before running. But if you want tapping the toggle to actually control a device, you need an automation that links the toggle to scripts.

How do I create a toggle switch button in Home Assistant?

Add a tile card or button card to your dashboard pointing to your input_boolean entity. Set tap_action to “toggle”. The card displays as a tappable button that flips the helper state, which then triggers your automation and runs the matching script.

Why use input_boolean instead of a template switch?

Template switches work great if Home Assistant fully controls the device. But if the device can also be controlled externally (like manual remote presses), template switches can lose sync with the real device state. The input_boolean + automation pattern keeps state ownership entirely in HA, which is more robust for devices controlled via IR/RF commands.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.