Fully kiosk volume slider

You can verify what capabilities and commands the device is reporting in SharpTools:

  1. Open your SharpTools.io User Page
  2. Tap the ... next to your location
  3. Scroll down and tap on the device
  4. Review the capabilities section (toward the top) and commands (toward the bottom)

The Custom Tile code would have to explicitly implement that functionality which this one doesn’t.

I would recommend getting familiar with your browser’s developer tools for this kind of thing though (F12 on most modern browsers). For example, this Custom Tile logs a bunch of stuff to the console… and if there are errors, they usually show up in the console.

The json payload is wrong.
This works.

{ "commands": [ { "component": "main", "capability": "audioVolume", "command": "setVolume", "arguments": [100] } ] }
1 Like

Thank you for the help! do you have the whole script to make it work? Im still getting a lot of errors. When I do F12 I am seeing status code 400 and
:{“code”:“ConstraintViolationError”,“message”:“The request is malformed.”,“details”:[{“code”:“PatternError”,“target”:“deviceId”,“message”:“deviceId value "RINCON_5CAAFDEF097E01400:113932966" not a properly formed GUID.”,“details”:}]}}

So I am getting an error 401 when trying to access the smarrthings API… I have generated multiple tokens… they are all giving me the same issue… is there another step that I need to do to allow access to the API?

You need to replace this.

    
    var data = '{"commands": [{"component": "main", "capability": "volume", "command": "setLevel", "arguments": ['+value+']}]}';

With this. The capability and command was wrong, and the argument was being passed as a string and not an integer.

  var data = '{ "commands": [ { "component": "main", "capability": "audioVolume", "command": "setVolume", "arguments": [+value+] } ] }';

Thank you Jake… that cleaned up some of the errors. However I am still getting the error 401 please see below:

Just to confirm… I went here (Samsung account) and generated a Token… I selected every option.

I then went here (https://graph.api.smartthings.com/) to get the Device Network Id for the sonos amp I would like to control.

Is there any step that I am missing to allow this sharptools tile to communicate with the device?

I really appreciate your help, thank you!

The overall steps seem right, but something about your token apparently is not right. Did you double check that after you got the new token with DEVICE access, that you updated the settings within your Custom Tile instance that’s on your dashboard (eg. edited the settings of the tile that you put on a dashboard) and made sure to save them?

HI Josh,
Thank you for the reply. Yes I made sure to add the new token to the Custom Tile and save it. I just generated another new token, added it to the tile, saved the tile and I am still getting the same issue. I dont know enough about all of this, but seems for whatever the reason smartthings is blocking access to the device. Is there something wrong with the way the token is being used to access the API?

No its 401, so I guess something is wrong with the token?

If you want to PM me screenshots showing how you’re creating the token and what the final token is, I can test it out.

I noticed you blacked out the renderToken, but missed redacting the token from your screenshot (which I blurred out for you), so I tried a List Devices command with that token and it’s not working which makes me think there’s something wrong with how the token is getting created or how its getting saved.

How many devices are you trying to control? If it’s only 1.

In the settings remove all DeviceID settings then add back in one with the name of DeviceID.

Change the
var devices = ;
To
var deviceId = null;

Then

function getAxiosConfig(){
    return { "headers": { "Authorization": "Bearer " + patToken } }
}
    
stio.ready((data)=>{
    console.log("Starting Volume Dimmer [shortyyy]");
    console.log("stio library is ready with token", data.settings.token);        
    if(data.settings.token == null || data.settings.DeviceID == null){
        console.log("Please configure the authorization token and at least 1 device");
        return;
    }
    else{    
       deviceId = data.settings.DeviceID;
        patToken = data.settings.token;
        console.log("device ID", deviceId);
    }

    initSlider();
    getVolLevel();
    setInterval(getVolLevel, 30000);
});

Can you supply the full code?

Thanks for sending the PM. It looks like the issue is with the Device ID.

From what I can tell, the value you used looks more like a “Device Network ID” whereas we’re looking for the device ID. The device ID has the same format as the token with the dashes and everything. Personally, I find the easiest way to get it is:

  1. Open your SharpTools.io User Page
  2. Tap the ... next to your location
  3. Scroll down and tap on your device
  4. Flip the ‘Advanced’ toggle on so you can see and copy the Device ID field
1 Like