HOW TO MAKE A SOFTWARE TOGGLE? Hunter Douglass on HAI Omni 2 Pro

martytess

Member
I am integrating Hunter Douglass shades with a Omni 2 Pro and Radio RA2. The issue is that Hunter Douglass only gives serial command control to choose a preset scene. So to make even a simple open/close takes 2 buttons, I am dealing with many more features on the shades like top down bottom up, dualite etc, basic control will eat up endless buttons. 
 
So...
 
I would like to have a Radio RA button in essence scroll through 2 or more serial commands. 
 
I first tried using flags, a "If on then off - if off then on" approach:
 

WHEN TOGGLE TEST (Button) 
AND IF TOGGLE TEST ON  (flag)
THEN TOGGLE TEST OFF (flag)

 
 

WHEN TOGGLE TEST (Button) 
AND IF TOGGLE TEST OFF (flag)
THEN TOGGLE TEST ON (flag)
 
But the flag defeats itself,  I monitored its state in the "Status/Control" section, should see it go "0" to "1", but it does not. If it starts "on" this code then turns it "off" then "on" leaving it in the state that it started in, on. And vice versa for "off".
 
Can anyone solve this puzzle?
 
Marty

 
 
 
You can use a flag timer to avoid that behavior and use a single flag and test for both states.
 
In your first block you want the flag to toggle, but do not want the second block to execute until the next time the button is fired.

WHEN TOGGLE TEST (Button)
     AND IF TOGGLE TEST ON  (flag)
        THEN TOGGLE TEST ON FOR 5 SECONDS (flag)  

WHEN TOGGLE TEST (Button)
     AND IF TOGGLE TEST OFF (flag)
        THEN TOGGLE TEST ON (flag)

 
In the first block, if the flag is on when the button is triggered then a 5 second timer will be set.
The Omni then moves on to evaluate the next block.
Since the flag is ON, the conditional is false and the flag does not toggle to ON.
5 seconds later the flag turns OFF automatically.
 
So the next time the button is triggered, the flag is OFF and first block does not execute, the Omni moves on to the next block and toggles the flag.
 
Thank you! you are a wizard!
 
I then added the triggering of the serial out, the RadioRA button and it works perfectly!
 
WHEN Hot tub North Blind
WHEN HotTub6Btn SW4 PRESSED
    AND IF HotTubNBlind ON
        THEN Hot Tub Room ON FOR 1 SECOND
        THEN SEND HotTubOpen OUT SERIAL 3
 
WHEN Hot tub North Blind
WHEN HotTub6Btn SW4 PRESSED
    AND IF Hot Tub Room OFF
        THEN HotTubNBlind ON
        THEN SEND HotTubClose OUT SERIAL 3
 
 
Now the final step, how to add a third serial out trigger on the same button, for example blind "open", "closed" or "half way" on the third press? 
 
 
Thanks again.
 
Marty
 
You can set the flag to a number.
So use a routine to set it to number 1 or 2 and then check the condition as a value instead of simply "on"
"0" is a value of "off"
 
Does this look correct? Seems I am back to the original problem as there is no option to set a delay on a flag value.
 
 
WHEN S'sRm 6 Butn SW5 PRESSED
    AND IF SWBedBlind CURRENT VALUE IS 1 
        THEN SET SWBedBlind TO 2
        THEN SEND SW Bed Blind Closed OUT SERIAL 3
 
WHEN S'sRm 6 Butn SW5 PRESSED
    AND IF SWBedBlind CURRENT VALUE IS 2 
        THEN SET SWBedBlind TO 3
        THEN SEND SW Bed Blind Sheer OUT SERIAL 3
 
WHEN S'sRm 6 Butn SW5 PRESSED
    AND IF SWBedBlind CURRENT VALUE IS 3 
        THEN SET SWBedBlind TO 1
        THEN SEND SWBlindOpen OUT SERIAL 3
 
 
That will progress 1-3 and looks ok.

You'll have to manually set the flag to one of the three values at controller startup, otherwise the flag value will start as 0 and none of those will ever execute.

That's why I suggested using 0, 1 and 2 instead of 1,2 ,3.

If you wanted to operate any of the three modes without stepping through them, the conditional checking would be a bit more complicated.
 
I tried this, it does not work as was the problem in my first post, it steps through all three steps at one button press (0 to 1, 1 to 2, 2 to 0 ).
 

WHEN HotTub6Btn SW5 PRESSED
    AND IF HTubEBlind CURRENT VALUE IS 0 
        THEN SET HTubEBlind TO 1
        THEN SEND HTubEOpen OUT SERIAL 3
 
WHEN HotTub6Btn SW5 PRESSED
    AND IF HTubEBlind CURRENT VALUE IS 1 
        THEN SET HTubEBlind TO 2
        THEN SEND HTubEClose OUT SERIAL 3
 
WHEN HotTub6Btn SW5 PRESSED
    AND IF SWBedBlind CURRENT VALUE IS 2 
        THEN SET HTubEBlind TO 0
        THEN SEND HTubE50% OUT SERIAL 3

 
I want:
 
1st press - go to flag 0 & blind is open
2nd press - go to flag 1 & blind is closed
3rd press - go to flag 2 & blind is 50%
4th press same as 1st press, continuous loop.
 
and in the future maybe add a 4th or more in the loop...
 
Your last post you explained what I need as "conditional checking". I guess that is what I am after.
 
Thank you again for your brainpower and time.
 
I would be happy to pay you for your time if you are not enjoying this puzzle as much as I am... I really appreciate the help.
 
Cheers,
 
Marty
 
Let me noodle on it a bit
 
I enjoy solving these logic puzzles, and trying to do it as efficiently as possible.
 
I think Experience level: Average...Needs an update...
 
That toggle was ingenious and will make my situation twice as good, even if the holy grail "scroll" cant happen...
 
PS, wait til you hear my other programming issues : O
 
Marty
 
I reordered the statements so they cascade in reverse numerical order and used the same timer trick as in the first example to go from 2 to 0.
Any non-zero value of a flag is interpreted as "ON".
When the timer executes, the flag value should be "2", the timer should not change the flag value, only set a timer to expire 1 second later and then turn the flag "OFF" to a value of "0".
 
ETA:
That didn't work.
 
Here's why.
With a flag value of 2 (or higher) a command to turn "ON For xx Seconds"  is then interpreted to have a value of 1, so the block below would also trigger, which would then change the flag value back to 2 and cancel the timer.
 
If a flag is being evaluated to determine if it is "ON", any non-zero value will be evaluated as true.
When commanded to turn on, it appears to take on the value of 1, even if it was already on and at a higher non-zero value than 1.
(need to verify that last behavior, but I observed the "On For xx Seconds" behavior so this makes logical sense).
 
This works (tested it).
You should be able to add an infinite number of additional actions (within the limits of the number of programming lines).
 

WHEN HotTub6Btn SW5 PRESSED
    AND IF HTubEBlind CURRENT VALUE IS 2
        THEN SEND HTubE50% OUT SERIAL 3

WHEN HotTub6Btn SW5 PRESSED
    AND IF HTubEBlind CURRENT VALUE IS 1
        THEN SEND HTubEClose OUT SERIAL 3

WHEN HotTub6Btn SW5 PRESSED
    AND IF HTubEBlind OFF
        THEN SEND HTubEOpen OUT SERIAL 3

WHEN HotTub6Btn SW5 PRESSED
    THEN INCREMENT HTubEBlind

WHEN HotTub6Btn SW5 PRESSED
    AND IF HTubEBlind CURRENT VALUE IS GREATER THAN 2
        THEN HTubEBlind OFF
 
 
It still looks kludgy to me, but it does work.
There may be a more elegant solution.
 
Sorry for the late response, I finally had time to try this (I have a 2 and 5 year old that keep me running...) and it works perfectly!
 
I then stared at it for about 20 min, was writing you that I have no idea how this works and then the light bulb above my head came on. Another ingenious chunk of code!
 
I assume if I wanted to add more steps I would add blocks at the top starting 3 then 4 etc then change the number in the last block to the highest number?
 
This makes my blind integration so much better...If you think of a more elegant solution, I would love to see it but I am very happy to have a solution.
 
Thank you again!
 
Stay tuned for your next challenge codemaster... (again, I am happy to pay you for your time...)
 
Thanks for the kind words, but it's not necessary.
These puzzles help me with my own system.
Glad we got it to work for you.
 
You are correct, to add additional steps just add another block to the top of the ladder, and change the final value at the bottom.
Like this:
 
 
WHEN HotTub6Btn SW5 PRESSED
    AND IF HTubEBlind CURRENT VALUE IS 3
        THEN SEND (something else) OUT SERIAL 3

WHEN HotTub6Btn SW5 PRESSED
    AND IF HTubEBlind CURRENT VALUE IS 2
        THEN SEND HTubE50% OUT SERIAL 3

WHEN HotTub6Btn SW5 PRESSED
    AND IF HTubEBlind CURRENT VALUE IS 1
        THEN SEND HTubEClose OUT SERIAL 3

WHEN HotTub6Btn SW5 PRESSED
    AND IF HTubEBlind OFF
        THEN SEND HTubEOpen OUT SERIAL 3

WHEN HotTub6Btn SW5 PRESSED
    THEN INCREMENT HTubEBlind

WHEN HotTub6Btn SW5 PRESSED
    AND IF HTubEBlind CURRENT VALUE IS GREATER THAN 3
        THEN HTubEBlind OFF
 
I have one other idea I'll try at home that is one line shorter, but only when there are 3 states, as in your original request.
With 4 or more states it starts to get longer than this version because of the efficiency of the INCREMENT block.
 
 
If the n-1 states logic is confusing, i.e., a four state ladder is numbered 0-3 instead of 1-4, you should be able to modify it like this and still have it work correctly.
 
WHEN HotTub6Btn SW5 PRESSED
    THEN INCREMENT HTubEBlind

WHEN HotTub6Btn SW5 PRESSED
     AND IF HTubEBlind CURRENT VALUE IS GREATER THAN 4
         THEN SET HTubEBlind TO VALUE OF 1

WHEN HotTub6Btn SW5 PRESSED
    AND IF HTubEBlind CURRENT VALUE IS 4
        THEN SEND (something else) OUT SERIAL 3

WHEN HotTub6Btn SW5 PRESSED
    AND IF HTubEBlind CURRENT VALUE IS 3
        THEN SEND HTubE50% OUT SERIAL 3

WHEN HotTub6Btn SW5 PRESSED
    AND IF HTubEBlind CURRENT VALUE IS 2
        THEN SEND HTubEClose OUT SERIAL 3   
 
WHEN HotTub6Btn SW5 PRESSED
    AND IF HTubEBlind CURRENT VALUE IS 1 
        THEN SEND HTubEOpen OUT SERIAL 3
 
This will also work if the controller resets and the flag values all revert to 0.
 
 
Here's another one...I have 2 exterior cameras that have motion sensing capabilities. The lights shutting off abruptly is triggering the motion sensor so they are stuck in an endless cycle. To fix this I need the lights to gently fade. How can I get a automated fade? Set light level to 80% for 1 second then 60% for 1 second then 40% for 1 second etc or is there a better way?
 
Back
Top