Countdown kitchen timer

Hi all,

Very new to HA and coding in general. I have implemented Tileboard on my HASS.IO install on my pi and am wondering about the possibility of a kitchen timer type function. I would like to be able to choose the duration with a slider, and then see the timer countdown on the screen.

I’ve had a good look around and cant find any info on someone who has previously implemented something like this, so thought I would put it to the floor: do you have any suggestions / could point a beginner like me in the right direction? Many thanks!

3 Likes

Intressting idea - but when i go for:

timer:
  input_timer:
    duration: '00:01:00'
    duration: '00:{{ states('input_number.timertest')}}:00'

input_number:
  timertest:
    name: timertest
    min: 0
    max: 10
    step: 1
    initial: '3'

 expected <block end>, but found '<scalar>'
 in "..../packages/timertest.yaml", line 5, column 30

So rather not so good to use the timer component
but this aproach would possible work with delay - But there you lose the ability to read the values

You can’t template configurations unless the configuration explicitly says it can. This will not work.

Also, side note. The reason you are getting an error is not related to the fact that templating is not allowed. The error you are getting is because of the miss use of quotations for your template. If duration actually alloud templates, you’d still get an error. Whenever you use quotes inside a string, you need to use the opposite quote type. Just take a look at the color of your template. '00:{{ states(' is red input_number.timertest is black and ')}}:00' is red. That means that the parser is seeing this as 2 strings (the red) and a method (the black). It’s what’s causing the error. When you properly enter the quotes in correctly, you string should be all red.

    duration: "00:{{ states('input_number.timertest')}}:00"
              ^                                           ^
              |                                           |

or

    duration: '00:{{ states("input_number.timertest")}}:00'
                            ^                      ^
                            |                      |
2 Likes

Take a look at the timer component

in combination with a input date_time

I’m not sure how a timer looks in the UI so you may need a script (I.E. button) to start the timer.

The only thing I can say for certian is that the text will not be large. It will be the size of all other ui elements, so this may not be what you are looking for. But if tileboard can handle large text, then you could always place the timer there and it may appear the way you want it to.

The input datetime will allow you to set any time. You can omit the date because you wont be needing it. In the UI it will appear as a combination of 2 input number like things where you can change the hours and the minutes (possibly seconds).

If you don’t want the input datetime, you could go with an input number, which is a slider. But keep in mind, you will only be able to handle the slider as 1 unit type. I.E. Minutes OR Hours OR seconds. If you want to control minutes and seconds, you’ll need 2 sliders.

1 Like

Ah! - Thanks for this very good clearification - I’d known that - but when its coming down to configuring some new enteties I always forget it T_T
But how to go on this? The timer component only takes his “hard coded” minutes and secconds.
With input datetime i could think on "set time{{ now() + (state.inputnumber)*60}} and then a sensor with {{ inputdatetime - now()}} (wich is by the way a horrible idea )

I would probably do the following:

Create a timer. Duration doesn’t matter.
Create a input datetime with only time.

Then make a script that starts a timer using the datetime setting as the duration:

script:
  start_my_timer:
    sequence:
      - service: timer.start
        data_template:
          entity_id: timer.xxx
          duration: "{{ states('datetime.xxx') }}:00"

This would create a timer, which I understand, but is there any resource for displaying the countdown on the screen?

Thank you all for your help so far

Didnt knew that we can override the duration.
Set it up and try it out :wink: The timer itself - But as petro said - Its not too big.
something like “useful markdown card” or tileboard could counter.

1 Like

The timer should be displayed on the screen as a sensor, and it should count down. It just won’t be large.

@Underknowledge Yes, it’s part of the services. There’s a whole bunch of new stuff that was added recently too, you should check out the docs.

Thanks for your help. For anyone else totally new like me, here is how I implemented it:

In configuration.yaml

timer:
  cooking_timer:

input_number:
  timer_seconds:
    name: Seconds
    initial: 0
    max: 60
    min: 0
    step: 1
  timer_minutes:
    name: Minutes
    initial: 0
    max: 60
    min: 0
    step: 1

In my scripts.yaml

cooking:
  sequence:
    - service: timer.start
      data_template:
        entity_id: timer.cooking_timer
        duration: '00:{{ states.input_number.timer_minutes.state | int }}:{{ states.input_number.timer_seconds.state | int }}'

In automations.yaml

- alias: 'Timer done'
  trigger:
    - platform: event
      event_type: timer.finished
      event_data: 
        entity_id: timer.cooking_timer
  action:
    - service: persistent_notification.create
      data:
        title: "Timer DONE"
        message: "THE TIME IS DONE!"

It looks like this in lovelace:

00

The notification is not idea as it just puts an orange marker on the notification icon in the top right, so I’ll need think of a better solution to that.

4 Likes

This meight be that your automation got a trigger, but no action and therefore throws an error.

want to get an phone call when the timer finishes? you can do that…

Whoops, I do have an action I just didn’t include it in the paste my mistake. Will edit my other post

action:
    - service: persistent_notification.create
      data:
        title: "Timer DONE"
        message: "THE TIME IS DONE!"

Hey:) does your timer sensor counts down in seconds? Would love to integrate that🤗

Hi yes it does, you can visually see it count down the seconds. The text is the size that you can see in the screenshot so it’s not massive, but I’m sure you could find some custom card to display it larger!

my solution for the timer notification is a conditional card - perhaps that is something you hadn’t in mind… if you thought about that just ignore my post=)

>           - type: conditional
>             conditions:
>               - entity: input_boolean.timer
>                 state: "on"
>             card:
>               type: "custom:button-card"
>               entity: input_number.timer
>               show_state: true
>               color_type: card
>               color_off: rgb(218, 108, 108)
>               action: more-info
>               style:
>                 - font-size: 24px
>                 - font-weight: bold
1 Like

Hey out there, im still fiddling with this timer and countdown sensor solution - till now, i integrated your solution and got a sensor running with the value of the timer. i doesn’t get values out of states.timer.timer.attributes.remaining / states.timer.timer.state and also not trough state_attr('timer.timer', 'remaining') - my solution is dirty as hell but works sometimes, i really would appreciate help, think there must be a way with templating this with input_number1 > 1 and input_number2 > 1 – but i not good enough at this. back to the following, the fiddling part cames in with the integration of hours…

my files:

input_number.yaml:

timer_minutes2:
  name: Minuten
  initial: 0
  max: 60
  min: 0
  step: 1
timer_seconds2:
  name: Sekunden
  initial: 0
  max: 60
  min: 0
  step: 1
timer_hours2:
  name: Stunden
  initial: 0
  max: 24
  min: 0
  step: 1

configuration.yaml:

timer:
  timer2:

input_boolean.yaml:

timer2:
  initial: off
  name: Timer 2

automation.yaml:

##########################
#### Timer Automation 2####
##########################
  - alias: 'Timer done 2'
    trigger:
      - platform: event
        event_type: timer.finished
        event_data:
          entity_id: timer.timer2
    action:
      - service: homeassistant.turn_off
        entity_id: input_boolean.timer2
      - service: WHATYOUNEED
        entity_id: SAME
  - id: 'Timer 2'
    alias: 'Timer 2'
    hide_entity: False
    trigger:
      platform: state
      entity_id: input_boolean.timer2
      to: 'on'
    action:
      - service: timer.start
        data_template:
          entity_id: timer.timer2
          duration: '{{ (states.input_number.timer_hours2.state | int) }}:{{ states.input_number.timer_minutes2.state | int }}:{{ states.input_number.timer_seconds2.state | int }}'



### Timer Off 2#
  - id: 'Timer Off 2'
    alias: Timer Off 2
    trigger:
      platform: state
      entity_id: input_boolean.timer2
      to: "off"
    action:
      - service: timer.cancel
        entity_id: timer.timer2

  -------> if your planing to use with alarm system
########################################################################
########################################################################
######################### Counter for Timer 2 ###########################
########################################################################
########################################################################
  - id: 'Counter 21'
    alias: counter 21
    trigger:
      platform: time_pattern
      seconds: '/1'
    condition:
      condition: state
      entity_id: 'input_boolean.timer2'
      state: 'on'
    action:
      - service: input_number.decrement
        data:
          entity_id: input_number.timer_seconds2

  - id: 'Counter 22'
    alias: Counter 22
    trigger:
      platform: state
      entity_id: input_number.timer_seconds2
      to: "0.0"
    condition:
      condition: and
      conditions:
        - condition: state
          entity_id: 'input_boolean.timer2'
          state: 'on'
        - condition: or
          conditions:
            - condition: numeric_state
              entity_id: input_number.timer_minutes2
              above: "0.0"
            - condition: numeric_state
              entity_id: input_number.timer_hours2
              above: "0.0"
    action:
      - service: input_number.decrement
        data:
          entity_id: input_number.timer_minutes2
      - service: input_number.set_value
        data:
          entity_id: input_number.timer_seconds2
          value: 59.0

  - id: 'Counter 23'
    alias: Counter 23
    trigger:
      platform: state
      entity_id: input_number.timer_minutes2
      to: "0.0"
    condition:
      - condition: state
        entity_id: 'input_boolean.timer2'
        state: 'on'
      - condition: numeric_state
        entity_id: 'input_number.timer_hours2'
        above: '0.0'
    action:
      - service: input_number.decrement
        data:
          entity_id: input_number.timer_hours2
      - service: input_number.set_value
        data:
          entity_id: input_number.timer_minutes2
          value: 59.0
  - id: 'Counter 23'
    alias: Counter 23
    trigger:
      platform: state
      entity_id: input_number.timer_hours2
      to: "0.0"
    condition:
      - condition: state
        entity_id: 'input_boolean.timer2'
        state: 'on'
    action:
      - service: input_number.set_value
        data:
          entity_id: input_number.timer_minutes2
          value: 59.0
  - id: 'Counter 24'
    alias: Counter 24
    trigger:
      platform: state
      entity_id: input_boolean.timer2
      to: "on"
    condition:
      condition: and
      conditions:
        - condition: state
          entity_id: 'input_number.timer_seconds2'
          state: '0.0'
        - condition: numeric_state
          entity_id: input_number.timer_minutes2
          above: "0.0"
    action:
      - service: input_number.decrement
        data:
          entity_id: input_number.timer_minutes2
      - service: input_number.set_value
        data:
          entity_id: input_number.timer_seconds2
          value: 59.0
  - id: 'Counter 25'
    alias: Counter 25
    trigger:
      platform: state
      entity_id: input_boolean.timer2
      to: "on"
    condition:
      condition: and
      conditions:
        - condition: state
          entity_id: 'input_number.timer_minutes2'
          state: '0.0'
        - condition: numeric_state
          entity_id: input_number.timer_hours2
          above: "0.0"
    action:
      - service: input_number.decrement
        data:
          entity_id: input_number.timer_hours2
      - service: input_number.set_value
        data:
          entity_id: input_number.timer_minutes2
          value: 59.0
      - service: input_number.set_value
        data:
          entity_id: input_number.timer_seconds2
          value: 59.0

ui-lovelace.yaml:

  - type: vertical-stack
    cards:
      - type: markdown
        content: >
          ## Timer 2
      - type: entities
        entities:
          - input_boolean.timer2
          - input_number.timer_hours2
          - input_number.timer_minutes2
          - input_number.timer_seconds2
          - timer.timer2
          - sensor.timer2

sensor.yaml:

  - platform: template
    sensors:
      timer2:
        value_template: "{{ states.input_number.timer_hours2.state | round}}:{{ states.input_number.timer_minutes2.state | round}}:{{ states.input_number.timer_seconds2.state | round}}"
        friendly_name: 'Timer 2'

as mentioned its not really finished but the work in progress with the call for help =)=)

@lukenn, any way you can post the lovelace config for your timer? Thanks!

  # Kitchen timer
  - type: entities
    title: Timer
    show_header_toggle: false
    entities:
      - entity: input_number.timer_minutes
      - entity: input_number.timer_seconds
      - type: "custom:button-entity-row"
        buttons:
          - entity: script.timer_start
            icon: mdi:timer
            name: Start
          - entity: script.timer_cancel
            icon: mdi:timer-off
            name: Stop
      - entity: timer.cooking_timer
        name: Timer
        icon: none

In script.yaml:

##########################
#    COOKING TIMER
##########################

timer_start:
  sequence:
    - service: timer.start
      data_template:
        entity_id: timer.cooking_timer
        duration: '00:{{ states.input_number.timer_minutes.state | int }}:{{ states.input_number.timer_seconds.state | int }}'

timer_cancel:
  sequence:
    - service: timer.cancel
      data:
        entity_id: timer.cooking_timer
2 Likes

Is it posible to make this cooking timer without the sliders?
I want it to count down from 1h, 20min?
The programe we use most on our washing machine takes 1h, 18min.
And I want the countdown time to show in Lovelace.
Counter starts when I close the door on the washing machine (got a door sensor on it).

That wouldn’t be too hard.

Create an automation with your sensor as the trigger, and the action should activate the timer_start script.

Copy the ‘timer_start’ script I posted above but in the duration you can simply set your 1hr 20mins instead of using the templates from the sliders

1 Like