Hide text if not needed under certain conditions?

Greetings,

In a supertile, is there any method to hide a THING VALUE if certain criteria are not met? In my case charging is done, so hide the line of text indicated… if time=0 don’t show. I can’t find anything and somehow I doubt it can be done. But I thought I might ask just in case. :slight_smile:

What about using a rule to copy the value to a variable… and if the value is 0, set the variable to be blank?

There’s also a feature request for the ability to style individual parts of a Super Tile which has picked up some interest lately if you want to cast a vote on that:

:white_check_mark: Add ability to style individual parts of a super tile

1 Like

Thanks Josh. This sounds like a good solution, but this wouldn’t effect the text part. Right now I have “charging mins left” as a custom unit so it would be beside the minutes number reguardless of it’s length. Padding a variable wouldn’t hide the text?

I was thinking you could embed the ‘units’ directly into the variable text that way you would have the option of setting the variable completely blank when desired.

Would your method apply to numeric variables as this attribute is numerical only. So I can’t set it to nothing… it’s unfortunatly only expecting a number.

In this case, I was suggesting just using a text variable to store the value.

Here’s an example rule using the energy attribute of one of my smart plugs as an example, but any attribute / value could be used here.

Any time the value changes, this rule runs. I used an expression because it simplifies the number of clicks needed, but you could use a regular IF Condition if you want as well. The main thing is we are using the Event Value context variable ($context.event.value) for the condition and concatenating into the string.

Here’s the expression for reference:

$context.event.value == 0 ? '' : concat(stringify($context.event.value), " charging mins left")

It’s using a ternary condition which takes the format:

condition ? trueCase : falseCase

So it reads left to right as:

If the value is 0, then return a blank string, else return a string in the format {value} charging mins left

1 Like

For reference, an IF Condition approach would look something like the following.

The Set Variable action doesn’t allow a completely empty field, so you would need to copy in a blank character or use an expression with nothing in it.

1 Like

Sorry for the last reply. Thanks again Josh. I’ll give this a try today and see how it goes. :slight_smile: