Page 1 of 1

Can I use a block to go to the slide upon pressing?

Posted: Friday 22 February 2019 9:56
by Marque1968
On my main screen I want to display the room temperature. However, upon pressing the button, I would like to go to a second screen where the temperature is shown again aswell as other temperatures in the house and the option to set the required temperatures.

Code: Select all

blocks['26_1'] = {} //Temperatuur
blocks['26_1']['title'] = 'Temp';
blocks['26_1']['hide_data']= false;
blocks['26_1']['width']= 12;
blocks['26_1']['switch'] = true;
blocks['26_1']['gotoslide'] = 2;
This however does not work, as it needs a change to activate the slide, thus pressing it shows a pop-up with the log.

And as it did this, it made my question even harder. As now I would like the block['26_1'] on 1st screen to go to the second slide with all temperature info, but on that 2nd screen I want block['26_1'] to display the log (as I am already on screen 2).

Oh, and this is just the first page I am thinking off. I want to repeat this functionality for the power use, where on screen 1 I show the current electric and gas use of the house, and on screen 3, the power use of the most devices displayed.

Re: Can I use a block to go to the slide upon pressing?

Posted: Tuesday 05 March 2019 9:43
by Marque1968
(p.s. If this is not possible, is it otherwise possible to make a button and set the name to the value of block 26_1? Thus I don't display the 26_1 block, but have the value on a button in stead)

Re: Can I use a block to go to the slide upon pressing?

Posted: Tuesday 05 March 2019 17:14
by Lokonli
Marque1968 wrote: Tuesday 05 March 2019 9:43 (p.s. If this is not possible, is it otherwise possible to make a button and set the name to the value of block 26_1? Thus I don't display the 26_1 block, but have the value on a button in stead)
Yes, I think so :)

Define a button with a slide parameter and with a key parameter so it can be identified

Code: Select all

buttons.page1 = { width:12, key:'first', title:'page 1', slide:1};	
Then in custom/custom.js replace the function afterGetDevices with the following code:

Code: Select all

function afterGetDevices(){
	$('.buttons-first .state').html(alldevices["26"].Data);
}
Replace 'first' in .buttons-first with the key you used in the button definition.

Re: Can I use a block to go to the slide upon pressing?

Posted: Sunday 10 March 2019 9:53
by Marque1968
I am sorry, I haven been trying for over an hour and a half now, but to no avail. I have tried to search online how afterGetDevices() works, but to my surprise, the above is the only example google is aware of. All other references are to people showing their custom.js with the default empty function.

BUT I must add, to test general working of custom_2/custom.js I added a precense indicater I found online:
Spoiler: show

Code: Select all

function getBlock_148(device,idx){ //change 233 to the idx of your device!
   $('.block_'+idx).attr('onclick','switchDevice(this)');
   var html='';
   html+='<div class="col-xs-4 col-icon">';
      if(device['Status']=='Off') html+=iconORimage(idx,'fa-toggle-off','','off icon');
      else html+=iconORimage(idx,'fa-toggle-on','','on icon');
   html+='</div>';
   html+='<div class="col-xs-8 col-data">';
   html+='<strong class="title">'+device['Name']+'</strong><br />';
   if(device['Status']=='Off') html+='<span class="state">AFWEZIG</span>';
   else html+='<span class="state">AANWEZIG</span>';
   if(_SHOW_LASTUPDATE) html+='<br /><span class="lastupdate">'+moment(device['LastUpdate']).format(_LASTUPDATE_FORMAT)+'</span>';
   html+='</div>';
   return html;
But this one is not working for me either. So I am a bit at a loss here...

Re: Can I use a block to go to the slide upon pressing?

Posted: Sunday 10 March 2019 11:10
by Lokonli
Marque1968 wrote: Sunday 10 March 2019 9:53 I am sorry, I haven been trying for over an hour and a half now, but to no avail. I have tried to search online how afterGetDevices() works, but to my surprise, the above is the only example google is aware of. All other references are to people showing their custom.js with the default empty function.

BUT I must add, to test general working of custom_2/custom.js I added a precense indicater I found online:
Spoiler: show

Code: Select all

function getBlock_148(device,idx){ //change 233 to the idx of your device!
   $('.block_'+idx).attr('onclick','switchDevice(this)');
   var html='';
   html+='<div class="col-xs-4 col-icon">';
      if(device['Status']=='Off') html+=iconORimage(idx,'fa-toggle-off','','off icon');
      else html+=iconORimage(idx,'fa-toggle-on','','on icon');
   html+='</div>';
   html+='<div class="col-xs-8 col-data">';
   html+='<strong class="title">'+device['Name']+'</strong><br />';
   if(device['Status']=='Off') html+='<span class="state">AFWEZIG</span>';
   else html+='<span class="state">AANWEZIG</span>';
   if(_SHOW_LASTUPDATE) html+='<br /><span class="lastupdate">'+moment(device['LastUpdate']).format(_LASTUPDATE_FORMAT)+'</span>';
   html+='</div>';
   return html;
But this one is not working for me either. So I am a bit at a loss here...
This is pretty old code, and indeed doesn't work anymore. We are preparing to update the user documentation. That will be a good moment to provide working examples again.

Re: Can I use a block to go to the slide upon pressing?

Posted: Monday 18 March 2019 12:05
by Marque1968
p.s. Any idea when the updated documentation will be released?

Re: Can I use a block to go to the slide upon pressing?

Posted: Monday 18 March 2019 13:26
by HansieNL
@Marque1968 : you can find work in progress here https://dashticz-v2.readthedocs.io/en/latest/index.html

Re: Can I use a block to go to the slide upon pressing?

Posted: Monday 18 March 2019 19:34
by Lokonli
HansieNL wrote: Monday 18 March 2019 13:26 @Marque1968 : you can find work in progress here https://dashticz-v2.readthedocs.io/en/latest/index.html
You are a bit early. Work in progress...