Jump to content

Programing Challenge


Bob Amott

Recommended Posts

Posted

Could use a great deal of help on this one. Thanks!!

Question: is there a way to program the following scenario?

On a stairway there are two Insteon Motion II detectors. One is at the Entry (at the base stairs) and the other is at the top of the stairs ((Hall-Up). There are three lights in the mix. Bottom of stairs (Entry), Middle of stairs and top in Hall at the top of the stairs.

Other switches in the mix include:

  • Entry Switch - Keypad (Insteon KeyPadLinc 5 button switch) at hallway next to the front door, bottom of stairs using Main Off and On buttons.
  • Upper Hall Switch for ENTRY switch (ToggleLinc Dimmer) at top of stairs multi linked to the KeyPadLinc at the bottom of stairs
  • Middle Stairs (Insteon InLineLinc Dimmer)
  • Upper Hall Switch (ToggleLinc Dimmer) (Used to trigger Multi Link Scene which includes A lower Switch for the upper Hall light and a lower switch for the upper hall)

The outcome to be desired is if either of the sensors sense motion then that motion triggers one of the two scenes reverent to the time of day.

Results : I’ve tried several variations of the following programs with all work perfectly when tested within the program “Run (if), Run Then. The results when running the program pretty much ignore the time parameters. Once in awhile it might work but most of the time it runs through the night program and then the Day program and at night ends up on all lights on. 

 

My attempt, which I tried several variations:

Created two 2 scenes: Day Lights & Night Lights.

Daylight:

Devices include: All the devices above at 100%

Night Lights:

Middle stairs only at 33%

ProgramContent for “Hall Day

If

‘Hallways / Hall-Up Sensor / Hall-Up.1 Motion’ is switched On

Or ‘Hallways  / Hall Entry Sensor / Entry.1 Motion’ is switched On

and  From Sunrise To Sunset  (same day)

Then

Set ‘Hallways / Hall Lights Day’ on

Wait 35 seconds

Set ‘Hallways / Hall Lights Day’  off

Else

-No Actions

 

Program Content for ‘Hall Night’

If

‘Hallways / Hall-Up Sensor / Hall-Up.1 Motion’ is switched On

Or ‘Hallways  / Hall Entry Sensor / Entry.1 Motion’ is switched On

and  From Sunset To Sunrise (next day)

Then

Set ‘Hallways /  ‘Hall Night Lights’ on

wait 20 seconds

Set ‘Hallways / Hall Night Lights’  off

Else

-No Actions

Posted

I wouldn't use programs to do any of this.  Just make a scene with the motions sensors as controllers and set the motion sensor to 20 or 30 or 40 seconds timeout, or whatever you want (sorry, can't do 35).  Not sure why you need to have the daytime timeout to be 15 seconds different from the nighttime one.  Seems like a needless complication.  But if indeed you do, you can have a program re-write the scene at sunset/sunrise.

But if you want to keep the programs, probably you need to set the motion sensor to "report on only" commands.

Posted

The actual timeouts are not the issue.  They actually work. The problem is that the scenes are not being called in relation to the time parameters stated in the “If” statement. 

Posted
7 hours ago, Bob Amott said:

The actual timeouts are not the issue.  They actually work. The problem is that the scenes are not being called in relation to the time parameters stated in the “If” statement. 

I think you have a logic (boolean hierarchy) problem in your program.  Try (same approach for both programs):

If

‘Hallways / Hall-Up Sensor / Hall-Up.1 Motion’ is switched On

Or ‘Hallways  / Hall Entry Sensor / Entry.1 Motion’ is switched On

)

and  From Sunrise To Sunset  (same day)

Then 

Set ‘Hallways / Hall Lights Day’ on

Wait 35 seconds

Set ‘Hallways / Hall Lights Day’  off

Else

-No Actions

 

  • Like 1
Posted (edited)

+1 for the order of evaluation (not, and, then or) problem, but more specifically it may be a mixture of the order of evaluation and the program re-entrant nature of the IoX programming model. Remember that each of these programs is going to get called twice as someone moves through the stairwell, once for the Hall-Up Sensor motion and once for the Hall Entry Sensor motion. In addition, the programs will both get called and sunrise and sunset each day, cancelling any running timers (and subsequent "Turn Off" commands).

Here's what may be happening:

1. Hall-Up Sensor is triggered 
2. Both programs run their Then branch (because of the order of evaluation problem), turn on their respective scenes, and start their respective waits.
3. Hall Entry Sensor is triggered within a few seconds the Hall-up Sensor
4. Both programs are run again, cancelling their respective waits (and subsequent Turn Off commands), and depending on whether it's day or night, one of the programs Then branch is run and the other's Else branch is run. Depending on what order things happen, that may be why the lights are being left on. Either way, this is not the behavior you are expecting, I imagine.

Looking at it more broadly, you may need to rethink your approach to programming in IoX (IMO, of course). Many of these types of anomalies that arise for the event-driven and re-entrant natures of the IoX model can be avoided by having two tiers of programs, a first for testing for trigger events to execute the program(s), and another for testing for conditions for conditional execution of statements (i.e., "Then" vs. "Else" branches). So in your case, a first program (e.g. "Hallway Motion"):

If

‘Hallways / Hall-Up Sensor / Hall-Up.1 Motion’ is switched On

Or ‘Hallways  / Hall Entry Sensor / Entry.1 Motion’ is switched On

Then

Run Program "Hallway Lights" (If)

Else

-No Actions

And then a second program ("Hallway Lights"):

If

From Sunrise To Sunset  (same day)

Then

Set ‘Hallways / Hall Lights Day’ on

Wait 35 seconds

Set ‘Hallways / Hall Lights Day’  off

Else

Set ‘Hallways /  ‘Hall Night Lights’ on

wait 20 seconds

Set ‘Hallways / Hall Night Lights’  off

The first program "Hallway Motion" is enabled. The second program "Hallway Lights" is disabled. What you have now is that the "Hallway Motion" program ensures that, upon motion from either sensor, the "Hallway Lights" program will be run. The "Hallway Lights" program then decides which scene to turn on based on the time of day and starts the respective wait timer. Since the "Hallway Lights" program is disabled, it will never be  triggered on its own. 

This approach is handy in most situations where the trigger events and the conditional events are really separate things, i.e. where you have conditions that you don't want to act as triggers to the programs. In addition, if there are multiple levels of conditional statements ("nested ifs") that need to be tested, then you can add additional tiers of programs to accomplish that. Moreover, again IMO, having your programs structured this way makes them more clearly self-documenting of their intended functionality.

Edited by Goose66
  • Like 2
Posted

It just seems to me that giving up the 15 second difference between night and daytime is trivial and would allow you to directly link the devices.  Direct link will work faster, use less resources, and be more obvious to edit in the future when you forgot about this program because it is buried in with a hundred other programs.  If you wanted to do something different night vs day, you could write a program that changes the on level and/or ramp rate at day vs night.

Posted

As I replied, the timeout is not critical. So I infer you are saying I should write programs that control the scenes by time day(/night) and let the sensor deal with the triggering the resulting scenes. I did not think of being able to modify a scene in the background and then calling on that modified scene having been preset to levels. I will experiment with that also.

Posted
2 hours ago, apostolakisl said:

It just seems to me that giving up the 15 second difference between night and daytime is trivial and would allow you to directly link the devices. 

@apostolakisl I think you missed the hidden part about what the program is actually doing. @Bob Amott has different brightness levels based on time of day/night that he is trying to trigger. It's not the difference of on time. 

 

21 hours ago, Bob Amott said:

Created two 2 scenes: Day Lights & Night Lights.
Daylight:
Devices include: All the devices above at 100%
Night Lights:
Middle stairs only at 33%

THIS is the meat of the problem. The programs aren't triggering the correct brightness!

(at least that's how I interpreted the "challenge"). 

I think the option given by @Goose66 should work for activating the proper brightness. Will be interested in heard the results. 

Actually, I do have a program somewhat like @apostolakisl mentioned at the end, but I don't use motion sensors. I have a program that sets the on level (30%) during a particular time (night) in the "THEN" and 100% in the "ELSE". When the switch is controlled during the "THEN" time the lights do only come on to 30%. All other times they're 100%. So, it is possible either way. Just depends if you have those lights as part of other scenes triggering with other programs. 

Posted (edited)

Goose66 & Geddy,

Thanks for the info! I actually started to go down the path of two programs for each time period but I didn't get them quite right. The description of the effects of my programs posted here were correct and allows me more insight into the IoX. Over the years as a novice, I have programed some interesting interactions between devices and scenes but this one just totally stumped me. I will integrate your input and see what happens this evening.   

Edited by Bob Amott
Goose suggesting solution and Geddy confirming
Posted
46 minutes ago, Geddy said:

@apostolakisl I think you missed the hidden part about what the program is actually doing. @Bob Amott has different brightness levels based on time of day/night that he is trying to trigger. It's not the difference of on time. 

 

Actually, I do have a program somewhat like @apostolakisl mentioned at the end, but I don't use motion sensors. I have a program that sets the on level (30%) during a particular time (night) in the "THEN" and 100% in the "ELSE". When the switch is controlled during the "THEN" time the lights do only come on to 30%. All other times they're 100%. So, it is possible either way. Just depends if you have those lights as part of other scenes triggering with other programs. 

In that case, this is totally something that you would do with direct links and just re-write the scene attributes with a program but let the motion sensor run all the on/off commands directly.

I have a MS in my pantry that controls two devices.  I wrote this program to show how I would make the MS turn the lights on to 50% while the sun is down and 100% while it is up.  The actually turning on/off of the scene is directly controlled by the MS.

 

New Program - [ID 001B][Parent 0093][Not Enabled]

If
        From    Sunrise
        To      Sunset  (same day)
 
Then
        In 'Kitchen / Pantry Motion' Set 'Kitchen / Pantry - Light L' To 100% in 0.5 seconds, 1 retry
        In 'Kitchen / Pantry Motion' Set 'Kitchen / Pantry - Undercabinet L' To 100% in 0.5 seconds, 1 retry
 
Else
        In 'Kitchen / Pantry Motion' Set 'Kitchen / Pantry - Light L' To 50% in 0.5 seconds, 1 retry
        In 'Kitchen / Pantry Motion' Set 'Kitchen / Pantry - Undercabinet L' To 50% in 0.5 seconds, 1 retry
 

image.png.ff40cde96e410e68e98375fa1f3fea10.png

image.thumb.png.12e7430100ebb09a30be86a7e158b963.png

  • Like 1
Posted
1 minute ago, Bob Amott said:

All wonderful input to learn from. I understand one advantage to this approach is there is little delay. Correct?

 

The name "insteon" is a product of how fast the com is (like instant?).  And in fact, it does pretty much live up to the name.  A program can be quick, but it will sometimes take a second or more.  You can easily see how fast Insteon works when you have a scene of switches and you push one of the paddles in the scene that is not the load switch, and yet, from a human perspective, it seems to be instant, as though you were pushing the load switch.  This is certainly something that Insteon has over other technologies like Zwave.  

Anyway, if you are OK with the on time to be the same during the day or night and just want the brightness to be different, I would do it the way I just showed.

Some have argued that re-writing the memory on the switches twice a day can "wear it out", but that does not appear to be an actual concern.  The memory chips on Insteon devices do not seem to "wear out", the other stuff will be their demise (mostly caps).  

  • Like 1
Posted

SUNSET CAME AND ALL HAS RESPONDED CORRECTLY TO THE INTENDED OUTCOMES. 
Thanks to all for sharing your knowledge. I’ve been able to use all your  input, if not on obtaining the ultimate desired result of this program then also applying your input to enhance other programs. Again many thanks!

  • Like 4
Posted

I am grateful for all the input. Goose66 & Geddy provided very helpful details of what was needed to understand and be considered in the programing to reach my specific objective. Input from others was also much appreciated and I have used those approaches in a couple of other new programs that use the Insteon Motion II detectors in a way that don't need a program to execute leaving the sensors to take on actions after triggering, such as waiting for X amount of time before turning off. So again thanks to all of you for your thoughtful responses.  

  • Like 2
Guest
This topic is now closed to further replies.

  • Recently Browsing

    • No registered users viewing this page.
  • Who's Online (See full list)

    • There are no registered users currently online
  • Forum Statistics

    • Total Topics
      37.1k
    • Total Posts
      371.5k
×
×
  • Create New...