Author Topic: Here are some Tips for iTach, IR and UI7  (Read 3590 times)

Offline rostmo

  • Newbie
  • *
  • Posts: 12
  • Karma: +1/-0
Here are some Tips for iTach, IR and UI7
« on: March 01, 2017, 01:34:03 pm »
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.

Tip 1.
Don't use devices for IR commands. Instead:
  • You don't need the Global Cache GC100 app for this. Actually, no app is needed on Vera for this to work.
  • 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.
  • Execute the command "luup.reload()".  From "Apps | Develop apps | Test luup code (LUA)"
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:

require "ircommand"
ircommand.benqon()
ircommand.screendown()
ircommand.stream()


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:

c = assert(socket.connect("192.168.1.97", 4998))

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.

Tip 2.
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.

Tip 3.
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  ;) )

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

Other resources used was:
https://www.globalcache.com/files/docs/API-iTach.pdf
http://lua-users.org/wiki/ModulesTutorial
« Last Edit: March 01, 2017, 02:23:25 pm by rostmo »

Offline Thomas1975

  • Newbie
  • *
  • Posts: 2
  • Karma: +0/-0
Re: Here are some Tips for iTach, IR and UI7
« Reply #1 on: March 12, 2017, 04:47:55 pm »
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

Offline FeuerMeister

  • Newbie
  • *
  • Posts: 2
  • Karma: +0/-0
Re: Here are some Tips for iTach, IR and UI7
« Reply #2 on: April 09, 2017, 09:53:29 am »
Works Great! months waiting to use my itach vith Vera. Thank You!

Offline cormaza

  • Newbie
  • *
  • Posts: 3
  • Karma: +0/-0
Re: Here are some Tips for iTach, IR and UI7
« Reply #3 on: April 11, 2017, 11:01:51 am »
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

Offline rostmo

  • Newbie
  • *
  • Posts: 12
  • Karma: +1/-0
Re: Here are some Tips for iTach, IR and UI7
« Reply #4 on: April 15, 2017, 12:47:53 pm »
@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: https://winscp.net/eng/download.php

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.
« Last Edit: April 15, 2017, 12:54:06 pm by rostmo »

Offline cormaza

  • Newbie
  • *
  • Posts: 3
  • Karma: +0/-0
Re: Here are some Tips for iTach, IR and UI7
« Reply #5 on: April 17, 2017, 01:39:47 am »

@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: https://winscp.net/eng/download.php

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.

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 :)

thank you very much for your help!!!

Best regards
Cristian

Offline Don Phillips

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +18/-16
    • Worthington Engineering, Inc.
Re: Here are some Tips for iTach, IR and UI7
« Reply #6 on: April 17, 2017, 07:16:24 pm »
+1 to rostmo for the excellent instructions to log into my Vera (and NAS). It may come in handy one day.
Vera 3, UI7 1.7.947, CT101 t-stat, Everspring motion detector, GE/Jasco switch, Leviton outlet, AeonLabs door sensor, Insteon garage control, Blue Iris, Sricam SP011, iPhone locator, APCUPSD, VeraMate, VeraAlerts, PLEG, House Modes, Countdown Timer, DVR, Virtual & Multi Switch, Weather, Sys. Mon.

Offline parkerc

  • Sr. Hero Member
  • ******
  • Posts: 2364
  • Karma: +33/-45
  • Life Moves Pretty Fast....
    • Node Central
Re: Here are some Tips for iTach, IR and UI7
« Reply #7 on: April 24, 2017, 02:17:18 pm »
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' :)


Offline rostmo

  • Newbie
  • *
  • Posts: 12
  • Karma: +1/-0
Re: Here are some Tips for iTach, IR and UI7
« Reply #8 on: May 02, 2017, 08:48:02 am »
@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.

Offline jjwork

  • Newbie
  • *
  • Posts: 1
  • Karma: +0/-0
Re: Here are some Tips for iTach, IR and UI7
« Reply #9 on: May 19, 2017, 05:18:22 am »
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 ....

Offline rostmo

  • Newbie
  • *
  • Posts: 12
  • Karma: +1/-0
Re: Here are some Tips for iTach, IR and UI7
« Reply #10 on: May 22, 2017, 02:19:01 pm »
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 ....
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


Offline shallowearth

  • Hero Member
  • *****
  • Posts: 919
  • Karma: +42/-9
Re: Here are some Tips for iTach, IR and UI7
« Reply #11 on: May 22, 2017, 04:59:02 pm »
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

Code: [Select]
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.
« Last Edit: May 22, 2017, 05:01:00 pm by shallowearth »

Offline sebpoterie

  • Newbie
  • *
  • Posts: 2
  • Karma: +0/-0
Re: Here are some Tips for iTach, IR and UI7
« Reply #12 on: August 03, 2017, 06:23:07 am »
Thank You Rostmo !!


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


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.

Offline rostmo

  • Newbie
  • *
  • Posts: 12
  • Karma: +1/-0
Re: Here are some Tips for iTach, IR and UI7
« Reply #13 on: August 29, 2017, 02:12:09 pm »

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.

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.

Offline sebpoterie

  • Newbie
  • *
  • Posts: 2
  • Karma: +0/-0
Re: Here are some Tips for iTach, IR and UI7
« Reply #14 on: August 29, 2017, 11:06:32 pm »
Many thanks.