Lovelace Card - Light with Profiles

Yes you have to create the files. You always had to. :slight_smile:

I do beleive you can do it without yaml mode

Done. But it is not working as expected.
When I choose a light profile, nothing changes. Neither dims, nor change colour. Also doesn’t show which profile is enabled. Just on-off option.

Light_profiles.csv (in config folder):

Relax,0.5119,0.4147,144
Concentrate,0.5119,0.4147,219
Reading,0.4448,0.4066,240
Energise,0.368,0.3686,203
group.all_lights.default,0.326,0.333,255

ui-lovelace.yaml (in config folder):

resources:
  - type: module
    url: /local/light-with-profiles.js

light_profiles:
  bright: '0.5119,0.4147,254'
  dimmed: '0.5119,0.4147,77'
  nightlight: '0.363,0.3686,1'
  brightness_only: '0,0,150'

title: Home
views:
  - badges:
      - entity: binary_sensor.updater
      - entity: person.agma
      - entity: sensor.illumination_44237c82f84a
      - entity: sun.sun
    cards:
      - entities:
          - entity: automation.toggle_bedroom_light
          - entity: automation.toggle_kid_s_room_light
          - entity: automation.turn_off_night_light
          - entity: automation.night_mode
        title: Automation
        type: entities
      - entity: weather.spiti
        type: weather-forecast
      - aspect_ratio: 50%
        type: iframe
        url: 'https://www.home-assistant.io'
      - entities:
          - entity: person.agma
          - entity: device_tracker.eml_l29
        type: map
      - entities:
          - entity: camera.bedroom
        type: entities
    icon: 'mdi:home'
    path: default_view
    title: Home
  - badges: []
    cards:
      - entities:
          - entity: light.bedroom
            profiles:
              - name: bright
                icon: 'mdi:brightness-5'
              - name: dimmed
                icon: 'mdi:brightness-4'
              - name: nightlight
                icon: 'mdi:brightness-3'
          - entity: light.kid's room
            profiles:
              - name: bright
                icon: 'mdi:brightness-5'
              - name: dimmed
                icon: 'mdi:brightness-4'
              - name: nightlight
                icon: 'mdi:brightness-3'
        title: Lights
        type: 'custom:light-with-profiles'
    icon: 'mdi:lightbulb-on'
    path: lights
    title: Lights

Looks like whatever xy color I change in light_profiles.csv, my bulbs are not recognized in HA. Accepts only stock values. Any thoughts?

I really like the look and functionality of this.
And with the brightness only update, I can get some info out from my IKEA lights also :slight_smile:
Thank you for sharing.

You need to use the same profiles in the card as you have the profile.csv.

So you could add the profiles you use to the Light_profiles.csv (in config folder):

Relax,0.5119,0.4147,144
Concentrate,0.5119,0.4147,219
Reading,0.4448,0.4066,240
Energise,0.368,0.3686,203
bright,0.5119,0.4147,254
dimmed,0.5119,0.4147,77
nightlight,0.363,0.3686,1
group.all_lights.default,0.326,0.333,255

Now when you trigger the bright profile from the card, there is a bright profile in the csv config that can send that info to the light bulb.

1 Like

Hi there,

thanks for sharing the card. I really like the functionality.

However I have one issue. Somehow it looks like the card puts the space for an icon in front of the text:

image

Any idea to remove this space or what the problem could be?

Many thanks.

Raphael

Hi,
I tried to get this working but horribly failed.
I installed it via HACS. As soon as I add the light_profiles.csv in my config folder and restart hass my hue lights become unavailable.
I tried to add

bright: '0.457,0.408,254'
dimmed: '0.457,0.408,77'
nightlight: '0.509,0.411,1'

Also tried to include

group.all_lights.default,0.326,0.333,255

Allways get an error message that my light conf is wrong. Not sure what to do.

That’s because group.all_lights is not created by default any more. Your options are:

  1. Create are new light group manually.
  2. Specify individual lights in light_profiles.csv (e.g. light.porch.default).
  3. Follow my guide: How to survive without the "ALL groups" to create a new group.all_lights.

You’re using YAML in a CSV file. Try out

bright, 0.457, 0.408, 254
dimmed, 0.457, 0.408, 77
nightlight: '0.509,0.411,1'

Where do I define the YAML that displays the coloured icon when it’s active? I can’t seem to find the location. I installed this via HACS if that makes a difference.

I followed all installation docs, put the light_profiles.csv inside the /config folder, added the entry light_profiles inside the ui.lovelace.yaml with the same values of light_profiles.csv, added the card inside ui.lovelace.yaml. but this is what i get:

Schermata 2020-10-25 alle 14 23 22

I am able to turn on and off the lights, but clicking over a profile it do not nothing. Nothing change…

For more informations my light_profile.cvs is:

bright,0.5119,0.4147,254
dimmed,0.5119,0.4147,77
nightlight,0.363,0.3686,1

And this is what i added into ui.lovelace.yaml:

light_profiles:
  bright: '0.5119,0.4147,254'
  dimmed: '0.5119,0.4147,77'
  nightlight: '0.363,0.3686,1'

My card is:

  - title: Profili Luci
    path: profili
    icon: mdi:lightbulb
    cards:
      - type: custom:light-with-profiles
        title: Profili Luci
        debug: true
        entities:
          - entity: light.yeelight_1
            profiles:
              - name: bright
                icon: 'mdi:brightness-5'
              - name: dimmed
                icon: 'mdi:brightness-4'
              - name: nightlight
                icon: 'mdi:brightness-3'
          - entity: light.yeelight_2
            profiles:
              - name: bright
                icon: 'mdi:brightness-5'
              - name: dimmed
                icon: 'mdi:brightness-4'
              - name: nightlight
                icon: 'mdi:brightness-3'
          - entity: light.yeelight_5
            profiles:
              - name: bright
                icon: 'mdi:brightness-5'
              - name: dimmed
                icon: 'mdi:brightness-4'
              - name: nightlight
                icon: 'mdi:brightness-3'
          - entity: light.yeelight_9
            profiles:
              - name: bright
                icon: 'mdi:brightness-5'
              - name: dimmed
                icon: 'mdi:brightness-4'
              - name: nightlight
                icon: 'mdi:brightness-3'

I am running HASSOS 0.116.4 inside a RPi4

Hi @maurizio53,

I currently have the same issue. I’m on RPi4 and 0.116.0.
Also have double-checked my two configs + card debug mode.

Nevertheless, it seems like you’re using non RGB lights (x,y: null), is that correct?
In that case both your light_profiles.csv and the profiles in your ui-lovelace.yaml must contains zeros for x & y:

light_profiles.csv

id,x,y,brightness
bright,0,0,254

and

ui-lovelace.yaml

light_profiles:
  bright: '0,0,254'

and then in debug mode you should see
x,y: null brightness: 254

Almost a year ago I’ve struggled with the issue that just RGB lights were supported by the card.
It’s documented in this very thread (also see the following posts).

Hope this helps.

Yes, one of them was a non RGB light.
I discovered also id di not put id,x,y,brightness inside the light_profiles.csv.
Now after a reset it seems working but when i click over a profile i do not have the change of the color in the icon. Maybe because i must put id,x,y,brightness also inside the light_profiles in ui-lovelace.yaml?
BTW thanks for the hints…


FIXED ICON ACTIVE COLOR

@maurizio53

I discovered that the system actually DO add an ‘active’ attribute to the selected profiles. However, due to a CSS bug(feature) it does not change.

However, this can besolved!!!

Install Card Mod and add this:

style: |
  ha-card [active] {
    color: var(--primary-color);
  }
  ha-card .profile-icon {
    margin: -5px 5px;
    zoom: 1.3;
  }

So, complete card script:

entities:
  - entity: light.vensterbanken
    name: Vensterbanken
    profiles:
      - icon: 'mdi:brightness-5'
        name: bright
      - icon: 'mdi:brightness-4'
        name: dimmed
      - icon: 'mdi:brightness-3'
        name: nightlight
title: Woonkamer
debug: false
style: |
  ha-card [active] {
    color: var(--primary-color);
  }
  ha-card .profile-icon {
    margin: -5px 5px;
    zoom: 1.3;
  }
type: 'custom:light-with-profiles'

Works like a charm!

Thanks, it gives me the lamp icons correctly shown, but not the profiles icon as shown in the example GIF at the beginning of this thread…

Can you check the code with inspector in Chrome? Please click one of the profile icons to ‘activate’ it. Than right click on the same icon and click: ‘inspect’. The Chrome Inspector will popup.

You should see this:

Mind the ‘active’ attribute. If it’s not there then something is wrong. But you can test the CSS code by clicking ‘add attribute’ by right clicking the

<ha-icon class="profile-icon" title="bright"></ha-icon>

element and click; ‘add attribute’ and type ‘active’.
The the HTML for that element should look like:

<ha-icon class="profile-icon" title="bright" active></ha-icon>

My card with this CSS working:

light_example

Yes, adding active the icon changes accordingly, but how to make it definitive in the yaml file?

That’s not how YAML works… It is definitive.

did you add:

light_profiles:
  bright: '0.457,0.408,254'
  dimmed: '0.457,0.408,77'
  nightlight: '0.509,0.411,1'

On the very top of you lovelace yaml config (three dots on top right; raw config editor).

The values and names should match the ones in your light_profiles.csv (in the root of your config folder, next to where configuration.yaml is)

Yes, i did it and the two are same for names and values…

Actually i have this after clicking over the bright profile:

Schermata 2020-10-28 alle 19.47.13