zwave2Mqtt device handler - how to manually add

Hi All,
I have a new Zooz Zen31 RGB light strip controller which i’m tring to figure out how to control via HA.
Not entirely sure if this post is better in Config or Third party, but figured i would try here first.

my setup;
I have zwave2mqtt, mosquito, and HA core all running in docker containers.
I’ve paired the zooz controller to zwave2mqtt (which is using OZW 1.6), and I can see all the configuration and user settings in the zwave2mqtt interface. I can also control the RGB light strip well enough (testing type control) via the user and configuration settings (all in zwave2mqtt).

where we get into the grey area of knowledge is how these user settings get translated via MQTT and show up in HA. There is some auto-magic that goes on where wave2mqtt autodiscovers the various paramaters, packs them up in Json, and sends them to the mqtt broker. HA then subscribes, and create the various entities.
But it would appear some of the paramaters around these entities are incorrect, and i need to figure out either 1. how to correct the json, or 2. just manually define the object in HA.

the following screen shot shows light_rgb_dimmer_3 (an entitiy which shows up in HA), and the auto-generated json. so 11/38/3/0 corresponds with the R channel of the RGB on the controller.
the user value (11/38/3/0/set) can take a value of 0-99. However the json, and what HA sees, is a max value of 255. Not sure where that value is coming from.


I can map this entitiy in HA to a Dimmer button, and adjust to say 10% - which will result in a 25 value (based on the value tempate forula) on the channel. so kinda works.

another one… the 11/51/1/0 can be set to a RGBW value, but the json only shows an RGB format string, and I dont see anywhere to set this value in the objects on the HA side anyway.

SO…
is there some way for me to just ignore the auto-create objects, or define them manually, or just define the switches manually in HA, and map them to the correct topics?

Alright, making some progress:

added the following to my configuration.yaml

  - platform: mqtt
    name: Test RGB
    command_topic: "homeassistant/11/38/1/0/set"
    "state_value_template": "{{ 'OFF' if value_json.value == 0 else 'ON' }}"
    "brightness_state_topic": "homeassistant/11/38/2/0"
    "brightness_command_topic": "homeassistant/11/38/2/0/set"
    "brightness_value_template": "{{ (value_json.value ) | round(0) }}"
    brightness_scale: 99
    "rgb_command_template": "{{ '#%02x%02x%02x' | format(red, green, blue)}}"
    "rgb_command_topic": "homeassistant/11/51/1/0/set"
    "rgb_state_topic": "homeassistant/11/51/1/0"
    "rgb_value_template": "{{ value_json.value[1:3] | int(0, 16) }},{{ value_json.value[3:5] | int(0, 16) }},{{ value_json.value[5:7] | int(0, 16) }}'"
    effect_command_topic: "homeassistant/11/112/1/157/set"
    effect_state_topic: "homeassistant/11/112/1/157"
    effect_list:
      - "preset programs disabled"
      - "fireplace"
      - "storm"
      - "rainbow"
      - "polar lights"
      - "police"
    device: 
      identifiers: "zwave2mqtt_0xfd523452_node11"
      "manufacturer": "Zooz"
      "model": "ZEN31 RGBW Dimmer (0x2000)"
      "name": "___RGB"
      "sw_version": "5.00"
    "name": "Zooz RGB_rgb_dimmer test"
    "unique_id": "zwave2mqtt_0xfd523452_11-38-1-0"

the 11/51/1/0 input for RGB actually shows as RGBW on the zwave side, but it appears to accept values okay anyway.

one problem i am having. every time i set a value in HA on brightness (11/38/2/0) HA also sends a 99 value to 11/38/1/0. both values can be used for brightness. i think HA is basically sending an ‘ON’ with a value of 99 whenever i change brightness, but it has the effect of light always being 100%

2020-04-23T03:22:36.917Z z2m:Mqtt Message received on homeassistant/11/38/2/0/set
2020-04-23T03:22:36.923Z z2m:Mqtt Message received on homeassistant/11/38/1/0/set
2020-04-23T03:22:37.118Z z2m:Zwave zwave node 11: changed: 38-2-0:Instance 2: Level:33 -> 36
2020-04-23T03:22:37.120Z z2m:Zwave zwave node 11: changed: 38-2-9:Instance 2: Target Value:33 -> 36
2020-04-23T03:22:37.121Z z2m:Zwave zwave node 11: changed: 38-2-5:Instance 2: Dimming Duration:0 -> 0
2020-04-23T03:22:37.261Z z2m:Zwave zwave node 11: changed: 38-1-0:Instance 1: Level:99 -> 99
2020-04-23T03:22:37.262Z z2m:Zwave zwave node 11: changed: 38-1-9:Instance 1: Target Value:99 -> 99
2020-04-23T03:22:37.263Z z2m:Zwave zwave node 11: changed: 38-1-5:Instance 1: Dimming Duration:0 -> 0

also HA is having issues reading the RGB value.

Exception in rgb_received when handling msg on 'homeassistant/11/51/1/0': '{"value_id":"11-51-1-0","node_id":11,"class_id":51,"type":"string","genre":"user","instance":1,"index":0,"label":"Color","units":"#RRGGBBWW","help":"Color (in RGB format)","read_only":false,"write_only":false,"min":0,"max":0,"is_polled":false,"value":"#FF54D600","lastUpdate":1587611742449}' Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/mqtt/light/schema_basic.py", line 356, in rgb_received rgb = [int(val) for val in payload.split(",")] File "/usr/src/homeassistant/homeassistant/components/mqtt/light/schema_basic.py", line 356, in <listcomp> rgb = [int(val) for val in payload.split(",")] ValueError: invalid literal for int() with base 10: "214'"

Also as an alternate to the RGB set command, i can also set the values of each channel R,G,B,W separately via 11/38/3/0, 11/38/4/0, 11/38/5/0, and 11/38/6/0.
unsure if i can expose the four channels via 4 sliders in the UI to set individually.

Did you have any joy resolving your RGB error invalid literal for int() with base 10 as I’ve been getting that for a while with one RGBW light running Tasmota and set as an AI Light?

Yes i did… i just basically overrode the various entities in my config.yaml

dump of my entire config for the RGB below:

i have an RGB control attached to the first one (which exposes the RBG color via the RGB command template).

and the lower sliders i have individual slider controls on, so i can set the 4 channels individually.

as there are two different ways to control the lights, it can be a little interesting… but if you are just looking to set a color / mood on an automation or scene state, then the individual sliders are good for that.

  
  - platform: mqtt
    command_topic: "homeassistant/11/38/2/0/set"
    on_command_type: "brightness"
    #payload_on: "{{ '%i' | format( state_attr( 'light.rgb_rgb_dimmer_2' ,'brightness') * 99/255 )}}"
    state_topic: "homeassistant/11/38/2/0"
    state_value_template: "{{ 'OFF' if value_json.value == 0 else 'ON' }}"
    brightness_state_topic: "homeassistant/11/38/2/0"
    brightness_command_topic: "homeassistant/11/38/2/0/set"
    brightness_value_template: "{{ value_json.value  }}"
    brightness_scale: 99
    rgb_command_template: "{{ '#%02x%02x%02x' | format(red, green, blue)}}"
    rgb_command_topic: "homeassistant/11/51/1/0/set"
    rgb_state_topic: "homeassistant/11/51/1/0"
    rgb_value_template: "{{ value_json.value[1:3] | int(0, 16)}},{{ value_json.value[3:5] | int(0, 16) }},{{ value_json.value[5:7] | int(0, 16) }}"
    white_value_command_topic: "homeassistant/11/38/6/0/set"
    white_value_scale: 99
    white_value_state_topic:  "homeassistant/11/38/6/0"
    white_value_template: "{{ value_json.value }}"
    effect_command_topic: "homeassistant/11/112/1/157/set"
    effect_state_topic: "homeassistant/11/112/1/157"
    effect_list:
      - "preset programs disabled"
      - "fireplace"
      - "storm"
      - "rainbow"
      - "polar lights"
      - "police"
    "name": "Zooz RGB_dimmer test"
    "unique_id": "zwave2mqtt_0xfd523452_11-38-1-0"
    retain: true


  - platform: mqtt
    state_topic: "homeassistant/11/38/2/0"
    command_topic: "homeassistant/11/38/2/0/set"
    brightness_state_topic: "homeassistant/11/38/2/0"
    brightness_command_topic: "homeassistant/11/38/2/0/set"
    on_command_type: "brightness"
    state_value_template: "{{ 'OFF' if value_json.value == 0 else 'ON' }}"
    "brightness_value_template": "{{ value_json.value  }}"
    brightness_scale: 99
    name: ALL_dimmer_2
    unique_id: "zwave2mqtt_0xfd523452_11-38-2-0"

  - platform: mqtt
    state_topic: "homeassistant/11/38/3/0"
    command_topic: "homeassistant/11/38/3/0/set"
    brightness_state_topic: "homeassistant/11/38/3/0"
    brightness_command_topic: "homeassistant/11/38/3/0/set"
    on_command_type: "brightness"
    state_value_template: "{{ 'OFF' if value_json.value == 0 else 'ON' }}"
    "brightness_value_template": "{{ value_json.value  }}"
    brightness_scale: 99
    name: R_dimmer_3
    unique_id: "zwave2mqtt_0xfd523452_11-38-3-0"
    
  - platform: mqtt
    state_topic: "homeassistant/11/38/4/0"
    command_topic: "homeassistant/11/38/4/0/set"
    brightness_state_topic: "homeassistant/11/38/4/0"
    brightness_command_topic: "homeassistant/11/38/4/0/set"
    on_command_type: "brightness"
    state_value_template: "{{ 'OFF' if value_json.value == 0 else 'ON' }}"
    "brightness_value_template": "{{ value_json.value  }}"
    brightness_scale: 99
    name: G_dimmer_4
    unique_id: "zwave2mqtt_0xfd523452_11-38-4-0"
    
  - platform: mqtt
    state_topic: "homeassistant/11/38/5/0"
    command_topic: "homeassistant/11/38/5/0/set"
    brightness_state_topic: "homeassistant/11/38/5/0"
    brightness_command_topic: "homeassistant/11/38/5/0/set"
    on_command_type: "brightness"
    state_value_template: "{{ 'OFF' if value_json.value == 0 else 'ON' }}"
    "brightness_value_template": "{{ value_json.value  }}"
    brightness_scale: 99
    name: B_dimmer_5
    unique_id: "zwave2mqtt_0xfd523452_11-38-5-0"
    
  - platform: mqtt
    state_topic: "homeassistant/11/38/6/0"
    command_topic: "homeassistant/11/38/6/0/set"
    brightness_state_topic: "homeassistant/11/38/6/0"
    brightness_command_topic: "homeassistant/11/38/6/0/set"
    on_command_type: "brightness"
    state_value_template: "{{ 'OFF' if value_json.value == 0 else 'ON' }}"
    "brightness_value_template": "{{ value_json.value  }}"
    brightness_scale: 99
    name: W_dimmer_6
    unique_id: "zwave2mqtt_0xfd523452_11-38-6-0"    
    
    

oh yea… the error was a typo:

end of this line:

    rgb_value_template: "{{ value_json.value[1:3] | int(0, 16)}},{{ value_json.value[3:5] | int(0, 16) }},{{ value_json.value[5:7] | int(0, 16) }}"

notice that single quote in there… that was killing it.

Whoa! That looks a little above and beyond my capabilities. My light is working a treat and I can control it, I’m just trying to figure out the error. Here is the full log just in case you’ve got ant tips.

2020-05-02 16:25:27 ERROR (MainThread) [homeassistant.util.logging] Exception in rgb_received when handling msg on 'tele/office_rgb/STATE': '{"Time":"2020-05-02T05:25:27","Uptime":"35T02:34:22","UptimeSec":3033262,"Heap":27,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":18,"POWER":"OFF","Dimmer":100,"Color":"0000FF00","HSBColor":"240,100,100","Channel":[0,0,100,0],"Scheme":0,"Fade":"OFF","Speed":1,"LedTable":"ON","Wifi":{"AP":1,"SSId":"IoT-GV40","BSSId":"02:9F:C2:F7:D8:B3","Channel":11,"RSSI":60,"Signal":-70,"LinkCount":11,"Downtime":"0T00:15:19"}}'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/mqtt/debug_info.py", line 35, in wrapper
    msg_callback(msg)
  File "/usr/src/homeassistant/homeassistant/components/mqtt/light/schema_basic.py", line 360, in rgb_received
    rgb = [int(val) for val in payload.split(",")]
  File "/usr/src/homeassistant/homeassistant/components/mqtt/light/schema_basic.py", line 360, in <listcomp>
    rgb = [int(val) for val in payload.split(",")]
ValueError: invalid literal for int() with base 10: '0000FF00'

And the RGB code section that seems to be causing the problem is:

    rgb_command_topic: "cmnd/office_rgb/Color2"
    rgb_state_topic: "tele/office_rgb/STATE"
    rgb_value_template: "{{value_json.Color.split(',')[0:3]|join(',')}}"

okay…
so in zwave2mqtt, what does that value line look like?
mine looks like this:
image
notice the # at the front.
so my rgb_value_template is basically taking character 2-3, converting to int, character 4-5, converting to int, and 6-7 and converting to int.

you can probably just cut/paste that line in, but if you dont have the # for hex value, you might need to adjust the position numbers a bit.

to test, go into Dev Tools (in HA), and the template page, and paste this in:

{% set value = “#AABB0000” %}
“{{ (value[1:3] | int(0, 16)) }},{{ (value[3:5] | int(0, 16)) }},{{ (value[5:7] | int(0, 16)) }}”

replace value with whatever you get from zwave2mqtt, and it will confirm the format is working like you expect it to.

Thanks, that’s very helpful. I’ll give that a try.