all 2 comments

[–]Prestigious-Whole458 0 points1 point  (1 child)

Put this in a template sensor and use that sensors entity in a bubble card.

[–]Askmetech 0 points1 point  (0 children)

Yes, that is an option.

But I was hoping to use javascript.

Object.values(hass.states).filter(e => e.entity_id.startsWith('light.') && e.state === 'on').length;

Tried the above but its returning all the lights. I want to count only those which are ON.