Guides

Disable or enable an entity from an automation

Home Assistant has no action to disable an entity. Spook adds one, and one to enable it again. With an example, and what to use instead when you only want it out of sight.

Home Assistant lets you disable an entity by hand, in its settings, but it has no action to do it from an automation or a script. Spook adds two: homeassistant.disable_entity and homeassistant.enable_entity. They flip the same Enabled switch you find in the settings of the entity.

Only want it off your dashboards, or want to stop an automation? That is something else, and Home Assistant does both itself. Both are below.

Disable an entity in Home Assistant

The way by hand, without Spook:

  1. Open the entity, and select the cog at the top for its Settings.
  2. Turn off Enabled.
  3. Select Update.
The settings of an entity, with the Enabled switch ringed.
The settings of an entity. Enabled is the switch.

Home Assistant says what happens: "Disabled entities will not be added to Home Assistant." The entity has no state anymore, records no new history, and is gone from your dashboards. Its name, area and settings stay, and so does the history it already had.

More than one at once? In Settings > Devices & services > Entities, select Enter selection mode, tick the entities, and select Disable selected in the menu with the three dots.

To get one back, turn Enabled on again. Home Assistant adds it again about 30 seconds later, when it reloads the integration it belongs to.

Disable an entity from an automation

  1. Open the automation or script, and select Add action.
  2. Search for disable an entity, and select Home Assistant Core Integration: Disable an entity 👻.
  3. Under Entity, pick one or more entities.
  4. Select Save.

In YAML:

action: homeassistant.disable_entity
data:
  entity_id:
    - sensor.pool_water_temperature
    - sensor.pool_ph
The Actions tool with Disable an entity 👻 picked and filled in with an example.
Disable an entity in the Actions tool.

The full reference is Disable an entity.

Enable an entity again

The same, the other way around: Enable an entity, homeassistant.enable_entity. Like by hand, the entity comes back about 30 seconds later.

A typical pair: the sensors of the pool, only in the months the pool is open.

alias: Pool sensors only while the pool is open
triggers:
  - trigger: template
    value_template: "{{ now().month in [5, 6, 7, 8, 9] }}"
    id: open
  - trigger: template
    value_template: "{{ now().month not in [5, 6, 7, 8, 9] }}"
    id: closed
actions:
  - choose:
      - conditions:
          - condition: trigger
            id: open
        sequence:
          - action: homeassistant.enable_entity
            data:
              entity_id:
                - sensor.pool_water_temperature
                - sensor.pool_ph
      - conditions:
          - condition: trigger
            id: closed
        sequence:
          - action: homeassistant.disable_entity
            data:
              entity_id:
                - sensor.pool_water_temperature
                - sensor.pool_ph

A template trigger fires when its template turns true. These two each turn true once a year: on the first of May, and on the first of October.

A whole device, or a whole integration

Turning off everything of one device? Disable the device instead, and its entities go with it: Disable a device, homeassistant.disable_device. Everything of one integration: Disable an integration, homeassistant.disable_config_entry.

The other way around has a catch. An entity of a disabled device stays disabled, even when you enable the entity itself. Enable the device: Enable a device.

Hide it instead

Often you do not need the entity gone. You want it off your dashboards, and still working.

That is hiding, and Home Assistant has it built in: in the settings of the entity, turn off Visible. A hidden entity keeps its state and its history, and actions still work on it. It is only left out of dashboards Home Assistant fills in by itself, and out of actions that target its area, device or label.

From an automation, Spook adds Hide an entity and Unhide an entity: homeassistant.hide_entity and homeassistant.unhide_entity.

Stop an automation instead

Searching for how to disable an automation from another automation? Home Assistant does that itself, no Spook needed: automation.turn_off, and automation.turn_on to start it again.

action: automation.turn_off
target:
  entity_id: automation.motion_light_hallway

What to keep in mind

  • Only entities with a unique ID. An entity without one has no settings in Home Assistant, so there is nothing to disable. Home Assistant says so in its settings. The action gives an error for it.
  • Automations that use it. While an entity is disabled, it has no state. An action on it does nothing. What a condition on it does depends on the condition: a state condition does not pass, but a template that checks it is not on does. Check for it first with Spook's Entity is available condition. Spook knows a disabled entity is still yours, so it does not report it as unknown.
  • Run by hand, the actions need an administrator. Automations can always run them. A script started by a user who is not an administrator cannot.