Switch

The Switch integration集成将 Home Assistant 与您的设备、服务等连接和集成。 [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

构建模块集成

这个 switch 是一个构建模块集成,无法直接添加到你的 Home Assistant 中,但可以被其他集成使用和提供。

构建模块集成不同于典型的与设备或服务连接的集成。相反,其他将设备或服务集成到 Home Assistant 中的集成使用这个 switch 构建模块来提供实体、服务和其他你可以在自动化或仪表板中使用的功能。

如果你的某个集成具有这个构建模块,这个页面记录了 switch 构建模块所提供的功能。

The state of a switch entity

The state of a switch entity实体表示 Home Assistant 中的传感器、执行器或功能。实体用于监控物理属性或控制其他实体。实体通常是设备或服务的一部分。 [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

设备类别是 Home Assistant 中的一种测量分类。它影响实体在 仪表板 中的表示方式。这可以在 自定义部分 中进行修改。例如,不同的状态可能会用不同的图标、颜色或文本来表示。

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.