Zigbee configure: IllegalArgumentException: Needs to be string or int

I’m trying to integrate a Zigbee device and I have the following configure method.

def configure() {
    def configCmds = []

    configCmds += zigbee.batteryConfig()

    return configCmds
}

However when I press on the configure button, I see the following error, which points the zigbee.batteryConfig() line. What do you think is the problem?

java.lang.IllegalArgumentException: Needs to be string or int @ line 110

By the way, I have Hub v2 (UK) with latest firmware.

This can be done much simpler like this

def configure() {
    zigbee.batteryConfig()
}

SmartThings new simplified ZigBee library commands/config/refresh statements do not get returned to the hub to be processed.

It’s not a problem of code simplicity. In Groovy, the last statement is returned, so what you write is equal to:

def configure() {
    return zigbee.batteryConfig()
}

Both my original code, your code and the above code produce the same IllegalArgumentException. What shall I do to fix this? Is it a platform error?

You are correct the code should work. Unless you have some unprintable character hiding in there. Here is code from SmartThings multi-sensor. It matches your original code.

def configure() {
	// Device-Watch allows 2 check-in misses from device + ping (plus 1 min lag time)
	// enrolls with default periodic reporting until newer 5 min interval is confirmed
	sendEvent(name: "checkInterval", value: 2 * 60 * 60 + 1 * 60, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])

	log.debug "Configuring Reporting"
	def configCmds = []

	if (device.getDataValue("manufacturer") == "SmartThings") {
		log.debug "Refreshing Values for manufacturer: SmartThings "
		/* These values of Motion Threshold Multiplier(0x01) and Motion Threshold (0x0276)
            seem to be giving pretty accurate results for the XYZ co-ordinates for this manufacturer.
            Separating these out in a separate if-else because I do not want to touch Centralite part
            as of now.
        */
		configCmds += zigbee.writeAttribute(0xFC02, 0x0000, 0x20, 0x01, [mfgCode: manufacturerCode])
		configCmds += zigbee.writeAttribute(0xFC02, 0x0002, 0x21, 0x0276, [mfgCode: manufacturerCode])
	} else {
		// Write a motion threshold of 2 * .063g = .126g
		// Currently due to a Centralite firmware issue, this will cause a read attribute response that
		// indicates acceleration even when there isn't.
		configCmds += zigbee.writeAttribute(0xFC02, 0x0000, 0x20, 0x02, [mfgCode: manufacturerCode])
	}

	// temperature minReportTime 30 seconds, maxReportTime 5 min. Reporting interval if no activity
	// battery minReport 30 seconds, maxReportTime 6 hrs by default
	configCmds += zigbee.batteryConfig() +
			zigbee.temperatureConfig(30, 300) +
			zigbee.configureReporting(0xFC02, 0x0010, DataType.BITMAP8, 10, 3600, 0x01, [mfgCode: manufacturerCode]) +
			zigbee.configureReporting(0xFC02, 0x0012, DataType.INT16, 1, 3600, 0x0001, [mfgCode: manufacturerCode]) +
			zigbee.configureReporting(0xFC02, 0x0013, DataType.INT16, 1, 3600, 0x0001, [mfgCode: manufacturerCode]) +
			zigbee.configureReporting(0xFC02, 0x0014, DataType.INT16, 1, 3600, 0x0001, [mfgCode: manufacturerCode])

	return refresh() + configCmds

@ertanden can you try this?

    log.debug "endpointId is ${zigbee.endpointId}"
    return zigbee.batteryConfig()

It looks like something might be up with the endpointId variable so I want to see what value your code sees.

I got;

endpointId is null

This is a Temp/Humidity sensor and I can get temperature and humidity values out of this sensor, so why is the endpointId null? Any guesses?

Did you manually create the device in the system or was it created automatically when you joined the device? The endpoint id should be populated if the system created it. Either way I just manually set the endpointId on the device to 01 so see if works now.

I manually created the device, probably that’s the problem… Thanks a lot.

By the way, it would be nice to have raw Zigbee log messages somewhere (with manual enable and a timeout to auto-disable to prevent lots of logs causing performance issues). SmartThings seems to hide some of the details but for advanced debugging I think it would be invaluable.

Especially it’s hard to debug device join etc…

Ertan, are you using the Xiaomi sensors, or something else? By coincidence I was writing a device handler for this today and ran into the same issue. Did you solve this?

Tom, can you be more specific with how to “just manually set the endpointId on the device to 01”? Where do I do this? I know I can add it to additionalParams for attribute reads and writes, but that doesn’t seem to immediately solve the problem for me (can give info if required - don’t want to distract from Ertan’s issue if it is not resolved).

@Richard_Gordon yes I’m messing with the Xiaomi Temp/Humidity sensor.

You can circumvent the problem by writing the following just before calling any zigbee methods;

device.endpointId = 1

Unfortunately, I couldn’t manage to “auto pair” Temp/Humidity sensor, although Xiaomi Door/Window and Motion sensors can “auto pair” and be discovered… They seem to act the same upon pressing their reset buttons, but still I couldn’t figure out why the Temp/Humidity is not auto discovered.

Anyways, my manually adding the sensor, I can get values out of it for the time being…

2 Likes

Thanks @ertanden, that works for me.

I paired mine manually and it gives temprature and humidity readings pretty easily. I’m a little stuck trying to get the battery status from it and haven’t even looked at ‘auto pair’ yet. I’d be interested to see any progress you make and happy to help where I can (though this is my first time working with this).

I couldn’t get the battery report. I’m not very experienced too actually. Anyways, still it’s good that we have most important values from the device

Further to this, I just spent some time looking for battery status and found that:

  • The sensor correctly reports it is powered by battery
  • Reading the battery voltage attribute always returns zero for me
  • The extended attribute for battery percentage in the zigbee home automation profile is not supported

I notice that for the other Xiaomi sensors, people have been using the final catchall data value returned when clusterid is zero.
I have three sensors so compared several readings and can’t see any field that looks like a voltage or battery status.
I even took one of the three sensors and replaced the battery with a variable voltage power supply. Working up from 2.2v to 3.2v in steps of 0.1v didn’t show any change in data values that might relate to voltage. I must be looking in the wrong place.