Author Topic: Tip: Delayed IR action with iTach (e.g. lowering a screen to exact position)  (Read 80 times)

Offline rostmo

  • Newbie
  • *
  • Posts: 17
  • Karma: +1/-0
I have controlled my projector screen (and other IR devices) for a while with Vera as described in the ?NOTE? below. The problem is that my projector screen goes too far down. Adjusting the default stop mechanism of my screen (from Elite Screens) is rather cumbersome. Either it goes down to max length (default) or I have to actually open it and adjust the mechanical off (max) switch manually.

So, this is how I solved this with Vera:

NOTE: See this thread for preperation

First I clocked the screen to take exactly 55 seconds to my wanted ?max low position?.

Then I added a delayed action into the lua file (ircommand.lua) like this.

Step 1:

Code: [Select]
function screendown()
-- Prepare to send screen stop command after 55 sec
cmd = 'sendir,1:3,1,38000,1,1,17,46,17,1141,46,18,46,18,46,18,46,18,17,46,17,46,17,46,17,47,17,46,17,46,17,46,46,18,17,46,46,18,17,46,46,18,46,18,46,18,17,46,17,46,46,18,46,18,17,46,17,47,17,46,46,18,46,18,46,18,46,18,17,46,17,46,17,3700'

-- Start lowering screen
cmd = 'sendir,1:3,1,38000,1,1,47,15,47,15,47,15,47,15,15,47,15,47,15,47,15,47,15,47,47,15,15,47,15,1329,47,15,47,15,47,15,47,15,15,47,15,47,15,47,15,47,15,47,47,15,15,47,15,3379'

Step 2:

For the call_timer function to work, that means for the call_timer function too recognize the ?sendir? function, the latter needs to be global. To do this change ?function sendir(commandtosend)? to ?function _G.sendir(commandtosend)?, so the senddir function should now look like this:

Code: [Select]
function _G.sendir(commandtosend)
commandtosend = commandtosend .. ',\r'
local socket = require("socket")
c = assert(socket.connect("", 4998))
local sres, serr = c:send(commandtosend)
local data, rerr = c:receive(5)

That's all. If anyone see any issues, or suggestions to do it better please give feedback.