Close

Basics: Binary Output

A project log for Experiences with ESPhome

Setting up some ESPhome-devices

mabe42MaBe42 9 hours ago0 Comments

This can be something like a LED or a relay that can be switched by switching a digital output.

There are several possibilities to do this which end up in slightly different appearances in HA:

Output - GPIO

output:
  - platform: gpio
    pin: GPIO13
    id: gpio_d7

 But this does not show up in HA.

If you want it to be shown in HA, you can for example use

Light - Binary Light

You need to add a few lines to the above. The result is:

output:
  - platform: gpio
    pin: GPIO13
    id: gpio_d7

light:
  - platform: binary
    name: "red LED"
    output: gpio_d7

 As you see, in the light you refer to the output's id.

The result looks like this in HA:

You could also define a

Switch - GPIO Switch

The code is:

switch:
  - platform: gpio
    name: "Yellow output"
    pin: GPIO12

 Result:


or you can use

Switch - Generic Output Switch

Replace the above code with:

output:
  - platform: gpio
    pin: GPIO12
    id: gpio_d6

switch:
  - platform: output
    name: "Generic yellow switch"
    output: gpio_d6

 Beware, you can have only a single output section. So together with the red LED it looks like:

output:
  - platform: gpio
    pin: GPIO12
    id: gpio_d6
  - platform: gpio
    pin: GPIO13
    id: gpio_d7
    
light:
  - platform: binary
    name: "red LED"
    output: gpio_d7

switch:
  - platform: output
    name: "Generic yellow switch"
    output: gpio_d6

 And the result in HA:

And there are other components which in the end only toggle a GPIO between 0 and 1.

Discussions