Tea timer with flashing lights

Hi there, I’m rather new to Home Assistant, and I almost have all my devices in there.

Today I created multiple timers for tea:

### Tea Timer ###
timer:
  great_hunan_green_tea:
    duration: "00:02:30"
  earl_grey_royal_tea:
    duration: "00:03:00"

Which works fine. And now I want a light to flash when the timer is finished. I put this in automations.yaml:

- id: one
  alias: Turn on light when tea is ready
  trigger:
    - platform: state
      entity_id: timer.great_hunan_green_tea
      to: 'timer.finished'
  action:
    - service: light.turn_on
      data:
        entity_id: light.twiggy_c1
        brightness: 255
        rgb_color: [255, 0, 0]
        flash: long

but that doesn’t work. What am I doing wrong?

Look in Developer Tools / States to find the actual state of your timer when it is finished. What you have is almost certainly not correct. There is also a list here https://www.home-assistant.io/integrations/timer/#possible-states

You could also use an event trigger instead of a state trigger https://www.home-assistant.io/integrations/timer/#events

https://www.home-assistant.io/docs/automation/trigger/#event-trigger

As I recall there is no state to show when a timer finish.
You need to use the event trigger.

You could use from: 'active' to: 'idle' but yeah there are other ways that could be triggered (e.g. timer cancelled), events would definitely be the best way.

This would trigger if the timer was stopped also (cancelled).

Yep That is what I said

Just like I said to use an event trigger.

It’s working! Thanks :grinning:

- alias: "Timerstop_green"
  id: "Timerstop_green"
  trigger:
  - platform: event
    event_type: timer.finished
    event_data:
      entity_id: timer.green_tea
  action:
    - service: light.turn_on
      data:
        entity_id: light.hue_iris
        brightness: 255
        rgb_color: [102, 255, 0]
        flash: short

- alias: "Timerstop_earl"
  id: "Timerstop_earl"
  trigger:
  - platform: event
    event_type: timer.finished
    event_data:
      entity_id: timer.earl_grey_tea
  action:
    - service: light.turn_on
      data:
        entity_id: light.hue_iris
        brightness: 255
        rgb_color: [0, 0, 255]
        flash: short

Different light colors for different brews. Great stuff.

If you’re interested, here’s one way to consolidate the two automations.

- alias: "Timerstop_tea"
  id: "Timerstop_tea"
  trigger:
    - id: 'lawngreen'
      platform: event
      event_type: timer.finished
      event_data:
        entity_id: timer.green_tea
    - id: 'blue'
      platform: event
      event_type: timer.finished
      event_data:
        entity_id: timer.earl_grey_tea
  action:
    - service: light.turn_on
      target:
        entity_id: light.hue_iris
      data:
        brightness: 255
        color_name: '{{ trigger.id }}'
        flash: short

Color names are listed here.

Thanks for the effort, but both timers flash green. I tried replacing color_name with rgb_color but that doesn’t change anything. I added a 3rd, which also flashes green:

- alias: "Timerstop"
  id: "Timerstop"
  trigger:
    - id: '[102, 255, 0]'
      platform: event
      event_type: timer.finished
      event_data:
        entity_id: timer.great_hunan_green_tea
    - id: '[0, 0, 255]'
      platform: event
      event_type: timer.finished
      event_data:
        entity_id: timer.earl_grey_royal_tea
    - id: '[255, 0, 0]'
      platform: event
      event_type: timer.finished
      event_data:
        entity_id: timer.oolong_milky_tea
  action:
    - service: light.turn_on
      target:
        entity_id: light.hue_iris
      data:
        brightness: 255
        rgb_color: '{{ trigger.id }}'
        flash: long

EDIT; sorry did you say it didn’t work the way Taras wrote? I’m surprised…

I believe what you did there was to replace a working automation with an automation that does not work.

[102,255,0] is different from '[102,255,0]' since one is an array/list and the other is a string that looks like an array/list.

It turns out that when the Hue Iris light is off, it flashes the last color it had when it was on, regardless of the command. Which is already better than Hue bulbs, that only flash when they’re already on. Is there a way to switch bulbs on?

Probably:

  action:
    - service: light.turn_on
      target:
        entity_id: light.hue_iris
    - delay:
      hours: 0
      minutes: 0
      seconds: 0
      milliseconds: 500
    - service: light.turn_on
      target:
        entity_id: light.hue_iris
      data:
        brightness: 255
        color_name: '{{ trigger.id }}'
        flash: short

That does not make a difference.

That’s odd. The example I posted clearly uses different color_names for each timer.

The reason I didn’t use rgb_color is because I’m uncertain native typing will interpret the supplied string, like '[102, 255, 0]', as a list.

How does that explain your previous statement:

After consolidating the light only flashed green. It turned out that was caused by the Hue Iris light, not by HA.

Wasn’t the Hue Iris light the same light used when you said it worked with separate automations?

Follow-up question: how do I put the lights back in the previous state after flashing? So back to off when they were off and back to the right colour/temperature when they were on.

I also would like to have an actual hard button I can press for the right timer to start (for instance the Hue dimmer switch). Anyone knows how to do that?

For the prev state I would use a helper that stores the state of the bulb and is used to recall the status once the timer has finished.
As for the hardwarebutton the trigger would be the push of the button.

How to do it? No clue, would have to google it myself. Maybe there is a blueprint out there?