Hi again!
Just wanted to share few late additions that are worth mentioning:
User popups
I did use the default user / person popups for a while but lately it started to be inconvenient to click through multiple users to see their location and in addition, to realize that their current location might be reasonable old. Therefore I decided to create two new popups; one for single user details and one for seeing everyone on a single map.
A single user popup:
I can see relevant info about the user’s sensors plus I can request a location update for that user.
Family popup:
The nice thing here is that I can request a location update for all users with a single button click.
The family popup led to another discovery that some users probably have used for a long time but I discovered just now; you can dynamically generate your lovelace cards when you are inside a button-card context! More about this below.
Dynamic creation of cards in button-card context
I have a lot of duplicate code which often times is due to the layout differences between mobile and tablet. On mobile I prefer swiping through pages instead of scrolling up and down and I use swipe-card for this purpose. On the tablet view, everything fits nicely to the screen so most of the time no need for swiping. This leads to duplication assuming you don’t like YAML anchors or use declutter card.
The nice thing about button-card is that you can construct lovelace configuration dynamically in Javascript. This also allows me to adjust the layout based on screen width etc. As an example I can do something like this:
browser_mod:
service: browser_mod.popup
data:
... redacted ...
content:
type: vertical-stack
cards:
- |
[[[
const isMobile = screen.availWidth < 600
if (isMobile) {
// return something that suits mobile such as entities card
const entities = ["sensor.one", "sensor.two"]
return {
"type": "entities",
"entities": entities,
}
} else {
// return something that works for tablet like grid with 4 columns
const cards = [...]
return {
"type": "grid",
"columns": 4,
"square": false,
"cards": cards,
}
}
]]]
I also use this method to dynamically construct light cards of groups in the light popup that I use on both, mobile and tablet.
The downside of this is that you don’t have the support of VSCode Home Assistant addon but for me that is an acceptable loss.
Hope someone finds this useful! Check my repo for more details. The link is on the first post.
Thanks!