Change button image/url depends data other block Topic is solved

Dashticz, alternative dashboard based on HTML, CSS, jQuery

Moderators: leecollings, htilburgs, robgeerts

Post Reply
michelscholte
Posts: 75
Joined: Friday 08 January 2016 10:02
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Nederland
Contact:

Change button image/url depends data other block

Post 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,
});
}
Lokonli
Posts: 2296
Joined: Monday 29 August 2016 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Change button image/url depends data other block

Post 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.
michelscholte
Posts: 75
Joined: Friday 08 January 2016 10:02
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Nederland
Contact:

Re: Change button image/url depends data other block

Post by michelscholte »

Great. This works.

Thanks again.
Post Reply