I (finally) got the coding figured out.
Here’s how it looks:
One of the keys was noticing that the not_home/Away status has no zone attached to it. (Tautological, I know.) The other key is that the names of all your zones have to match the “device name” (“zone.ICC” has to have the friendly name “ICC” and the cases have to match as well.)
One issue is that the template editor could get me to the basic coding, but it doesn’t handle ha-icon and some other HTML bits.
and here’s the code:
I was incorrect on one point: Apparently case does matter. Your device name has to match ‘zone.’+Friendly name in both case and exact text. (former post has been corrected)
I’m having some trouble combining templates, does anyone have an idea why my local definition or STATE ON is not overwriting the template config? The docs say local config takes priority.
Commenting out the two templates does get it working as expected with the blink.
I’ve also tried moving the location of the template definition above and below the state definition with no change.
You can merge states together by id when using templates. The states you want to merge have to have the same id. This idparameter is new and can be anything (string, number, …). States without id will be appended to the state array. Styles embedded in a state are merged together as usual. See here for an example.
Just wanted to thank you for this write up. I was able to do some pretty cool things with templating thank to you and the conversation you had with qoheleth. It’s really cool that you continued to help everyone with their individual needs to. Someone should be paying you!
@Bearded_Beef, I’m glad you found this helpful. I have a natural desire to both learn and teach, so I enjoy writing up the result of something I spent a lot of time figuring out. The act of writing it up often helps me refine and improve what I started with too, so it’s a win-win
@ktownsend-personal - great write up Keith, thanks for sharing. I have two questions if you dont mind?
I will start with what may be a simpler one to describe. Here is an extract from part of a lovelace I have. There are a few buttons related to my solar. The Exporting Electric button you see in red, i would like to have the state read “Exporting” or “Importing”, instead of on or off, is that possible do you know?
My second question. The blue card shows how much i am importing or exporting, at the moment i use colours to identify import or export. I know i can have different icons but ideally i would like to duplicate the card, one for export and one for import, but only show the Wattage value for the relevant card based on its value (i.e. greater or less than/equal to 0).Is it possible to set the show value based on condition?
I don’t know the attributes of a consumption sensor (but you can post it, see Developer Tools → States), so I can only speculate; probably something like this:
state_display: |
[[[
if (entity.state <= 0) return entity.state;
if (entity.state > 0) return 'big up the pace!'
]]]