Here are some Tips for iTach, IR and UI7

After trying for a long time to add a device to control an IR command, it suddenly dawned on me that that I actually don’t want devices at such tasks. I don’t want to have a device where I can lower the screen etc. Because Vera is not an extra remote, it’s a “scene tool”. The screen should be lowered based solely on a scene. Watching Netflix is a scene where many things happen, not a collection of devices. So here are my tips.

[size=12pt]Tip 1.[/size]
Don’t use devices for IR commands. Instead:

[ol][li]You don’t need the Global Cache GC100 app for this. Actually, no app is needed on Vera for this to work.
[/li]
[li]Create a text file called “ircommand.lua” (see attachement), and saved it under “/usr/lib/lua”.
NOTICE: You MUST configure this file based on your needs and settings. See below.
[/li]
[li]Execute the command “luup.reload()”. From “Apps | Develop apps | Test luup code (LUA)”[/li][/ol]
Now you can send IR commands to the AV system using LUA in scenes. There are no need for any Vera devices. I put the LUA code into a scene like this example:

[font=courier]require “ircommand”
ircommand.benqon()
ircommand.screendown()
ircommand.stream()[/font]

This will lower the Screen, turn on the projector and turn on the AVR and activate the HDMI where Chromecast is connected. (Yes, I now use this method instead of an app for the AVR.)
I also have other devices configured normally in the same scene like turning off the lights etc.

About step 2:
You will need to adjust the IP address in the file. Only IP though, the port is correct. Look for this line:

[font=courier]c = assert(socket.connect(“192.168.1.97”, 4998))[/font]

The need for IR commands to end with “,\r” is handled in the code. Do not apply this at the end of your IR codes.
Add your IR codes based on your need and name the functions thereafter. The module name and the function name builds the command you will use in your scene.
The file I attached have some comments which might assist.

[size=12pt]Tip 2.[/size]
When using iLearn to fetch IRs from the remote, set the Format to “GC Compressed” when learning. This will solve the problems reading long IR commands. E.g. I was not able to fetch any working code from my Onkyo AVR remote before using the compressed format. After iTach has read it, set the Format back to “Global Cache” before you press Edit. Then it will be copied correctly into the “Edit view” field, and is now ready to be copied to the file mentioned in Tip 1.

[size=12pt]Tip 3.[/size]
Try the commands in “Apps | Develop apps | Test luup code (LUA)” before applying them to scenes. Remember to start with: require “ircommand”.

If anyone see any issue in the LUA file, or suggestions to do it better please give feedback.

Hope this can be of help. (It would have been for me when first starting on the “iTach, IR and UI7” path :wink: )

Thanks to wilme2 for the code I reused here. See [url=http://forum.micasaverde.com/index.php/topic,32420.msg299775.html#msg299775]http://forum.micasaverde.com/index.php/topic,32420.msg299775.html#msg299775[/url]

Other resources used was:
[url=https://www.globalcache.com/files/docs/API-iTach.pdf]404 Error
[url=http://lua-users.org/wiki/ModulesTutorial]http://lua-users.org/wiki/ModulesTutorial[/url]

Worked really well and an elegant simple approach to Ir control with the iTach. Had spent 6 hours trying to add my devices and given up :'(…thank you for sharing

Works Great! months waiting to use my itach vith Vera. Thank You!

rostmo:
thanks very much for sharing this approach that will allow me to control air conditioners by vera

after review and implement all the steps for implement your solution, i stopped in the step 2:
"Create a text file called “ircommand.lua” (see attachement), and saved it under “/usr/lib/lua”.

i’ve the “ircommand.lua” whit the IR codes for my equipement created and stored in my windows pc, but i can’t figurite out how transfer it to /usr/lib/lua dir in vera
i must reocnginze that i don?t have any expirience and knowledge about unix and SSH

i need step by step instructions to transfer de file from my pc to the vera system

could yo please help me?

Best Regards
Cristian

@cormaza:

Step 1:
You will need to connect to your Vera with a file browser. If you are using Windows I recommend you download WinSCP. Download from here: WinSCP :: Official Site :: Download

Step 2:
After installation of WinSCP you should be able to log into Vera by using it’s IP.
Username is: root
password is noted under your Vera as the WIFI password

After you press login. You will then see all the files in Vera in the right pane.

Step 3:
You should now be able to navigate to the following path in the Vera File system:

/usr/lib/lua

Step 4:
In WinSCP locate the new lua file from your local drive. Navigate in the left pane to the correct path where the fie is located.

Than drag it over to the right pane, so it is copied to Vera. IMPORTANT: Make sure you are on the correct location in Vera, that is /usr/lib/lua

That should be it. Remember Tip 1, #3 in the original post. That is: luup.realod().

Please inform if I can assist further.

[quote=“rostmo, post:5, topic:195673”]@cormaza:

Step 1:
You will need to connect to your Vera with a file browser. If you are using Windows I recommend you download WinSCP. Download from here: WinSCP :: Official Site :: Download

Step 2:
After installation of WinSCP you should be able to log into Vera by using it’s IP.
Username is: root
password is noted under your Vera as the WIFI password

After you press login. You will then see all the files in Vera in the right pane.

Step 3:
You should now be able to navigate to the following path in the Vera File system:

/usr/lib/lua

Step 4:
In WinSCP locate the new lua file from your local drive. Navigate in the left pane to the correct path where the fie is located.

Than drag it over to the right pane, so it is copied to Vera. IMPORTANT: Make sure you are on the correct location in Vera, that is /usr/lib/lua

That should be it. Remember Tip 1, #3 in the original post. That is: luup.realod().

Please inform if I can assist further.[/quote]

dear rostmo:
i folowed the detailed step by step instructions for transfet the file to vera. result: i’m controlling my ac conditioners (2) from scenes in vera :slight_smile:

thank you very much for your help!!!

Best regards
Cristian

+1 to rostmo for the excellent instructions to log into my Vera (and NAS). It may come in handy one day.

Hi @rostmo

Thanks for sharing this.

Seeing as you are using the GC100, have you got any examples that uses the serial port / RS232 connections ?

A ‘sendser’ function to add to your ‘sendir’ :slight_smile:

@parkerc

Hi.

Sorry for delayed reply.

No, I haven’t done any other testing with this. Though I have had a private mail dialog with another user here (based on this thread) who used GC Flex. I can confirm that worked fine.

I think it ill work though, just apply the correct commands for RS232. The LUA file only opens IP connection to an IP host and submit a command which the host can understand. Rather simple. You might need to remove the “/r” which is added to the lines which is needed for IR (I’m not sure if it’s needed for RS232). Test with or without it to see which work. Remember to execute luup.reaload() when updating the LUA file.

I’m planning to do the same with my AVR. That means not using IR but communicate directly with IP to the AVR. I just haven’t had the time yet. IR is not a good solution for controlling volume, as it submits it by steps up or down. I want to send a certain volume percent (e.g. 65%) in one command. I will update when I have tried it.

Br
Rostmo.

Thank You Rostmo !!

You are a life saver !!

I have managed to get multiple Flex units working on IR.

Now for the holy grail of Serial …

I am anxiously waiting to see if anyone has had any success.

I think it is a different beast as the serial commands are different to the IR …

[quote=“jjwork”]Thank You Rostmo !!

You are a life saver !!

I have managed to get multiple Flex units working on IR.

Now for the holy grail of Serial …

I am anxiously waiting to see if anyone has had any success.

I think it is a different beast as the serial commands are different to the IR …[/quote]
Can you show me (post here) a command that you know is correct for the serial? I can see if I can add it to the file.

Sent fra min E6653 via Tapatalk

Here is a code example of how to you talk to a ITach Flex is that is configured for Serial comms
This is to talk to a Monoprice 6-zone audio amp

local socket = require("socket")
host = "1.0.0.5"
c = assert(socket.connect(host, 4999))
c:settimeout(5)
 
local sres, serr = c:send("<10PR01\r")
local data, rerr = c:receive(8)
luup.sleep(1000)
c:close()

Some things to know about the Serial.
They don’t all require a return code at the end. Monoprice specifically asks for the “\r” return code at the end.
You do actually have to listen for a receive, the iTach won’t take another send command if it gets a response and you don’t call receive. (monoprice always sends back a 8 char response which is why I use 8. Not sure if the buffer and response actually have to match though).
I also noticed you can close the connection too early and Monoprice will just stop processing the commands you sent. So I put a sleep in before the closing of the socket particularly if you are sending a bunch of commands (I break them in to no more than 6 commands in a row than sleep for a second, etc). Definitely sleep before you close the socket if sending more than 4 or 5 commands.

[quote=“jjwork, post:10, topic:195673”]Thank You Rostmo !!

I have managed to get multiple Flex units working on IR.[/quote]

Hello gentlemen,

How did you manage to use several units ?
The IP address of the unit is adjusted in the file “ircommand.lua”.
Help appreciate
Regards.

[quote=“sebpoterie, post:13, topic:195673”]Hello gentlemen,

How did you manage to use several units ?
The IP address of the unit is adjusted in the file “ircommand.lua”.
Help appreciate
Regards.[/quote]

You can have two units by either:
1: Create another lua-file. E.g. ir2command.lua which have another IP set. This might be the easiest if you’re not familliare with programming.

or

2: Add a parameter to the function, and use an IF-ELSE clause to set the IP into a variable at the top of the ircommand.lua file.

Hope this helps.

Many thanks.

Hi @shallowearth

just an FYI - I understand from reading other threads that luup.sleep is not the best thing to use as it can cause restarts.

I haven’t seen any restarts using that code on my Vera edge. It has been very stable. But The sleeps are very short and could probably be reduced even further, if you see instability. General the sleep commons is s problem of you are talking long sleeps. This is just a second pause to allow the itach to catchup.

Hi
I have tried controlling an iTach as descibed in this post.
I have modified the ircommand.lua file and have uploaded it to my vera… but when i try a command i get “Failed to test code” error.
Although if i use the code From wilme2 it works!!
Any ideas?

[quote=“JCH”]Hi
I have tried controlling an iTach as descibed in this post.
I have modified the ircommand.lua file and have uploaded it to my vera… but when i try a command i get “Failed to test code” error.
Although if i use the code From wilme2 it works!!
Any ideas?[/quote]
I had similar issues and one I started again using the provided Scipt as a template again and working through step by step it worked. I guess I am suggesting to check your code logic

Question for the script experts. Is it possible to add to the lua script that first time the script is executed it will send xyz IR command and second time it is executed it will send xyz IR command ( I assume a count of 1st 2nd will be required to be held somewhere).
The purpose of this will be when I assign the scene to a physical button I can turn on all AV units and with the second press of the same physical button (second time the scene is executed) turn off all the required AV units (as one of the units has a different on/off IR command)