I had a ton of trouble with this as well, and I ended up making the below script to do it for me. It grabs the white brightness using array indexing from the attribute on the strip, then grabs the standard ‘brightness’ attribute (which represents the color brightness slider) and then applies a markup to them. I haven’t spent a ton of time using it, so it prob needs some edits, but then I tied this to my up button presses on my pico and it is working for what I need right now.
Ok, so after playing with it for a min, the next thing to add is to get the variables for the current R,G,B colors and use those in the color setting so it maintains the color while changing bright level. But this at least gives you a way to handle it with an automation. (I tied mine to a remote).
For the ‘decrement’ brightness function, I just multiplied by 0.85 instead of 1.25, and it worked perfectly.
alias: Light_ShellyStripIncrBright
variables:
strip02WhiteBrightVal: "{{state_attr('light.kitchen_strip_02','rgbw_color')[3]}}"
strip02BrightVal: "{{state_attr('light.kitchen_strip_02','brightness')}}"
sequence:
- service: light.turn_on
data:
rgbw_color: [255, 255, 255, "{{strip02WhiteBrightVal * 1.25}}"]
brightness: "{{strip02BrightVal * 1.25}}"
target:
entity_id: light.kitchen_strip_02
mode: single
I’ve updated the inc brightness to fix an issue with setting values outside the available range and allowed the script to keep the RGB values. It still has an issue with scaling. Since it is percent based, when the light is low, the inc/decr values are much lower. At some point I will add a ‘min step’ type value. The ‘min/max’ settings in the script are already a bit confusing as written though, so it could use some cleanup for that too. The logic in the scripts makes sure the range is between 1-255, and at least one more or one less than the current value (since when below a certain number, incrementing by a % doesn’t actually go up unless you do a ceiling rounding).
Inc Brightness:
alias: Light_ShellyStripIncrBright
variables:
strip02RVal: "{{state_attr('light.kitchen_strip_02','rgbw_color')[0]}}"
strip02GVal: "{{state_attr('light.kitchen_strip_02','rgbw_color')[1]}}"
strip02BVal: "{{state_attr('light.kitchen_strip_02','rgbw_color')[2]}}"
strip02WVal: "{{state_attr('light.kitchen_strip_02','rgbw_color')[3]}}"
strip02WValAdjMax: "{{[strip02WVal * 1.45 , 255]}}"
strip02WValMinMax: "{{[strip02WValAdjMax|min|int,([strip02WVal+1,255]|min)]}}"
strip02BrightVal: "{{state_attr('light.kitchen_strip_02','brightness')}}"
strip02BrightValAdjMax: "{{[strip02BrightVal * 1.45 , 255]}}"
strip02BrightValMinMax: "{{[strip02BrightValAdjMax|min|int,([strip02BrightVal+1,255]|min)]}}"
sequence:
- service: light.turn_on
data:
rgbw_color:
- "{{strip02RVal}}"
- "{{strip02GVal}}"
- "{{strip02BVal}}"
- "{{strip02WValMinMax|max|int}}"
brightness: "{{strip02BrightValMinMax|max|int}}"
target:
entity_id: light.kitchen_strip_02
mode: single
Decr Brightness
alias: Light_ShellyStripDecrBright
variables:
strip02RVal: "{{state_attr('light.kitchen_strip_02','rgbw_color')[0]}}"
strip02GVal: "{{state_attr('light.kitchen_strip_02','rgbw_color')[1]}}"
strip02BVal: "{{state_attr('light.kitchen_strip_02','rgbw_color')[2]}}"
strip02WVal: "{{state_attr('light.kitchen_strip_02','rgbw_color')[3]}}"
strip02WValAdjMax: "{{[strip02WVal * 0.85 , 1]}}"
strip02WValMinMax: "{{[strip02WValAdjMax|max|int,([strip02WVal-1,1]|min)]}}"
strip02BrightVal: "{{state_attr('light.kitchen_strip_02','brightness')}}"
strip02BrightValAdjMax: "{{[strip02BrightVal * 0.85 , 1]}}"
strip02BrightValMinMax: "{{[strip02BrightValAdjMax|max|int,([strip02BrightVal-1,1]|min)]}}"
sequence:
- service: light.turn_on
data:
rgbw_color:
- "{{strip02RVal}}"
- "{{strip02GVal}}"
- "{{strip02BVal}}"
- "{{strip02WValMinMax|max|int}}"
brightness: "{{strip02BrightValMinMax|max|int}}"
target:
entity_id: light.kitchen_strip_02
mode: single
Oh yeah, prob last edit. It does not work if the light is off. It isn’t a perfect solution. The best solution would be for Shelly to add a setting in their firmware for ‘brightness controls both white and color brightness’…
Another Edit:
Ok, I couldn’t help but add this in, because it was driving me crazy. I will add logic for put in a ‘choose’ action with selections for my primary house schedules, but this at least prevents an error for Inc if the light is off:
alias: Light_ShellyStripIncrBright
sequence:
- choose:
- conditions:
- condition: state
entity_id: light.kitchen_strip_02
state: "off"
sequence:
- service: light.turn_on
data: {}
target:
entity_id: light.kitchen_strip_02
default:
- variables:
strip02RVal: "{{state_attr('light.kitchen_strip_02','rgbw_color')[0]}}"
strip02GVal: "{{state_attr('light.kitchen_strip_02','rgbw_color')[1]}}"
strip02BVal: "{{state_attr('light.kitchen_strip_02','rgbw_color')[2]}}"
strip02WVal: "{{state_attr('light.kitchen_strip_02','rgbw_color')[3]}}"
strip02WValAdjMax: "{{[strip02WVal * 1.45 , 255]}}"
strip02WValMinMax: "{{[strip02WValAdjMax|min|int,([strip02WVal+1,255]|min)]}}"
strip02BrightVal: "{{state_attr('light.kitchen_strip_02','brightness')}}"
strip02BrightValAdjMax: "{{[strip02BrightVal * 1.45 , 255]}}"
strip02BrightValMinMax: "{{[strip02BrightValAdjMax|min|int,([strip02BrightVal+1,255]|min)]}}"
- service: light.turn_on
data:
rgbw_color:
- "{{strip02RVal}}"
- "{{strip02GVal}}"
- "{{strip02BVal}}"
- "{{strip02WValMinMax|max|int}}"
brightness: "{{strip02BrightValMinMax|max|int}}"
target:
entity_id: light.kitchen_strip_02
mode: single