Hi,
I have pool lights which can be set to color by switching it off and on until you have the right color. (It comes with a remote as well but that only works if you are really standing next to the lights).
To select the color I made a text drop box to pick the color and then I run a script based on the selection which switches on/off the lights until the preferred color appears. Really simple. This is how it looks like:
And the script is like this:
alias: Pool Light Color
sequence:
- if:
- condition: state
entity_id: input_select.colour_selector
state: Red
then:
- repeat:
count: 1
sequence:
- service: switch.turn_off
data: {}
target:
entity_id: switch.sonoff_100079182a
- delay:
hours: 0
minutes: 0
seconds: 1
milliseconds: 0
- service: switch.turn_on
data: {}
target:
entity_id: switch.sonoff_100079182a
- delay:
hours: 0
minutes: 0
seconds: 1
milliseconds: 0
- if:
- condition: state
entity_id: input_select.colour_selector
state: Green
then:
- repeat:
count: 2
sequence:
- service: switch.turn_off
data: {}
target:
entity_id: switch.sonoff_100079182a
- delay:
hours: 0
minutes: 0
seconds: 1
milliseconds: 0
- service: switch.turn_on
data: {}
target:
entity_id: switch.sonoff_100079182a
- delay:
hours: 0
minutes: 0
seconds: 1
milliseconds: 0
- if:
- condition: state
entity_id: input_select.colour_selector
state: Blue
then:
- repeat:
count: 3
sequence:
- service: switch.turn_off
data: {}
target:
entity_id: switch.sonoff_100079182a
- delay:
hours: 0
minutes: 0
seconds: 1
milliseconds: 0
- service: switch.turn_on
data: {}
target:
entity_id: switch.sonoff_100079182a
- delay:
hours: 0
minutes: 0
seconds: 1
milliseconds: 0
- if:
- condition: state
entity_id: input_select.colour_selector
state: Yellow
then:
- repeat:
count: 4
sequence:
- service: switch.turn_off
data: {}
target:
entity_id: switch.sonoff_100079182a
- delay:
hours: 0
minutes: 0
seconds: 1
milliseconds: 0
- service: switch.turn_on
data: {}
target:
entity_id: switch.sonoff_100079182a
- delay:
hours: 0
minutes: 0
seconds: 1
milliseconds: 0
- if:
- condition: state
entity_id: input_select.colour_selector
state: Pink
then:
- repeat:
count: 5
sequence:
- service: switch.turn_off
data: {}
target:
entity_id: switch.sonoff_100079182a
- delay:
hours: 0
minutes: 0
seconds: 1
milliseconds: 0
- service: switch.turn_on
data: {}
target:
entity_id: switch.sonoff_100079182a
- delay:
hours: 0
minutes: 0
seconds: 1
milliseconds: 0
- if:
- condition: state
entity_id: input_select.colour_selector
state: Cyan
then:
- repeat:
count: 6
sequence:
- service: switch.turn_off
data: {}
target:
entity_id: switch.sonoff_100079182a
- delay:
hours: 0
minutes: 0
seconds: 1
milliseconds: 0
- service: switch.turn_on
data: {}
target:
entity_id: switch.sonoff_100079182a
- delay:
hours: 0
minutes: 0
seconds: 1
milliseconds: 0
- if:
- condition: state
entity_id: input_select.colour_selector
state: White
then:
- repeat:
count: 7
sequence:
- service: switch.turn_off
data: {}
target:
entity_id: switch.sonoff_100079182a
- delay:
hours: 0
minutes: 0
seconds: 1
milliseconds: 0
- service: switch.turn_on
data: {}
target:
entity_id: switch.sonoff_100079182a
- delay:
hours: 0
minutes: 0
seconds: 1
milliseconds: 0
mode: single
icon: mdi:wall-sconce-round-outline
For those who are interested I would like that once the color is selected the script runs directly after without manually starting the script. Secondly I would like to assign a variable to count like
count: x
Where is x the number of repeats based on the selected color. And to be honest I don’t know how to do that…