Service light.turn_on not available in dropdown

Hey guys!

I started working with HA this week and I tried to follow this example: Automating Home Assistant - Home Assistant (home-assistant.io)

After choosing “Service” I wanted to choose “light.turn_on” but this entry is not available in the dropdown list (see screenshot). How can I get this service?
I set an ESP8266 as light with this code:

output:
  - platform: gpio
    pin: D1
    id: gpio_d1

light:
  - platform: binary
    name: "Lamp"
    output: gpio_d1

I can turn on the ESP by toggling the switch in dashboard.

Many thanks in advance!
Regards
Stefan

Do you have light: somewhere in your homeassistant configuration?

i was thinking the same, service light.turn_on will only be available when there are light devices…

and i have:

If you have you lights configured as switches it would be switch.turn_on. You can see the domain of your entities in the developer tools.

@anon43302295 From my point of view I configured an ESP as light (see code in first post). Isn’t this what you mean?
@Syntox Right now I don’t have access to my HA, but can you please tell me where within the developer tools I can find the “real” domain of my entities?

In the states menu.

Your entities will be of the form domain.object_id e.g. light.bedroom or switch.bedroom

1 Like

The developer tools are located in the sidebar:

1 Like

I’m wondering about the -platform binary…

shouldn’t that be:

light:
  - platform: switch
    name: Light Kitchen Window
    entity_id: switch.kitchen_window

(this is a copy of my own config)

I think ‘binary’ is only used for sensors (=input)

Didn’t knew you could use switch but I use binary too and it works fine.

Binary sensors gather information about the state of devices which have a “digital” return value (either 1 or 0). These can be switches, contacts, pins, etc.

Oh, you’re talking about the HA config. For ESPHome I think I didn’t configure anything there. The config he posted above is the ESPHome config

EDIT: But I have light: in my HA config

Okay, to prevent more misunderstandings:

I have an ESP8266.
First I defined it as switch and I was able to control it manually.
Then I started the next step and wanted to set it as light, so I used the code I found on GitHub (as posted above).
It seems that this setting is not working (because the service light.turn_on) is not available - I’ll check that this afternoon - thanks so far for this advice.
I’ll also try the suggestion from @aceindy to use this combination:

light:
  - platform: switch
    name: "Lamp"
    output: gpio_d2

switch:
  - platform: gpio
    pin: 2
    id: gpio_d2

That shoul work, shouldn’t it?

@Syntox: Thanks for your last post - I think you’re right, I configured that in ESPHome config - what would I need to configure in the HA config then to set my ESP entity as light?

my bad…didn’t see that :yum:

I don’t think this works

as he posted his HA config.

If you look at config > integrations does your ESPHome node shows up in the ESPHome card? And is it a light if you click on the node > entities (light.lamp)?

Hmm…
i think defining it a switch in ESPhome works in combination with HAconfig defining the light from platform switch :yum:

light:
  - platform: switch
    name: Light Kitchen Window
    entity_id: switch.kitchen_window

This is how i changed from switch to light :wink:

1 Like

sure this works too but it’s just an extra step you usually don’t need.
BTW this s my ESPHome config:

output:
  - platform: gpio
    pin: GPIO12
    id: relay
  
light:
  - platform: binary
    name: light
    output: relay
    restore_mode: RESTORE_DEFAULT_OFF #this is just to ensure that the light is off if the ESP reboots
1 Like

My switch is not on ESPHome, so i need it :wink:

Sooo - I got it to work now:

ESPHome config:

switch:
  - platform: gpio
    pin: 2
    name: "ESP switch"

HA config:

light:
  - platform: switch
    name: ESP light
    entity_id: switch.esp8266_switch

Thank you guys!

You’re welcome :wink:

Good to know you got it working!
I tried it myself yesterday with a new D1 mini. First I configured a switch and that worked.
Then I deleted that switch from the esp config and added a binary light and for my surprise the esp didn’t got discovered. I had to manually add it by typing in the IP of the D1 mini. Maybe that was your problen too…