How do I center text?

@Lgkahn wrote a great device type for Smart Alarm Status but in IOS I have a problem where the text isn’t centered on the tiles. Below is a screenshot. Anyone have any ideas on how to center this text? Thanks.

It’s not a great solution, but if you use a valueTile instead of a standardTile, the text will be centered.

If I use this code below the color behind the lettering shows for a split second then disappears any ideas? Also the text becomes bigger than the circle of color.

valueTile(“armDisarm”, “device.armDisarm”, width: 2, height: 2) {
state “unlite”, label: ‘Disarmed’, backgroundColor: "#ffffff"
state “lite”, label: ‘Disarmed’, backgroundColor: “#4f9558
If I change it to this the color is showing on all the tiles no matter what state I have a tile for Disarmed, Armed-Stay and Armed-Away so the code repeats for each.

valueTile(“armDisarm”, “device.armDisarm”, width: 2, height: 2) {
state “lite”, label: ‘Disarmed’, backgroundColor: "#4f9558"
state “unlite”, label: ‘Disarmed’, backgroundColor: “#ffffff

I’m pretty sure there’s nothing you can do about the sizing problem. The last Android and iOS update made that problem a lot worse.

Did it work OK with the standardTile?

I recently ran into a similar problem with the valueTile not showing the text, but mine was caused by having it set to decoration: “flat” and you don’t appear to have that on yours.

You do have the attribute “armDisarm” declared and the only events being created for that attribute are “lite” and “unlite”, right?

Yes it works with standard tile as the screenshot above shows, but the text is offset. My text shows when in value tile but the background color shows on all three at once no matter if disarmed, armed-away or armed -stay. and the only attributes are “lite” and “unlite”

I have no idea what could be causing that.

You could try adding another state line above the other 2 that looks like:

state "default", label: 'Disarmed', backgroundColor: "#ffffff"

I recently had to use the code below to fix a problem, but I can’t remember if it was the same problem you’re having or if it had something to do with the way things appeared in the activity feed.

FYI: “detected” and “clear” are the only values for the attribute used below.

valueTile("tampering", "device.tamper", label: 'Tamper', width: 2, height: 2) {
  state "default", label:'', icon:"", backgroundColor: "#FF0000"
  state "clear", label:'Tamper Clear', backgroundColor: "#CCCCCC"
  state "detected", label:'Tamper Detected', backgroundColor: "#FF0000"            

I’m out of ideas so if that doesn’t fix it you’re probably better off sticking with the standardTile and the non-centered text.

Either way, ST will most likely find a new way to break the UI the next time they release an update.

The state “default”, label: ‘Disarmed’, backgroundColor: “#ffffff” didn’t work the color behind was gone. I am at a lose to figure this out.

It could be related to another tile or the way the attribute is updated so without seeing the code, I’m out of suggestions.

Here is the code:

Thanks, it is appreciated.

In order to test, I changed the on/off tiles actions to onPhysical and offPhysical and then changed those commands so they send the 3 events for those tiles 2 using lite and the other using unlite and the opposite for the other command.

On Android, pressing the on tile made 2 green and then pressing it again made those 2 normal color and the other 1 green which is exactly what my changes were supposed to make it do.

The problem either only affects iOS or it has something to do with the parse method because I’m unable to test that part of the code.

Well I guess until someone with IOS could check I will live with off center text. Thanks for the help. I will wait and maybe someone else will come up with an answer. I am like a dog with a bone I don’t give up easy. I know there is an answer.