Author Topic: Show saved values in input control  (Read 162 times)

Offline Deeps

  • Newbie
  • *
  • Posts: 16
  • Karma: +0/-0
Show saved values in input control
« on: July 05, 2018, 06:07:48 am »
Hi

I have UI to show some input controls and save button.
on save click I read values and save it using
luup.variable_set(SPECTRUM_SERVICE_ID, "onTime", onTime, LUL_DEVICE);

during startup I again read it using
onTime = luup.variable_get(SPECTRUM_SERVICE_ID,"onTime",lul_device);

I get proper values. But now I need to show my input control prefilled with this previously saved values. How can i do this
  My input control is as follow

{
            "ControlGroup": "1",
            "ControlType": "input",
            "ID": "on_time",
            "Display": {
               "Left": 70,
               "Width": 200,
               "Height": 20
            }
         },


Offline rigpapa

  • Sr. Member
  • ****
  • Posts: 467
  • Karma: +66/-0
Re: Show saved values in input control
« Reply #1 on: July 05, 2018, 05:45:57 pm »
Hi

I have UI to show some input controls and save button.
on save click I read values and save it using
luup.variable_set(SPECTRUM_SERVICE_ID, "onTime", onTime, LUL_DEVICE);

during startup I again read it using
onTime = luup.variable_get(SPECTRUM_SERVICE_ID,"onTime",lul_device);

I get proper values. But now I need to show my input control prefilled with this previously saved values. How can i do this
  My input control is as follow

{
            "ControlGroup": "1",
            "ControlType": "input",
            "ID": "on_time",
            "Display": {
               "Left": 70,
               "Width": 200,
               "Height": 20
            }
         },

Try this...


{
    "ControlGroup": "1",
    "ControlType": "input",
    "ID": "on_time",
    "Display": {
        "Left": 70,
        "Width": 200,
        "Height": 20,
        "Service": "your-service-id-goes-here",
        "Variable": "onTime"

    },
...
Author of Rachio, Deus Ex Machina II, Intesis WMP Gateway, SiteSensor, DelayLight, Auto Virtual Thermostat and VirtualSensor plugins. Vera Plus w/100+ Z-wave devices. Vera3 sandbox.

Offline Deeps

  • Newbie
  • *
  • Posts: 16
  • Karma: +0/-0
Re: Show saved values in input control
« Reply #2 on: July 06, 2018, 02:02:01 am »
Hey thank you
It worked ...thank you very much

Offline Deeps

  • Newbie
  • *
  • Posts: 16
  • Karma: +0/-0
Re: Show saved values in input control
« Reply #3 on: July 06, 2018, 05:59:22 am »
Hi

I have further query to this, as its started working :)

So for example,
initially all input fields will show values 0
now user enters all valid values and now I saved it into system variables
so now whenever I refresh UI, those values are shown in input fields.

Now if user changes those values, to some invalid values(i have my own validation constraints about range and format)
So on click of save button I validate it and show error to user,without saving wrong values but that time previously stored correct values gets displayed with error, which looks confusing to user

is there any way by which I can keep currently entered values with error if any on save click