Error occur "java.lang.IllegalArgumentException: Needs to be string or int, received null value"

Hello,

I’m developing device Handler using sense open/closed sample code.
because I want to make temperature getting interval shorter.

I copy and paste this URL code: https://github.com/SmartThingsCommunity/SmartThingsPublic/blob/master/devicetypes/smartthings/smartsense-open-closed-sensor.src/smartsense-open-closed-sensor.groovy

I use simulator and test with my Physical sense open/closed sensor.
but when I click the refresh button, below error is occurred

java.lang.IllegalArgumentException: Needs to be string or int, received null value

my refresh code is

def refresh() {
	log.debug "Refreshing Temperature and Battery"
        def refreshCmds = zigbee.readAttribute(zigbee.POWER_CONFIGURATION_CLUSTER, 0x0020) +
            zigbee.readAttribute(zigbee.TEMPERATURE_MEASUREMENT_CLUSTER, 0x0000)
	return refreshCmds + zigbee.enrollResponse()
}

the line Starting with ‘def refeshCmd’ is making the error.

Thanks.

Try using the groovy safe navigation operator (?) to prevent errors with null object references.

zigbee?.readAttribute…

http://groovy-lang.org/operators.html#_safe_navigation_operator

I want to know why it returns null.
Do you know why?

It’s probably because the endpoint isn’t set. The endpoint is set when a zigbee device joins but won’t be set if you just manually create the device. You could try the suggestion here:

Or you can pass in additionalParams like documented here:

http://docs.smartthings.com/en/latest/ref-docs/zigbee-ref.html?highlight=configurereporting#low-level-commands

For example:

zigbee.readAttribute(zigbee.POWER_CONFIGURATION_CLUSTER, 0x0020, [destEndpoint:1])

2 Likes

Thank your advice!

I solve this problem by re-joining my physical open/closed device.

but I realize one more problem.

I set my temperature report interval like below for getting the temperature in real time.

zigbee.temperatureConfig(10,20)
sendEvent(name: "checkInterval", value: 10, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])

I put device in the refrigerator, and observe the change

However, I see that the temperatures are not changed in real time. it is changed very slowly

is it device’s problem?

@Wano can you post the entire function where you call zigbee.temperatureConfig(10,20)? The config call looks good but needs to be returned from a function like refresh or configure in order for it to work correctly.

@tpmanley Thanks

Below code is my configure() code.

I saved it in my IDE, and I click configure button in my simulator

After that, it returns temperatures every 20 seconds.

However, the temperatures don’t reflect the real temperature. they are changed very slowly.

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: 10, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])

    // temperature minReportTime 30 seconds, maxReportTime 5 min. Reporting interval if no activity
    // battery minReport 30 seconds, maxReportTime 6 hrs by default
    return refresh() + zigbee.batteryConfig() + zigbee.temperatureConfig(10, 20) // send refresh cmds as part of config
}