Change state of switch from on off to open closed

I have a switch in a glance card and the state shows as on or off. I would like to change the state label to open closed. I have tried sensor template, but that converts the switch to a sensor. What should I use. I do have card mod installed if that helps?

I dont know if this works out for you, but I do this using the custom button card. Its highly customizable.


This is my card config
entity: switch.shemin_bedroom_light
tap_action:
  action: none
show_name: true
show_icon: true
show_state: false
show_label: true
size: 20%
label: |
  [[[
    if (states['switch.shemin_bedroom_light'].state === "on")
      return "Open";
    else if (states['switch.shemin_bedroom_light'].state === "off")
      return "Close";
  ]]]                
styles:
  name:
    - left: 28%
    - top: 5%
    - position: absolute
  card:
    - height: 130px
  label:
    - left: 43%
    - top: 79%
    - position: absolute
type: 'custom:button-card'

This is how it looks in my UI
image image

1 Like

Switch are either on or off. That’s what they do, switch things on or off. How can a light be “open”?

Binary sensors can have device classes applied to represent more than on or off in the frontend.

Thank you both for your help. My problem is I am using Konnect to unlock a door. So I must use a switch, I can’t seem to make a binary sensor in Konnect swicth. Do I have any other options. I was hoping not to need custom cards, as I prefer the glance card. The label code doesn’t seem to work in the glance card for me.

Convert your switch into a lock:

Template Lock is good but will give you “locked” and “unlocked” states. If you want open/closed maybe you want a Template Cover:

1 Like

Did you ever get this figured out? I’m having the same issue right now

It’s a long time ago this was answered.

Tom, may I ask the same question but now later an maybe more doable?

I am looking into a way to change a switch from on/off to left/right.

I know a switch can only be on/off but I need a switch to present itself as left/right in my interface (or logic).

Is there a way to change the state name of a switch? Or create a template switch?

A template sensor wouldn’t work for your scenario?

sensor:
  - platform: template
    sensors:
     test:
        friendly_name: 'Test'
        unique_id: test
        value_template: >-
          {%- if is_state('switch.xxx', 'on') %}
           left
          {% else %}
           right
          {%- endif %}

I think that is only partially… it is a sensor then, not a switch :upside_down_face:

It depends on the application you are using it in. It’s still an entity that changes based on a state.

More information would help folks understand your end goal.