Zigbee2MQTT - RGBGenie Remote Control - ZB-5001/5004 4/5 Zone Dimmer ZB-5008/ZB-5028 RGBW 4 Zone Color Wheel and controls blueprint - all actions + should support other multi-zone Remote Controls and Wall Panels (Iluminize/Namron/Sunricher/Muller)

forked from @mbacks Z2M - Tint Remote blueprint.

V 1.1 - 13 Jul '21 - added input_boolean to monitor brightness_ & hue_stop commands. This allows the automation to run in parallel mode so that ZB-5004 Master On/Off’s work correctly while still monitoring for the stop button while in loops.

Written for RGBGenie ZB-5008/5028 RGBW Multi-Zone Remote Control (4 Zones / 3 Scenes per zone / On/Off/Dimmer/Color wheel and Color Temp/Hue controls) and RGBGenie ZB-5004 (4 Zones / 2 Scenes / On/Off/ Dimmer remote) or RGBGenie ZB-5001 (5 Zones / On/Off/ Dimmer remote) but you can populate as few or as many as you want. I’ve allowed up to (optional - will not break with less) 5 zones and can call up to (optional - will not break from 0 - 12) 12 scenes which can adjust any entity/ies via HA (i.e. not just lights). Only the first 2 Scenes will be recalled with ZB-5004 and none for ZB-5001.

You will need to create an input_boolean helper from Configuration>Helpers>Toggle screen.
Should work out of the box with Iluminize 511.314, RGBGenie controllers and any Sunricher whitelabel remotes with same or similar functions.

By changing the relevant button names (color_move == color wheel, etc) should work (with some editing) with: Müller Licht Tint 404011, Namron 4512706, Sunricher SR-ZG2868 (you will need to adjust for the scene recalls) Sunricher ZGRC-KEY-013, RGBGenie 3 Zone RGBW Wall Panel, RGBGenie ZB-5001/4/x 3/4/5 Zone on/off/dimmer/scenes remote or Namron equivalents (4512706).

If your remote control uses the action_group attribute (ZB-5004/1 e.g.) and does not give you a “zone/group_id” appended to the button press, look at @mbacks “Z2M - Tint Remote blueprint” to re-implement the action_group logic (maybe include some input selectors fro the group’s if you publish back here). Set the remote type to ZB-5004/1 (switch on) within the input selectors. As an aside, all of these remotes seem to use different 5 digit action_group id’s per zone, even from same manufacturer.

The ZB-5008/5028 button’s include:
on/off/color_move/hue_move/color_temperature_move/brightness_step_up/down brightness_move_up/down/stop,recall_1/2/3 followed by a zone:_1/2/3/4 for all of the commands except zone 1 on/off (see 1. and 2. below)!
The ZB-5004 button’s include:
on/off/brightness_move_up/down/stop,recall_1/2 . The scene recall is sent for all zones, but I have coded as a scene automation, so it just recalls scene 1 or 2.
The ZB-5001 button’s include:
on/off/brightness_move_up/down/stop

The RGBGenie ZB-5008/5028 has a few quirks…

  1. The big Power button controls Zone 1. If it is off, the remote is asleep, and wont wake up until you press it, so individual zone buttons 1/2/3/4 do nothing unless Zone 1 is on.

  2. The remote provides an “action_group” number for any button press addressed to zones 2/3/4, but none for zone 1, hence the way I have chosen to code the zone (group_id). If you wanted to turn off all light_groups with the big on-off button, turn zone 1 into a control group by adding all your lights to light_group_1.

  3. This automation does not care what button is pressed as long as it contains an “_”. If you are unsure what command is sent when buttons are being pressed, monitor your HA log and look at the info. Comment out the log service once you are happy.

  4. The ZB-5001/ZB-5004 Main On/Off sends On/Off for each individual Zone (1-5)

ToDo:

  1. write some logic for hue_move action. I don’t really see my need of this button, because you can just touch the color wheel, and instant color change. I’ve worked out that the Zigbee2MQTT converter for this remote is not passing the attributes through correctly, and will push a change to correct so that when the button is pressed and held, it will send hue_move and a “rate”, and send hue_stop when released.
    2. fix the brightness_move logic to recognise brightness_stop button to end the loop.

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

blueprint:
  name: Z2M - RGBGenie ZB-5008/5028 or ZB-5004 4 Zone Remote 1.1
  description: Control lights with a RGBGenie ZB 5008/5028 RGBW or ZB-5004 Dimmer 4 Zone Remote v1.0
  domain: automation
  input:
    remote:
      name: Remote
      description: Choose the Remote Control Sensor.action to use
      selector:
        entity:
          integration: mqtt
          domain: sensor
    zb_5004:
      name: Remote Type = ZB-5004 / ZB-5001 or similar?
      description: Turn On if this is a ZB-5004 (you want to use the "action_group" attribute to choose zones rather than receiving zone info from the "action" attribute). Default is ZB-5008/5028
      default: false
      selector:
        boolean: {}
    helper_stop_button:
      name: Helper - Brightness or Hue Stop
      description: Input Boolean used to monitor receipt of a brightness_stop or hue_stop button. Needs to be created before creating automation Configuration>Helpers>Toggle
      default: {}
      selector:
        entity:
          domain: input_boolean
    remote_zone_1_action_group:
      name: (Change if ZB-5004 / ZB-5001 - otherwise it is ignored) ZB-5004 Zone 1 Action Group ID
      description: Enter the 5 digit "action_group" for Zone 1 - look at Z2M log when you press Master On/Off or 1st Zone Button On/Off
      default: 48897
      selector:
        number:
          min: 1
          max: 99999
          mode: box
          step: 1
    remote_zone_2_action_group:
      name: (Change if ZB-5004 / ZB-5001 - otherwise it is ignored) ZB-5004 Zone 2 Action Group ID
      description: Enter the 5 digit "action_group" for Zone 2 - look at Z2M log when you press Master On/Off or 1st Zone Button On/Off
      default: 48898
      selector:
        number:
          min: 1
          max: 99999
          mode: box
          step: 1
    remote_zone_3_action_group:
      name: (Change if ZB-5004 / ZB-5001 - otherwise it is ignored) ZB-5004 Zone 3 Action Group ID
      description: Enter the 5 digit "action_group" for Zone 3 - look at Z2M log when you press Master On/Off or 1st Zone Button On/Off
      default: 48899
      selector:
        number:
          min: 1
          max: 99999
          mode: box
          step: 1
    remote_zone_4_action_group:
      name: (Change if ZB-5004 / ZB-5001 - otherwise it is ignored) ZB-5004 Zone 4 Action Group ID
      description: Enter the 5 digit "action_group" for Zone 4 - look at Z2M log when you press Master On/Off or 1st Zone Button On/Off
      default: 48900
      selector:
        number:
          min: 1
          max: 99999
          mode: box
          step: 1
    remote_zone_5_action_group:
      name: (Change if ZB-5001 - otherwise it is ignored) ZB-5001 or other 5 zone remote - Zone 5 Action Group ID
      description: Enter the 5 digit "action_group" for Zone 5 - look at Z2M log when you press Master On/Off or 1st Zone Button On/Off
      default: 48901
      selector:
        number:
          min: 1
          max: 99999
          mode: box
          step: 1
    light_group_1:
      name: Optional - light group 1
      default: {}
      selector:
        target:
          entity:
            domain: light
    light_group_2:
      name: Optional - light group 2
      default: {}
      selector:
        target:
          entity:
            domain: light
    light_group_3:
      name: Optional - light group 3
      default: {}
      selector:
        target:
          entity:
            domain: light
    light_group_4:
      name: Optional - light group 4
      default: {}
      selector:
        target:
          entity:
            domain: light
    light_group_5:
      name: Optional - light group 5 (if 5 zone remote e.g.)
      default: {}
      selector:
        target:
          entity:
            domain: light
    scene_1_1:
      name: scene 1 zone 1
      description: Optional - Enter Scene 1 for ZB-5004 or Scene 1 Zone 1 for ZB-5028
      default: {}
      selector:
        target:
          entity:
            domain: scene
    scene_2_1:
      name: scene 2 zone 1
      description: Optional - Enter Scene 2 for ZB-5004 or Scene 2 Zone 1 for ZB-5028
      default: {}
      selector:
        target:
          entity:
            domain: scene
    scene_3_1:
      name: scene 3 zone 1
      description: Optional - ZB-5028 only
      default: {}
      selector:
        target:
          entity:
            domain: scene
    scene_1_2:
      name: scene 1 zone 2
      default: {}
      selector:
        target:
          entity:
            domain: scene
    scene_2_2:
      name: scene 2 zone 2
      default: {}
      selector:
        target:
          entity:
            domain: scene
    scene_3_2:
      name: scene 3 zone 2
      default: {}
      selector:
        target:
          entity:
            domain: scene
    scene_1_3:
      name: scene 1 zone 3
      default: {}
      selector:
        target:
          entity:
            domain: scene
    scene_2_3:
      name: scene 2 zone 3
      default: {}
      selector:
        target:
          entity:
            domain: scene
    scene_3_3:
      name: scene 3 zone 3
      default: {}
      selector:
        target:
          entity:
            domain: scene
    scene_1_4:
      name: scene 1 zone 4
      default: {}
      selector:
        target:
          entity:
            domain: scene
    scene_2_4:
      name: scene 2 zone 4
      default: {}
      selector:
        target:
          entity:
            domain: scene
    scene_3_4:
      name: scene 3 zone 4
      default: {}
      selector:
        target:
          entity:
            domain: scene
variables:
  remote_type_zb_5004: !input zb_5004
  stop_button_received: !input 'helper_stop_button'
  stopper: !input 'helper_stop_button'
  remote_action_group: 
    - !input remote_zone_1_action_group
    - !input remote_zone_2_action_group
    - !input remote_zone_3_action_group
    - !input remote_zone_4_action_group
    - !input remote_zone_5_action_group
  light_entities:
    - !input light_group_1
    - !input light_group_2
    - !input light_group_3
    - !input light_group_4
    - !input light_group_5
  scene_entities:
    - !input scene_1_1
    - !input scene_2_1
    - !input scene_3_1
    - !input scene_1_2
    - !input scene_2_2
    - !input scene_3_2
    - !input scene_1_3
    - !input scene_2_3
    - !input scene_3_3
    - !input scene_1_4
    - !input scene_2_4
    - !input scene_3_4
mode: parallel
max: 5
max_exceeded: silent
trigger:
- platform: state
  entity_id: !input 'remote'
condition:
- condition: and
  conditions:
  - condition: template
    value_template: '{{ trigger.from_state.state != trigger.to_state.state }}'
  - condition: template
    value_template: "{% if remote_type_zb_5004 %} {{ trigger.to_state.attributes.action in ('off', 'on', 'brightness_move_down', 'brightness_move_up', 'brightness_stop', 'recall_1', 'recall_2' ) }} {% else %} {{ trigger.to_state.attributes.action.find('_') != -1 }} {% endif %}"
action:
- variables:
    button_group_press: '{% if not remote_type_zb_5004 %} {{ trigger.to_state.attributes.action.rsplit("_", 1) }} {% endif %}'
    button: '{% if remote_type_zb_5004 %} {{ trigger.to_state.attributes.action | string }} {% else %} {{ button_group_press[0] | string }} {% endif %}'
    group_id: '{% if remote_type_zb_5004 %}{{ remote_action_group.index(trigger.to_state.attributes.action_group) | int }} {% else %} {{ button_group_press[1] | int }} {% endif %}'
    light_target: '{% if remote_type_zb_5004 %}{{ light_entities[group_id] }} {% else %} {{ light_entities[group_id - 1] }} {% endif %}'
    recall_found: '{{ ( "recall" ) in button }}'
    recall_press: '{% if recall_found %} {{ button.rsplit("_", 1) }} {% endif %}'
    recall_scene: '{% if recall_found %} {{ recall_press[1] | int }} {% endif %}'
    recall_scene_index: '{% if recall_found %} {{ (recall_scene - 1 | int) if remote_type_zb_5004 else (((group_id - 1) * 3) + recall_scene - 1 | int) }} {% endif %}'
    scene_target: '{% if recall_found %} {{ scene_entities[recall_scene_index] }} {% endif %}'
    scene_target_valid: '{% if (scene_target | length) > 0 %} {{ true }} {% else %} {{ false }} {% endif %}'
- service: system_log.write
  data:
    level: info
    message: 'ZB-5028/5004 Button pressed: {{ trigger.to_state.state }} {{ trigger.to_state.attributes }} Length {{ trigger.to_state.attributes.action | length }} Button {{ button }} Zone {{ group_id }}'
- choose:
  - conditions:
      - condition: template
        value_template: '{{ button in ( "on", "off" ) }}'
    sequence:
    - service: light.turn_{{ button }}
      data: {}
      target: '{{ light_target }}'
  - conditions:
    - condition: template
      value_template: '{{ button in ( "color_move" ) }}'
    sequence:
    - service: light.turn_on
      data_template:
        xy_color:
          - '{{ trigger.to_state.attributes.action_color.x | float }}'
          - '{{ trigger.to_state.attributes.action_color.y | float }}'
      target: '{{ light_target }}'
  - conditions:
    - condition: template
      value_template: '{{ button in ( "brightness_stop " ) }}'
    sequence:
    - service: system_log.write
      data:
        level: info
        message: 'stop button received: {{ trigger.to_state.state }} {{ trigger.to_state.attributes }} Button {{ button }} Zone {{ group_id }}'
    - service: input_boolean.turn_on
      entity_id: !input 'helper_stop_button'
  - conditions:
    - condition: template
      value_template: '{{ button in ( "brightness_move_up", "brightness_move_down" ) }}'
    sequence:
    - service: input_boolean.turn_off
      entity_id: !input 'helper_stop_button'
    - repeat:
        while: '{{ repeat.index < 50 and states(stopper) == "off" }}'
        sequence:
        - delay: 0.3
        - choose:
          - conditions: '{{ button in ( "brightness_move_up" , "brightness_move_down" ) }}'
            sequence:
              - variables:
                  factor: '{% if button in ( "brightness_move_down" ) %} -{{ trigger.to_state.attributes.action_rate / 2| int }} {% else %} {{ trigger.to_state.attributes.action_rate / 2 | int }} {% endif %}'
              - service: system_log.write
                data:
                  level: info
                  message: 'In the LOOP:                       Iteration {{ repeat.index }} Button {{ button }} Group {{ group_id }}'
              - service: light.turn_on
                data_template:
                  brightness_step: '{{ factor | int }}'
                target: '{{ light_target }}'
  - conditions:
    - condition: template
      value_template: '{{ recall_found and scene_target_valid }}'
    sequence:
      - service: scene.turn_on
        data:
          transition: 2
        target: '{{ scene_target }}'
  - conditions:
    - condition: template
      value_template: '{{ button in ( "color_temperature_move" ) }}'
    sequence:
    - service: light.turn_on
      data_template:
        color_temp: '{{ trigger.to_state.attributes.action_color_temperature | int }}'
      target: '{{ light_target }}'
  - conditions:
    - condition: template
      value_template: '{{ button in ( "brightness_step_up", "brightness_step_down" ) }}'
    sequence: 
      - variables:
          factor: '{% if button in ( "brightness_step_down" ) %} -{{ trigger.to_state.attributes.action_step_size /2 | int }} {% else %} {{ trigger.to_state.attributes.action_step_size /2 | int }} {% endif %}'
      - service: light.turn_on
        data_template:
          brightness_step: '{{ factor | int }}'
        target: '{{ light_target }}'
  - conditions:
    - condition: template
      value_template: '{{ button in ( "hue_move" ) }}'
    sequence: []
  default: []

How did you configure the RGBGenie ZB-5001 to work with Zigbee2MQTT?

Hi, I have a ZB-5004, not ZB-5001. I’ve only tested the 5004 4 zone dimmer and 5028 RGBW. I had a quick look at the devices file in zigbee-herdsman-converters, and it looks like there is no definition for the ZB-5001, so I’m assuming you are getting an “unsupported” error when you pair it. Did you try adding an external converter and use the ZB-5004 model definition via an external converter?

Anyone still using this?

I’m the author and still use it. Is there anything particular you would like to know?

The add blueprint link and GitHub link didn’t seem to work. Is there any way to pull the color wheel?

No worries. - Fixed now.

Is there any way to pull the color data? From the wheel?

Hi, I’m not sure what you mean by “pull the data from the color wheel”?
It’s an input only button, it doesn’t read the existing color of the lights if that’s what you mean?
But you could add something to read the current xy_color state of the light entity at any time.
However as you can see from below, touching the wheel and the relevant xy_color is captured.

If you have activated a zone on the remote, ‘touching the color wheel’ is handled by the “color_move” sequence of code:

  - conditions:
    - condition: template
      value_template: '{{ button in ( "color_move" ) }}'
    sequence:
    - service: light.turn_on
      data_template:
        xy_color:
          - '{{ trigger.to_state.attributes.action_color.x | float }}'
          - '{{ trigger.to_state.attributes.action_color.y | float }}'
      target: '{{ light_target }}'

Looking at the automation trace yields:

level: info
    message: >-
      ZB-5028/5004 Button pressed: color_move_2 {'action': 'color_move_2',
      'action_color': {'x': 0.267, 'y': 0.054}, 'action_group': 4xxxxx,
      'action_transition_time': 0, 'battery': 100, 'linkquality': 0, 'voltage':
      3800, 'icon': 'mdi:gesture-double-tap', 'friendly_name':
      'Colour_remote_1_action'} Length 12 Button color_move Zone 2
Result:
params:
  domain: light
  service: turn_on
  service_data:
    xy_color:
      - 0.267
      - 0.054
    entity_id:
      - light.couch_lights
  target:
    entity_id:
      - light.couch_lights
running_script: false
limit: 10

What is the issue that you want to solve?

Yeah. I’m just not seeing any of the X/Y data come across on MQTT. I see it in the state on Zigbee2MQTT, but its not getting passed along. Just the action itself.

OK, so that would possibly be what Zigbee2MQTT is passing to HA. I don’t have the time at the moment to help with debugging, but the template acts on what it is passed from the event, so that’s the place to start in the developer tools. Other avenues of exploration - determine if the remote has been recognised in Zigbee2MQTT as the right device, and have a look at the doco and also the herdsman converter for the device to see what info and format it is expecting. https://github.com/Koenkk/zigbee-herdsman-converters. It was a while ago that I set these up, and I think I committed a change to the herdsman converter to fix some unexpected behaviour on the hue change button rather than the color wheel. That worked straight out of the box. Good luck. I’ll keep monitoring the topic, so if you have any questions around the template, happy to help.

Finally figured out why… now the next question. They are X/Y values… how does one convert to RGB? Is it using CIE or ?

Have a look at the Zigbee2MQTT IKEA 5 Button Remote blueprints. From memory, the author covered all different color spaces, but I can’t remember the details.

I’ll take a look and see if I can find it. Thanks

Hello,
Do you think your bluescript could work with this remote Control ?

And could it be adapted for a conbee stick (I don’t use zigbee2mqtt)
Thank you

It “looks” the same as the ZB-5001/4 remote, so would probably be a reasonable bet. Re Conbee, my understanding (might be wrong) is that it also uses the Zigbee protocol, so it would be a matter of a. device support within Conbee, and the messaging protocol back to HomeAssistant. I’d be confident that it could be adapted, but I don’t know enough to advise.

I love the blueprint and really want to get my RGBGenie ZB-5028 working with my light group. But it’s trhowing the following error, and I am unable to diagnose the problem. Any suggestions? Thanks in advance!

Source: helpers/template.py:540 
First occurred: January 28, 2023, 2:22:15 PM (78 occurrences) 
Last logged: 12:22:13 AM

Template variable error: 'homeassistant.util.read_only_dict.ReadOnlyDict object' has no attribute 'action' when rendering '{% if remote_type_zb_5004 %} {{ trigger.to_state.attributes.action in ('off', 'on', 'brightness_move_down', 'brightness_move_up', 'brightness_stop', 'recall_1', 'recall_2' ) }} {% else %} {{ trigger.to_state.attributes.action.find('_') != -1 }} {% endif %}'

Here is the corresponding code from automations.yaml

  alias: Z2M - RGBGenie ZB-5008/5028 or ZB-5004 4 Zone Remote 1.1
  description: ''
  use_blueprint:
    path: bayview252/rgbgenie-zb-5004-and-zb-5028-combined.yaml
    input:
      remote: sensor.rgbgeniezb5028_action
      zb_5004: false
      helper_stop_button: input_boolean.rgbgenie_automation_helper
      scene_1_1:
        entity_id: scene.daytime_bright_orange_light
      scene_1_2:
        entity_id: scene.early_morning_dim_red_light
      light_group_1:
        entity_id: light.rgb_lights

So, quick glance at the above.

Could you confirm what device is registering when paired. Also confirm if you are using zigbee2mqtt?

Device type will allow you to look inside the zigbee2mqtt device converters to see how the button press is being interpreted before being passed to MQTT broker in HA.

I would use something like MQTT Explorer to have a look at the messages your button press(es) is/are generating and see where that takes you.

2nd thing would be to monitor the topics in the Developer Tool section within Home Assistant, and make sure they match.

Full description on the how to’s is beyond me as I set these up a while back, and don’t have a lot of spare time nowdays.

Thanks, Gerry! I understand time pressures, so any of your time is very much appreciated.

The MQTT Integration in HA shows:

RGB remote with 4 endpoints and 3 scene recalls (ZB-5028)
by RGB Genie
Firmware: 2.2.3_r12

It’s paired with Zigbee2MQTT and here’s what Z2M reports:

Description Product ID: ZB-5028 www.RGBgenie.com (520)-338-8849
Last seen N/A
Availability [Disabled](https://www.zigbee2mqtt.io/guide/configuration/device-availability.html#availability-advanced-configuration)
Device type EndDevice
Zigbee Model RGBgenie ZB-5028
Zigbee Manufacturer RGBgenie
Description RGB remote with 4 endpoints and 3 scene recalls
Support status Supported
IEEE Address 0x000d6f001668b688
Network address 0x2884
Firmware build date NULL
Firmware version 2.2.3_r12
Manufacturer [RGB Genie](https://www.zigbee2mqtt.io/supported-devices/#v=RGB%20Genie)
Model [ZB-5028](https://www.zigbee2mqtt.io/devices/ZB-5028.html#rgb%2520genie-zb-5028)
Power Battery 100%
Interview completed True

The device was paired with Z2M with all defaults and I’ve confirmed that there are no Z2M filters set.

FYI, in case this is helpful, Z2M reports the state as

    "battery": 100,
    "brightness_2": 159,
    "linkquality": 100,
    "voltage": 3800,
    "action": "",
    "action_color": {
        "x": 0.201,
        "y": 0.243
    },
    "action_group": 33795,
    "action_transition_time": 0,
    "action_color_temperature": 230
}

Under the MQTT integration settings “Listen to a Topic,” and pressing the power button once:

zigbee2mqtt/RGBGenieZB5028
 
Message 1 received on zigbee2mqtt/RGBGenieZB5028 at 8:30 AM:
{
    "action": "",
    "battery": 100,
    "brightness_2": 159,
    "linkquality": 112,
    "voltage": 3800
}
QoS: 0 - Retain: false

Message 0 received on zigbee2mqtt/RGBGenieZB5028 at 8:30 AM:
{
    "action": "on_1",
    "battery": 100,
    "brightness_2": 159,
    "linkquality": 112,
    "voltage": 3800
}
QoS: 0 - Retain: false

Here’s one thing that I am wondering about:

[sensor.rgbgeniezb5028_action] doesn’t appear to have any other attributes besides icon and friendly_name, according to the States page in HA. But the code seems to be expecting that it has an action attribute.

Well, thanks for taking a look!

Michael

Ok, MQTT is seeing the action attribute, so that’s good. Looks like when you paired the device, for some reason, Home Assistant decided either not to register the “action” attribute OR zigbee2mqtt did not expose the attribute. I don’t think it is “case 3”: that the attribute is disabled within HA, but you could check that in Settings>Device page for the remote, and look in Diagnostics. Link Quality is disabled in my example.


You could delete the device from Z2M, and re-pair. Sometimes that is all that is required, but check Z2M Debug logs, see what’s in there when re-pairing.
Check for other debugging info on how to debug the setup of Home Assistant Device/Entities with Z2M. Good luck!