Jump to content
C4 Forums | Control4

NYCE provides programming examples


Recommended Posts

Oooo. theres a wild "loop" program in there.


So you don't want someone to write it up here/on a blog, and want to hope manufacturers do this and make it available on their site?


I think you should get a large batch of sample programming as part of a purchase like this, or when you purchase a system or Composer HE (right now it depends on your dealer more than anything).  But yeah, if the loop isn't good then they ought to leave it to the experts.  I wondered about that loop...

Link to comment
Share on other sites

The big issue that they potentially heavily bog down controllers. Timers are much safer options than WHILE statements. Plus Timers can be 'manually' stopped if required with a custom button, schedule et al.


Examples of issues:


WHILE light is ON

...and then that light senses an overload and goes into protection. You'll have NO way of remotely cutting the loop.


WHILE TV current input is...

someone manually changes the input...


Careful use can be fine, but there are perfectly good alternatives available for almost ANY situation - using timers, start/stop commands vs pulse and so-on.


Even something like

WHILE security is in alarm state

toggle light

delay 1 second

Why bother? Just do

WHEN security goes to alarm state

Start 1 second timer


When 1 second timer expires


When security alarm state cleared

Stop timer


Yes that's more lines, HOWEVER that WHILE statement is VERY likely to have created a back-log in the system and will likely continue to toggle the light for several seconds, in somne cases several minutes or even longer.


Even on your motion, the WHILE statement is sending constant light on traffic across the ZigBee mesh - both from the motion potentiatlly, but for sure the light.

Using timers there only sends occasional traffic - basically only once when you turn the light on, and once when you turn it off.



I won't say it's WRONG to use WHILE statements, but it should be used with caution if at all. The alternatives, while a few extra lines of code, are often simply better.

Link to comment
Share on other sites

  • 4 years later...

Interesting read even though its 5 years old! I would like to program something like this and don't seem to be able to get this working with either a while or an if statement. Some thoughts on this would be very much appreciated.

IF CorridorAlarmSensor senses motion

THEN MasterBedroomAlarmSensor should sense motion within 10 seconds if someone enters the room, in which case: do nothing

ELSE (Someone has left the room), and reset RoomOccupied=FALSE

P.S. I want to ensure RoomOccupied is only reset when someone leaves the room, and not when someone enters the room.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.