Visual time lamp

Hear me out, please.
I’m thinking of an automation for a person with hearing problems. I wanted to create automation with sonoff switch, which on the top of each hour turn light on and of (e.g. if its 2, then two times, 3 - 3 times and so on). I know I could write a lengthy code for each hour, but perhaps there is a shortcut for that. Any thoughts? Thank you

EDIT: Just noticed that you’re a new member, Welcome to the community!

Use repeat and a time_pattern trigger. Assuming you want this pattern off a 12 hour clock…

- trigger:
  - platform: time_pattern
    # Matches every hour at 0 minutes past whole
    minutes: 0
  action:
  - repeat:
      sequence:
      - service: light.turn_on
        entity_id: light.xxx
      - delay: "00:00:01"
      - service: light.turn_off
        entity_id: light.xxx
      - delay: "00:00:01"
      until:
      - condition: template
        value_template: >
          {{ repeat.index >= now().hour % 12 + 1 }}

if you want a 24 hour flash, change this:

      value_template: >
        {{ repeat.index >= now().hour % 12 + 1 }}

to

      value_template: >
        {{ repeat.index >= now().hour + 1 }}
1 Like

Thank you for such a prompt response!
I have implemented the above, but my HA says: missing property condition, and, that ‘until’ is not allowed.
Yes, I’m new here, but been around for a longer while. :wink:

ALSO this:
Invalid config for [automation]: must contain at least one of count, while, until. for dictionary value @ data[‘action’][0][‘repeat’]. Got None.

Can you post your entire configuration for this automation?

I just copied/pasted:

  • trigger:

    • platform: time_pattern

      Matches every hour at 0 minutes past whole

      minutes: 0

    action:

    • repeat:

      sequence:

      • service: light.turn_on

        entity_id: switch.30753800d8f15bb02172

      • delay: “00:00:01”

      • service: light.turn_off

        entity_id: switch.30753800d8f15bb02172

      • delay: “00:00:01”

      until: (HERE IT SAYS PROPERTY UNTIL IS NOT ALLOWED)

      • condition: template

        value_template: >

        {{ index =< now().hour % 12 + 1 }}

Please post this with proper code formatting. See step 11 here: Help us help you.

Use the tick mark (not single or double quote mark!) that should be on the same key as the tilde. On a normal north american keyboard this is directly to the left of the “1” key.

Put three of those at the top of your code, and three at the bottom, so it looks like this:

```
code goes here
```

I see my mistake, I fixed it in the original post above. Check it out now.

Yes, I apologize. I really am new here.

Looks good now! But I really don’t see what was the mistake.

until and everything below it needed an extra 2 spaces. It was supposed to be in-line with sequence, not repeat.

I’ve just re-checked the configuration and got this:

Invalid config for [automation]: invalid template (TemplateSyntaxError: expected token 'end of print statement', got '=') for dictionary value @ data['action'][0]['repeat']['until'][0]['value_template']. Got None. (See /config/configuration.yaml, line 26).

And I’m sorry I don’t know how to paste is correctly

yep another typo, =< changed to <=

Hi, I’m sorry to bother you again, but it seems there is still something with the automation. It turns on and of, but in a loop, on/off with no end.

Ok, yep. Sorry, I should have tested this before posting. My mistake, the original post has been updated… yet again.