(Hubitat) How to send custom device commands (outside normal Capabilities)

As of 3.11.1 it is possible to use a new generic “Command” capability to execute any command on any device. Details on how to use this to follow from Bill.

Original thread from older Google Groups forum:

To send a generic command to any Hubitat device:

  1. Add Command to the Device object’s Capabilities. Unlike the other Capabilities, this is not automatically assigned during synchronization. You will need to manually enter it.

  2. Add a DataAction to your control that sets the YourDeviceName.Command attribute. The Value you supply is the command name. The Value will be appended to the Maker API URL without any manipulation.

When to use?

  • If the command you need to send is not listed on this Hubitat Driver page, you’ll most likely need this new Command capability. Most commands listed on the Driver page are already handled internally when you request a value change on one of your attributes.

Hubitat_CommandCapability.hrp (4.0 KB)

1 Like

Hi Bill,

Thanks for adding this feature.

This seems to work fine when executing for instance a button clicked event on a page linked to MainPage.xaml (EventTrigger ‘clicked’ --> DataAction: “LhBedroomTv.Command” value = mute). However when using either ‘@device.Command’ or ‘devicename.Command’ within a template assigned to a device to appear as part of a group, neither seems to send the ‘command’ to MakerApi on Hubitat (going by Hubitat log output). Am I misunderstanding the intention here?

I was basically using a modified copy of the supplied ‘MediControllerDetails.xaml’ template as a starting point for a virtual TV remote.

Thanks for any help you can offer.



I beleive it’s case-sensitive so you’d need to use @Device.Command. Also, MediaControllerDetails.xaml uses @Device.MediaCommand. You’ll need to replace MediaCommand with just Command. Other than that, everything should work. You should be able to create a template for it.

One other thing that could make that a little difficult for you to reuse is many of the buttons are enabled/disabled based on the SupportedMediaCommands attribute. You don’t have that. You’ll need to delete all of those conditions.

Oh sorry, my bad, I was using ‘@Device.Command’ (capital D), I just messed up in the email to you. Ok it must be the enabled/disabled thing. I’ll give it another look.

Thanks again.



It was the enabled/disabled state of the controls. Stupidly I didn’t notice all controls on the page were dimmed a little until I saw the contrast when one was enabled. Doh, sorry for wasting your time.



1 Like

Is it posible to have multiple custom commands linked to one device?

Yes, for @Joel_Groves I know his devices all had several commands. If you look at his JSON from that post in the Google Group, 1 of his devices had “back”, “chdown”, “chup”, “configure”, etc. All of those commands could be sent with 1 Home Remote Device object.

In that example I shared, you can copy & paste that Button and just update the Value for that DataAction. They can all share the same HubitatDevice.Command binding.

1 Like

Works great! Thank you! :slight_smile:

1 Like

Is it possible to to send a secondary value?

Send Device Command (replace [Device ID] with actual subscribed device id and [Command] with a supported command. Supports optional [Secondary value][Device ID]/[Command]/[Secondary value]?access_token=xxxxxxxxxxxxxxxxxxxxxxx

Yes. Just set the Value in the action to your combined value.

[Command]/[Secondary value]

Well that was easy.

What about if I want to pass an attribute from one device to another, or pass a variable.
Example value: Command/device.attribute or Command/variableName.

I’ve tested in different ways, but Hubitat only receives the exact text string that i put i the textbox.

I originally posted that you will need a ScriptAction. This is no longer necessary in

Original Post:

What you could do is use a ScriptAction to build & send your command. I generally discourage use of ScriptActions but in this case you don’t really have another choice until I add reference support to the DataAction Value.

For the time being, you could write a script that looks like this:

var attributeValue = App.GetDeviceAttribute("YourReferenceDevice.Attribute");
App.SetDeviceAttribute("YourCommandDevice.Command", "Command/" + attributeValue);

Great! Thank you! :slight_smile:

I updated my original response to you showing the new preferred way of passing an attribute from 1 device to another.

Hey Bill,

How would I go about sending a command and secondary command with the secondary command coming from an element binding like a text bar variable?

For example I can make the Value of my command searchAppleMusic/Usher which works well, however I would like that second command value to be from a element binding (text bar). Basically to create a search bar in HR to my echo via Hubitat.

Use a MultiBinding as the Value of your DataAction. Attached is an example.
MultiBinding_Action.hrp (8.1 KB)

Thanks Bill,

This is neat and works fine. However, what I’m trying to do is have the button primary command pre-defined with the secondary command be a variable from a text box. So if I type in “Usher” in the text box it sends the command as follows:

http://192.xxx.xx.xx/apps/api/58/devices/[Device ID]/searchAppleMusic/Usher?access_token=xxxxxxxxxxxxxxx

Attached is a revised example that is more in line with what you are looking for. You’ll need to create a virtual variable to store the contents of the search box. It looks like MultiBinding currently only supports device bindings & not element bindings. So you can’t bind directly to the TextBox. Also, you don’t need the plugin I have in the example. Instead you will use an actual HubitatDevice.Command variable. It will replace my virtual one created with the plugin.
MultiBinding_Action_v2.hrp (8.1 KB)