Renaming State of button card

I have a button card that controls my gate that shows the gate is off when it is closed and shows that the gate is on when gate is open what I would like is to have it show Closed and Open instead
gate

gateopen

See: https://www.home-assistant.io/integrations/binary_sensor/#device-class

I already have a sensor that states that it is open or closed what I want is to have have the Button itself state open or closed instead of on or off

this is my sensor for the state of the gate

   sensors:
      gate_position:
        value_template: >-
          {% if is_state('binary_sensor.gate_sensor' , 'off') %}
            Closed
          {% else %}
            Open
          {% endif %}
        friendly_name: "Gate Position"

it works fine and displays what I want how do I get the button to do that?

Delete that template and use the gate device class for the binary sensor.

and how do I do that with a MIMOlite

Using customize.

well thanks that tells me nothing but thank you for replying

1 Like

Read the link I posted.

I did that and that means nothing to me

so back to my original question looking to get the off and on on my button to show open and closed anybody willing to help that is not cryptic about it would be appreciated

The very first sentence of the link I posted links to how to customize entities.

In your customize.yaml file:

binary_sensor.gate_sensor:
  device_class: gate

Or use the Configuration / customize menu.

Then use the binary sensor for the button.

not sure how the sensor going to trigger the gate switch and that link does not explain in any language I understand on building a custom anything

this is my switch template the button refers to

 - platform: template
    switches:
      mygate:
        value_template: "{{ is_state('binary_sensor.gate_sensor', 'on') }}"
        turn_on:
          service: switch.toggle
          data:
            entity_id: switch.gate_switch
        turn_off:
          service: switch.toggle
          data:
            entity_id: switch.gate_switch

so back to my original question looking to get the off and on on my button to show open and closed anybody willing to help that is not cryptic about it would be appreciated

I see what your problem is now. The problem isn’t the sensor. It’s that you are using a switch.

Switch states can only ever be on or off. So you’re out of luck with that.

You could use a template cover with your switch and binary sensor, that would have the state open or closed.

This is what I have:

- platform: template
  covers:
    driveway_gate:
      device_class: gate
      friendly_name: "Gate"
      value_template:  "{{ is_state('switch.open_gate', 'on') }}"
      icon_template: >-
          {% if states('switch.open_gate') == "on" %}
            mdi:gate-open
          {% else %}
            mdi:gate
          {% endif %}       
      open_cover:
        service: switch.toggle
        data:
          entity_id: switch.open_gate
      close_cover:
        service: switch.toggle
        data:
          entity_id: switch.open_gate
      

As you can see, I don’t have a specific command to close the gate, as it is based on a timer to close it automatically. Anyway I have a switch to control it, so if you create a Cover Template you should be fine.
I added a button card in my Front End, and used the Cover Template as entity… works flawlessly

Mine works as it should just want to to say open or closed instead of on or off does your template show that?
My gate has the timer option as well I disabled that and use a script to close the gate as there is certain times I want the gate open till I close it

Of course mine shows open/close status. Here it is (in italian):

image

Fabio has even shown you an example.

Follow what @mcfly76 is doing. It will have the correct state names you expect. It goes in the cover section, not the switch section. Yours would look like this:

cover:
- platform: template
  covers:
    mygate:
      device_class: gate
      friendly_name: "Gate"
      value_template:  "{{ is_state('binary_sensor.gate_sensor', 'on') }}"
      open_cover:
        service: switch.turn_off
        entity_id: switch.gate_switch
      close_cover:
        service: switch.turn_off
        entity_id: switch.gate_switch

When you place this anywhere in the UI (except for custom cards) it should be properly translated to your language’s open/close.

1 Like