Non-interactive switch

Hello,

I’d like to visualise some of my entities as non-interactive switches.
I’ve made some scripts, to know if an integration started successfully or if my various devolo PLC are connected.
It is using MQTT to send the results (i.e.: on/off)
I’d like to see them in an entities card as switches. Which I can of course but then it becomes interactive switches which I don’t want : If my script returns that my “living room” devolo is off, it is off, the user can’t switch it on through HA.

Is there a proper way to configure this?

Thank you.

P.S.: What I’ve done so far : add an input boolean in my configuration.yaml. Display that one, instead of the script result. And in Node-RED, as soon as this input boolean is changing, I put it back to the “real” value returned by the script. But the result is a flickering switch, if you switch it through the interface, Node-RED reset it in a fraction of a second but it is visible.

You can use a picture elements card and make a conditional view.
Say light.somewhere is on then “this” should be displayed.
And “this” can be pretty much anything, icon, text, image.

Hi @Hellis81,

Thank you, this is a good idea.
But then, it is not reacting to dark mode or themes.

That would be great to have an option on entities that set it read-only for interface, like “read-only: true

Exemple:

entities:
  - entity: input_boolean.vaillant_started
    icon: 'mdi:check'
    name: Sucessfully started
    read-only: true
  type: entities

Why wouldn’t it?
Use colors that work both on light and dark theme.
Or I don’t understand the problem here.

A switch looks like a circle, slightly wider than a gutter, right.
In the default theme, when off, the circle is white and the gutter is light grey.
If I’m switching to dark mode, the circle is light grey and the gutter is dark grey.
If I’m using the midnight theme (downloaded I can’t remember where), the circle is dark grey and the gutter is black.

If I’m using an image, even with transparency, like the one from mdi toggle-switch-outline, it will stay always the same colors, not like the regular knob.

It will be awful when all the other switches will change their color but not my image.

You seem very limited.
Are you a apple user? :smiley:

I mean you can do whatever you want.
Even if the icon of the entity is a knob then you can replace that on the card only to a lightbulb with green color when on and red when it’s off.

Set the condition to the switch ‘on’
Elements is then one icon with lightbulb green.
Condition when switch is ‘off’ , elements, same lightbulb, same position, but red.

This “read only” switch will be in a card with plenty other switches that are “normal”.
From an aesthetic point of view, I’d like all of my entities to look the same.
If it makes me limited and an apple user then I’d say that apple is right on this point even if I’m not an apple user.

If you look inside HA, there are “disabled” switches but I can’t find a way to use such a disabled switch to display my entity state.

You could lock the switches down with this:

Hi @tom_l,

Thanks, I’ll have a look at this custom card.
I’ll come back to mark it as a solution (or not) later.

And you think that this is not counter intuitive?
Here is one button on the same card as everyone else and it just won’t work.
:roll_eyes:

1 Like

I’d say yes and no.
It depends on the label you put in front of the switch.
If you put “kitchen light”, obviously it is a normal switch.
If you put “Vaillant integration successfully started” or “TV’s PLC connected”, it is a factual state that can’t be switched.

Maybe it is counter intuitive for you but for me it makes sense. And at the end, I’m the end-user and “the customer is always right” :slight_smile:

Which should be a sensor, not a switch.

It is a sensor.

sensor:
  - platform: mqtt
    name: vaillant_started
    state_topic: "vaillant/started"

Then I’ve attached a input_boolean to it so it is displayed as a switch, my wish.
Otherwise, it is displayed as a stupid on or off text

Entity State Attributes
input_boolean.vaillant_started on editable: false
icon: mdi:check
sensor.vaillant_started on friendly_name: vaillant_started

Restriction card works

However, it is not easy to configure and the lock is not always behaving the right way.
It is not bulletproof either, if you double click to see the history, it will allow you to trigger the switch anyway.

Thank you for the help.

Does not sound like your configuration is correct. That is not my experience at all.

If I set

    restrictions:
      block: true

I can’t see the history. So no issue but … well … I’d like to look at the history.
But if I set a pin, then it is prompting for the pin if I tap. And double tap is showing the history but there, it is possible for me to switch, without pin.

The issue with the lock icon is that, sometimes, it is at the start of the row and the icon of the entity is after. Which is ugly. But this is not all the time, I think it is a side effect of the “custom:vertical-stack-in-card” card that I’m using to display those entities.

So given your description, I’m going to assume you had something like this

entities:
  - type: custom:restriction-card
    card:
      entity: input_boolean.vaillant_started

For the icon placement, you’ll want to add row: true to your configuration to have it over the switch. e.g.

entities:
  - type: custom:restriction-card
    row: true
    card:
      entity: input_boolean.vaillant_started

For your double click scenario, I want to know more as in my testing I cannot replicate what I think you’re saying. e.g.

entities:
  - type: custom:restriction-card
    row: true
    restrictions:
      pin:
        code: 1234
    card:
      entity: input_boolean.vaillant_started

You’re saying with the above configuration or similar, a double_tap will cause the switch to trigger? Or is with the configuration above with no restrictions? I have to assume it is with no restrictions, as in that case your first tap is unlocking the row and your second tap is a single tap for the row itself. You’d want to tap (to unlock) and once unlocked do your double tap to bring up more-info. If you’re saying double click was bringing up more-info with a PIN set, I’d have to see your configuration and ideally a screen recording.

Also note, that all actions for an entities card’s row is for the the icon/text. The switch is always a switch. You cannot double tap the switch or long hold it to perform other actions. Those are reserved for the icon/text area.

cards:
  - entity: climate.thermostat
    name: vSmart
    type: thermostat
  - entities:
      - entity: sensor.year_season
      - entity: sensor.moon_phases
    type: entities
  - entities:
      - type: 'custom:restriction-card'
        card:
          entity: input_boolean.vaillant_started
          name: Démarrage complet
        restrictions:
          block: true
        row: true
    show_header_toggle: false
    state_color: true
    type: entities
type: 'custom:vertical-stack-in-card'

This one has the

row: true

Nevertheless, it is showing the lock between the entity icon and the label (which is fine for me), not on the switch.

For the double tap, indeed, it was not asking for the pin, so you’re probably right, I was frenetically tapping the row to test and that was in fact a unlock + double tap that was triggered. As I was in the history, I was able to switch it on/off. My fault.