@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!'
]]]
For your first question, there are 2 ways you can do it:
javascript template for the name to examine the state and return the name you want to see
the state feature of the custom button card to specify what name to use based on state value
For your second question, you have the same options as the first question.
Something to consider is that you can make a single button to show all of that together, rather than having 3 buttons as you mentioned. The name would show “importing” or “exporting” and the state would show watts. To make it all work as a single button you’d need to use javascript templates rather than the state feature so you can examine multiple entities.
thanks @pedolsky and @ktownsend-personal , great advice from the forum and now have simplified to one button using name state, all working nicely now so thank you (i’m no java coder so this simple option worked well for me!)