Lovelace entity card - disable switch control; only display current state

This seems to have been asked many times before, but none of the options have worked out for me so far and it seems like this should be something simple.

Card type: Entities card

I have a card with various entities (switches & lights) on it. For one of the rows I don’t want the toggle to appear – no control of it – I just want it to display the state (on or off).

I’ve tried a bunch of things, and these are what I want to avoid (because I think it should be simpler than having to do these options):

  • switch template thing (not sure how to do this anyway)
  • using the restriction card on the entry
  • using a separate card (like a glance card) or whatever; I just want to show one row on an entity card

This seems close and seems like it should work - display an attribute like “state”:

type: entities
entities:
  - entity: light.hallway_hue_pendant
    name: Hue pendant
  - entity: switch.small_trees_on_off
    name: Small hallway trees
  - type: attribute
    entity: switch.small_trees_on_off
    attribute: status
    prefix: "state: "
    name: Tree switch state
title: Hallway
show_header_toggle: false
state_color: true

The display to the right of the attribute row is “Tree switch state state: --” always.

Hoping someone has a good idea here for this. Also, other things that didn’t seem to work:

type: button
tap_action: none

Somehow trying to add a line like: control:none or something like that - didn’t work.

Thanks in advance for any advice!

1 Like

You need to make a template binary sensor and display that instead:

template:
  - binary_sensor:
      - name: "Tree switch state"
        state: "{{ is_state('switch.small_trees_on_off', 'on' }}"
        icon: "mdi:pine-tree"
1 Like

Hi, thank you for the reply. I think as a newbie I’m going to need some additional advice on how to implement that. I looked through the configuration.xml and other files & directories and didn’t see anything about templates. Also, under the automations section there’s a scripts tab, is that where I need to add a file?

It doesn’t work directly in the card, so I know this isn’t correct:

type: entities
entities:
  - entity: light.hallway_hue_pendant
    name: Hue pendant
  - entity: switch.switch.small_trees_on_off
    name: Small hallway trees
template:
  - binary_sensor:
      - name: "3D Printer Power"
        state: "{{ is_state('switch.small_trees_on_off', 'on' }}"
        icon: "mdi:pine-tree"
title: Hallway
show_header_toggle: false
state_color: true

I did find a template “tester” under development tools and it works there. I get this (since it’s on):

template:
  - binary_sensor:
      - name: "Hallway small trees"
        state: "True"
        icon: "mdi:pine-tree"

This is closer… but isn’t quite what I was looking for:

type: entities
entities:
  - entity: light.hallway_hue_pendant
    name: Hue pendant
  - entity: switch.small_trees_on_off
    name: Small hallway trees
  - type: custom:hui-markdown-card
    content: >-
      state: Power "{{ is_state('switch.small_trees_on_off', 'on') }}"
title: Hallway
show_header_toggle: false
state_color: true

Gives me this output:

2022-07-07_07h51_10

You may disable a toggle by using card-mod.
So it shows a state (on/off) but you cannot change it.
Goto card-mod thread → 1st post → link at the bottom → styles for toggle.

2 Likes

Is there anything card-mod can’t do?

Yes, unfortunately ))).

1 Like