bokub / rgb-light-card

💡 A Home Assistant card for RGB lights
MIT License
441 stars 24 forks source link

control separate LEDs for R,G,B #76

Closed wspeth closed 1 year ago

wspeth commented 1 year ago

Boris, I would kindly ask for your advice on how to control devices that show up as separate entities for the colors, like light.0x00124b002a5ecb75_l1, light.0x00124b002a5ecb75_l1, light.0x00124b002a5ecb75_l3, light.0x00124b002a5ecb75_l4 (RGBW) My first idea is to change card.js, replace line 134 this._hass.callService('light', 'turn_on', serviceData); by four calls while changing const serviceData = { entity_id: this.config.entity, ...color, to something like const serviceData = { entity_id: this.config.entity.replace(/.$/,str(i)), color[i] when looping i from 1 to 4

would you agree or can you envisage a simpler approach?

bokub commented 1 year ago

Hi @wspeth,

Why don't you create a script that accepts variables, then call this script whenever you click on a color circle?

You could also create multiple scenes and assign a different scene to each color circle

wspeth commented 1 year ago

good advice, greatly appreciated. After a day of fiddling around I am getting closer to it. Now I am stuck again

      - type: call-service
        service: script.i_colors
        service_data_template:
          device_id: "{{ device }}"
          brightness: [0,0,0,0]

renders "undefined error, brightness is undefined". going with service_data instead of service_data_template it does not substitue device. Also tried to enclose [0,0,0,0] by {{ }} or {% %}. Neither works,

bokub commented 1 year ago

Hello,

You should use service_data to pass variables to your service, not service_data_template.

What is {{ device }} supposed to be in the context of your card ?