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

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 #15 on: September 08, 2017, 04:02:29 am »
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.

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.

Offline shallowearth

  • Hero Member
  • *****
  • Posts: 919
  • Karma: +42/-9
Re: Here are some Tips for iTach, IR and UI7
« Reply #16 on: September 08, 2017, 11:53:18 am »
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.

Offline JCH

  • Jr. Member
  • **
  • Posts: 51
  • Karma: +0/-0
Re: Here are some Tips for iTach, IR and UI7
« Reply #17 on: September 27, 2017, 01:27:34 am »
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?

Offline PrincessCleavage

  • Jr. Member
  • **
  • Posts: 90
  • Karma: +2/-1
Re: Here are some Tips for iTach, IR and UI7
« Reply #18 on: September 30, 2017, 11:18:50 pm »
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?
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

Offline PrincessCleavage

  • Jr. Member
  • **
  • Posts: 90
  • Karma: +2/-1
Re: Here are some Tips for iTach, IR and UI7
« Reply #19 on: September 30, 2017, 11:24:38 pm »
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)

Offline rostmo

  • Newbie
  • *
  • Posts: 12
  • Karma: +1/-0
Re: Here are some Tips for iTach, IR and UI7
« Reply #20 on: October 01, 2017, 04:03:40 am »
@JCH:
I suspect an error in the LUA-file. You might post it her (as an attchement) so it can be examined, or you can PM it to me and I'll have a look.   


@PrincessCleavage:
If I understand your need correctly I suggest you do not apply that logic into the LUA-file, but solve it before the LUA call. Two approaches:

1. Add an IF-ELSE clause in the Scene Edit (where you call the ircommand's). Then you can send the commands needed from the LUA file based on what's inside the clause. You will need a virtual switch which tracks the status (ON/OFF). The IF-ELSE clause reads from this virtual switch. See http://wiki.micasaverde.com/index.php/Luup_Scenes_Events.

2. This might be the simplest approach. Use the Program Logic Event plugin. As soon as you start using and understand this plugin you will see how to apply the solution to your problem.

Offline PrincessCleavage

  • Jr. Member
  • **
  • Posts: 90
  • Karma: +2/-1
Re: Here are some Tips for iTach, IR and UI7
« Reply #21 on: October 01, 2017, 06:46:33 am »
@JCH:
I suspect an error in the LUA-file. You might post it her (as an attchement) so it can be examined, or you can PM it to me and I'll have a look.   


@PrincessCleavage:
If I understand your need correctly I suggest you do not apply that logic into the LUA-file, but solve it before the LUA call. Two approaches:

1. Add an IF-ELSE clause in the Scene Edit (where you call the ircommand's). Then you can send the commands needed from the LUA file based on what's inside the clause. You will need a virtual switch which tracks the status (ON/OFF). The IF-ELSE clause reads from this virtual switch. See http://wiki.micasaverde.com/index.php/Luup_Scenes_Events.

2. This might be the simplest approach. Use the Program Logic Event plugin. As soon as you start using and understand this plugin you will see how to apply the solution to your problem.
Thanks for the tips rosmoto, can I have the virtual switch change each time I execute the scene ( as the avr has not network link to check on or off status).
So far I have created several scenes for on or off of my RF devices and they all work as expected. Would it be possible to assist with the line of code that I should add to change the virtual switch and execute scene 1 or scene 2 (on or off for the AVr amp) please

Offline rostmo

  • Newbie
  • *
  • Posts: 12
  • Karma: +1/-0
Re: Here are some Tips for iTach, IR and UI7
« Reply #22 on: October 01, 2017, 09:11:33 am »
OK, I created a script which monitor the "status" of my BENQ projector. (Because the projector will turn on if I by error try to turn it off when its already off).

You should be able to use it for your purpose. The virtual switch (plugin) has ID 100 in my installation. You will need to find the unique ID in your setup and adjust the line "LOCAL dID = 100". The rest should work if you use the same addon as in my setup.

This code will NOT try to turn off the BENQ if it's not ON. IF the projector is ON it will turn off and set the virtual switch to off.

require "ircommand"
local dID = 100
local sID = "urn:upnp-org:serviceId:VSwitch1"
local TEMP= luup.variable_get(sID, "Status", dID)
if (TEMP == "1") then
     ircommand.benqoff()
     luup.call_action(sID, "SetTarget", {newTargetValue = "0"}, dID)
end
ircommand.screenup()


This is another scene for turning everything on:

require "ircommand"
local dID = 100
local sID = "urn:upnp-org:serviceId:VSwitch1"
luup.call_action(sID, "SetTarget", {newTargetValue = "1"}, dID)
ircommand.screendown()
ircommand.benqon()
ircommand.stream()


I use two scenes in my case above, but you can combine the two actions into one scene so you can use the same physical button trigger the same scene and send different ircommands based on status like this:

require "ircommand"
local dID = 100
local sID = "urn:upnp-org:serviceId:VSwitch1"
local TEMP= luup.variable_get(sID, "Status", dID)
if (TEMP == "1") then
     ircommand.benqoff()
     luup.call_action(sID, "SetTarget", {newTargetValue = "0"}, dID)
else
    ircommand.benqon()
    luup.call_action(sID, "SetTarget", {newTargetValue = "1"}, dID)
end


« Last Edit: October 01, 2017, 09:18:00 am by rostmo »

Offline PrincessCleavage

  • Jr. Member
  • **
  • Posts: 90
  • Karma: +2/-1
Re: Here are some Tips for iTach, IR and UI7
« Reply #23 on: October 01, 2017, 09:23:53 am »
OK, I created a script which monitor the "status" of my BENQ projector. (Because the projector will turn on if I by error try to turn it off when its already off).

You should be able to use it for your purpose. The virtual switch (plugin) has ID 100 in my installation. You will need to find the unique ID in your setup and adjust the line "LOCAL dID = 100". The rest should work if you use the same addon as in my setup.

This code will NOT try to turn off the BENQ if it's not ON. IF the projector is ON it will turn off and set the virtual switch to off.

require "ircommand"
local dID = 100
local sID = "urn:upnp-org:serviceId:VSwitch1"
local TEMP= luup.variable_get(sID, "Status", dID)
if (TEMP == "1") then
     ircommand.benqoff()
     luup.call_action(sID, "SetTarget", {newTargetValue = "0"}, dID)
end
ircommand.screenup()


This is another scene for turning everything on:

require "ircommand"
local dID = 100
local sID = "urn:upnp-org:serviceId:VSwitch1"
luup.call_action(sID, "SetTarget", {newTargetValue = "1"}, dID)
ircommand.screendown()
ircommand.benqon()
ircommand.stream()


I use two scenes in my case above, but you can combine the two actions into one scene so you can use the same physical button trigger the same scene and send different ircommands based on status like this:

require "ircommand"
local dID = 100
local sID = "urn:upnp-org:serviceId:VSwitch1"
local TEMP= luup.variable_get(sID, "Status", dID)
if (TEMP == "1") then
     ircommand.benqoff()
     luup.call_action(sID, "SetTarget", {newTargetValue = "0"}, dID)
else
    ircommand.benqon()
    luup.call_action(sID, "SetTarget", {newTargetValue = "1"}, dID)
end

Thanks I will give it a try tomorrow morning and report back.

Offline PrincessCleavage

  • Jr. Member
  • **
  • Posts: 90
  • Karma: +2/-1
Re: Here are some Tips for iTach, IR and UI7
« Reply #24 on: October 01, 2017, 09:19:19 pm »
OK, I created a script which monitor the "status" of my BENQ projector. (Because the projector will turn on if I by error try to turn it off when its already off).

You should be able to use it for your purpose. The virtual switch (plugin) has ID 100 in my installation. You will need to find the unique ID in your setup and adjust the line "LOCAL dID = 100". The rest should work if you use the same addon as in my setup.

This code will NOT try to turn off the BENQ if it's not ON. IF the projector is ON it will turn off and set the virtual switch to off.

require "ircommand"
local dID = 100
local sID = "urn:upnp-org:serviceId:VSwitch1"
local TEMP= luup.variable_get(sID, "Status", dID)
if (TEMP == "1") then
     ircommand.benqoff()
     luup.call_action(sID, "SetTarget", {newTargetValue = "0"}, dID)
end
ircommand.screenup()


This is another scene for turning everything on:

require "ircommand"
local dID = 100
local sID = "urn:upnp-org:serviceId:VSwitch1"
luup.call_action(sID, "SetTarget", {newTargetValue = "1"}, dID)
ircommand.screendown()
ircommand.benqon()
ircommand.stream()


I use two scenes in my case above, but you can combine the two actions into one scene so you can use the same physical button trigger the same scene and send different ircommands based on status like this:

require "ircommand"
local dID = 100
local sID = "urn:upnp-org:serviceId:VSwitch1"
local TEMP= luup.variable_get(sID, "Status", dID)
if (TEMP == "1") then
     ircommand.benqoff()
     luup.call_action(sID, "SetTarget", {newTargetValue = "0"}, dID)
else
    ircommand.benqon()
    luup.call_action(sID, "SetTarget", {newTargetValue = "1"}, dID)
end

Simple but Elegant!
Works great!
Thanks a million Rostmo
I used the below code with virtual switch app (Id 133) and substituted my IR calls for Rostmo IR calls:
require "ircommand"
local dID = 100
local sID = "urn:upnp-org:serviceId:VSwitch1"
local TEMP= luup.variable_get(sID, "Status", dID)
if (TEMP == "1") then
     ircommand.benqoff()
     luup.call_action(sID, "SetTarget", {newTargetValue = "0"}, dID)
else
    ircommand.benqon()
    luup.call_action(sID, "SetTarget", {newTargetValue = "1"}, dID)
end

Offline PrincessCleavage

  • Jr. Member
  • **
  • Posts: 90
  • Karma: +2/-1
Re: Here are some Tips for iTach, IR and UI7
« Reply #25 on: October 01, 2017, 11:26:25 pm »
OK, I created a script which monitor the "status" of my BENQ projector. (Because the projector will turn on if I by error try to turn it off when its already off).

You should be able to use it for your purpose. The virtual switch (plugin) has ID 100 in my installation. You will need to find the unique ID in your setup and adjust the line "LOCAL dID = 100". The rest should work if you use the same addon as in my setup.

This code will NOT try to turn off the BENQ if it's not ON. IF the projector is ON it will turn off and set the virtual switch to off.

require "ircommand"
local dID = 100
local sID = "urn:upnp-org:serviceId:VSwitch1"
local TEMP= luup.variable_get(sID, "Status", dID)
if (TEMP == "1") then
     ircommand.benqoff()
     luup.call_action(sID, "SetTarget", {newTargetValue = "0"}, dID)
end
ircommand.screenup()


This is another scene for turning everything on:

require "ircommand"
local dID = 100
local sID = "urn:upnp-org:serviceId:VSwitch1"
luup.call_action(sID, "SetTarget", {newTargetValue = "1"}, dID)
ircommand.screendown()
ircommand.benqon()
ircommand.stream()


I use two scenes in my case above, but you can combine the two actions into one scene so you can use the same physical button trigger the same scene and send different ircommands based on status like this:

require "ircommand"
local dID = 100
local sID = "urn:upnp-org:serviceId:VSwitch1"
local TEMP= luup.variable_get(sID, "Status", dID)
if (TEMP == "1") then
     ircommand.benqoff()
     luup.call_action(sID, "SetTarget", {newTargetValue = "0"}, dID)
else
    ircommand.benqon()
    luup.call_action(sID, "SetTarget", {newTargetValue = "1"}, dID)
end


How would I join a call to http (to sleep my media PC) into code? I already have a WOL/Ping switch setup for the PC to monitor if it is ON or OFF, if the WOL/Ping sensor is ON then would need to call:
http://I.P address of PC:Port/suspend
If the WOL/Ping sensor is OFF then it would need to Turn ON WOL/Ping App (which would send a WOL call to the device)
       
« Last Edit: October 01, 2017, 11:43:49 pm by PrincessCleavage »

Offline rostmo

  • Newbie
  • *
  • Posts: 12
  • Karma: +1/-0
Re: Here are some Tips for iTach, IR and UI7
« Reply #26 on: October 05, 2017, 01:33:04 pm »
I doesn't have anything to test this on in my setup, so this is only a guide to point you in a direction.

See this post http://forum.micasaverde.com/index.php?topic=11745.0

And this for syntax on  the wget function.
http://wiki.micasaverde.com/index.php/Luup_Lua_extensions#Module:_luup.inet

Hope this helps.


Sent fra min E6653 via Tapatalk

Offline brucehvn

  • Jr. Member
  • **
  • Posts: 75
  • Karma: +0/-3
Re: Here are some Tips for iTach, IR and UI7
« Reply #27 on: October 29, 2017, 07:44:26 am »
Wow, this is exactly what I was looking for.  I just need to control a few devices, mainly turning off and on via a scene.  Seems the wife never turns off the TV, AV receiver, and Sat box when she goes to bed.  It's just one button on the remote, but I guess that's too much work for her  ;D

If anyone needs codes for the GlobalCache for your devices, check out http://irdb.globalcache.com.  They have complete codesets for many devices already in GC format, so you don't have to use the iLearn app.