MQTT Dual Color Light with separated white mqtt topics

Good day.

I have 6 pcs Z-wave CCT controllers (by Sunricher )
Connected to Z-Way placed on same Raspberry.
All controllers connected to HA via MQTT
Big trouble is - z-way can connect this controllers only as 3 different devices:

  • Main brightness (topic zway/walls_dim )
  • Soft white brightness (topic zway/walls_sw )
  • Cool white brightness (topic zway/walls_cw )

Can any body help me - how can i connect this controllers as Light with Color temperature?

Maybe create your own MQTT Light, assuming the topics all exist. Use MQTTExplorer or something to see if they exist on the MQTT Server? If they don’t the problem is with Z-Way and I would have no idea how to fix it…

If the color topics do exist and you can set the colors this way, create your MQTT light pointing to the right topics.

In MQTT Light no CONFIGURATION VARIABLES for different topics of color…
Something like

  - platform: mqtt
    name: "Walls Light"
    brightness_state_topic: "zway/walls_dim"
    brightness_command_topic: "zway/walls_dim/set"
    soft_color_state_topic: "zway/walls_sw"
    soft_color_command_topic: "zway/walls_sw/set"
    cool_color_state_topic: "zway/walls_cw"
    cool_color_command_topic: "zway/walls_cw/set"
    qos: 0
    payload_on: "ON"
    payload_off: "OFF"
    optimistic: false

But this not work…

Oh, I see.

Not sure what a cool color vs soft color is.

2 options. Either just use one of the topic for all colors, or create a template light and write a custom template in the set_color command to determine which of the mqtt lights to use. It might have to parse one of the other states to determine if it needs to use soft_color or cool_color. For example, parse the current temperature, then from that, pick the right mqtt light to send the command to.

About Soft and Cool colors of white:

Another call White temperature (in Kelvin)

Can you explain, or write example…
How parse current temperature from two topics?

Like this:

zway/walls_sw = 30 
zway/walls_cw = 99 

So, my guess is it’s a percent value from 0 to 100?

I would just create 2 MQTT sensors looking at those states and 1 MQTT light that does everything else.

Then I would use a template light to combine the 3 things. For all templates, just refer to the MQTT light values. For temperature, here is where you would combine them.

Your job now is to translate those numbers to a kelvin value. For example, I would assume

zway/walls_sw = 30
zway/walls_cw = 99

Means the cool color is max brightness, and the soft color is 30% brightness? Thus, temperature would be defined by the ratio of the 2 values and brightness would be the sum. We just need to know the Kelvin of the soft and cool white.

Here’s my guess. It’s probably wrong. Calculate the ratio, then subtract the difference. Take the ABS.

temperature_template: >
  {% set c = states('sensor.cool_white') | int %}
  {% set w = states('sensor.soft_white') | int %}
  {% set avg = (c + w)/2 %}
  {% set cr = c / avg %}
  {% set sr = w / avg %}
  {{ (5000 * cr - 2000*sr) | abs }}

Quick test:
Cool 100%, Soft 0% --> 5000k
Cool 100%, Soft 100% --> 3000K
Cool 50%, Soft 50% --> 3000K
Cool 0%, Soft 100% --> 2000K

Going the other way is going to be trickier. We know the brightness from the brightness topic, so we have 2 equations and 2 unknowns. You’d have to calculate the soft and warm components given brightness and temp.

        friendly_name: "Example Light"
        level_template: "{{ state_attr('light.mqtt_light', 'brightness') }}"
        value_template: "{{ states('light.mqtt_light') }}"
        # Convert the 2 separate MQTT sensors to one temperature. 
        temperature_template: >
          {% set c = states('sensor.cool_white') | int %}
          {% set w = states('sensor.soft_white') | int %}
          {% set avg = (c + w)/2 %}
          {% set cr = c / avg %}
          {% set sr = w / avg %}
          {{ (5000 * cr - 2000 * sr) | abs }}
          service: light.turn_on
          entity_id: light.mqtt_light
          service: light.turn_off
          entity_id: light.mqtt_light
          service: light.turn_on
          entity_id: light.mqtt_light
            brightness: "{{ brightness }}"
          - variables:
              cool_value: "{{ <function to calculate cool value> }}"
              soft_value: "{{ <function to calculate soft value> }}"
          - service: mqtt.publish
              topic: "zway/walls_sw"
              payload: "{{ soft_value }}"
          - service: mqtt.publish
              topic: "zway/walls_cw"
              payload:  "{{ cool_value }}"

Thank you - i will try…