Automation with RGB lights based on and MQTT controller

Hi everybody. it’s the first time in the forum so I hope category an request are clear and correct. I would like to have a controller that allow me to control light without using home assistant UI. so what I’ve been done so far is an ESP8266 chip with a neopixel LED strip connected, and a rotary encoder that changes brightness and hue of the connected LEDS. what I would like to do is to fire those information to a group of lights. it works fine for brightness but I’m stuck with colors. I don’t get any errors, it just don’t work… here’s my code so far:

   -  alias: Adjust Brightness
      trigger:
        platform: state
        entity_id: input_slider.controllo_luminosita
      condition: 
        condition: numeric_state
        entity_id: input_slider.controllo_luminosita
        above: 0
        below: 255
      action:
        - service: light.turn_on
          data_template:
            entity_id: group.luci_dimmerabili
            brightness: '{{ trigger.to_state.state | int }}'


    - alias: Mqtt automation/brightness
      trigger:
        platform: mqtt
        topic: "/knob/brightness"
      action:
         service: input_slider.select_value
         data_template:
          entity_id: input_slider.controllo_luminosita
          value: '{{ trigger.payload}}'
            
            ##TURN OFF When brightness is 0
    - alias: Turn off when dim to 0
      trigger:
        platform: numeric_state
        entity_id: input_slider.controllo_luminosita
        below: 1
      action:
        service: light.turn_off
        entity_id: group.luci_dimmerabili

###(THIS PART BELOW IS NOT WORKING) ####

## COLORS for RGB Lights on Rotary Encoder #########
- alias: Color selection RGB
  trigger:
    platform: mqtt
    topic: "/knob/color"
  action:
    - service: light.turn_on
      data_template:
        entity_id: group.luci_dimmerabili
        rgb_color: '{{ trigger.payload}}'

#what I don’t like
brightness works but I actually have to pass an MQTT data to input slider and then automate that. I’d rather do it by passing via a sensor and not an mqtt topic. (mqtt sensor " /knob/brightness " -> automation on input slider from mqtt sensor)
#what is not working
for RBG I’m thinking about 2 different solution:

  • use the same automation as used for brightness (/topic/red -> input slider red -> automation on single channel) pretty stupid thou and if I want to use this on web GUI that would not be that cool to have 3 sliders (that wouldn’t be a problem by the way), and morover I don’t know how to pass parameters R G and B in automation

  • use a “fake” light: this light would be the MASTER which controls the others in the group (no idea how to write an automation on that).

so if anyone does have any idea how to fix this or have other solution in mind I would really appreciate it.

thanks

mp

I’m not certain I fully understand all of that, but one thing to bear in mind is that you can have multiple physical lights (each esp8266 controlled) all subscribed to the same topic. This means you set up one light in HA but it controls multiple things in the real world. This eliminates your need for groups.