I’m not too sure on your problem but I’ll give you a way of maybe testing it a bit further to see if you are getting a meter event. The command classes are just functions that the z-wave devices support, reference material on them can be found here. In smart things you basically parse the event coming in using the parse
method and then use the create event
method to create an event for the given command. The function zwaveEvent
is normally an overloaded function which means depending upon the particular z-wave command passed to it a different implementation will be called.
In the original device handler you should have a refresh function that is called when you click the refresh button in the GUI. Add the lines for voltage, watts, kwh and amps below. Here I use version 3 of the meter command class and I am using the command zwave.meterV3.meterGet
to poll these values.
def refresh() {
log.debug "refresh()..."
delayBetween([
// Change back to encap
crcEncap(zwave.associationV2.associationRemove(groupingIdentifier: 1, nodeId:[])), // Refresh Node ID in Group 1
crcEncap(zwave.associationV2.associationSet(groupingIdentifier: 1, nodeId:zwaveHubNodeId)), //Assign Node ID of SmartThings to Group 1
crcEncap(zwave.meterV3.meterGet(scale: 0)), //kwh
crcEncap(zwave.meterV3.meterGet(scale: 2)), //Watts
crcEncap(zwave.meterV3.meterGet(scale: 4)), //Voltage
crcEncap(zwave.meterV3.meterGet(scale: 5)) //Amps
])
}
I see you have the function encap
which if you are using the default device handler should look something like this.
private encap(physicalgraph.zwave.Command cmd) {
if (zwaveInfo.zw.contains("s")) {
secEncap(cmd)
} else if (zwaveInfo?.cc?.contains("56")){
crcEncap(cmd)
} else {
cmd.format()
}
}
private crcEncap(physicalgraph.zwave.Command cmd) {
zwave.crc16EncapV1.crc16Encap().encapsulate(cmd).format()
}
I noticed that it always reverted to using the secEncap
with this meter as zwaveInfo.zw
returns Ls
but the device commands show that this meter uses CRC16 Encapsulation so thats why I call crcEncap
in the first snippet to format the command.
When the meter is polled it will return with a meterV3.MeterReport
command to the parse method. You need to define a function to handle this command, the one I am using is shown below.
def zwaveEvent(physicalgraph.zwave.commands.meterv3.MeterReport cmd) {
def meterTypes = ["Unknown", "Electric", "Gas", "Water"]
def electricNames = ["energy", "energy", "power", "count", "voltage", "current", "powerFactor", "unknown"]
def electricUnits = ["kWh", "kVAh", "W", "pulses", "V", "A", "Power Factor", ""]
def map = [ name: electricNames[cmd.scale], unit: electricUnits[cmd.scale], displayed: state.display]
//NOTE ScaledPreviousMeterValue does not always contain a value
// Either will be first value if true or other value
def previousValue = cmd.scaledPreviousMeterValue ?: 0
// Switch is like a case statment in bash
// Testing the scale for each of the sensors
switch(cmd.scale) {
case 0: //kWh
previousValue = device.currentValue("energy") ?: cmd.scaledPreviousMeterValue ?: 0
map.value = cmd.scaledMeterValue
break;
case 1: //kVAh
map.value = cmd.scaledMeterValue
break;
case 2: //Watts
previousValue = device.currentValue("power") ?: cmd.scaledPreviousMeterValue ?: 0
map.value = Math.round(cmd.scaledMeterValue)
break;
case 3: //pulses
map.value = Math.round(cmd.scaledMeterValue)
break;
case 4: //Volts
previousValue = device.currentValue("voltage") ?: cmd.scaledPreviousMeterValue ?: 0
map.value = cmd.scaledMeterValue
break;
case 5: //Amps
previousValue = device.currentValue("current") ?: cmd.scaledPreviousMeterValue ?: 0
map.value = cmd.scaledMeterValue
break;
case 6: //Power Factor
case 7: //Unknown
map.value = cmd.scaledMeterValue
break;
default:
break;
}
createEvent(map) // Will handle updating the values for the meter
}
Now anytime you click the refresh button it should poll the meter for the current value of voltage, energy, power and current. Might be a bit of an easier way of debugging.
Regarding the configuration parameters I have got the timer working however it only updates every 10 minutes. According to the official user manual the meter can report on a minimum interval of 60 seconds. However according to the z-wave alliance the meter can only report at an minimum interval of 10 minutes.
Is your device reporting at a regular interval of 60 seconds or is your values of Watts changing quite frequently so it is inducing a report?