How to write simple av command

HI;

   I want to write a simple av command to implement my device ,but it cannot work ,here is my code 

private List avCommands ( byte seq , List val )
{[
zwave.simpleavcontrolv1.SimpleAvControlSet (
sequenceNumber : sql,
commands : val ,
)
]}

void ZAvControl(avchannel, avbutton) {
debugLog( "ZAvControl: (${ SET_TV[avbutton] })" )
Random random = new Random();
// create a random number
byte sequence = (byte)random.nextInt();
List<hubitat.zwave.Command> cmds=
String hexString = device.deviceNetworkId
Integer ep = Integer.parseInt(hexString, 16);

Integer val = (Integer)SET_TV[avbutton]
 Short[] codeBytes = parseRemoteCode(val)
cmds.add(zwave.multiChannelV4.multiChannelCmdEncap(
     destinationEndPoint : avchannel.toInteger(),
    sourceEndPoint : ep
 ).encapsulate(avCommands(sequence, [val]))    

)
sendToDevice(cmds)
}

and this is the error log
errorgroovy.lang.MissingPropertyException: No such property: simpleavcontrolv1 for class: hubitat.zwave.Zwave Possible solutions: simpleAvControlV1 on line 506 (method ZAvControl)

According to Z-Wave Classes | Hubitat Documentation
class hubitat.zwave.commands.simpleavcontrolv1.SimpleAvControlSet {
List commands
Integer itemId
Short keyAttributes
Short sequenceNumber
List getPayload()
String format()

I don't know why it is error .
This is very urgent , anyone who can help ?

The error message provides you a hint.

Have you tried zwave.simpleAvControlV1 instead of zwave.simpleavcontrolv1?

Also, while I don't see any errors for this (yet?), you'll probably want something like this:

zwave.simpleAvControlV1.simpleAvControlSet()

instead of this:

zwave.simpleavcontrolv1.SimpleAvControlSet()

That is the name of the class itself. You are creating a command (using method in Groovy), which uses a slightly different capitalization convention.

Thanks, it so kind of you .
using zwave.simpleAvControlV1.SimpleAvControlSet works ok . But my script still cannot work. Can you help to fix ?

dev:2072024-07-25 12:03:07.101 AMerrorgroovy.lang.MissingMethodException: No signature of method: user_driver_yong_Remotec_ZXT_800_738.avCommands() is applicable for argument types: (java.lang.Integer, java.util.ArrayList) values: [5, [[0, 39]]] on line 539 (method ZAvControl)

dev:2072024-07-25 12:03:07.077 AMdebugcsdsdsf DEBUG : commands: ([0, 39])

dev:2072024-07-25 12:03:07.073 AMdebugcsdsdsf DEBUG : ZAvControl: (39)

private List avCommands ( Short seq , List val )
{[
zwave.simpleAvControlV1.SimpleAvControlSet (
sequenceNumber : seq,
commands :val ,
)
]}

void ZAvControl(avchannel, avbutton) {
debugLog( "ZAvControl: (${ SET_TV[avbutton] })" )
Random random = new Random();
// random value
Integer sequence = random.nextInt(20);
List<hubitat.zwave.Command> cmds=
String hexString = device.deviceNetworkId
Short ep =(Short) Integer.parseInt(hexString, 16);

Integer val = (Integer)SET_TV[avbutton]    
 Short[] codeBytes = parseRemoteCode(val)
debugLog( "commands:  (${ codeBytes })" )   
cmds.add(zwave.multiChannelV4.multiChannelCmdEncap(
     destinationEndPoint : avchannel.toInteger(),
    sourceEndPoint : ep
 ).encapsulate(avCommands(sequence, [codeBytes]))    

)
sendToDevice(cmds)
}

I don't know. :slight_smile: But your code is very hard to read without proper formatting. A separate link (e.g., a GitHub gist) or formatting your code in your post will help a lot:

That being said:

This error again tells you what the problem is. (Groovy doesn't always give you helpful errors, but you're two out of two so far.) As it says, you're providing two arguments, and Integer and a List. Your method is defind to take a Short and a List:

I don't know how your device actually works, and I'm not familiar with these Z-Wave command classes, so my ability to help beyond this point may be limited.

This works OK now .

  1. simple av command is simpleAvControlV1
    2.please notice the position of parameter ,if the position of parameter change it cannot work . for example , it is commands and itemId , if change itemId and then commands , it is error . Here is my works code :

def keyHex = 0x27
state.sequence = (state.sequence ?: 0) + 1
zwave.simpleAvControlV1.simpleAvControlSet(commands :[keyHex], itemId: 0x0000, keyAttributes: 0x00, sequenceNumber: state.sequence)

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.