PowerHome/Elk Conditional macros for Insteon

I have been playing with Powerhome lately and since I mostly use my Elk M1 to set up rules,Tasks and Timed events I never really messed with PH for that stuff . I recently upgraded to the latest Beta 2.1b of PH and it Kinda got me playing around with the new timer & Control wizards. Then I decided to take it a bit further and try and set up some Macros. Then it dawned on me that there is now easy or obvious way to do conditional Macros with IF,Then, Else stuff. It is real easy to do this stuff with ELK RP using the M1 as the controller.
I know PH power users with a programmer mentality find this stuff a no brainer but for me its about as convoluted as it can be. I love PH for setting up my Insteon Network and configuring links and simple Triggers and macros are pretty easy but for more complex stuff it is just not for regular folks.
I searched for some 101 on this sorta stuff and did not come up with much useful information. I would like to see a Setting up Powerhome Conditional Macros and Timers for Dummies.
Now I am sorta rethinking my setup and considering using an ISY-99 controller connected to my ELK-M1 instead of my current PH-M1 setup.
I guess I am just asking for opinions or advice on staying with PH or jumping to ISY.
Dave.
 
It needs to be updated, but I did a tutorial on something close to this years ago.

Tony,
I have no problem setting up simple Timers,Macros and Triggers using PH. It is the more complex ones where I want ti make a macro or trigger conditional that I am lost.
For instance say I want device A to turn on only if it is later than 6:00 pm and motion is detected on device B and only on fridays. Or another example Say I want to have PH announce that that Motion is detected and turn on my outside light only if its after dusk and the alarm is set.
I can do this sort of thing very easily using the ELK-M1 Controller with rules with Whenever, And,Then statements. It would be nice if Dave would update the new wizards to include drop down conditions to the mix.
To me the strength of PH is in its integration with ELK for monitoring Status and simple Device control and Insteon/X10 Device set up. I find it very complicated for anything else.
 
I'm not a programmer either. It took me a couple of tries in PH before it clicked with me, but I figure if I can do it anyone can.

The IF/THEN/ELSE in PH2 is covered by a JUMP command in a macro. If your checking to see if X=1 for example, than the logic would be as follows:

if(x=1,THEN GOTO 1, ELSE GOTO 10) - so if X=1 the macro would go to the next line (1). If x doesn't equal 1 then it would go to the 10th line following the JUMP line.

If you don't want to count lines, PH2 also has label commands instead. The above could read if(x=1, GOTO "TEST1", ELSE GOTO "END") and you would use the LABEL command to label the appropriate lines.

The above is the logic not the syntax.
The syntax for the first example would be:
JUMP if(x=1.1.10)

The syntax for the second example would be:
JUMP if(x=1,"TEST1","END")

So, for your first question:
"I want device A to turn on only if it is later than 6:00 pm and motion is detected on device B and only on fridays."

The first thing you would do would be to set up a simple trigger which would 'trigger' when motion is detected on device B. The trigger would run a macro of your choice each time motion was detected. The macro would check if it was Friday. If it was Friday it would then check to see if it was after 6 pm. If it was after 6pm it would would turn on Device A.

The syntax for returning the day's actual text name is:
dayname(today())


The syntax for returning the current time in 24 hour format is:
now()

So the macro would look like this

10 Jump if(dayname(today())="Friday",1,999)
20 Jump if(now()>18,1,999)
30 Formula ph_insteon("Device A",ion,255)

Line 10 checks to see if today is Friday. If it is it goes to the next line. If not it goes to non existent line 999 and ends.
Line 20 checks to see if it is after 6 pm and not later than 11:59 pm (you can change this of course to catch any hours you would like). If it is after 6 pm then it goes to line 30, if not it goes to non existent line 999 and ends.
Line 30 is the PH function to turn on Device A.
If you want to announce that Device A has been turned on you would add a line 40 as follows:
40 TSS "I have turned on Device A"

In PH you can do the same thing in many, many different ways. In fact, instead of using the above macro you can put all the logic in a formula and make it part of the trigger - so you don't even need a macro (altho I find a macro easier for me to follow).

If you are comfortable with the above 3 lines, you will be comfortable with doing almost anything in PH and the beauty of PH is that is can do almost anything. If you need additional examples or clarification, let me know.

Noel
 
...If you are comfortable with the above 3 lines, you will be comfortable with doing almost anything in PH ...

You can do almost anything with assembly language also but it ain't pretty. The last time I saw a programming language that involved jumping to labeled statements was over 20 years ago. It was a nameless language for a custom processor built out of discrete components designed 10 years earlier! You could point to chips on the PCB and state "That's Register One and there's the ALU!".

I tip my hat to all of you patient PH users who preserve this style of programming. However, the first bullet in PH's feature list is its support for programming languages like VBScript and Jscript.

Not being a PH user, I can't guarantee all of the following code works in PH. However, it serves to illustrate the difference between the two programming styles.
Code:
if Weekday(now)=6 and Hour(now)>18 then
	ph_insteon("Device A",ion,255)
	TSS "I have turned on Device A"
end if
versus this:
Code:
10 Jump if(dayname(today())="Friday",1,999)
20 Jump if(now()>18,1,999)
30 Formula ph_insteon("Device A",ion,255)
40 TSS "I have turned on Device A"

If PH was object-oriented, the code could look like this:
Code:
if Weekday(now)=6 and Hour(now)>18 then
	Device_A.Brightness=100
	Device_A.Power=true
	Speech.Phrase="Device A is on"
	Speech.Speak=true
end if

I suggest you investigate PH's support for VBScript. There's no shortage of VBScript references and examples on the web.
 
...If you are comfortable with the above 3 lines, you will be comfortable with doing almost anything in PH ...

You can do almost anything with assembly language also but it ain't pretty. The last time I saw a programming language that involved jumping to labeled statements was over 20 years ago. It was a nameless language for a custom processor built out of discrete components designed 10 years earlier! You could point to chips on the PCB and state "That's Register One and there's the ALU!".

I tip my hat to all of you patient PH users who preserve this style of programming. However, the first bullet in PH's feature list is its support for programming languages like VBScript and Jscript.

Not being a PH user, I can't guarantee all of the following code works in PH. However, it serves to illustrate the difference between the two programming styles.
Code:
if Weekday(now)=6 and Hour(now)>18 then
	ph_insteon("Device A",ion,255)
	TSS "I have turned on Device A"
end if
versus this:
Code:
10 Jump if(dayname(today())="Friday",1,999)
20 Jump if(now()>18,1,999)
30 Formula ph_insteon("Device A",ion,255)
40 TSS "I have turned on Device A"

If PH was object-oriented, the code could look like this:
Code:
if Weekday(now)=6 and Hour(now)>18 then
	Device_A.Brightness=100
	Device_A.Power=true
	Speech.Phrase="Device A is on"
	Speech.Speak=true
end if

I suggest you investigate PH's support for VBScript. There's no shortage of VBScript references and examples on the web.

I appreciate all the suggestions and thoughtful comments but I just don't have a great desire to learn code or script. I want a graphical interface with pull down menus or drag and drop functions. I have better things to do with my time than to spend hours doing it the old fashion way. We live in the 21st century why must we we operate like its still the stone ages. I applaud all you programmer types for your perseverance and dedication its just not my thing.
Thanks, Dave
 
...I just don't have a great desire to learn code or script. ... I have better things to do with my time than to spend hours doing it the old fashion way. We live in the 21st century why must we we operate like its still the stone ages. ...its just not my thing.

"Dave...stop...stop, will you...stop, Dave...will you stop, Dave...stop, Dave...I'm afraid..."

Yee-ahh, I'll probably never see a computer like HAL in my lifetime. Why not? Because programming such a beast is an incredibly difficult undertaking ... even with current "21st century" software engineering.

What you're asking for isn't as difficult to achieve but remains a significant challenge. "Point and click" programming attempts to simplify the process of building logic. It is a feature that exposes simple programming constructs (like if/then/else) so, by design, it is limited to easy-to-digest principles. To expose more sophisticated techniques would require an inordinately clever user-interface because some programming constructs are not intuitive. Consider Microsoft Outlook's use of Rules. It offers an effective UI to build mail-handling rules. However, it also provides a full programming model using VBA because written languages offer tremendous power, control, and flexibility.

If you think programming with a written language is "old fashioned" and from the "stone ages" then you have a unique perspective because virtually all modern software is developed in this manner. It remains the most powerful technique for programming.

There are many HA programs that offer "point and click" programming. I'm sure one of them will fit your requirements. Athough I'm afraid you will have to invest many waking hours learning whichever one you choose. It may me the 21st century but we still don't have hypnopaedia. :)
 
There is not much out there that is both point-and-click and capable. Maybe someday.

Also, multiple JUMP's are not the best way to do this, although it would work. Timed Events and a bit of code in the Boolean field would be much cleaner. If anyone is interested, I can go into detail.
 
I guess I should fess up. I'm an attorney, not a programmer (no jokes, please). My point was that if I could use PH having no background in programming, anyone can. As Tony mentioned, PH supports many better ways of doing what Dave wanted to do, my suggestion probably being the ugliest and least efficient. But it does work.

Noel
 
I appreciate all the suggestions and thoughtful comments but I just don't have a great desire to learn code or script. I want a graphical interface with pull down menus or drag and drop functions. I have better things to do with my time than to spend hours doing it the old fashion way. We live in the 21st century why must we we operate like its still the stone ages. I applaud all you programmer types for your perseverance and dedication its just not my thing.
Thanks, Dave

Dave-

I have to say that I agree with you 100%. Coming from a background of using a Stargate as my primary automation controller I have been continually amazed that newer products have not been able to match the combination of simplicity and sophistication of the Stargate programming interface. The ancient Stargate interface managed to combine point-and-click ease of use with extremely complex constructs such as deeply nested if-then statements, complex mixtures of AND and OR logic, analog input scaling, Macros, and so on, without ever resorting to manual code entry of any sort. It was a shock to me when starting to use newer platforms like Homeseer etc. to see how limited the GUI based logic was and how quickly you had to resort to scripts and code to acccomplish anything.

Like you I want to spend my time applying automation logic to my devices and not struggling with scripting syntax and command switches. There will always be an argument that scripting provides the most flexibility while Point-and click the greatest ease of use, but based on the Stargate example I don't think current GUI based programming interfaces are as good as they could be.
 
... I don't think current GUI based programming interfaces are as good as they could be.
I agree; there is plenty of room for improvement. I wouldn't characterize deeply nested if's, boolean logic and sub-macros as being very sophisticated but, given the Stargate's vintage, it speaks volumes about the current state of "point and click" programming.

An effective tool would provide:
  • templates or wizards (handle common HA scenarios)
  • suggestions (offer a limited list of applicable choices, like Intellisense in Visual Studio)
  • repetition (repeat a set of instructions n times)
  • multiplexing (different outcomes based on the input)
  • collections (ability to act on groups of related items)
  • timers
  • etc

A logic-development tool that completely replaces written programming is blue-sky thinking. A tool that raises the bar and makes written programming a last resort is well within the reach of current technologies. But is it enough of a product differentiator to make an HA vendor invest in the R&D?
 
Back
Top