This custom button does almost all of it, but I would like to tweak the “idle” state display text to something more engaging like “start timer”.
Is there a way to customize the state text? I can dynamically customize icon, color, background etc, but just not the text label.
I have tried using label as included in the code, but displaying the label instead of state overwrites the dynamic countdown .
Can somebody please explain why this returns a time like 7:44 when not idle? The condition doesn’t return anything, so I guess it’s using some default property… but which is it?
I’d like to use it in a string, like 7:44 minutes left, but I don’t know how to set up an else in that code. Thanks
This works well. It either shows the string “Start timer”, when idle, or the elapsed time, counting down.
My question is about the if/then logic, and what is the value when entity.state is not idle. If I can get that value (elapsed time) in an expression that would be useful.
Another related question, generalizing, is: is there anyway to output the whole thing, the whole entity object (in JSON or something like it) to see which fields are available, and work from there?
state_display overwrites the default state, as far as a certain state is defined in another way. In the example above the idle state is re-defined. When the timer is not idle, the active state is displayed. If you want another value for the active state, you can define an else that way:
state_display: |
[[[ if (entity.state == "idle") return 'Start Timer'; return 'Timer is active'; ]]]
I’m not sure if I understand you right. Do you mean the entity’s attributes?