irtrans plugin- handholding

It’s been years since i coded anything and i really am at a loss for lua. But i started reading the lua tutorial on their website that someone was kind enough to aim me at.

And I saw the panasonic tv plugin that guessed is working on and decided it wouldnt be impossible to try to figure out how to use that as a basis to run an irtrans ethernet to ir dongle.

The irtrans box is able to learn several “remotes” and the “commands” they would issue (you have to teach it via a program you run on a pc). Then you can get it to fire a command by calling a webpage at:

http://192.168.xxx.xxx/send.htm?remote=&command=

So unless I’m a complete idiot (possible here so be gentle if true ;D )seems basically all i need to do is fiddle with guessed’s tv plugin so rather then sending commands over serial all i have to do is use the luup.inet.wget command to call the pages the irtrans wants and presto chango I’m in business. Just brainstorming looks like I’d do something like: (please ignore the syntax as i know it’s completely wrong- I’d need to sit down with the lua tutorial in front of me to get the right syntax.)

define the variable named “remote” and the variable named “command” based on the particular thing I’m trying to do using the naming convention from the irtrans. (for the tv device I’d define “remote” for the tv once at the top and then the commands as i went along- so could just as easily make a dvd device following the same, etc)

then define a variable named “URL”
“URL” = http://192.168.xxx.xxx/send.htm?remote= + “remote” + &command=+ “command” +

then do
luup.inet.wget “URL”

supposedly the calling the irtrans that way even returns a status page so i could get the status back if it’s successful or not. If I get crazy I could try to dump that to the log (someone fancier might make it try again on a fail and then display a result on the vera after 2 bad tries or something)

so am i totally out there or is that basically what i’m aiming at?

thanks

Yes, that’s basically how it’s done, along with some general “parametrization” for things like the IP Address and the named-remote (code can be skimmed from Weather Plugin etc).

Note that there are other “actions” that can be defined. My Plugin only defines those actions relevant to a TV (and for which I could find a Panasonic counterpart “command”)

In these cases, you just need to add these additional definitions (things like Amps have more “Actions” than TVs, for example) by looking up the standard ones that ship with Vera.

You’ll get most of the string concat operators (etc) you need to glue things together from the Weather Plugin.