Build a string via the visualisation

Discussion in 'C-Bus Automation Controllers' started by Ks04, Dec 19, 2022.

  1. Ks04

    Ks04

    Joined:
    Dec 28, 2019
    Messages:
    107
    Likes Received:
    9
    Hi,

    I want to build a numeric keypad on a visualisation page which builds a string, then triggers an action when i press 'enter'. Is it possible to build a string in this way?

    I.e. pressing '1,2,3,4' builds a string '1234' in a user variable. Plan then is to when you push 'enter' this string is sent to an API endpoint.
     
    Ks04, Dec 19, 2022
    #1
  2. Ks04

    Pie Boy

    Joined:
    Nov 21, 2012
    Messages:
    248
    Likes Received:
    31
    Location:
    New Zealand
    I have a similar thing, here's what i did
    on the vis create a button for each number 0-9 plus an enter button, make them all preset i have GA 121 called pin_no for this
    eg
    1 = preset Ga 121 level to 1
    2 = preset Ga 121 level to 2 and so on
    0 = preset Ga 121 level to 10
    enter = preset GA 121 level to 15

    then an event script on GA 121 to manage the rest

    Code:
    local pin = event.getvalue()
    
    if pin == 15 then -- enter has been pressed
     
     last = storage.get('pin_store')
      log(last)
    -- execute some function here
      storage.set('pin_store', nil)
    end
    
    
    if pin >=1 and pin <=10 then
     
      last = storage.get('pin_store')
     
      if not last then -- this will get the first press if storage has no value
        storage.set('pin_store', tostring(pin))
      else
     
        storage.set('pin_store', last .. tostring(pin))
     
     end
    end
     
    SetLightingLevel(121, 50, 0)  -- reset GA to something not between 1-10 so a number can be used twice
    
     
    Last edited: Dec 19, 2022
    Pie Boy, Dec 19, 2022
    #2
  3. Ks04

    Pie Boy

    Joined:
    Nov 21, 2012
    Messages:
    248
    Likes Received:
    31
    Location:
    New Zealand
    Forum is screwing up the code formatting again.................... there is some ' and , and ) missing etc....
     
    Last edited: Dec 20, 2022
    Pie Boy, Dec 20, 2022
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.