Wano
(Wanho Im)
March 10, 2017, 5:51am
1
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.
rayzurbock
(Brian S. Lowrance)
March 10, 2017, 5:57am
2
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
Wano
(Wanho Im)
March 10, 2017, 6:01am
3
I want to know why it returns null.
Do you know why?
tpmanley
(Tom Manley)
March 10, 2017, 3:53pm
4
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:
@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…
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
Wano
(Wanho Im)
March 13, 2017, 5:25am
5
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?
tpmanley
(Tom Manley)
March 13, 2017, 4:42pm
6
@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.
Wano
(Wanho Im)
March 14, 2017, 12:27am
7
@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
}