Create a countdown timer

Can someone help me createing a countdown timer?

I want, when a switch is turned on, a timer appear with countdown 3hours.

Best regards

You’ll need a timer and an automation.

timer:
  laundry:
    duration: '01:00:00'
automation:
  - alias: Turn on the timer
    trigger:
      - platform: state
        entity_id: switch.some_switch
        to: 'on'
    action:
      - service: timer.start
        data:
          entity_id: timer.laundry
          duration: '03:00:00'
5 Likes

I love you man!

Thanx!! :smiling_face_with_three_hearts::kissing_heart:

Is it posible to show this timer with the countdown time in lovelace?

Yes. `

timer.name_of_timer

as an entity card

Configuration.yaml

timer:
  vaskemaskin:
    duration: '00:01:00'
    icon: mdi:washing-machine

ui-lovelace.yaml

      - type: entities
        entities:
          - type: section
          - entity: timer.vaskemaskin
            type: custom:multiple-entity-row
            name: Vaskemaskin
            icon: mdi:washing-machine
            primary:
              name: custom name
              entity: timer.laundry
              attribute: remaining
              unit: time

Just shows “Active” and “Idle” :thinking: The countdown stands still…
vaskemaskin

2 Likes

Totally guessing here, but try putting your duration in seconds.

timer:
  timer_name:
    name: Time remaining
    duration: 600 # Update this to the number of seconds you wish the timer to be.

The way I have my (only) timer set up is that I set up an input boolean, a timer, and an automation. When I turn on the input boolean, the automation is to start the timer.

input_boolean:
  zigbee_permit_join:
    name: Allow devices to join
    initial: off
    icon: mdi:cellphone-wireless

timer:
  zigbee_permit_join:
    name: Time remaining
    duration: 600 # Updated this to the number of seconds you wish

automation:
- id: enable_zigbee_join
  alias: Enable Zigbee joining
  hide_entity: true
  trigger:
    platform: state
    entity_id: input_boolean.zigbee_permit_join
    to: 'on'
  action:
  - service: timer.start
    data:
      entity_id: timer.zigbee_permit_join

And then my lovelace config looks like so:

4 Likes

Thank you so much for your help.
It turned out that the timer I had was working properly. The only problem was that the card I used in Lovelace (multiple-entity-row) couldn’t show the countdown.
When I switched to Entities card it worked as it should.
I probably wouldn’t have figured it out if I hadn’t tried the way you do it.
In addition, learned a little about input_boolean. :smiling_face_with_three_hearts: :smiling_face_with_three_hearts:

1 Like

Hi,

Any question, how to for when the count arrive to 0 stop the entity?

I need a temporize the switch for on 5 minutes, when count is 0 , put the switch of boolean off , and turn off the switch, how too?

Use an automation of time Event as trigger and timer.finished as event type as such:

event_data:
  entity_id: timer.porte_cours
event_type: timer.finished
platform: event

Sorry i understand, this is my automation, for off the counter, but this auto not off

- id: '1578952574812'
  alias: Temporizador OFF
  description: ''
  trigger:
  - event_data:
      entity_id: timer.temporizador
    event_type: 'timer.finished '
    platform: event
  condition: []
  action:
  - entity_id: switch.rboton2
    service: switch.turn_off
  - entity_id: input_boolean.temporizador
    service: input_boolean.turn_off

In the configuration… yaml

timer:
  temporizador:
    name: Time remaining
    duration: 60
input_boolean:
  temporizador:
    name: Temporizador
    initial: off
    icon: mdi:cellphone-wireless

What’s the code to start the timer? Also assuming you meant 60 seconds, try ‘00:01:00’ for duration.

A post was split to a new topic: Working with timer entities

were you able to get the countdown of the duration on an entity card?