So I set up the commands as indicated above in the app. Then renamed as many as I could via simple PATCH.
As I mentioned and you quoted, for a few commands, such as “ToggleUpLight”, I had trouble PATCHing the name of the command. For those, I got the command and signal of the existing buttons, then copied the command via a POST and the signal via a PUT, then removed the offending button via a DEL like so:
-
GET the command structure of existing “ToggleUpLight”
curl -H "BOND-Token: xxxxxxxxxxxxxxxx" -i http://192.168.a.b/v2/devices/yyyyyyyy/commands/zzzzzzzz
…which returns:
{"name":"Top Light","action":"ToggleUpLight","argument":null,"button_type":"tap","category_name":"Light","feedback":"state.light==1 and state.up_light==1","icon":"top_light","hidden":false,"_":"59262ec6","signal":{"_":"74af0fc3"},"tx":{"_":"56f0ee01"}}
-
GET the command->signal structure of existing “ToggleUpLight”
curl -H "BOND-Token: xxxxxxxxxxxxxxxx" -i http://192.168.a.b/v2/devices/yyyyyyyy/commands/zzzzzzzz/signal
…which returns (truncated the hex value for the Data field, represented with …, to make this post readable):
{"freq":38,"bps":40000,"reps":1,"modulation":"OOK","encoding":"hex","data":"0...0","_":"74af0fc3"}
-
Copy and paste the output from Step 1 in a plain text editor of your choice, then modify so you have a POST string like so, including the change you desire in the Name field and keeping (unmodified) everything else up to and including the Hidden field - as in, do not include the underscore + value pair, the signal node, or the tx node at the end of the output from Step 1.
Don’t forget to escape your " signs as necessary for your platform - this was my version on Windows for cURL:
curl -H "BOND-Token: xxxxxxxxxxxxxxxx" -i http://192.168.a.b/v2/devices/yyyyyyyy/commands -X POST -d "{\"name\":\"Wide Angle\",\"action\":\"ToggleUpLight\",\"argument\":null,\"button_type\":\"tap\",\"category_name\":\"Light\",\"feedback\":\"state.light==1 and state.up_light==1\",\"icon\":\"top_light\",\"hidden\":false"}"
…which returns your new command ID (keep track of this, you will need it for step 4):
{"_id":"nnnnnnnn"}
-
Copy and paste the output from Step 2 (up to and including the Data field, again not including the underscore + value pair at the end) at the end of a string PUTting the actual signal for the new command ID nnnnnnnn from Step 3 like so (truncated the hex value the Data field, represented with …, to make this post readable):
curl -H "BOND-Token: xxxxxxxxxxxxxxxx" -i http://192.168.a.b/v2/devices/yyyyyyyy/commands/nnnnnnnn/signal -X PUT -d "{\"freq\":38,\"bps\":40000,\"reps\":1,\"modulation\":\"OOK\",\"encoding\":\"hex\",\"data\":\"0...0\"}"
…which returns the same value as you put in the {} of the PUT command. -
Now test your new “Wide Angle” (or whatever you named it) command from the app, and if it works, you can DELete the original “Top Light toggle” command button that wouldn’t let you rename it via PATCH:
curl -H "BOND-Token: xxxxxxxxxxxxxxxx" -i http://192.168.a.b/v2/devices/yyyyyyyy/commands/zzzzzzzz -x DEL -d "{}"