input_boolean): Settings > Devices & services > Helpers > Create helper > Toggle. It controls nothing by itself, but your automations can read it and react to it, which makes it perfect for guest mode, vacation mode or a “pause automations” switch.A Home Assistant virtual switch is a switch with no hardware behind it. You can flip it on your dashboard, by voice or from an automation, and Home Assistant remembers whether it is on or off. That is all it does. The magic comes from what you connect to it.
Think of it as a sticky note that says “guests are here” or “we are on holiday”. Your automations look at the note and change how they behave. This guide shows how to create one in two minutes, the YAML alternative, four beginner projects, and the mistakes that trip most people up.
Everything here is written for Home Assistant 2026.10 and newer, and all YAML uses the current syntax (triggers:, conditions:, actions: and action:).
What a virtual switch is (and the three kinds)
Home Assistant does not have one feature called “virtual switch”. People use the name for three different tools, and it helps to know which one you need.
1. Toggle helper (input_boolean)
A helper is a small building block you create inside Home Assistant, like a timer, a counter or a dropdown. The Toggle helper is the on/off one. Its technical name is input_boolean (“boolean” just means a value that is either true or false). It creates an entity, which is Home Assistant’s word for one thing it can show or control, named something like input_boolean.guest_mode.
This is what most people mean by a virtual switch, and it is the right choice 90% of the time.
2. Template switch
A Template switch is a real switch entity whose on and off buttons run whatever actions you choose. You can also give it a “state” rule so it shows the true state of something else. It is handy when you want one entity that both shows a state and sends commands. You can create it in the UI under Helpers > Create helper > Template > Switch, or in YAML (example further down).
3. “Switch as x”
This helper does not create a new switch. It takes an existing switch and presents it as another type of device: a light, fan, cover, lock, siren or valve. A smart plug that powers a lamp is the classic case. Wrap it with Switch as x and Home Assistant (and your voice assistant) treats it as a light. Find it under Helpers > Create helper > Switch as x.
How to create a virtual switch in the UI
- Go to Settings > Devices & services and open the Helpers tab.
- Click Create helper in the bottom right corner.
- Pick Toggle from the list.
- Give it a clear name, for example “Guest mode”. Pick an icon if you like (for example
mdi:account-multiple). - Optional: open More options to choose what happens at startup. The default restores the last state, which is usually what you want.
- Click Create.
Home Assistant now has input_boolean.guest_mode. You can add it to a dashboard with an Entities card or a Tile card and tap it like any light switch.
The YAML alternative
YAML is the plain text format Home Assistant uses for its configuration files. If you prefer to keep your setup in files, add this to configuration.yaml:
input_boolean:
guest_mode:
name: Guest mode
icon: mdi:account-multiple
vacation_mode:
name: Vacation mode
icon: mdi:airplane
pause_automations:
name: Pause automations
icon: mdi:pause-circle
Then restart Home Assistant, or reload from Developer tools > YAML and choose the input booleans entry. Helpers made in YAML cannot be edited from the UI later, so pick one method per helper and stick with it.
There is one more option, initial: false (or true). Leave it out unless you really want the switch reset on every restart. Without it, the helper remembers its last state.
Using a virtual switch in automations
A virtual switch shows up in automations in two ways. Both are worth knowing because every project below uses one or the other.
As a condition: “only run when…”
A condition is a check that has to pass before the automation does anything. Here the hallway light only reacts to motion when the “Pause automations” switch is off:
alias: Hallway light on motion
triggers:
- trigger: state
entity_id: binary_sensor.hallway_motion
to: "on"
conditions:
- condition: state
entity_id: input_boolean.pause_automations
state: "off"
actions:
- action: light.turn_on
target:
entity_id: light.hallway
In the automation editor this is Add condition > State, then pick the helper and set the state to Off.
As a trigger: “when it flips, do this”
A trigger is the event that starts an automation. Here, turning on vacation mode switches off every light and sends a phone notification:
alias: Vacation mode starts
triggers:
- trigger: state
entity_id: input_boolean.vacation_mode
from: "off"
to: "on"
actions:
- action: light.turn_off
target:
entity_id: all
- action: notify.mobile_app_your_phone
data:
message: Vacation mode is on. All lights are off.
Replace notify.mobile_app_your_phone with your own phone’s notify action (you will find it in Developer tools > Actions if the Home Assistant app is installed on your phone).
4 practical uses for beginners
1. Guest mode
When friends stay over, you do not want the lights going off at midnight or the bathroom fan announcing itself at 6am. Create a “Guest mode” toggle and add it as a condition (state “off”) to the automations that would annoy visitors. Flip it on when guests arrive and off when they leave. Nothing else needs to change.
2. Vacation mode
Use it as a trigger, like the example above, to switch things off when you leave. Then use it as a condition on a “fake presence” automation that turns a living room lamp on in the evening, but only while vacation mode is on:
alias: Vacation evening lamp
triggers:
- trigger: sun
event: sunset
offset: "00:20:00"
conditions:
- condition: state
entity_id: input_boolean.vacation_mode
state: "on"
actions:
- action: light.turn_on
target:
entity_id: light.living_room_lamp
- delay:
hours: 3
- action: light.turn_off
target:
entity_id: light.living_room_lamp
If your phones already report location, you can also turn vacation mode on automatically. Our geofencing guide covers the location side.
3. A “pause automations” switch
Sometimes you just want the house to stop being clever. Maybe you are painting the hallway or fixing a sensor. Add the pause_automations condition to your motion and schedule automations, as in the hallway example above. One tap on the dashboard and they all sit still until you switch it back.
This is easier and safer than disabling ten automations by hand, because you will not forget which ones you turned off.
4. A dashboard button for a “dumb” device
A virtual switch can also stand in for a device that has no smart features, like a fan with an RF remote or an old air conditioner. The toggle sits on your dashboard, two scripts send the real on and off commands (for example through an IR or RF blaster), and one automation runs the right script when the toggle flips.
That build has a few moving parts, so we wrote a full step-by-step guide for it: how to build a Home Assistant toggle switch for any device. If you want one toggle that switches several lights at once, see toggle several entities with one helper. For older gear with serial ports or infrared, this RS-232, IR and RF guide shows how to send the commands.
When to use a Template switch instead
With the Toggle helper approach you end up with three pieces: the toggle, the scripts and the automation. A Template switch folds them into one entity. This example runs two existing scripts:
template:
- switch:
- name: Bedroom fan
unique_id: bedroom_fan_template_switch
turn_on:
- action: script.bedroom_fan_on
turn_off:
- action: script.bedroom_fan_off
Because there is no state: line, the switch runs in “optimistic” mode. That means it assumes each command worked and shows on or off based on the last button you pressed. If you have a sensor that tells you the real state (a power plug that measures watts, for example), add a state: template and the switch will follow reality instead.
A bonus: a Template switch is a normal switch entity, so you can wrap it with Switch as x and turn it into a fan or light. Voice assistants then understand “turn on the bedroom fan” more naturally.
Our rule of thumb: use a Toggle helper for modes (guest, vacation, pause) and a Template switch when the switch stands for a device.
Controlling a virtual switch by voice
Home Assistant only lets voice assistants see entities you choose, so locks and garage doors are not opened by accident. New helpers are usually not exposed, so do it yourself:
- Go to Settings > Voice assistants and open the Expose tab.
- Click Expose entities, search for your helper and select it.
- Choose which assistants get it: Assist (Home Assistant’s own), Google Assistant or Alexa.
Now “turn on guest mode” works in Assist. Google Assistant and Alexa need to be connected to Home Assistant first, for example through Home Assistant Cloud. The official exposing entities to Assist page has the details. Give the helper a short, unique name so the assistant does not confuse it with a real device.
Common mistakes
- Expecting the switch to control something by itself. A Toggle helper only stores on or off. If nothing reads it, nothing happens. You always need an automation, a condition or a Template switch around it.
- Forgetting the quotes around “on” and “off”. In YAML, a bare
onis read as true, not the text “on”. Writestate: "on"andto: "off"with quotes. - Leaving out
to:in a state trigger. Without it, the automation can also fire when the helper becomes unavailable during a restart. Always say which state you care about. - Adding
initial:by habit. It resets the switch at every restart. Vacation mode turning itself off after an update is not fun. - Creating loops. An automation that is triggered by the helper and also changes the same helper can keep firing itself. If you really need both, add a condition so it only changes the helper when it has to.
- Using vague names. “Switch 1” means nothing six months from now. Name the helper after what it means, like “Guest mode”, so your automations read like plain sentences.
New to Home Assistant and do not have it running yet? Start with our Raspberry Pi install guide, then come back here. The full list of Toggle helper options is on the official input_boolean documentation.
Frequently asked questions
Is a virtual switch the same as an input_boolean?
Mostly, yes. When people say “virtual switch” in Home Assistant they usually mean a Toggle helper, which creates an input_boolean entity. A Template switch is the other common kind: it is a real switch entity that runs actions you define.
Does a virtual switch keep its state after a restart?
Yes, by default a Toggle helper restores the state it had before Home Assistant stopped. It only resets if you set “initial” in YAML or choose a fixed startup state under More options in the UI.
Can a virtual switch control a real device?
Not on its own. You connect it with an automation that turns the device on or off when the switch changes, or you use a Template switch that runs your on and off actions directly.
Should I use a Toggle helper or a Template switch?
Use a Toggle helper for modes like guest mode, vacation mode or pausing automations. Use a Template switch when the switch represents one device and you want a single entity that sends the commands.






