Light entity: indication only

If a light entity is added to a lovelace card, it is possible to switch on/off the light.

I want the option to to disable the manual on/off switch of the light entity in lovelace.
image

In my use case, i switch the light over a motion sensor (KNX device). So I want to know the status of the light on a lovelace card, but it is not possible to switch this entity on/off (somebody could fall down the stairs if the light is turned off manually…)
To turn on/off the light, the motion sensor usually offers an external switch input. So I can turn on this light over a binary_input entity that is connected to the motion sensor external input.

You can’t with a standard “Entities” card, unless you want to create a template binary sensor, but if you use a “Button” card you can switch the tap action and hold action both to “No Action” and it will still show the status, but it won’t be able to act on the switch.

In this grid card, both of these buttons represent the same device. The button on the left has no actions, but it shows the correct state if toggled by the button on the right:

You could just use a binary_sensor with device_class: light.

Great feedback. The binary_sensor with device_class: light is exactly what i was looking for. Is there a posibility to change the text? I only need ON or OFF as text not “light detected”.

You could just not use device_class: light and only change the icon 🤷

The binary_sensor is working. Now i want to change the displayed text. If you have a hint, good. If not I will consult the documentation…

image

The device_class defines the text (and the default icon). The icon can always be customized. Imho that’s all there is to a binary_sensor UI wise.
If you don’t like the text use a different device_class.

I’m puzzled how do I create a binary sensor for a bulb

No need to create extra entities.
Just disable a toggle by card-mod.
изображение
card-mod thread → 1st post → link at the bottom → how to disable a toggle

IOkay, but that involves to use hacs and mod the complete card. don’t want taht. So how do I convert a light into a binary sensor or how do I create an extra binary sensor for the bulb?

Use a state based binary template sensor. See Template - Home Assistant

Benieve in code is what I tried in configuration yaml, but now I get: This entity (‘binary_sensor.patio_light_binary’) does not have a unique ID, therefore its settings cannot be managed from the UI. See the documentation for more detail.

binary_sensor:
  - platform: template
    sensors:
      patio_light_binary:
          friendly_name: Patio light Binary
          entity_id: light.patio_light
          value_template: >-
            {%- if is_state("light.patio_light", "on") -%}
            licht is aan
            {%- else -%}
            licht is uit
            {%- endif -%}

Well, have you read the documentation you linked there?

Yes, but I don’t get it.

A few selected integrations (such as template and mqtt) allow the user to define a unique ID.

You can configure a unique_id in yaml.

Thanks but I still don’t understand what i did wrong. patio_light_binary Is unique in my system.

That’s the entity_id. unique_id is something different. You can use the same string if it is unique, but you have to explicitly configure it.

Okay added unique id and that seems okay, but still the binanry sensor is not repsonding on change of the light.patio.

Binary_sensor
  - platform: template
    sensors:
      patio_light_binary:
          unique_id: patio_light_123
          friendly_name: Patio light Binary
          entity_id: light.patio
          value_template: >-
            {%- if is_state('light.patio', 'on') -%}
            licht is aan
            {%- else -%}
            licht is uit
            {%- endif -%}

Tried another thing which worked but now the icon does not change.

template:
  - sensor:
      - name: "light_at_patio"
        state: >
            {%- if is_state('light.patio', 'on') -%}
            light is onn
            {%- else -%}
            light is off
            {%- endif -%}

Hi snhnic, can you elaborate more why you want the light icon on a binary sensor? It is hard to guess what you are heading for…

Regarding the binary sensors, there is a device class “light”:

binary_sensor:
    - name: my_binary_sensor
      device_class: light

I used this type to detect the status of a light controlled by a motion sensor. On the dashboard you use a standard “element” card and use a light bulp icon. In this case “mdi:lightbulb-auto”. In the card you activate “colore icons based on state”.

image
image

Is that what you are looking for? If not please try to explain you are use case…