Logic Machine Forum
Combo box on visualization - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Visualization (https://forum.logicmachine.net/forumdisplay.php?fid=9)
+--- Thread: Combo box on visualization (/showthread.php?tid=1340)



Combo box on visualization - gdimaria - 17.04.2018

Hi, 

I would like to put a combo box on in visualization from wich I can choose a value (taken from an array, string in that case) to update a address group.

Do you have any solution?

Thank you

Peppe


RE: Combo box on visualization - admin - 17.04.2018

Add Custom values to control object and set Control type to "Custom value select" in Vis. parameters


RE: Combo box on visualization - gdimaria - 17.04.2018

(17.04.2018, 10:04)admin Wrote: Add Custom values to control object and set Control type to "Custom value select" in Vis. parameters

Sorry, I don't understand

Can you give me an example?


RE: Combo box on visualization - Daniel - 17.04.2018

(17.04.2018, 10:37)gdimaria Wrote:
(17.04.2018, 10:04)admin Wrote: Add Custom values to control object and set Control type to "Custom value select" in Vis. parameters

Sorry, I don't understand

Can you give me an example?



RE: Combo box on visualization - gdimaria - 17.04.2018

Thank you so much!

I just need the last puzzle card: how I can do the above via script? I need to:
1) read an array of string
2) create or update the display text value for every object value with each string of the array

BR

Peppe


RE: Combo box on visualization - admin - 17.04.2018

Can you explain what kind of task do you have? Another solution is to create html select element via Custom JavaScript.


RE: Combo box on visualization - gdimaria - 17.04.2018

(17.04.2018, 13:04)admin Wrote: Can you explain what kind of task do you have? Another solution is to create html select element via Custom JavaScript.

That's my script:



------

ok I can get the playlist name to play with your hints, but... I get the playlists every time with:

playlists = http://192.168.0.107/api/v1/listplaylists

which an array. So i have to update time by time the value on '32/1/19' with the elements of the array.

value = event.getvalue()
address = event.dst

if value then
 
 playlist = grp.getvalue('32/1/19')
 
 
 
require('socket.http')
socket.http.TIMEOUT = 5

 socket.http.request('http://192.168.0.107/api/v1/commands/?cmd=playplaylist&name='..playlist)
 os.sleep(2)

 grp.update(address, 0)
end


RE: Combo box on visualization - admin - 18.04.2018

You can overwrite custom values with grp.create. You will need a scheduled script to reload playlist from time to time. You will also need to put this list into storage so you can get playlist name from numeric object value in your event script.

Code:
grp.create({
  address = '32/1/1',
  enums = {
    [0] = 'Playlist 1',
    [1] = 'Playlist 2',
    [2] = 'Playlist 3'
  },
})

This will still require visualization reload in case custom values are changed.


RE: Combo box on visualization - gdimaria - 18.04.2018

Great!

Thank you so much.

Peppe


RE: Combo box on visualization - gdimaria - 20.04.2018

(18.04.2018, 08:35)admin Wrote: You can overwrite custom values with grp.create. You will need a scheduled script to reload playlist from time to time. You will also need to put this list into storage so you can get playlist name from numeric object value in your event script.

Code:
grp.create({
 address = '32/1/1',
 enums = {
   [0] = 'Playlist 1',
   [1] = 'Playlist 2',
   [2] = 'Playlist 3'
 },
})

This will still require visualization reload in case custom values are changed.

Please, can you give me the right code to require visualization reload by button clicking?


RE: Combo box on visualization - Erwin van der Zwart - 20.04.2018

Hi,

Here is a JS code sample to reload visu by KNX command:
Code:
$(function(){
if (typeof grp != 'undefined') {
  grp.listen('10/1/1', function(object, state) {
    var value = object.value;
    if (state == 'value') {
      if (value == true) {
        location.reload();
      }
    }
  });
}
});
BR,

Erwin


RE: Combo box on visualization - gdimaria - 23.04.2018

(20.04.2018, 12:30)Erwin van der Zwart Wrote: Hi,

Here is a JS code sample to reload visu by KNX command:
Code:
$(function(){
if (typeof grp != 'undefined') {
  grp.listen('10/1/1', function(object, state) {
    var value = object.value;
    if (state == 'value') {
      if (value == true) {
        location.reload();
      }
    }
  });
}
});
BR,

Erwin

Thank you! Wink