Hi, new to yaml
I am trying to get just the current saturation of the lights, using a defined variable “curr_sat”, and check if it is above a threshold (80) with the choose action using templates, and then flash either lower in saturation, or higher depending on the value.
Ive made sure to isolate the other actions and triggers so I know the only thing about this automation that doesn’t work the way I want it to is either the “curr_sat” variable or the condition template, not sure which.
This is probably a really easy fix but I couldn’t find anywhere how to fix it.
I’ve tried a couple different ways to check if it was formatting such as
‘{{ curr_sat | float(0) > 80 }}’ and ‘{{ curr_sat > 80 }}’
Any help appreciated :- )
sequence:
- variables:
step: 20
curr_value: >
{% set hs = state_attr(curr_target, 'hs_color') | default([0, 100],
true) %} {% set cm = state_attr(curr_target, 'color_mode') %} {% set
hue = hs[0] | float(0) if cm in ['hs', 'xy', 'rgb', 'rgbw', 'rgbww']
else 0 %} {{ [hue, (hs[1] | float(100)) | round(2)]}}
curr_sat: >
{% set hs = state_attr(curr_target, 'hs_color') | default([0, 100],
true) %} {{(hs[1] | float(100)) | round(2)}}
- choose:
- conditions:
- condition: template
value_template: '{{ curr_sat | float(0) > 80 }}'
sequence:
- variables:
target_value: >
{% set hs = state_attr(curr_target, 'hs_color') |
default([0, 100], true) %} {% set cm =
state_attr(curr_target, 'color_mode') %} {% set hue = hs[0]
| float(0) if cm in ['hs', 'xy', 'rgb', 'rgbw', 'rgbww']
else 0 %} {{ [hue, (hs[1] | float(0) - step) | round(2)]}}
- conditions:
- condition: template
value_template: '{{ curr_sat | float(0) < 81 }}'
sequence:
- variables:
target_value: >
{% set hs = state_attr(curr_target, 'hs_color') |
default([0, 100], true) %} {% set cm =
state_attr(curr_target, 'color_mode') %} {% set hue = hs[0]
| float(0) if cm in ['hs', 'xy', 'rgb', 'rgbw', 'rgbww']
else 0 %} {{ [hue, (hs[1] | float(0) + step) | round(2)]}}