Countdown kitchen timer

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.

See my code attached:

type: conditional
conditions:

  • entity: timer.cooking_timer
    state: active
    card:
    type: ‘custom:button-card’
    entity: timer.cooking_timer
    show_state: true
    show_label: false
    show_icon: false
    aspect_ratio: 2/1
    name: Timer
    styles:
    card:
    • font-size: 70px
    • font-weight: bold
    • padding: 1%
    • color: grey
    • align-self: middle
      name:
    • font-size: 40px
    • color: grey
    • align-self: center
    • text-transform: capitalize
    • 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? ]]]’

5 Likes

I try to use a condition in a script to check is the timer-countoun below than 2 minutes. I tried it with something like that:

      - condition: template
        value_template: '{{ states.timer.gardenlight.attributes.duration | int < 00:02:00 }}'

But it doesn’t work. @petro do you know a solution? Thanks a lot

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. :slight_smile:
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.

{{ (states_attr("timer.gardenlight", "duration") | int) < 120 }} 

Not tested! :slight_smile:

Thanks fir the hint @paddy0174 :+1:
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? :slight_smile: Or do you just want an explanation? :slight_smile:
In the snippet I posted, the duration will be type casted to INT or Integer or at least should get type casted… :smiley: :smiley: :smiley:

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.). :see_no_evil:
If you have the solution as code, that would be perfect.:clap:

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

This is what I made for my Xiaomi Smart fan 1C. Thanks for the inspiration :slight_smile:

Would you please let me know what am I doing wrong on this automation? The problem is on the trigger/condition. Thanks in advance.

- id: 'Start Cooking Timer When Temp Reached'
  alias: 'Start Cooking Timer When Temp Reached'
  trigger:
    platform: numeric_state
    entity_id: sensor.temperature
   condition:
    condition: template
    value_template: "{{ (states('sensor.temperature') | int) >= (states('input_number.cooking_temperature') | int) }}" 

  action: 
    - service: timer.start
      data_template:
        entity_id: timer.cooking_timer
        duration: "00:{{ states('input_number.cooking_time') | int }}:00"


Condition is indented, make it line up with alias, trigger, id, and action.

1 Like

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.

that points to your configuration not being correct. Can you post your full automation section here?

My entire automation file is 2400 lines long. This is the automation that is giving me trouble:

- id: 'Start Cooking Timer When Temp Reached'
  alias: 'Start Cooking Timer When Temp Reached'

  trigger:
    platform: numeric_state
    entity_id: sensor.temperature
  
  condition:
    condition: template
    value_template: "{{ (states('sensor.temperature') | int) >= (states('input_number.cooking_temperature') | int) }}" 

  action: 
    - service: timer.start
      data_template:
        entity_id: timer.cooking_timer
        duration: "00:{{ states('input_number.cooking_time') | int }}:00"

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. :frowning:

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.

- id: 'Start Cooking Timer When Temp Reached'
  alias: 'Start Cooking Timer When Temp Reached'
  
  trigger:
    platform: numeric_state
    entity_id: sensor.temperature
    above: 50

  condition:
    condition: template
    value_template: "{{ (states('sensor.temperature') | int) >= (states('input_number.cooking_temperature') | int) }}" 

  action:
    service: timer.start
    data_template:
      entity_id: timer.cooking_timer
      duration: "00:{{ states('input_number.cooking_time') | int }}:00"

Would it be possible to share the code for this?

Thanks!

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.

Screenshot

type: conditional
conditions:
  - entity: timer.timer_garage
    state_not: nothing
card:
  type: 'custom:button-card'
  entity: timer.timer_garage
  icon: 'mdi:lightbulb'
  name: Garage
  show_state: true
  show_label: true
  show_icon: true
  size: '7%'
  tap_action:
    action: call-service
    service: light.toggle
    service_data:
      entity_id: light.jasco_products_zw7101_smart_led_light_bulb_ze26i_level
  styles:
    icon:
      - color: |
          [[[
            if (states["light.jasco_products_zw7101_smart_led_light_bulb_ze26i_level"].state == 'off') return 'deepskyblue';
            else return 'yellow';
          ]]]
4 Likes

Ok… I’m tired of banging my head against the HA wall… Its time to ask for help… I know its me… its always me! LOL
Timer declaration…in config yamal
TimerConfigYamal
The automation in automations.yamal
TimerAutomation
The script in scripts.yamal


and the UI
TimerUI

I’m getting an error in the logs concerning the timer…


and line 46…
ConfigYamal2

Thanks in advance!

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”

Petro…

As usual thanks for your reply!

I thought Id circumvent the back and forth by just posting the actual code…

Thanks again… I’ll implement and check back!

-Aaron