Convert Random Sensor to Integer for use in Setting RGB Values

Using 3 random helpers configured between 0 and 255 to set the RGB values of a light.

I understand HA defaults sensor values to string.

Cant seem to find how I’d convert these sensors to integer in a way that works without complaining of data types…

action: light.turn_on
metadata: {}
data:
  rgb_color:
    - { states('sensor.random1')|int(0)}
    - { states('sensor.random2')|int(0)}
    - { states('sensor.random3')|int(0)}
target:
  entity_id: light.tz3210_xz5yasnb_ts0505b_light

Im definitely missing something very simple…

Greatly appreciated!

Hi Justin,

I made a tool you can use.
Use as-is or look at the code and roll your own with it.

You can find it in HACS.

In order to get the values from Jinja you need to use double brackets, like {{ and }}

No idea if the rgb_color can be templated though.