Zigbee Color and Level Control

Hi,

I am currently trying to build a node application to control Philips Hue Lights with the Matrix Creator. I am using the matrix-protos npm package (v 0.0.28).

I only found this example. However, the example is incorrect since it puts the nodeId and endpointIndex directly into the MoveToHueAndSatCmdParams object when building a Zigbee Message. These values need to be in the ZCLCmd object (see my code below).

At the moment I am able to turn lights on and off by building a zigbee message like this:

function onOffMessage(type, nodeId, endpointId){
  const ZigBeeMsg = matrix_io.malos.v1.comm.ZigBeeMsg;
  return matrix_io.malos.v1.driver.DriverConfig.encode(
    matrix_io.malos.v1.driver.DriverConfig.create({
      zigbeeMessage: ZigBeeMsg.create({
        type: ZigBeeMsg.ZigBeeCmdType.ZCL,
        zclCmd: ZigBeeMsg.ZCLCmd.create({
          type: ZigBeeMsg.ZCLCmd.OnOffCmd.ZCLOnOffCmdType.ON_OFF,
          onoffCmd: ZigBeeMsg.ZCLCmd.OnOffCmd.create({type: type}),
          nodeId: nodeId,
          endpointIndex: endpointId
        })
      })
    })
  ).finish();
}

I am not yet able to also control brightness and color. For brightness I tried building a message like this:

function brightnessMessage(brightness, nodeId, endpointId){
  const ZigBeeMsg = matrix_io.malos.v1.comm.ZigBeeMsg;
  return matrix_io.malos.v1.driver.DriverConfig.encode(
    matrix_io.malos.v1.driver.DriverConfig.create({
      zigbeeMessage: ZigBeeMsg.create({
        type: ZigBeeMsg.ZigBeeCmdType.ZCL,
        zclCmd: ZigBeeMsg.ZCLCmd.create({
          type: ZigBeeMsg.ZCLCmd.LevelCmd.ZCLLevelCmdType.LEVEL,
          levelCmd: ZigBeeMsg.ZCLCmd.LevelCmd.create({
            type: ZigBeeMsg.ZCLCmd.LevelCmd.ZCLLevelCmdType.MOVE_TO_LEVEL,
            moveToLevelParams : ZigBeeMsg.ZCLCmd.LevelCmd.MoveToLevelCmdParams.create({
              level: brightness,
              transitionTime: 1
            })
          }),
          nodeId: nodeId,
          endpointIndex: endpointId
        })
      })
    })
  ).finish();
}

For color I tried it like this:

function colorMessage(color, nodeId, endpointId){
  const ZigBeeMsg = matrix_io.malos.v1.comm.ZigBeeMsg;
  return matrix_io.malos.v1.driver.DriverConfig.encode(
    matrix_io.malos.v1.driver.DriverConfig.create({
      zigbeeMessage: ZigBeeMsg.create({
        type: ZigBeeMsg.ZigBeeCmdType.ZCL,
        zclCmd: ZigBeeMsg.ZCLCmd.create({
          type: ZigBeeMsg.ZCLCmd.COLOR_CONTROL,
          colorcontrolCmd: ZigBeeMsg.ZCLCmd.ColorControlCmd.create({
            type: ZigBeeMsg.ZCLCmd.ColorControlCmd.ZCLColorControlCmdType.MOVETOHUEANDSAT,
            movetohueandsatParams: ZigBeeMsg.ZCLCmd.ColorControlCmd.MoveToHueAndSatCmdParams.create({
              hue: color,
              transitionTime: 1,
              saturation: 100
            })
          }),
          nodeId: nodeId,
          endpointIndex: endpointId
        })
      })
    })
  ).finish();
}

What is wrong with these color and brightness messages? Since I can succesfully turn the lamp on and off there has to be something wrong with these messages.

Thanks.

Since this does not seem to work using JavaScript I switched to Python.

1 Like