Switch

The Switch integrationIntegrations connect and integrate Home Assistant with your devices, services, and more. [Learn more] manages the state of the switch entities and allows you to control them.

  • Maintains a state per switch and a combined state all_switches.
  • Registers actions switch.turn_on, switch.turn_off, and switch.toggle to control switches.

Note

Building block integration

This switch is a building block integration that cannot be added to your Home Assistant directly but is used and provided by other integrations.

A building block integration differs from the typical integration that connects to a device or service. Instead, other integrations that do integrate a device or service into Home Assistant use this switch building block to provide entities, services, and other functionality that you can use in your automations or dashboards.

If one of your integrations features this building block, this page documents the functionality the switch building block offers.

The state of a switch entity

The state of a switch entityAn entity represents a sensor, actor, or function in Home Assistant. Entities are used to monitor physical properties or to control other entities. An entity is usually part of a device or a service. [Learn more] can be either On or Off.

In addition, the entity can have the following states:

  • Unavailable: The entity is currently unavailable.
  • Unknown: The state is not yet known.

Device class

A device class is a measurement categorization in Home Assistant. It influences how the entity is represented in the dashboard. This can be modified in the customize section. For example, different states may be represented by different icons, colors, or text.

The following device classes are supported for switches:

  • None: Generic switch. This is the default and doesn’t need to be set.
  • outlet: A switch for a power outlet.
  • switch: A generic switch.

Using the actions

In the frontend open Settings. Select Developer tools, click Actions. From the Action dropdown menu choose switch.turn_on or switch.turn_off from the list of available actions. In the Entity dropdown menu choose or enter the entity ID you want to work with. This will enter something like the sample below into the data field. Now select Perform action.

{"entity_id":"switch.livingroom_pin2"}
Data attribute Optional Description
entity_id no String or list of strings that point at entity_ids of switches. To target all switches, set entity_id to all.