Somehow I assumed there would be a service like light.effect_select_next as there is for input_select.select_next but since there wasn’t, I created the following script which I’m sharing in case anyone else has a use for it.
light_effect_select_next:
sequence:
- service: light.turn_on
data:
effect: >
{% set effects = state_attr(light, 'effect_list') %}
{% set state = effects[0] if state_attr(light, 'effect') is none else state_attr(light, 'effect') %}
{{ effects[0] if (effects.index(state)+1 == effects|length) else effects[effects.index(state)+1] }}
target:
entity_id: '{{ light }}'
mode: parallel
alias: light effect select next
The target light is passed as the variable light when calling the script.
In my case, most of my lights are template lights so I use effects as presets which I find cleaner than scenes. This script lets me cycle through presets.
While the template in theory works, there’s an issue when the light is off which will result in a None value. An error will occur as there is no option for None