Trouble parsing hs_value for mqtt light

I’m trying to add hs_value states to a Tasmota mqtt light but my json values include brightness and I don’t know how to properly parse them.



 hs_value_template: "{{ value_json.HSBColor }}"

it doesn’t work, my hs_value state is always 0,0

Looking at the code I think it wants to see just two numbers separated by a comma. Assuming HSBColor is Hue, Saturation, Brightness, I think the following might work:

 hs_value_template: "{{ value_json.HSBColor.rsplit(',', 1)[0] }}"

This takes everything up to, but not including, the last comma.


Much simpler than what i came up with

hs_value_template: "{{ value_json.HSBColor | string | replace(',',' ') | truncate(8,false,'',0)  | replace(' ',',') }}"