Thanks for the quick reply, @RomRider . That makes sense, but I now have a very expected behavior with the code below. instead of (or maybe in addition to) evaluating the if statement in the template, the actual logged-in user name for Home Assistant changes to TOPFLOORTAB, both as shown on the sidebar and when opening the user settings menu from the sidebar.
The Lovelace code editor automatically changes entity_picture: > (as shown in the template docs) to entity_picture: | when saving the card. Iâm a JavaScript novice. Could that have something to do wiht it?
Thanks a lot for your reply @gerard33 . I had tested that change earlier by replacing the ==, swapping to another dashboard and then going back to the TOPFLOORTAB dashboard. I had the same behavior. I now realize that I should have also cleared the cache. This now works.
I appreciate that this isnât a JavaScript tutorial thread but is there a reason in the context of the button card that = instead of == appears to mean that the if statement is ignored and instead itâs treated as variable settingâIf thatâs whatâs happening?
In almost ANY language = means assign a variable, == means compare.
You can assign a variable in a if statement (even if thatâs pretty unusualâŠ), but it will not return true, so the if will not do anything. Nothing specific to button-card, this is just plain javascript.
Next up I would like to get my bathroom lights onto the wall panel. The problem is that I have 3 things to control when I want the bathroom lights to go âonâ or âoffâ.
I have a hue group, light.master_bathroom_group
a single hue light, light.master_bathroom_loo
and then a wall toggle switch that works the walk in closet lights switch.master_bathroom_closet_lights_switch
I would like to have two buttons on my panel instead of a single one that does toggle. The reason for this is that at night only the light.master_bathroom_loo comes on so it is difficult to describe âonâ since it changes based on the time of day.
Button 1: Turns off those three devices
Button 2: Turns on those three devices
I can take care of the styling of the button but I am not sure how to architect the tap action
Should I create two automations and call the automation when the user pushes the button
automation 1: turn those three devices off
automation 2: turn those three devices on
or should I accomplish it some other way. I am relatively new to Home Assistant and am still not fully aware of the things available to us.
Hello! I really love the Button card but since a few days I have a problem with it: The icon doesnât get resized any longer. âsize:â is ignored, and different sizes of the button donât change anything. The icon is always displayed very small.
Does anyone here have an idea where to search for a solution? I already updated HA to 110.4 and loaded the latest button-card.js. Many thanks for your help!
The answer is probably somewhere already, but I donât seem to search on the correct keywords. But how do you arrange size different size buttons next to each other. Assume a full columns in lovelace with butons in a 2x3 grid where I want to have a double width button in it:
1 2 3
4 4 5
where 4 4 is one single wider button. I tried using aspect ratio but this just makes makes the height unequal to the button next to it (button 1,2,3,5 have all aspect ratio 1/1
It seems to me that entity.state is not available if the button is included in a pop-up.
It might of course be that it is actually a âproblemâ with browser_mod but I have no way of knowing.
Also, you might decide that is too obscure to want to look into but here it is in case you want to look at it.
This is the error when used in a pop-up:
button-card.js:1693 Uncaught ButtonCardJSTemplateError: TypeError: Cannot read property 'state' of undefined in 'var on_icon = 'mdi:checkbox-marked';
var off_icon = 'mdi:checkbox-blank-outline';
if (entit...'
at HTMLElement.eval (eval at _evalTemplate (http://192.168.1.25:8123/hacsfiles/button-card/button-card.js:1691:14), <anonymous>:7:14)
at HTMLElement._evalTemplate (http://192.168.1.25:8123/hacsfiles/button-card/button-card.js:1691:106)
at HTMLElement._getTemplateOrValue (http://192.168.1.25:8123/hacsfiles/button-card/button-card.js:1700:97)
at http://192.168.1.25:8123/hacsfiles/button-card/button-card.js:1958:62
at Array.forEach (<anonymous>)
at n (http://192.168.1.25:8123/hacsfiles/button-card/button-card.js:1957:40)
at http://192.168.1.25:8123/hacsfiles/button-card/button-card.js:1958:40
at Array.forEach (<anonymous>)
at n (http://192.168.1.25:8123/hacsfiles/button-card/button-card.js:1957:40)
at http://192.168.1.25:8123/hacsfiles/button-card/button-card.js:1958:40
Iâm struggling with some custom colouring of a button card.
I have a button to control a garage door (cover). I also have an automation that starts a timer when itâs opened. I will get a notification on the companion app when this timer expires (i.e. I regard the door as left open for too long, for safety reasons).
On my button, I want to show an icon to indicate whether the door is open or closed. This works fine when using the cover as the entity. The button has a name displayed at the top, then the icon and underneath it the timer which should either display idle or the remaining time.
I discovered on this thread that for the countdown to work, the buttonâs entity must be the timer and not the cover. This is fine, as I can still implement the different icons and all that (I think). The config below will show a timer/stopwatch icon â Iâm not worried about that for now.
I set the buttonâs entity to the timer and defined a style for the state with colours for the conditions, but it doesnât change the red countdown time back to blue when the state changes to idle and I canât see why.
The label in the config below is just a bit of debugging and also because I tried to do this with the label before I learned that the label wonât update.
Does anybody have an idea why itâs not working as I expect?
The state part of your config should be a main config entry, not under styles.
state under styles is to apply CSS to the state field. state as a main config entry is to apply several settings based on different state of the entity declared in the button.
When I move that section, it colours the icon red but not the state (meaning the timer countdown/idle below the icon), and the iconâs colour doesnât change (revert) when the state is idle. I must still be doing something wrong but I see the docs say that the colour change will only apply to the icon. How would one apply dynamic colours to the timer state text?
I noticed something else. When I define a minimal config for this button, I get an error in the log. Iâm not sure whether this is related to my issue. Iâm performing a full upgrade at the moment.
UPDATE:
Iâve upgraded to HA 0.110.5 (latest) and Iâm using Button Card 3.3.5 (also latest) and I still see the error. Then I saw this was already reported above and logged as issue #337.
SOLUTION:
Iâm quite happy with this. The power was in using an embedded custom button card that represents the timer. I first did it with the main card tied to the timer and then using a lot of JavaScript to get it to show state according to the coverâs status but then one needs to do more work for the actions to be tied to the cover. So, I reversed all the logic, which I think makes more sense and reads easier (but just mentioning it anyway to confirm how powerful this custom button is).
I just installed button-card using HACS in my âregularâ install of HA on RPi running HASSOS. Super excited about adding it to my UI! On the HACS screen, when I click on the Plugin, I can see the instructions, including the TOC. The links in the TOC donât seem to be working. I can see the anchor reference in the URL when clicked, but (at least in Firefox on Windows), it doesnât take me to the anchor. Also, I would have thought that this web page would be in /config/www, but itâs not there, so I assume it is in a container somewhere, relatively inaccessable. Am I missing something?
Also, is the ui-lovelace-card.yaml still a thing? I thought that went away.