Light Entity Card

Light Entity Card

Source

Features

  • Works on any light and switch based entity
  • Toggle on/off
  • HS Color wheel
  • Color temperature and white value support
  • Support for configured language
  • compact card support for grouped entities

Usage

- type: custom:light-entity-card
  entity: light.downstairs

Options

Name Type Requirement Default value Description
type string Required custom:light-entity-card
entity string Required The entity name of the light entity to control
group boolean Optional false Compacts card
20 Likes

Added support for groups, switches, and compact mode.

2 Likes

added support for custom effects_list from input_select entities

1 Like

Trying to get this card working but it seems to have an issue with other custom cards.

If I try to open the this custom card I get the following in the GUI:
image

and this in the error log:
Time)

https://xxxxx:8123/local/custom_ui/light-entity-card.js?v=1.2.0:1:1 Uncaught SyntaxError: Identifier ā€˜LitElementā€™ has already been declared

Latest version is 1.3.0 try that one

Unfortunately I get the same result:

https://xxxxx:8123/local/custom_ui/light-entity-card.js?v=1.3.0:1:1 Uncaught SyntaxError: Identifier ā€˜LitElementā€™ has already been declared

note: this card is currently inside another custom card (custom popup), but I did notice that the error comes up in the log as soon as I log into HA, before even navigating to the page that has this card on it. That was after a browser cache clear

This error comes from another custom card incorrectly defining LitElement using let/const instead of var. I can change to code to fix this but there are a number of other cards out there that wouldnā€™t work either. Not sure how many custom cards you have but I would try commenting out all of the ones in resources except this one and see if it works. From there enable one custom card at a time to see which one is misbehaving. Iā€™d be interested to know because the dev needs to know his card is not configured correctly.

My guess is that itā€™s this oneā€¦ but Iā€™ll have to do the testing that you mentioned to be sure as I have a fair few custom cards, but in saying that, most of them are from Thomas.

I looked at the code for that one and itā€™s not that one. Iā€™ve used a lot of Thomasā€™s cards and they tend to be setup correctly so I would be surprised if itā€™s one of his.

Other than Thomasā€™s, I have the below ones:

ok I updated the card to avoid issues from other cards. Try version 1.3.1 and let me know if you have any problems. I looked at some of the cards you referenced that I dont use myself and they looked fine. Itā€™s definitely something thatā€™s defining LitElement incorrectly just not sure what.

Champion! That works perfectly and doesnā€™t spit out any errors. Great work and thanks for helping with the issues I was having :grinning:

Love this project. I just got it working, but having problems with my effects list. I tried using input_select and also tried listing all of my effects, but no matter what it doesnā€™t show up. Iā€™m not getting any errors and the color wheel and brightness slider are working perfect.
Any ideas?

Thanks for the work you put into this and sharing it with everyone.

Can you give an example of your input_select config and lovelace config for this card? Are there any errors in the console?

not getting any errors.

lovelace config 1:

 - type: 'custom:light-entity-card'
   entity: light.led_144
   persist_features: true
   effects_list: input_select.144_led_effects

lovelace config 2:

 - type: 'custom:light-entity-card'
   entity: light.led_144
   persist_features: true
   effects_list:
     - "Christmas"
     - "Candy Cane"
     - "Holly Jolly"
     - "Valentine"
     - "Lovey Day"
     - "St Patty"
     - "Easter"
     - "USA"

input_select config:

144_led_effects:
name: ā€˜144 LED Effectsā€™
options:
- ā€œChristmasā€
- ā€œCandy Caneā€
- ā€œHolly Jollyā€
- ā€œValentineā€
- ā€œLovey Dayā€
- ā€œSt Pattyā€
- ā€œEasterā€
- ā€œUSAā€

I have tried both ways and I donā€™t get any errors either way, but my effect list doesnā€™t show up.

The problem is caused by line 301:

      if (this.dontShowFeature('effectList', stateObj)) return html``;

If you rework it like this:

      let effect_list = stateObj.attributes.effect_list || [];

      // if we were given a custom list then use that
      if (this.config.effects_list && Array.isArray(this.config.effects_list)) {
        effect_list = this.config.effects_list;

      } else if (this.config.effects_list && this.hass.states[this.config.effects_list]) {
        // else if given an input_select entity use that as effect list
        const inputSelect = this.hass.states[this.config.effects_list];
        effect_list = (inputSelect.attributes && inputSelect.attributes.options) || [];
      
      } else if (this.dontShowFeature('effectList', stateObj)) { 
        return html``;
      }    

it should work

If thats the problem then HA is not computing the correct features list for those entities or the light entity is not configred correctly. Iā€™ll try to see if there is a way to include it anyways without breaking other functionality. The problem is when you include group entities custom effect_lists will show up for all of them. Iā€™m on the fence about this change for this card as whatā€™s really happening is HA isnā€™t giving the correct feature list or some people are misconfigured.

Make sure you have effect: true on the light component so HA knows this entity has the effect_list feature. For my mqtt based light:

- platform: mqtt
  schema: json
  name: "LED Strip"
  state_topic: "bruh/porch"
  command_topic: "bruh/porch/set"
  effect: true
  color_temp: true
  effect_list:
  - Rainbow
  - Rainbow With Glitter

Got it working. I was using the DrZZs version of the Bruh LED strip. After I uploaded the Bruh LED strip my Card is now displaying just like it should.

Iā€™m not saavy enough with this stuff to know why 1 sketch works and another doesnā€™t, but thatā€™s what happened.

Thanks again for the time and effort you put into this.

Take care

Updated card to v2.0.0 from a breaking change in upcoming HA v0.88. No config changes needed.

Is there a way to disable the color wheel? I have a couple of switches that control Hue light groups that have just white lights in the group, but the color wheel still shows up. When controlling a single white light, it appears as is should, without the wheel.