Good morning!
Relatively new to this whole HAOS experiment but things are going well so far a few weeks in with over 50 devices. A few speed bumps along the way (a couple I’m still working on) but so far, so good.
I’ve finally begun working on my mobile dashboard to have something more user friendly on mobile devices for the wife & I. Thanks to some online videos and articles I found I’ve got a very functional + aesthetically appealing UI foundation in place. So far, I dig it and she approves as well so that’s huge for adoption of this new interface as our old one (Vera) was very familiar for her but incredibly dated in terms of functionality and customization.
One thing I’m trying to do in terms of code is probably super basic for most reading this but I’m pretty new at this thing so I’m not sure what the steps look like to combine things for the cleanest and most simplistic code to perform the task.
My current dashboard has tiles for each subpage for rooms. Each one has a long press setting to turn the most used device on/off within that room. The icons are also all black/gray but light up (orange) when said device is in an on state. What I’m learning is that the long press on the dashboard isn’t as responsive as I’d like and I’m afraid this could lead to more frustration than user experience optimization. What I’m going to do is have each tile tap only to open the corresponding room.
What I need is help to merge the code I have to do this. An example for one of my tiles is my “Garage” tile that leads to a few garage door openers and locks. Each device tile individually behaves the way I want on that “Garage” sub-page. I’d like a way to have all of my rooms indicate anything that may need attention at a single glance. I’m wanting the tile to have a green icon when all devices are closed/locked and turn red if any one of them is open/unlocked.
These are the three devices and their code:
► Device #1: Double Garage Door state red/green ◄
{% if is_state(‘cover.garage_door_opener_double’, ‘closed’) %}
green
{% endif %}
{% if is_state(‘cover.garage_door_opener_double’, ‘open’) %}
red
{% endif %}
► Device #2: Single Garage Door state red/green ◄
{% if is_state(‘cover.garage_door_opener_single’, ‘closed’) %}
green
{% endif %}
{% if is_state(‘cover.garage_door_opener_single’, ‘open’) %}
red
{% endif %}
► Device #3: Back Garage Door Lock State ◄
{% if is_state(‘lock.garage_back_door_deadbolt’, ‘locked’) %}
green
{% if is_state(‘lock.garage_back_door_deadbolt’, ‘unlocked’) %}
red
{% endif %}
How do I combine those for one section of code so that if any one of them is open, the color of that main dashboard tile turns red? I’m sure there is an “else” in my future somewhere maybe. I think it would benefit from having a different color than the default (gray/black) like green. That would give me what I need so that I could use or remove that bit of code as necessary for each one.
With this, I can then modify for each room’s corresponding tile on an as-needed basis. I did some searching for similar code to modify but wasn’t successful finding something simple as most examples were very complex with things I didn’t need and I wasn’t quite sure how these could be modified for my specific and basic needs.
Thanks for the help as I start out on this journey!
ETA: the lines of code above have the colors indented properly but the forum is showing them as left justified same as the other lines. I was going to add something to indicate this but wanted to leave the code alone w/o any characters for human eyes that would affect functionality. Just use your imagination.