No, apps, in general, can only look at attributes and commands from a device. (This is part of how Hubitat's "capability" model extracts lower-level device and driver details into these higher-level concepts so that apps can work with any device without knowing details of how it or the driver works.)
One exception is if this is a child device of a parent app; in that case, I believe setting the value "directly" would work (using updateSetting() on the device, the same way you'd do it in a driver), but you could for sure always write a method in the child driver and call it from the parent app, or vice versa, and that method can do whatever you need.
If that's not your situation, you'll need a command to do it.
PS -
Not sure where you got this from (actually, I have some ideas ) but it's not a parameter for input in Hubitat.
Do you just want to change the preferences, or are you using them as part of an automation? If the latter, they are likely better done as a command anyway. If the former, the built-in Preference Manager app can help with changing a lot of preferences at once (I know, I said apps can't do this--system apps have rare exceptions).
I'm not sure I understand what you're asking. You don't need two different inputs for the same device to send two different commands (like on or off) to it if that's the implication. Sharing more details about what you're doing may be helpful, possibly including code snippets or screenshots of the app.
Let's ignore Inputs for now and focus on Commands.
Imagine a Hubitat Device implementing a Telnet connection to a remote piece of hardware. And a Hubitat App (which uses that Device) processing the data sent from the hardware and sending data to that hardware.
Now for purposes of debugging I want to be able to log the data sent by the Device and/or the data received by the Device.
So I implement four Commands in the Device: TraceSendOn, TraceSendOff, TraceRecvOn, TraceRecvOff.
def TraceSendOn() {
state.traceSend = true
}
def TraceSendOff() {
state.traceSend = false
}
def TraceRecvOn() {
state.traceRecv = true
}
def TraceRecvOff() {
state.traceRecv = false
}
In the Device code I can test the state of the traceSend and traceRecv to control if the data sent is logged and/or the data received is logged.
In the App code I can call the four commands as needed to set the desired state of traceSend and traceRecv as desired.
But having four commands just to set two "flags" to true or false seems rather inelegant.
I was thinking perhaps there is a way to have just one Command accept two parameters something like:
TraceControl("Send", "On")
TraceControl("Send", "Off")
TraceControl("Recv", "On")
TraceControl("Recv", "Off")
Commands can accept parameters, so what you propose is indeed a possibility.
But are these just random apps and drivers? It sounds like you wrote them both. Would it make sense to have them as parent/child? In that case, you can just call a method from one directly on the other (without the need to "elevate" it into a formal command). If not, the above should still work.
Yeah, the method signature needs to match the parameters of the command in terms of number (and type if you specify them in your method signature, though Groovy can use dynamic types if not). I don't think lowercase "string" is anything in Groovy, but String is indeed the class for a plain string data type.
In other words, as you've probably discovered by now, that looks right!
You can look for something similar implemented in the Tuya Zigbee Multi-Sensor 4 In 1 driver - the SetPar() command. It accepts 2 parameters- the first one is the preference name and the second is the preference new value. The implementation is not the clearest one, but may give you some ideas.