[Version 2.1]
Added animated gif for state âonâ (red dash circling 5th badge ), custom thermostat-card, column-card
picture-elements card: local variables to set relative position of âbadgesâ, changed unit % to vw for better scaling across devices
To do: figure out scaling of picture-elements card size across devices, show/hide âbadgeâ based on entity state ( tried monster-card, wonât work inside picture-elements card)
[Version 2.2]
Added compact-custom-header compact-custom-headerto save screen space on top. Tested moving the banner setup under a conditional card to hide/show banner, works fine.
Column-card did not create the banner, it make use of panel:true, 1st card will be full width and then let the cards under the 1st one auto flow based on screen size/orientation.
In my banner done with picture-element card, I created composite âbadgeâ using combinations of state-icon/image/state-label types. You can also use the simple state-badge but I found it does not scale.
In column-card case, I can use my banner or you can just use badge under view badge in view
The âgreenâ (actually the primary color of the theme) circle is created from border-radius/border under style here:
- type: image
entity: sensor.local_date
state_image:
âopenâ: /local/lightbulb-outline.png
âclosedâ: /local/lightbulb-outline.png
filter: opacity(0)
style:
. . . .
border-radius: 100%
border: var(âprimary-color) double 0.2vw
The state_image does not matter here since filter: opacity(0) make whatever it is âdisappearâ and showing only the border/circle.
I have theme change periodically and wanted the badges to look part of the theme, so I set the border color to var(âprimary-color). You can set border to any color you want, just replace var(âprimary-color) with a color name.
The red circle is actually an animated gif , I overlay that on top the âgreenâ circle image:
- type: image
entity: binary_sensor.motion
state_image:
âonâ: /local/loading.gif
âoffâ: /local/loading.gif
state_filter:
âonâ: opacity(1)
âoffâ: opacity(0)
style:
. . . .
border-radius: 100%
I wanted the red circling to âappearâ only when the binary_sensor.motion is on, so I used opacity(0) to make it âdisappearâ when off.
These 2 images have to been defined in this order to have the correct overlay result.
Getting the state-badges to align was a minor pain, but I got it working somehow, with the exception of the gap between the first and the second badge, which is smaller.
But my problem is the friendly_names of my sensors, which in case of the DWD weather sensor come from the sensor-attributes so I canât change them in customization. This wrecks the panel pretty much:
Does anyone have an idea how to style around this?
You mean as you explained in the post about badges and animated gifs?
Anyway, I got around the very long friendly names that I unfortunately canât change in customization - I simply created a value_template-sensor that gives me the state of the real sensor, now I can set a friendly name as I like.
While the relative positioning of entities on picture-maps is fine for a floor, it doesnât suit a panel. If I resize the browser window, the background image of the floor scales and all icons move, effectively âstaying in the same placeâ - that is fine and as it should be. But with
top: 50%
left: 10%
the badges slide around and change their positions and distances. No go! But since this is CSS, you can use absolute positioning. I didnât find any documentation in the HA-docs about that, but it worked alright:
Iâm looking to create similar views in Lovelace as I have in legacy frontend using CustomUI, is that at all possible? Different colors if family members are home or not, and diffrent colors depending on temperature and humidity etc.
I used binary_sensor/input_boolean state to do color change in type: state-icon, those are relatively easy, under style, --paper-item-icon-color is the off state color, --paper-item-icon-active-color is the on state color.
To use this method for sensor entities, like temperature and humidity, youâll have to create template binary_sensor for each of them, that may not be what you want.
You may also want to look at this discussion about icon-template and customization.