Is there a way to control shelly rgbw over KNX?

Hello i look for a way to control shelly RGBW over KNX.
On/Off is no problem, but i don´t find a way to change colors.

Can someone help me?

greetings, Wolle

Hi :wave:!
You can use knx_event and get r, g and b values from the raw telegram payload (trigger.event.data.data is the telegram payload as a list of int 0…255).

Hi Matthias,

do you have a little bit more for me?
KNX_event is clear, but I have no idea how to forward that to shelly.

In Automation i don´t see a way to control colours for shelly rgbw.

greetings, Wolle

The light.turn_on service should do that - have a look at the service documentation. I have never used rgb myself 🤷

where can i find the service doc?

i found it, now i have to do a look.

OK,

this is a way to control shelly rgbw, but I’m not sure how I’m supposed to manage that all 4 colors (RGBW) from KNX are to be adopted in this automation.

In KNX all 4 colors come as a single group address.

- id: '1671048140828'
  alias: Neue Automatisierung
  description: ''
  trigger:
  - platform: device
    type: changed_states
    device_id: ca399f7f569aadb1db260270c73197a7
    entity_id: switch.shellyplug_s_4022d8890ed1
    domain: switch
  condition: []
  action:
  - service: light.turn_on
    target:
      entity_id: light.shellyrgbw2_d88e91
    data:
      brightness: 130
      rgbw_color:
      - 0
      - 0
      - 255
      - 0

your needed data in rgbw_color: is a list of 4 int 0…255 too, so just use a template to pass the list (or the first 4 items) to that service.

I dont´t understand it.

i have these:

configuration.yaml

knx:
  event:
    # Philipp RGBW - Rot
    - address:
        - "1/0/48"
      type: "percent"

    # Philipp RGBW - Grün
    - address:
        - "1/0/50"
      type: "percent"

    # Philipp RGBW - Blau
    - address:
        - "1/0/52"
      type: "percent"

    # Philipp RGBW - Weiß
    - address:
        - "1/0/54"
      type: "percent"

automations.yaml

- id: '1671048140828'
  alias: Neue Automatisierung
  description: ''
  trigger:
  - platform: event
    event_type: knx_event
    event_data:
      destination: 1/0/48
  action:
  - service: light.turn_on
    target:
      entity_id: light.shellyrgbw2_d88e91
    data:
      brightness: 65
      rgbw_color:
      - 0
      - 0
      - 255
      - 0

I can’t get any further from this point.

How do I get these 4 values ​​in here now. They are individual values ​​and I don’t understand how to deal with them.

You never said that the colors are spread over multiple GAs 🤷
Maybe you can store the values in a helper attribute or something. Not sure if that works though.
If not you could use individual sensors to store the value.

Hello Matthias,

All colors are always separate in KNX. Each color a percent type group address.

how can i do this and once I have that, what’s next?

I don´t have any idea how to do this.

Thank´s for your help.

Is there anybody who can help me whith this problem?

  • configure 3 knx sensors. One for each color. type: percent or type: percentU8 (latter is 0-255)
  • make an automation listening for state changes of these 3 sensors.
  • use their states to set a new color for your entity with light.turn_on service in the automation action - read documentation about templates on how to do this.

OK, now i have the 4 sensors:

  sensor:
    - name: "Philipp RGBW - rot"
      state_address: "1/0/48"
      type: percentU8

    - name: "Philipp RGBW - grün"
      state_address: "1/0/50"
      type: percentU8

    - name: "Philipp RGBW - blau"
      state_address: "1/0/52"
      type: percentU8

    - name: "Philipp RGBW - weiß"
      state_address: "1/0/54"
      type: percentU8

and i have these automation:

- id: '1671048140828'
  alias: Philipp RGBW
  description: ''
  trigger:
  - platform: event
    event_type: knx_event
    event_data:
      destination: 1/0/48
  action:
  - service: light.turn_on
    target:
      entity_id: light.shellyrgbw2_d88e91
    data:
      brightness: 65
      rgbw_color:
      - 0
      - 0
      - 255
      - 0

the automation works whith the fixed valus for RGBW colors, but i have no idea how to replace the fixed values ​​with the sensor values.
I can´t find something in docs for how to do this. Maybe I’m looking wrong, but I’m treading water.

Could you possibly give me a solution, or at least give a contribution from which one can derive it in a meaningful way?

Use templates to get the states of your sensors.

rgbw_color:
  - "{{ states('sensor.rot') | int(0) }}"
  - ...

Here is documentation for this: https://www.home-assistant.io/docs/configuration/templating/

You also don’t need to use knx_event as trigger (and define it in configuration.yaml) when you have sensors defined. You can use

automation:
  trigger:
    - platform: state
      entity_id:
        - sensor.rot
        - sensor.grün
        - ...

Here is documentation for this: https://www.home-assistant.io/docs/automation/trigger/#state-trigger

Thank you very much,

the way with templates is new for me.

Here is my complete solution to control Shelly rgbw.

In configuration.yaml

knx:
  sensor:
    - name: "Philipp RGBW - rot"
      state_address: "1/0/48"
      type: percentU8

    - name: "Philipp RGBW - grün"
      state_address: "1/0/50"
      type: percentU8

    - name: "Philipp RGBW - blau"
      state_address: "1/0/52"
      type: percentU8

    - name: "Philipp RGBW - weiß"
      state_address: "1/0/54"
      type: percentU8

In automation.yaml

- id: "1671048140828"
  alias: Philipp RGBW
  description: ""
  trigger:
    - platform: state
      entity_id:
        - sensor.philipp_rgbw_rot
        - sensor.philipp_rgbw_grun
        - sensor.philipp_rgbw_blau
        - sensor.philipp_rgbw_weiss
  action:
    - service: light.turn_on
      target:
        entity_id: light.shellyrgbw2_d88e91
      data:
        brightness: 65
        rgbw_color:
          - "{{ states('sensor.philipp_rgbw_rot') | int(0) }}"
          - "{{ states('sensor.philipp_rgbw_grun') | int(0) }}"
          - "{{ states('sensor.philipp_rgbw_blau') | int(0) }}"
          - "{{ states('sensor.philipp_rgbw_weiss') | int(0) }}"

Now I need help for the way back.

Do you also have any idea how I send shelly’s status back to the KNX?

First of all, I would have to break down the 4 colors into individual objects again, that’s where the chaos begins for me.

"{{ state_attr('light.shelly...', 'rgb_color')[0] }}"
would get you the red part. [1] green etc.

Have a look at Open your Home Assistant instance and show your template developer tools. to play with templates
And Open your Home Assistant instance and show your state developer tools. to inspect your entities states and attributes.

Thank you, you are the best.

I will try and give feedback.

OK, I also worked with an automation here. Here is my solution Color States from Shelly to KNX.

- id: '1672774943675'
  alias: Philipp RGBW Status
  description: ''
  trigger:
  - platform: state
    entity_id:
    - light.shellyrgbw2_d88e91
    attribute: rgbw_color
  action:
  - service: knx.send
    data:
      address: 1/0/49
      payload: '{{ state_attr(''light.shellyrgbw2_d88e91'', ''rgbw_color'')[0] }}'
      type: percentU8
  - service: knx.send
    data:
      address: 1/0/51
      payload: '{{ state_attr(''light.shellyrgbw2_d88e91'', ''rgbw_color'')[1] }}'
      type: percentU8
  - service: knx.send
    data:
      address: 1/0/53
      payload: '{{ state_attr(''light.shellyrgbw2_d88e91'', ''rgbw_color'')[2] }}'
      type: percentU8
  - service: knx.send
    data:
      address: 1/0/55
      payload: '{{ state_attr(''light.shellyrgbw2_d88e91'', ''rgbw_color'')[3] }}'
      type: percentU8
  mode: single

It works fine for me, but is there a way to do it in one “knx.send”?