Construct JSON message payload based on switches in home assistatn

I want to construct and json payload for zigbee2mqtt that has to end up like :

{
 "effect": {
     "effect": "snake",
     "speed": 100,
     "colors": [
         {
             "r": 255,
             "g": 0,
             "b": 0
         },
         {
             "r": 0,
             "g": 255,
             "b": 0
         },
         {
             "r": 0,
             "g": 0,
             "b": 255
         }
     ]
 }
}

so what i’ve created is an helper switch “Kerstboom-Effect” which has the options from the following table | effect | # colors |
|------------------------|-----------------|
| steady | 1 |
| snow | 1 |
| rainbow | 0 |
| snake | 6 |
| twinkle | 2 |
| firework | 2 |
| horizontal_flag | 3 |
| waves | 3 |
| updown | 2 |
| vintage | 1 |
| fading | 1 |
| collide | 1 |
| strobe | 5 |
| sparkles | 3 |
| carnaval | 6 |
| glow | 6 |

then i’ve cread and “Kerstboom-speed” which has an slider from 0-100 now i want to use that to get those 2 options and created the mqtt payload from the start of the post

is that possible to create ?