Is there a way to pass a CSS variable as a badge color?
I have them with light and dark modes in which the color changes. in order to make the colors match, I donāt want to pass the rgb/hex value, but rather the CSS var.
Iām currently trying it like this:
routes:
- url: /mobile-development/alarm
badge:
color: |-
[[[const s = states['alarm_control_panel.alarmo'].state;
if (s.includes('armed_') || s === 'triggered') {
return "red"; // <=== this works fine
} else if (s === "disarmed") {
return "var(--token-rgb-green)"; // <=== these do not work
return "--token-rgb-green";
return "token-rgb-green";
} ]]]
Iām obviously not a CSS/JS guru, but Iāve tried so many variations and LLM suggestions that Iām not sure if itās even possible.
Hey all, Iām after a bit of help, I want to change the popup to a row of icons rather than the column, I have changed as many āflex-directionā CSS values from column to row as I can find using the styles.ts file as my guide
any help would be greatly appreciated, Iām probably missing something totally easy
EDIT:
Okay - sometimes all it takes is a coffee ⦠Iāve now found the badge within the routes in the visual view - great! ⦠but Iām still stuck with this code ⦠can anyone help me? (The lights are of course assigned to the rooms)
Iām completely off track ā itās only meant for a counter, right? It basically needs a counter.
But I donāt need that for the subcategories (rooms)⦠I just want to see if the light is on or off in that room. Does anyone have an idea how I can represent that visually?
Right now itās not possible to configure this behaviour. But maybe the icons should also change position when the popup is aligned to the right. Just as they do when using show_popup_label_backgrounds set to false.
Hi @nemo-gim , first of all, sorry for the delay. Iāve been quite busy with personal stuff over the past few months. Iām hoping to have much more free time starting in January.
As for your questionsā¦
It looks like you are using custom styles to display the navbar at the top of the screen, am I right? If thatās the case, thereās currently no option to change the popup direction. Iāve got a new feature pending that will allow to display the navbar at the top of the screen via position: top, both for mobile and desktop, which would solve your scenario.
There is! Check out the image prop for each route. You can even take a look at this example for a quick snippet on how to use images as route icons
Is this happening only on mobile or on desktop? Or both?
If both devices have the same issue, try disabling the auto padding feature under the layout section.
If you only need to disable for one of them, you can do something like this:
type: custom:navbar-card
...
layout:
auto_padding:
desktop_px: 0 # to disable auto_padding only for desktop
mobile_px: 0 # to disable auto_padding only for mobile
Adding support for position: top in mobile has been requested a few times. Iāll try adding it to the next release, and hopefully you wonāt need to use custom styles for navbar-card to be displayed properly
Iām guessing the Javascript code you pasted, is used inside the hidden prop of navbar-card, right? If thatās the case, you donāt need to return "on" or "off". The hidden prop expects a boolean value, so you can simply do:
It should work with either raw color values, or CSS variables. Just make sure --token-rgb-green is actually defined in your setup. You can take a look at some of the pre-defined css variables of Home Assistant in their github repo.
Hi @TripleQ ! If Iāve understood correctly, yes, you can! You can play with the min_width option in the Desktop configuration.
When using a number of, letās say, 1080, it means that all screens that are 1080px in width or more, will be displayed as desktop mode. All the devices with screen resolutions lower to that 1080px, will then be displayed in the mobile variant.
The states object contains the state of all entities in your HA instance. That means, states.light is not going to work, unless you have one entity conveniently named light.
So, to fix this, you can take a look at this example, and change the filter function to adapt it to your use case:
show: |-
// Store the light entities in a variable to avoid recomputing them on each render
if (!this._lightEntities) {
this._lightEntities = Object.keys(hass.states).filter(id => id.startsWith('light.'));
}
return this._lightEntities.filter(id => states[id].state === 'on' || hass.entities[id] == "buro_marcel").length > 0;
Maybe Iām not understanding something here, but you donāt actually need to add a counter. If you just configure the show option and leave the count one empty, the badge will be displayed as a small circle with no text inside. Just as you show in the original screenshot.
Iāve just tested with the standard Home Assistant theme in your link and it doesnāt always work.
None of the variables in my custom theme work and only some of the standard variables work.
Hey, thatās rude!
It sounds like youāre āsummoningā him.
This awesome project itās only possible because he pours his free time into it.
Youāre not paying him, nor buying something.
So, donāt go around expecting some kind of right for support.
Itās ok to ask for help, just be patient.