I am trying to create an automation to turn my rope lings red for 1 second then blue for one second then red… etc.
This is throwing a Message malformed: extra keys not allowed @ data[‘seconds’] error
alias: Alternate Red Blue
description: ''
mode: single
trigger:
platform: time
minutes: 0
seconds: 1
action:
service: light.turn_on
entity_id: light.rope_lights
data:
color_name: red
service: light.turn_on
entity_id: light.rope_lights
data:
color_name: blue
Even if you did mean to use a Time Pattern Trigger like this:
trigger:
platform: time_pattern
seconds: '/1'
the automation may not produce the desired effect because the action issues two consecutive service calls with no delay between them.
In addition, the only control you have over this color-toggling operation is by enabling/disabling the automation.
EDIT
Here’s an another way of achieving the goal. Create an input_boolean to control the color-toggling operation. This automation starts color-toggling when the input_boolean is on and stops when it’s off.
alias: Alternate Red Blue
trigger:
- platform: state
entity_id: input_boolean.alternate_colors
to: 'on'
action:
- repeat:
while: "{{ is_state('input_boolean.alternate_colors', 'on') }}"
sequence:
- service: light.turn_on
data:
entity_id: light.rope_lights
color_name: red
- delay: '00:00:01'
- service: light.turn_on
data:
entity_id: light.rope_lights
color_name: blue
- delay: '00:00:01'
Please consider marking my first post with the Solution tag. By doing this, it will automatically place a check-mark next to the topic’s title. It signals to other users that this topic has an accepted solution. It also helps users find answers to similar questions.