Hi team,
This is one of those questions that as soon as I ask it I’m sure the obvious answer will present itself to me and I’ll feel embarrassed to have asked it in the first place.
But I’m curious how others would solve this, so I’m going to ask it anyways, since I really enjoy learning from others.
To keep it brief, I’ll try to give a TL;DR:
- I use Mushroom cards and have created a fairly full-fledged mobile dashboard using them
- Each standard mushroom card contains support for: Title, Secondary Text, Icon, Badge Icon, and Badge Icon Color.
Here’s a screenshot of my main dashboard:
I’ve developed a pattern that I use, for example the “zzz” at the main status bar indicates our toddler is napping, and the “secondary text” of his room (lower right) contains how long he has been napping for.
Similarly, the secondary text on the Kitchen indicates when the dishwasher will finish, the backyard shows us how much the solar panels are producing, etc etc.
Clicking on any room takes you to that room’s details:
Now, when something is awry, I might have a badge icon and associated color (red for example) on that room.
Here is an example I created, where the cat litter box (located in Serena’s office) is rotating, Ethan’s space heater is heating, and one of the garage dehumidifiers is full and must be emptied:
So, all of this is controlled via template sensors, which are loaded up on the dashboard. This helps separate the presentation logic from the actual logic, so that for example the room’s current icon can be used elsewhere (not hard coded on the dashboard itself).
Here is an example, for the backyard:
Now, the problem is, you can already see the “if” condition for the power being produced < or > 0 is duplicated - one for each template sensor - since it might affect both the icon and the secondary text (which is true in this example).
Ideally, I can have a single template sensor for “backyard”, and have attributes for the badge icon, color, etc.
But, the way a template sensor is defined, I have to have an “if” statement for each attribute and the state itself - so, still have the duplication.
The only thing I can think of is to emit JSON from a sensor, and have JSON keys for badgeIcon, badgeColor, secondaryText, etc etc. That way I can not duplicate the “if” statements.
I hope this is making some/any sense.
Again, I’m sure there’s a much better way to think about this that I am missing!
Cheers
Matt