Hi there, in addition I’ve made myself a countdown card based on this code.
It is conditional, so it will only show when the timer is active. Also, when you click it, the timer is cancelled. But before that, a confirmation message pops up.
It is based on the custom-button-card.
text-shadow: 0px 0px 0px black
tap_action:
action: call-service
service: timer.cancel
service_data:
entity_id: timer.cooking_timer
confirmation:
text: ‘[[[ return Are you sure you want to cancel the timer? ]]]’
Have you read the documentation? Take a look here:
There you’ll find the following:
Avoid using states.sensor.temperature.state , instead use states('sensor.temperature') . It is strongly advised to use the states() , is_state() , state_attr() and is_state_attr() as much as possible, to avoid errors and error message when the entity isn’t ready yet (e.g., during Home Assistant startup).
The next point would be “Time”, there you’ll find, what you’re looking for.
You need to find out, what type duration is. Normally you would want to typecast this value to an integer or int. Than add 120 seconds.
Thanks fir the hint @paddy0174
The main problem are still there. I don’t know the type of the duration attribute. In the devlopment-tool shows the state as 00:05:00. (static, even if the timer is running)
Meaning, the code I posted, doesn’t work? Or do you just want an explanation?
In the snippet I posted, the duration will be type casted to INT or Integer or at least should get type casted…
sorry, my answer was a little short. Yes, I took over your code. The template logic is now correct. Unfortunately, the condition still does not change after 2 minutes. I think it’s because of the ‘120’. But I have no idea how to solve this (I’m not a programmer and not familiar with int.).
If you have the solution as code, that would be perfect.
I found the problem. The countdown is not an attribute. Just the start (and remaining) time. But both are not change, if you start the countdown. So isn’t possible to make a condition: https://github.com/home-assistant/core/issues/30062
Thanks for pointing that out. Maybe when I copied the code that line got moved but the original is correct. Nevertheless, I checked my code just to make sure, I went through the indentation again and that didn’t solve the problem.
When I check my configuration, it says that’s valid but when I reload automations I get a persistent notification saying that: The following integrations and platforms could not be set up: * automation Please check your config.
If I comment out the condition section then I can reload the automation without a problem. Thanks for your willingness to help.
When I check the configuration it says that’s valid. But when I reaload the automation it gives me the error. If I comment out the condition statement, it loads fine.
I don’t know what to tell you. You aren’t providing the information to help solve the problem. The automation syntactically is correct. Without seeing the full context, I cannot help.
I really appreciate your interest on helping. I found the problem. Under the trigger section I didn’t have a the required parameter above (or below) As soon as I added the above: 50 everything works fine. Thanks again for your help.
Found a pretty good solution using custom:button-card so sharing here. It shows the icon of the light with the timer and colors it appropriately. It also reacts to taps to turn it on and off manually. Then the time remaining before the light goes off is displayed below the icon.
indent message 2 spaces. Also please post text next time, not images. Thanks.
Lastly, you can decipher the error messages without consulting the help desk. It’s telling you exactly what’s wrong.
extra keys not allowed @ data['action'][0]['message']
↑ ↑ └───────This is what it does not expect, it is the 'extra key'
| └─── This means first item
this is only in automations...
the first action in an automation’s action has an unexpected key “message”