How to put current date in a tile's label?

My goal is in a valueTile to display the date when the last tamper event has occurred.

standardTile("tamper", "device.tamper", inactiveLabel: false, decoration: "flat", width: 1, height: 1) {
    state "clear", label:'NO TAMPER', backgroundColor:"#ffffff"
    state "detected", label:'Tampered: ' //+ the stored date variable
}

def zwaveEvent(physicalgraph.zwave.commands.notificationv3.NotificationReport cmd)
    if (cmd.event == 0x04) {
                // some code here that updates and stores the current date 
                result << createEvent(name: "tamper", value: "detected" , descriptionText: "$device.displayName was tampered")
    		}

I guess the “lastTamper” date should be stored so it can be displayed in the next run.
When I instantiate the date not in the label, I keep getting “null” and instantiating it there does not update it when another tamper appears (nor it stores it).

Look here for an example:

Start at line 196 through 258 and follow how the variable “timeString” is used.

1 Like

Thanks. The info was helpful and I fixed my problem (can close the topic)

1 Like