HAI OMNI Pro II Automation code

madburg

Member
First, I would like to say hello to all,

Great site, been meaning to join for quite sometime. I have an IT background and moving into HA. I have setup a HAI Omni Pro II in my personal home to get started and see/practice what can be done.

Trying to understand how the automation code is processed. I think that would go a long way, and greatly help coming up with custom/new automation code, etc. I am running ALC switches throughout the home, at the moment.
One simple (I believe :huh: ) automation block I started off with was to "Turn ON the front of home exterior lights at SUNSET with a 18% level and turn OFF those lights at SUNRISE, with one addition and that is to check every 5 minutes so if someone OR another automation block (say turn on front door light 100% when car in driveway) it would reapply the automation block (18% level or off, depending on SUNRISE or SUNSET).
Following is what I have set:
---
EVERY 5 MINUTES
TIMED SUNRISE MTWTFSS
THEN Entry HH/S L OFF
EVERY 5 MINUTES
TIMED SUNSET MTWTFSS
THEN SET LIGHTING LEVEL Entry HH/S L TO 18%
---

So the SUNSET code works fine, if I change the light level to 100% at night it change it to 18% within 5 minutes. But the lights never turn off at SUNRISE? If I manually turn of the light after SUNRISE time, it turns them back on within 5 minutes to 18% (seems that the SUNSET code is applying even though it is now past SUNRISE). I would appreciate the explanation of what i did wrong with the code and how the controller read it... How would one code this properly?

I am extremely eager to understand what is going on and how Automation blocks are being proceeded by the HAI controller. Is it constantly reading code in the automation section OR only when an event occurs. What i mean by this is, say all zones are secure and you have one piece of code that states every 4 hours do something. Does the controller only process the Automation block when 4 hours passes by (do to the one block requesting to do so) and IF a zone changed to NOT Ready, etc.. to see it there are any program blocks to process. I feel that is not the case as you could have automation block for even SECURE states, etc... So is it checking automation blocks every millsec?
Is there a manual or write up on what certain selections mean, example: AFTER SUNSET, BEFORE SUNSET. What do they actually mean, ex. 8am to 8pm.
 
How it works is like this. Each block has a trigger. The panel goes round and round looping through all the blocks. If the trigger is not true it moves on to the next block. If the trigger is true it evaluates the rest and only performs the action if the conditions are met. So the conditions after the trigger are only evaluated if the trigger is true at that very instant. If a trigger is not true, the panel moves on to the next block and looks at that trigger. So trigger events are instants in time. Conditions are steady-state flags that are evaluated a split second after the trigger evaluates true. So a trigger (the first test) does look for a change.

Once a trigger has activated a block, it won't activate again until that trigger goes NOT TRUE then TRUE again. In other-words, if you are triggering on a light turning on, once it goes on it triggers, but it won't trigger again until it goes off then back on.

Hope that helps.
 
I did understand the first paragraph. The second is a bit fuzzy for me, can you give me an example from my code?

My understanding is I have 2 triggers in my code blocks, trigger 1) "EVERY 5 MINUTES", so if it triggered 3 minutes ago will will not rerun/activate again, right? If 5 minutes passed from the last evaluations it does activates, but then I have my second trigger in the block 2) "TIMED SUNRISE MTWTFSS", is that correct? If so then it should read its been five minutes continue to the second trigger, SUNRISE (everyday). This is where I am fuzzy again, is SUNRISE stating EXACTLY the time programmed for the controller that day to be SUNRISE (ex. 6:51am) so if it is not exactly 6:51am it does not activate to move on to the condition "THEN Entry HH/S L OFF"?
 
I did understand the first paragraph. The second is a bit fuzzy for me, can you give me an example from my code?

My understanding is I have 2 triggers in my code blocks, trigger 1) "EVERY 5 MINUTES", so if it triggered 3 minutes ago will will not rerun/activate again, right? If 5 minutes passed from the last evaluations it does activates, but then I have my second trigger in the block 2) "TIMED SUNRISE MTWTFSS", is that correct? If so then it should read its been five minutes continue to the second trigger, SUNRISE (everyday). This is where I am fuzzy again, is SUNRISE stating EXACTLY the time programmed for the controller that day to be SUNRISE (ex. 6:51am) so if it is not exactly 6:51am it does not activate to move on to the condition "THEN Entry HH/S L OFF"?

First of all, a code block can have one and only one trigger. By definition, a trigger is an instant in time, so you can only have one instant in time. After Ver 3.0 Firmware, the panel allows many combinations of conditions but still only ONE trigger.

I don't have a panel in front of me now for reference, but you can have a repeating trigger that occurs "Every 5 minutes." So every 5 minutes this trigger occurs and at that time the conditions are evaluated, and if the conditions are met, the action occurs.

You can't have Sunrise and every 5 minutes both triggering a block, as I said, a block can only have one trigger. You could trigger every 5 minutes then at that time check for darkness, and if so, turn on a light.

While I understand the panel does allow a repeating trigger, like ever 5 minutes, its not good practice to use it if you can avoid it. Trigger on the thing you are waiting for, don't trigger every 5 minutes then check if the thing has occurred.
 
Actually, it will let you have multiple triggers on a block... I was surprised too, but I tried it and it works, and I've got the latest firmware and PC Access. However, it appears that the two triggers act independently, which is what you'd expect -- it's as if you wrote the block twice, once with the first trigger and once with the second.

So let's analyze what is happening with the OP's code. The first block runs every 5 minutes and at sunrise, and it turns the lights off. It does this around the clock. The second block runs every 5 minutes and at sunset. It sets the lights to 18%. It also runs around the clock. So what's happening? Every five minutes, the first block turns the lights off. However, this is immediately undone by the second block. If you had Upstart running and you looked at its UPB traffic log, you could see this happening.

So what happens at sunrise? Let's say that sunrise is 6:28 AM. At that time, the first block executes and it turns the lights off. However, at the next five-minute interval at 6:30, both blocks are triggered by the every-5-minutes trigger. Since the second block runs last, the lights wind up back on at 18%. And they stay on at 18% all day (which you may not be able to see in daylight unless you look at them closely).

As a first approximation of what you want, you need to condition the blocks on the time of day:

[codebox]
EVERY 5 MINUTES
TIMED SUNRISE MTWTFSS
AND IF TIME IS GREATER THAN SUNRISE
AND IF TIME IS LESS THAN SUNSET
THEN Entry HH/S L OFF

EVERY 5 MINUTES
TIMED SUNSET MTWTFSS
AND IF DARK
THEN SET LIGHTING LEVEL Entry HH/S L TO 18%
[/codebox]

Now, the first block will only execute during the daytime. (An aside: There really should be an "IF DAYLIGHT" condition...) And the second block will only execute at night, so it won't constantly be turning the lights back on all day. Actually, looking at it, the two TIMED conditions are now kind of superfluous; the condition will take effect a maximum of 4 minutes after sunrise or sunset.

This is still not really ideal. As ano pointed out, whenever possible you want to trigger directly on the event you are looking for, rather than running a loop that looks for it to happen. The other problem is that if you manually turn the lights full up, the amount of time that elapses before they go back to 18% varies depending on what time it is at the moment; the second code block may execute as soon as one second later. I'd think about re-writing the above something like:

[codebox]
TIMED SUNRISE MTWTFSS
THEN Entry HH/S L OFF
THEN SET Entry HH/S L Level TO 0

TIMED SUNSET MTWTFSS
THEN SET LIGHTING LEVEL Entry HH/S L TO 18%
THEN SET Entry HH/S L Level TO 18

WHEN Entry HH/S L ON
THEN Entry HH/S L Timer ON FOR 5 MINUTES

WHEN Entry HH/S L Timer OFF
THEN SET LIGHTING LEVEL Entry HH/S L TO Entry HH/S L Level
[/codebox]

where "Entry HH/S L Timer" is a flag, and "Entry HH/S L Level" is a user setting configured as a lighting level.
 
Now, the first block will only execute during the daytime. (An aside: There really should be an "IF DAYLIGHT" condition...) And the second block will only execute at night, so it won't constantly be turning the lights back on all day. Actually, looking at it, the two TIMED conditions are now kind of superfluous; the condition will take effect a maximum of 4 minutes after sunrise or sunset.

Isn't there conditions called 'dark' and 'light' that are essentially that?
'IF LIGHT' is the same as "IF DAYLIGHT" iirc
 
Hi ano,

Quote: First of all, a code block can have one and only one trigger. By definition, a trigger is an instant in time, so you can only have one instant in time. After Ver 3.0 Firmware, the panel allows many combinations of conditions but still only ONE trigger.

So why is it not graying out the "trigger" button once you select and apply a trigger in a block (not that it is your fault :huh:)?

From my screenshot attached it allowed me to select and input 2 triggers. Is an "action" also considered a condition? I ask because it seems my block consists of 2 Triggers and an Action?

Since I am new I cannot attach or use a link so my image is at the following location:

opensourze%replacewithdot%com/HAI/OPIIAB1.png
 
Sorry ano, I did not see all the other replies come in, scratch my last, but my screenshot, clearly shows you can have more than one trigger, for those that maybe interested (learning like me).

Thank you all for chiming in. Cornutt, I appreciate the samples, very much. few questions.

1) Does your second sample code able to accomplish what I was looking for in my original post "with one addition and that is to check every 5 minutes so if someone OR another automation block (say turn on front door light 100% when car in driveway) it would reapply the automation block (18% level or off, depending on SUNRISE/ or SUNSET).? I ask because, I went through your code and it was a great exercise, I created the "User Setting" & "Flag" (first time :huh:) to be able to reproduce the code you shared. But I dont understand what the
Code:
WHEN Entry HH/S L ON
	  THEN Entry HH/S L Timer ON FOR 5 MINUTES
does? I see it changes the FLAG "Timer" to ON for 5 minutes because it detected the Lights were on, due to the previous code turning it on because it was after SUNSET. But If I change the Light to 100%, what changes it back to 18%?

Unless the last bit of code
Code:
WHEN Entry HH/S L Timer OFF
	  THEN SET LIGHTING LEVEL Entry HH/S L TO Entry HH/S L Level
means when the 5 minutes runs out the "Timer" flag is turn back to "OFF" and then it picks up that the FLAG is "OFF" which trigger the action to then set the Light which is curently at 100% to 18% because that is what is stored in the User setting because it is after SUNSET.

Did I get this logic right?
 
Isn't there conditions called 'dark' and 'light' that are essentially that?
'IF LIGHT' is the same as "IF DAYLIGHT" iirc

Oh heck you're right. I was looking for something like "DAYLIGHT" and I didn't look for just "LIGHT". Head-smacky. :huh:
 
Unless the last bit of code
Code:
WHEN Entry HH/S L Timer OFF
	  THEN SET LIGHTING LEVEL Entry HH/S L TO Entry HH/S L Level
means when the 5 minutes runs out the "Timer" flag is turn back to "OFF" and then it picks up that the FLAG is "OFF" which trigger the action to then set the Light which is curently at 100% to 18% because that is what is stored in the User setting because it is after SUNSET.

Did I get this logic right?

Yes. That third block of code causes the timer flag to start counting down. When it counts down to zero, it triggers that last block of code, which sets the lights back to whatever light level is set in the user setting.

The third block deserves a bit more explanation: In theory, it would only be triggered when the UPB device changes state. In reality, though, it will be triggered whenever the controller sees an on-type command go to that unit, whether the controller thinks it was already on or not. So if it's after sunset and the lights are at 18%, and then say someone turns them on full at the switch, or some other block of code turns them on full, that will trigger the third block of code which will start the timer even thought the light was already "on" (at 18% brightness).
 
Unless the last bit of code
Code:
WHEN Entry HH/S L Timer OFF
	  THEN SET LIGHTING LEVEL Entry HH/S L TO Entry HH/S L Level
means when the 5 minutes runs out the "Timer" flag is turn back to "OFF" and then it picks up that the FLAG is "OFF" which trigger the action to then set the Light which is curently at 100% to 18% because that is what is stored in the User setting because it is after SUNSET.

Did I get this logic right?

Yes. That third block of code causes the timer flag to start counting down. When it counts down to zero, it triggers that last block of code, which sets the lights back to whatever light level is set in the user setting.

The third block deserves a bit more explanation: In theory, it would only be triggered when the UPB device changes state. In reality, though, it will be triggered whenever the controller sees an on-type command go to that unit, whether the controller thinks it was already on or not. So if it's after sunset and the lights are at 18%, and then say someone turns them on full at the switch, or some other block of code turns them on full, that will trigger the third block of code which will start the timer even thought the light was already "on" (at 18% brightness).

So what if someone/thing turns them on to 90%?
 
ano and cornutt,

Just wanted to say that this, for me a HAI programming newbie, has been the best explanation with examples of the HAI programming concept.

Thanks for posting!
 
ano and cornutt,

Just wanted to say that this, for me a HAI programming newbie, has been the best explanation with examples of the HAI programming concept.

Thanks for posting!

+1 Is there a way to give points, or rep power, etc. on this board, you guys deserve it.

Frunple, to answer your question
So what if someone/thing turns them on to 90%?
First and foremost it is a personal preference and tomorrow it can be a clients wish as well, or resemble one. I can share why I personally have this preference; I have outdoor landscape lighting including a post light and a number of sconces in the entry of the home. Keeping the Entry Lighting at 18% keeps them in the lighting scene with all others and the style of the home. So when a vehicle pulls into the driveway (vehicle detector), the entry lights will go to some where around 90%, or should someone in the home change (accidently or not) the light level to these same lights (detects on-type, thanks cornutt ;)) in 5 minutes it will go back to the preset I requested of 18%, again my personal preference is 5 mintues, which is plenty to get ones attention (the house knows you are there and brightens you up if you pull into the driveway :D, or if its us, then enough time to enter the home, under the 90% lighting).

What I also learned from this excersie, when I applied the coding on saturday evening it did not work exactly as I hoped, dug around, and noticed that the "User Setting Level" that should have been "18" was not, due to the fact it was way past SUNSET. So I had to manually set the Level to 18, eveything was perfect (many thanks cornutt). I felt that was all that was needed to jump start this programming but decide to let it ride for the upcoming SUNRISE and SUNSET the next day. All stayed true!!! NICE.

Now, I added a bit more code to light up foyer entry lights when one walks in (path light pattern) all was well, tweaked here and there (conditioned as long as the lights were already OFF prior too). Then yesturday night I moved on to "ALL OFF" right? As you end the night and go into your bedroom and you want anything you left ON at different levels in the home to turn OFF (hoping to actually have this as WHEN Security set to NIGHT, THEN ALL UNITS OFF, taking this one step at a time to learn things through). Well bummer, LOL. The Entry Lighting shutoff and stayed off, makes sense as only a ON-type would have trigger it being reverted back to 18%.

So this has me thinking, what are the options in handling this type of ALL Triggers/conditions (I personal am on ALC lighting, but interested in all/most types as well).
This excersie is not complete as Entry Lights went OFF and stayed OFF, we only allow this at SUNRISE, right :)

OPTIONS:

1) We can move the ALC switch to another BRANCH if available and select "Enable All Off" to "NO" (I am sure this is the same for all if not most lighting standards that integrate with HAI Controllers, but named differently, like "ROOM", "UNIT", etc..)

2) A programming block I came up with, I hope this is not silly:
Code:
WHEN ALL OFF
	AND IF DARK
		THEN SET LIGHTING LEVEL Entry Hat Hat/Sconce Lighting TO 18%
It did work, all went OFF, and fired back up the Entry Lights to 18% (User Level is not affected by this so it to is still at "18" and ready for any new ON-types, until SUNRISE), but I dont know if this is the correct approach/optimized. Looking forward to comments.

3) %Other options%

4) %Other options%...
 
Back
Top