Dynamically changing the unit property for tiles


#1

Did anyone manage to get a dynamic unit type selection to update the displayed tiles?

I can change the literal strigns in the Recently tab, but for the life of me i can’t seem to be able to change the displayed unit on the tiles themselves. They remain the same as the ones initially set in the state declaration.

Additionally, even using {$unit} in the state label next to {$currentValue} doesn’t seem to have an effect when i set the unit prop to a diferrent unit type. isStateChange:true doesn’t force the tile refresh, even though the actual value changes.

It’s as if ST’s apps don’t even use the unit property for a couple years now.


(Kevin) #2

I haven’t been able to get that to work either so when I run into a situation like that I use a custom string attribute for the tile instead of using the actual attribute.

I usually name it something like primaryStatus and create an event for it every time I create an event for the actual attribute.

That allows you to display whatever you want, but you won’t be able to use the value range backgroundColors feature for that tile.


#3

Thanks for the tip Kevin, it looks like it might just do the trick if i hide the events from the Recently tab.


#4

Mind sharing a code snippet of how you do this @krlaframboise?

I’ve tried two custom attribute states inside a tile without much success, but in case i use just one i’m afraid it’ll break automation options of the DH, which has a way higher value than the label changes so far.


(Kevin) #5

I can post a snippet tonight, but if the tile is using a custom attribute you shouldn’t need more than 1 attribute state.

The tile attribute states have no effect on automation so as long as you’re still setting the actual attribute vale the same way as before it shouldn’t break anything.

Doing this with a Standard Tile with multiple attribute states used to perform actions would cause problems with the Dashboard, Things screen, and Device Details, but it still wouldn’t effect automations.


(Kevin) #6

Did my last post provide enough information for you to figure it out or do yous till need that code snippet?


#7

Thanks for the help @krlaframboise i think i’ve found the right approach via your method, just need to test it some more.