Send command to device using device ID

Hi All,

I am new to Hubitat and I would like to turn off the virtual switch from the device code when a particular command is executed.

I did not subscribe to that virtual switch but I know the device ID of that switch. Is there a way where I can send an on() command to that virtual switch using its device ID?

something like, DeviceId.on()?

Regards,
Hardik

No, you need to have an input where you have the user select the device. The name of that input will then become the name of a field variable you can use to send commands to the device (or check its state, etc.).

See here for a recent post that describes app UIs in greater detail than anything else I'm aware of at the moment if you aren't familiar:

Otherwise, if you shared your code, someone can probably give more specific advice.