Lovelace: Button card

yep, I know, I’ve did the same for lights, switches etc…
I was just hoping there was a better way.

thanks anyway

That should do the trick :wink:
Object.keys(states).filter((name) => /^persistent_notification\./.test(name)).length;

1 Like

I confirm your conclusion.
Only way I solved this for now is with a script and a delay.
But is this really a big in the app?
No one else has this issue?

Yes, it works perfectly. Thank you so much.

May I ask you to explain the code so that we can learn what’s going on and how to achieve such results?

states is an object, each key is an entity (including persistent_notification.notification_id).

Object.keys(states) returns an array of all the keys of the states object. Then we filter it.
filter takes a function as an argument: (name) => /^persistent_notification\./.test(name).
This says: each key is a parameter to the function, and the parameter is name. Then we test the argument name and check if it matches against the regex /^persistent_notification\./. If it matches, then filter will add the key to its result array.
filter returns an array so you can then use length on it.

Hope it helps. :slight_smile:

2 Likes

has this been resolved somehere, or maybe cleared up?

I’m using a modern browser on an up to date system, so should not need the Cors settings (tried it anyhow, didn’t make a difference).

When casting from Chrome to my Google Hub, I see the instance, but all button cards are red, with error 'cannot read property 'config' of null' (see here for more issues

Using the NabuCasa connection doesn’t make a difference either, so I m stuck for now really, hope this thread might have some pointers how to solve the red button cards.
thanks for having a look.

Maybe a stupid question, but is this button card only configurable via yaml? I thought it would appear amongst other cards to choose form when I select configure UI and then choose “Add card”?

Gotta use yaml.

Oh okay, thanks for info!

The option to select from the UI is “Manual Card”. That’s the selection for any custom card, and then you enter your yaml

1 Like

I’m looking into this currently, can’t yet access a debugger on my chromecast device…
This is the same on the decluttering card.
@iantrich, did you manage to get some of your cards working with chromecast?

1 Like

Were they not working? I really don’t remember and have no issues saying they don’t :man_shrugging:

I’ll see about it this weekend, perhaps if I find time (likely won’t :stuck_out_tongue_winking_eye:)

Tried on my chromecast and neither button-card nor decluttering-card work :frowning:
cannot read property config of null. I need to find which code line is generating that so I need a debugger :slight_smile:

It’s related to the fact that Safari (and any tool using a web view) in the latest iPad OS identifies itself as a plain Mac… It is fixed in button-card’s dev branch and I’ll publish a new version soon (probably over the weekend).

thanks @RomRider, glad you recognize it and are on it. Let us know if we can help to solve the issue.

HI, where do you need the issue to be raised? Glad to do, simply thought this was sufficient in this thread.
Sorry if that was too obscure to notice in this huge thread…
let me know how to help

Referring to my cards alone

well, not really sure what you say here, but this:

image

made me think I needed to post in the button-card thread…

Issues are best raised on GitHub, you know that.

I was stating that my cards that I have developed do not have open issues related to casting so I have not looked into it.

sure, but, needed be sure it is an issue first, and not a mis configuration on my behalf. Posted the issue for the button card, thanks.