AboutBlogContact
Advanced & Guides

Changing Entity Type (Light / Switch)

Learn how to change a boneIO output from a 'light' entity to a 'switch' entity and vice versa in your ESPHome configuration.

Changing Entity Type (Light / Switch)

Sometimes the default configuration of an output as a light doesn't fit its actual use. For example, when you connect an outlet, a fan, or a pump to it. In such cases, it's a good idea to change the entity type to a switch so that Home Assistant categorizes it more appropriately.

  • Light: The entity appears in the light domain, is controlled by voice commands like "turn on all the lights," and is intended for light sources.
  • Switch: A more generic on/off entity. Perfect for outlets, fans, solenoid valves, and other non-illuminating devices.

Note: In YAML files, indentation is critical. Always use spaces, not tabs, and maintain proper alignment.


Prerequisites

  • A working ESPHome add-on installed.
  • Your boneIO device is adopted in the ESPHome dashboard.
  • You know how to edit the YAML configuration file.

Changing from light to switch

In this example, we will change light_02 into a switch_02 entity. The process consists of two simple steps.

Step 1: Change the output definition

We need to move the output definition from the light section to the switch section and modify it slightly.

BEFORE:

light:
  - platform: binary
    name: 'Light 01'
    output: out_01
    id: light_01
  - platform: binary
    name: 'Light 02'
    output: out_02
    id: light_02

AFTER:

light:
  - platform: binary
    name: 'Light 01'
    output: out_01
    id: light_01

# New section for switches
switch:
  - platform: output # Change 'binary' to 'output'
    name: 'Living Room Outlet' # New, more fitting name
    output: out_02
    id: switch_02 # New ID

Step 2: Update the button action

Now, we must tell the button to control the new switch (switch_02), not the old light (light_02), otherwise the configuration will be invalid.

BEFORE:

binary_sensor:
  - platform: gpio
    name: 'IN_02'
    # ... rest of the pin configuration
    on_press:
      then:
        - light.toggle: light_02 # This line refers to the old ID

AFTER:

binary_sensor:
  - platform: gpio
    name: 'IN_02'
    # ... rest of the pin configuration
    on_press:
      then:
        - switch.toggle: switch_02 # Updated domain (switch) and ID (switch_02)

After these changes, save the file and upload the new configuration. You're done!


Changing from switch to light

The process is almost identical, just in reverse. In this example, we will change switch_02 to light_02.

Step 1: Change the output definition

BEFORE:

switch:
  - platform: output
    name: 'Switch 01'
    output: out_01
    id: switch_01
  - platform: output
    name: 'Living Room Outlet'
    output: out_02
    id: switch_02

AFTER:

switch:
  - platform: output
    name: 'Switch 01'
    output: out_01
    id: switch_01

# Moved element to the light section
light:
  - platform: binary # Change 'output' to 'binary'
    name: 'Living Room Sconce' # New name
    output: out_02
    id: light_02 # New ID

Step 2: Update the button action

BEFORE:

binary_sensor:
  - platform: gpio
    name: 'IN_02'
    # ... rest of the pin configuration
    on_press:
      then:
        - switch.toggle: switch_02

AFTER:

binary_sensor:
  - platform: gpio
    name: 'IN_02'
    # ... rest of the pin configuration
    on_press:
      then:
        - light.toggle: light_02

Save the file and upload the configuration. The OUT02 output will now appear in Home Assistant as a light.