Light - convert toggle to button - yaml only

This is one of my lights configuration in light.yaml

- platform: mqtt
  name: "Living Room"
  state_topic: "shellies/shelly1-XXXXCF/relay/0"
  command_topic: "shellies/shelly1-XXXXCF/relay/0/command"
  payload_on: "on"
  payload_off: "off"
  optimistic: false
  retain: false

This will actually give me a toggle switch, as shown below.

I want to have a button, not a toggle, like this.

I tried adding this but it give me an error when I check the configuration
type: entity-button

I don’t want to do it using lovelace. I want to do it through yaml configuration.
How can I do this?

Where did you add type: entity-button? In the configuration part in light.yaml?

The buttons you show are buttons in lovelace.

You can change lovelace to yaml mode and then you can configure the whole lovelace interface in yaml configurations.

Like this, but it doesn’t pass “Check Config”

- platform: mqtt
  name: "Living Room"
  type: entity-button
  state_topic: "shellies/shelly1-XXXXCF/relay/0"
  command_topic: "shellies/shelly1-XXXXCF/relay/0/command"
  payload_on: "on"
  payload_off: "off"
  optimistic: false
  retain: false

I am already only using yaml files for all my Home Assistant configuration. I meant I want to also convert the toggle to a button using yaml, and not lovelace.

But…it’s only a button or toggle IN the UI, which means, Lovelace.
You can’t change it in the configuration yaml like that.

So there is no way to change this
to this

using yaml?


In your LOVELACE yaml.

ok, please help me understand.

Currently I have a clean Home Assistant installation that I never touched the UI interface. Every configuration I did so far was by editing yaml files. But I never had a lovelace.yaml file, I never needed it so far.

Follow the instructions here.

That’s weird. You said earlier:

Which would include the LOVELACE UI.

OK? So you are using the automatically generated interface? And you want to change something that you literally only see in the UI? The Lovelace UI? So you want to change the Lovelace?

I don’t understand, what’s not clear?

You do realize that literally any change I make has an effect on the Lovelace UI, right? And they are all done through yaml files, not the Lovelace UI.

No need to have an attitude here. The forums are for helping, correct?

Thank you. This actually helps.

This is not correct. When you add a new script to your scripts.yaml file for example, the lovelace UI will not change, what makes you think it changes the lovelace UI? The only thing it will do, is add a new entity to the default lovelace view, because this contains all the entities in your system.

Yes, this is what I mean. Every time I add a light/switch/outlet or whatever, it appears in the Lovelace UI. That’s a change. Lovelace changes without me having a separate lovelace.yaml. We are not disagreeing here.

My question was how to convert a toggle to a button without messing around in the UI, only with yaml. If a lovelace.yaml is required this is what I’ll do. This is why I said your link is helpful.

I agree that this is a change, but this is only the default view of lovelace, you can not change an input boolean to a button in the default view. It is meant that you create your own views, containing only the information you want for this view in the style you want it, the intention is not to use the default lovelace view, this is just the standard view that is created for every new setup.

This is a view from my lovelace UI that I configured myself, here the lights are buttons instead of a toggle:

Now there are two different ways to create your own views, either through the UI or through YAML. If you want to change it through YAML, you need to add the following to your configuration.yaml

  mode: yaml

Then create a file ui-lovelace.yaml in the same directory as configuration.yaml and in this file you create the views like you want them.

Not true. This shows you don’t understand what Lovelace is.

configuration.yaml is for CONFIGURING components/entities/devices/groups.

In the default “lovelace mode” every device/entity/component you add gets added to the lovelace view. You have no control of how anything looks. At all.

You need to switch to lovelace yaml mode or what they call “storage” mode (click on three dot menu in upper right, configure UI, and take control) in order to change what you see in Lovelace.

So again, you are changing how something LOOKS not how something functions. Changing how it is viewed is done in lovelace.

1 Like