[SOLVED] | Control Type - Input Box | Save input to variable

Hey

I have been trying for a few days by looking at other plugins and trying to imitate what I see but I cannot get it working. I would appreciate any advice or direction.

I am developing a Dynamic DNS plugin and I have an Input box for domain name.

In my json file I have this:

"Control" : [{
					"ControlType" : "label",
					"Label" : {
						"lang_tag" : "command_txt",
						"text" : "Enter Domain Name:"
					},
					"Display" : {
						"Top" : 0,
						"Left" : 200,
						"Width" : 100,
						"Height" : 20
					}
				}, {
					"ControlType" : "input",
					"ID" : "domainNameEntered",
					"Display" : {
						"Top" : 20,
						"Left" : 200,
						"Width" : 200,
						"Height" : 20
					}
				}, {
					"ControlType" : "button",
					"HorizontalMultiplier" : "6",
					"Label" : {
						"lang_tag" : "domain_button",
						"text" : "Save Domain Name"
					},
					"Display" : {
						"Top" : 40,
						"Left" : 200,
						"Width" : 200,
						"Height" : 20
					},
					"Command" : {
						"Service" : "urn:sharedfunctions-com:serviceId:DDNS1",
						"Action" : "SaveDomainName",
						"Parameters" : [{	
								"Name": "domain",
								"ID" : "domainNameEntered"
							}
						]
					}
				}, 

In my S_ file I have this:


<action>
      <name>SaveDomainName</name>
        <argumentList>
         <argument>
           <name>domainNameEntered</name>
            <direction>in</direction>
		  <relatedStateVariable>newdomainName</relatedStateVariable>
          </argument>
	</argumentList>
    </action>	
  </actionList>

	  <stateVariable sendEvents="no">
			<name>newdomainName</name>                 
			<dataType>string</dataType> 
			<shortCode>newdomainname</shortCode> 
						
	</stateVariable>

and in my I_ file I have this:

<action>
			<serviceId>urn:sharedfunctions-com:serviceId:DDNS1</serviceId>
			<name>SaveDomainName</name>
			 <job>
				local newDomain = lul_settings.newdomainName
				local newDomain2 = lul_settings.domainNameEntered
			
				luup.variable_set(DDNS_SID,"DomainName",newDomain,parentDevice)
				DDNS_UpdateVar("DomainName", newDomain2)	
                                luup.task("hh",1,newDomain,4)
		         </job>
		</action>

I know that my save username button correctly runs the function from my Impl file because I have a luup.task run to be sure it gets this far… but clearly, I am not passing the input string correctly…

can anyone see anything obvious in this?
Again, I appreciate any help you give.

There is some confusion over what you are calling the argument for your action. In the json, you call it domain. In the Service file it is called domainNameEntered. The code is expecting newdomainName and domainNameEntered - even though you are only passing one argument. The names need to agree.

The value used for an Input control ID can be confusing. Actually it is only visible inside the json where it is used to define the source of the passed argument. I usually just use a number.

Thanks mate…
I am not getting this though…

So… all I want to pass is one variable to my lua script – the string input from the user when they press save…

so are you saying I just need to name everything the same?

That’s about it. You are almost there. Change the json so Name is domainNameEntered instead of domain. The value from the Input should then turn-up in newDomain2 in your code.

I don’t know if your ID name could cause a problem. If it still doesn’t work, try changing it at both the Input and the Command to “1”.

THANK YOU SO MUCH… I lost a lot of time on this one…

Thanks again

[quote=“konradwalsh, post:5, topic:186942”]THANK YOU SO MUCH… I lost a lot of time on this one…

Thanks again[/quote]

You are welcome. Vera’s json files are essentially an un-mapped swamp. Only the brave or foolhardy venture off the beaten track. I count you as brave. :wink: