Page 1 of 1

Change button image/url depends data other block

Posted: Saturday 14 November 2020 11:51
by michelscholte
Is it possible to change the btnimage and url for a button depending on the data of another block.

I have a block "Yamaha_AlbumArt". I want the data of this block is the input for the btnimage and url.
Data is for example "http://x.x.x.x/YamahaRemoteControl/Albu ... RT8175.png".

Below an example, but this doesn't work:

config.js
blocks['Yamaha_AlbumArt'] = {
idx: 2636,
last_update: false,
width: 4,
}

buttons.yamahaalbum = {
width: 3,
key: 'yamahaalbum',
forcerefresh:1,
isimage: true,
refresh: 5,
}


custom.js
function getStatus_Yamaha_AlbumArt(block) {
var idx = block.idx;
var device = block.device;
console.log(device.Data);
Dashticz.setBlock("buttons.yamahaalbum", {
image: device.Data,
});
}

Re: Change button image/url depends data other block

Posted: Saturday 14 November 2020 15:00
by Lokonli

Code: Select all

function getStatus_Yamaha_AlbumArt(block) {
var idx = block.idx;
var device = block.device;
console.log(device.Data);
Dashticz.setBlock("yamahaalbum", {
btnimage: device.Data,
});
}
You might have to add btnimage to buttons.yamahaalbum as well.

Re: Change button image/url depends data other block

Posted: Saturday 14 November 2020 16:59
by michelscholte
Great. This works.

Thanks again.