Jump to content

Testing if a remote button has been pressed


pwaara

Recommended Posts

Posted

I'm still trying to get my remotes to behave they way I want them to. Ideally, my remote would be in non-toggle mode (since I cannot update its state) then when a button is pressed, it would toggle the state of the responders it was connected to. For example, I press the e button and if the light is on, it turns off; if the light was off it turns on. I tried writing a program that had a Condition saying

if 
  Control 'remote e' is switched On
  And Status 'light' is not Off
Then
  Set 'light' Off
Else
  Set 'light' On

What happens is the light cannot be turned off. It dims for a moment then turns on again. It appears that the Control statement looks at the state of the button on the remote, not the action of pressing the button. I'd like to know when the button has been pressed, not just its current state. Can that be done? Any other ideas on how to accomplish what I'm trying to do with my remote? Any help is greatly appreciated.

 

~Pat

Posted

It is the Status check that is creating the problem. When ever Status changes the Program is triggered. A Program that changes the Status of the device being checked in the If section often creates a problem.

 

Program 1

 

If

Control 'remote e' is switched On

Then

Run Program 2 (If section)

Else

 

Program 2 - must be marked Disabled to prevent change in Status triggering this Program

 

If

Status 'light' is not Off

Then

Set 'light' Off

Else

Set 'light' On

Posted

I am having a senior moment with my memory, but this sounds like the common problem where folks can fail to fully account for program triggers versus evaluation results. I can tell you that I avoid programs who's THEN or ELSE path can cause a change of the IF condition. For example, you have a THEN path which turns the "light" off. This would change the STATUS of the light from "not off" to "off". This change of status would trigger (again) the program, which could cause the ELSE path to run. In worse case you may have an infinite do loop.

 

There are a couple of options to avoid this problem. One is to use integer variables as a representation of light status (integer variables, when used in a program IF condition, do not trigger an evaluation when they change). Using this method may require a couple of programs to accomplish, such as:

 

if

status light is not off

then

set integer variable to 1

else

set integer variable to 0

 

if

control remote button is set on

and integer variable is = 1

then

set light off

else

set light on

 

Another option should you care to avoid the variable approach would be to break your single program into separate programs:

 

if

control remote button is set on

then

run second program (if path)

 

second program (must be disabled):

 

if

status light is not off

then

set light off

else

turn light on

 

Take your choice. There may be other options, but that should be enough to get you started. Report back if you have any problems.

 

edit: looks like LeeG beat me to it again.

Posted

Thank you LeeG and oberkc. That seems to have done the trick.

 

Just so I understand, do all programs get evaluated any time a state changes, a condition occurs, or a schedule fires? At that point any conditions that are true will execute. Is this correct?

 

~Pat

Posted

Basically, yes. STATUS conditions trigger at any change of state. CONTROL conditions trigger upon receipt of the specified control, but not other controls for the same device. FROM/TO conditions trigger only at the specified times...not anytime between.

Posted

I think I know the answer to this, but...

 

I had to remove the remote as a controller from the scene that would control the light I wanted the remote to control, since with the program, it was now getting called twice. The side effect of this is now, press and holding the remote button has no effect on the light. Do I need to create a control program for each kind of button press (e.g., press and hold and double tap)? Can I put that all in one program controlling that button or do I need separate programs for each type of button press?

 

Thanks for all of your help.

 

~Pat

Posted

If you are going to mimic all the button actions in a Program there needs to be multiple Programs.

 

One to handle On

one to handle Fast On although this might be rolled into the On Program

one to handle Dim

one to handle Bright

one to handle Off

one to handle Fast Off although this might be rolled into the Off Program

 

Each requires different commands sent to the Responder

Posted

Thanks, LeeG. That's what I thought (was afraid of). If only the remotes could act as a Responder, none of this would be necessary.

 

You have all been a great help. I truly appreciate it.

 

~Pat

Posted

More questions....

 

If I have the remote in non-toggle mode, what command gets sent if I press and hold the button? I tested it with Bright, but that didn't seem to get triggered. I was looking at the diagnostics to see if I could interpret the data going across. I see something being sent, but I don't have any clue what the codes mean. Is there and api or some reference document that describes what the codes mean in the diagnostics?

 

~Pat

Posted

The Mini Remote alternates between Bright and Dim. First press and hold issued a Fade Down/Fade Stop second press and hold issued a Fade Up/Fade Stop

 

Wed 02/19/2014 09:51:47 AM : [iNST-SRX ] 02 50 1C.27.E3 00.00.01 CB 17 00 LTMCON (DOWN)

Wed 02/19/2014 09:51:47 AM : [std-Group ] 1C.27.E3-->Group=1, Max Hops=3, Hops Left=2

Wed 02/19/2014 09:51:47 AM : [ 1C 27 E3 1] BMAN 0

Wed 02/19/2014 09:51:47 AM : [iNST-SRX ] 02 50 1C.27.E3 00.00.01 CB 17 00 LTMCON (DOWN)

Wed 02/19/2014 09:51:47 AM : [std-Group ] 1C.27.E3-->Group=1, Max Hops=3, Hops Left=2

Wed 02/19/2014 09:51:47 AM : [iNST-DUP ] Previous message ignored.

Wed 02/19/2014 09:51:52 AM : [iNST-SRX ] 02 50 1C.27.E3 00.00.01 CB 18 00 LTMCOFF(00)

Wed 02/19/2014 09:51:52 AM : [std-Group ] 1C.27.E3-->Group=1, Max Hops=3, Hops Left=2

Wed 02/19/2014 09:51:52 AM : [ 1C 27 E3 1] SMAN 0

Wed 02/19/2014 09:51:52 AM : [ 1C 27 E3 1] ST 0

Wed 02/19/2014 09:51:52 AM : [iNST-SRX ] 02 50 1C.27.E3 00.00.01 CB 18 00 LTMCOFF(00)

Wed 02/19/2014 09:51:52 AM : [std-Group ] 1C.27.E3-->Group=1, Max Hops=3, Hops Left=2

Wed 02/19/2014 09:51:52 AM : [iNST-DUP ] Previous message ignored.

 

 

Wed 02/19/2014 09:51:55 AM : [iNST-SRX ] 02 50 1C.27.E3 00.00.01 CB 17 01 LTMCON (UP)

Wed 02/19/2014 09:51:55 AM : [std-Group ] 1C.27.E3-->Group=1, Max Hops=3, Hops Left=2

Wed 02/19/2014 09:51:55 AM : [ 1C 27 E3 1] BMAN 1

Wed 02/19/2014 09:51:56 AM : [iNST-SRX ] 02 50 1C.27.E3 00.00.01 CB 17 01 LTMCON (UP)

Wed 02/19/2014 09:51:56 AM : [std-Group ] 1C.27.E3-->Group=1, Max Hops=3, Hops Left=2

Wed 02/19/2014 09:51:56 AM : [iNST-DUP ] Previous message ignored.

Wed 02/19/2014 09:52:01 AM : [iNST-SRX ] 02 50 1C.27.E3 00.00.01 CB 18 00 LTMCOFF(00)

Wed 02/19/2014 09:52:01 AM : [std-Group ] 1C.27.E3-->Group=1, Max Hops=3, Hops Left=2

Wed 02/19/2014 09:52:01 AM : [ 1C 27 E3 1] SMAN 0

Wed 02/19/2014 09:52:01 AM : [ 1C 27 E3 1] ST 255

Wed 02/19/2014 09:52:01 AM : [iNST-SRX ] 02 50 1C.27.E3 00.00.01 CB 18 00 LTMCOFF(00)

Wed 02/19/2014 09:52:01 AM : [std-Group ] 1C.27.E3-->Group=1, Max Hops=3, Hops Left=2

Wed 02/19/2014 09:52:01 AM : [iNST-DUP ] Previous message ignored.

 

I confirmed the Mini Remote was is non-toggle mode as it only issued On commands from single tap.

Guest
This topic is now closed to further replies.

×
×
  • Create New...