Author |
|
GCollins Groupie
Joined: March 27 2011 Location: United States
Online Status: Offline Posts: 54
|
Posted: March 13 2023 at 15:59 | IP Logged
|
|
|
March 2023:
My Alexa integration with PH2 is complete, and I may never touch another light switch or handheld remote again!
I followed the lead of using BWS Systems’ open source HA-Bridge that Smarty posted about 6 years ago:
http://power-home.com/forum/forum_posts.asp?TID=10699&PN=1&T PN=1
Plenty of things with Alexa have changed since then, but HA-Bridge has been keeping up. It was easy enough to setup the latest GA release 5.4.1 with Java 8 on the
same Windows 10 Home 22H2 PC that is hosting PH2 2.1.5c. According to the documentation, HAB needs to listen on port 80 for discovery by Alexa to work properly, so I
moved PH2 to port 81. Both applications get started automatically on boot by having shortcuts in the Win-R startup folder.
One critical thing I had to do with HA-Bridge was check the box under Bridge Control for “Unique ID to use 9 Octets” = True. This supports a change in device
discovery that Amazon made a few years ago. Aside from that, everything worked with the defaults.
I have about 45 virtual Hue “lights” working like a champ. These equate to scenes that I already had setup in our Lightolier Compose switches (X10 protocol)
throughout the house. These scenes are launched locally via room and whole-house keypads, as well as from PH macros that get called by various PH triggers,
schedules, and web pages. The HAB/Alexa integration adds voice control for those same macros. All that’s needed in HAB is to create an entry for each scene and
provide the single CGI URL (a series is possible) for calling the appropriate PH macro. You can also add macro calls for Off and Dim (and Color, tho my system has
none).
None of the other per device settings in HAB were needed. This includes Type, Delay, Count, Verb, etc. That’s good, because when I first saw all that stuff I had no
idea what to do with it!
Now I can say things like “Alexa, turn on the reading lights” or “Alexa, turn on the TV lights”. Both of these scenes involve the same set of fixtures, switches and
keypads, but adjusted to the task at hand.
There is clearly some handshaking going on between Alexa/HAB and HAB/PH2. Status of the scenes/devices is properly updated in all three places. The only quirk I’ve
seen is that on a couple of my scenes Alexa will announce “<Name of scene> isn’t responding. please check its network connection and power supply.” This is a false
alert, spoken before the macro has successfully completed. What’s different about these scenes is that the PH macros are longer than a standard pair of X10 commands,
such as for scenes that involve multiple rooms. I suspect Alexa has too short of a timeout period for receiving an ack from HAB. I’ve fooled with some of the HAB
settings like “UPNP Send Delay” to no avail. If anyone knows how to fix this minor issue, I’d love to hear about it. Else I’ll pursue it with the HAB support team.
FYI, one HAB device setting that looked promising is called “No State (Do not update state for device)”, but this produces the opposite of desired effect. It
guarantees that you’ll get a false “isn’t responding” complaint from Alexa on every bridge device where it’s used. At least this supports my timeout theory.
I know many of you have other voice control systems supported by PH2. I’ve had my own trials and tribulations with voice over the decades, and gave up long ago due
to it always being more trouble than it was worth. Perhaps there are more robust voice systems now that don’t come with all of the privacy concerns of Alexa, and I’d
be interested to know the best ones that are still supported.
In my case Alexa offered a lot of advantages: low cost, excellent voice recognition, and connected via WiFi. We had shunned the product for the first few years of
its existence over privacy concerns, but finally accepted the intrusion (alongside all the others IoT brings us) and have welcomed Alexa for access to its many other
services. We have five Echos of various models throughout the home, so there is always one within ear shot.
I wish I had installed this integration with PowerHome years ago!
__________________ PH2 Integr: JV Digital, Compose, Harmony, Insteon, Leviton, X10-Pro, DSC, Radio Shack, HA-Bridge/Alexa, UniFi Protect
Alexa Integr: Ecobee, Philips Hue, UniFi Protect, Sengled Zigbee, Kasa WiFi
|
Back to Top |
|
|
gg102 Senior Member
Joined: January 29 2013 Location: United States
Online Status: Offline Posts: 245
|
Posted: March 13 2023 at 16:06 | IP Logged
|
|
|
Congratulations!
|
Back to Top |
|
|
GCollins Groupie
Joined: March 27 2011 Location: United States
Online Status: Offline Posts: 54
|
Posted: March 13 2023 at 17:45 | IP Logged
|
|
|
Walt, thank you, and again especially for your help getting CGI macro calls working. That was step 1.
__________________ PH2 Integr: JV Digital, Compose, Harmony, Insteon, Leviton, X10-Pro, DSC, Radio Shack, HA-Bridge/Alexa, UniFi Protect
Alexa Integr: Ecobee, Philips Hue, UniFi Protect, Sengled Zigbee, Kasa WiFi
|
Back to Top |
|
|
GCollins Groupie
Joined: March 27 2011 Location: United States
Online Status: Offline Posts: 54
|
Posted: March 14 2023 at 11:50 | IP Logged
|
|
|
Alexa's "isn't responding" quirk was logged as HA-Bridge Issue #1213 back in 2020 and is still open. I've provided some clarifications over there.
It's a timeout issue for longer sequences. Not sure yet if it's something that can be fixed in HA-Bridge or Alexa, or if it will have to be worked around another way, such as by
breaking my longer macros into shorter ones.
https://github.com/bwssytems/ha-bridge/issues/1213
__________________ PH2 Integr: JV Digital, Compose, Harmony, Insteon, Leviton, X10-Pro, DSC, Radio Shack, HA-Bridge/Alexa, UniFi Protect
Alexa Integr: Ecobee, Philips Hue, UniFi Protect, Sengled Zigbee, Kasa WiFi
|
Back to Top |
|
|
smarty Super User
Joined: May 21 2006 Location: United States
Online Status: Offline Posts: 728
|
Posted: March 14 2023 at 13:33 | IP Logged
|
|
|
Great to hear your success!
My system continues to work quite well, but I too sometimes
hear the "isn't responding" quirk.
I haven't given the PH/Bridge process a "re-look" in quite
a while, I may see if I can work out a few more kinks using
some of your above feedback/input. Glad it's working for
you.
__________________ Elk - Insteon - BlueIris - DMC1 - PowerHome - XLobby - HA_Bridge w/Dots - Brultech
|
Back to Top |
|
|
gg102 Senior Member
Joined: January 29 2013 Location: United States
Online Status: Offline Posts: 245
|
Posted: March 14 2023 at 13:47 | IP Logged
|
|
|
Seems you need to do a test to determine "where" the problem resides. I would try to this: create a fake device, launch
a PH macro that only bumps a counter, then finishes. If that combination works flawlessly, then you know that your PH
macro need to finish quickly, then you can structure your macros to accommodate that issue.
If you still get timeouts, then it's probably NOT PH. It could still be communications.
You're shooting in the dark until you determine "where" the issue is.
Just a thought.
|
Back to Top |
|
|
smarty Super User
Joined: May 21 2006 Location: United States
Online Status: Offline Posts: 728
|
Posted: March 14 2023 at 14:12 | IP Logged
|
|
|
I am pretty sure it is the Insteon hop delay that is causing the issue. I have seen Insteon control delays occur when controlling directly from PH.
One of my thoughts was to relocate my wireless Insteon PLM (USB RF stick) controller to a more central location in my house so that whatever light I ask to control, the number
of Insteon "hops" is minimized. This is just my first thought....
Edited by smarty - March 14 2023 at 14:13
__________________ Elk - Insteon - BlueIris - DMC1 - PowerHome - XLobby - HA_Bridge w/Dots - Brultech
|
Back to Top |
|
|
gg102 Senior Member
Joined: January 29 2013 Location: United States
Online Status: Offline Posts: 245
|
Posted: March 14 2023 at 14:22 | IP Logged
|
|
|
Assuming that's true, then seems you need to restructure your macro to do the "work" in a second macro that gets called from the first macro
after the Alexa macro finishes.
So, in your first macro, call a second macro from a formula ph_macro("second_macro_name") that gets called "post" meaning it gets called
after the first macro completes.
Thus your Alexa macro completes and satisfies Alexa, then PH does the work of your macro.
|
Back to Top |
|
|
GCollins Groupie
Joined: March 27 2011 Location: United States
Online Status: Offline Posts: 54
|
Posted: March 14 2023 at 18:40 | IP Logged
|
|
|
Hey guys, thanks for your feedback. I'm pretty sure the problem is on the Alexa side. The Echo devices just don't wait long enough to get an acknowledgement from the "device"
I'm looking forward to any feedback from the HA-Bridge project. It would be cool if they could somehow tell Alexa to adjust or ignore her timeout for the bridge devices, but I
realize the capability may simply not be there. And I also know from experience (on a surveillance video integration) that trying to get Amazon tech support to acknowledge an issue
or pass it to development is near futile. They'll open a case, but getting traction is rare even for very well-known issues.
To be clear about my setup on the PH side of things, my devices are primarily X10 PLC, and the system is rock-solid. While PLC communications is inherently slow by today's
standards, Lightolier's implementation of X10 actually makes things very fast.
__________________ PH2 Integr: JV Digital, Compose, Harmony, Insteon, Leviton, X10-Pro, DSC, Radio Shack, HA-Bridge/Alexa, UniFi Protect
Alexa Integr: Ecobee, Philips Hue, UniFi Protect, Sengled Zigbee, Kasa WiFi
|
Back to Top |
|
|
GCollins Groupie
Joined: March 27 2011 Location: United States
Online Status: Offline Posts: 54
|
Posted: March 14 2023 at 18:46 | IP Logged
|
|
|
gg102 wrote:
Assuming that's true, then seems you need
to restructure your macro to do the "work" in a second
macro that gets called from the first macro
after the Alexa macro finishes.
So, in your first macro, call a second macro from a
formula ph_macro("second_macro_name") that gets called
"post" meaning it gets called
after the first macro completes.
Thus your Alexa macro completes and satisfies Alexa, then
PH does the work of your macro.
|
|
|
This is an excellent idea, and I'll give it a try. I've
already been giving some through to restructuring the
macros into parent (for whole-house scenes) calling
children
(for individual rooms). I didn't really want to do the
work, but it would probably be better overall.
Edited by GCollins - March 14 2023 at 18:50
__________________ PH2 Integr: JV Digital, Compose, Harmony, Insteon, Leviton, X10-Pro, DSC, Radio Shack, HA-Bridge/Alexa, UniFi Protect
Alexa Integr: Ecobee, Philips Hue, UniFi Protect, Sengled Zigbee, Kasa WiFi
|
Back to Top |
|
|
gg102 Senior Member
Joined: January 29 2013 Location: United States
Online Status: Offline Posts: 245
|
Posted: March 14 2023 at 22:00 | IP Logged
|
|
|
Thinking about this a bit more.
For convenience here, let's call the PH macro that you call from Alexa, the "Alexa macro."
I'm thinking that you should treat your "Alexa macro" more like an interrupt processing routine. Set a flag, bump a counter, then immediately
return. That probably needs to be a very quick process. Then later do the work as indicated by the flag or counter or as I suggested earlier, call
another macro as a post-process to the "Alexa macro."
My thinking is this.
It's possible that the "Alexa macro" is returning something to the thing that's calling your PH macro. That thing is waiting for a response but
seems to have a short timeout. Completing the "Alexa macro" might cause the PH WEB server to send something back to the caller, something like an ACK
or NAK. If your PH macro takes too long to process, then that calling thing posts a timeout error before the PH WEB server gives its ACK.
It would be a simple test to write just to test this theory. You don't need to restructure anything, just build a test to verify this. Invent a new
Alexa device, call a different PH macro that does basically nothing. If it works reliably, then you have the answer. I write little test things all
the time to verify something.
Just a thought.
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: March 15 2023 at 15:43 | IP Logged
|
|
|
Sorry Im a little late to this thread. You're absolutely right, the timeout on Alexa is causing the "isn't responding" feedback. This is
because the command on PowerHome is taking longer than Alexa expects.
While you're on the right track to have a macro that calls another macro so the original macro can return while the second macro executes, you
should be able to achieve the same effect without having to modify your macros.
Have a look at either the ph_postformula or ph_postexequeue functions. The syntax for the ph_postexequeue function is easier if you are calling
a macro without parameters. If you are calling the macro with parameters, then ph_postformula is probably easier.
So using a sample posted from the ph-cgi thread, the HTTP call below:
http://192.168.1.100/ph-cgi/eval?formula=ph_macro("GARAGE-ON ")
would be changed to:
http://192.168.1.100/ph-cgi/eval?formula=ph_postformula('ph_ macro("GARAGE-ON")')
Pay attention to the use of the single and double quotes. The ph_macro formula is being passed as a string to the ph_postformula function. A
string can be wrapped in either single quotes or double quotes so if you need quotes embedded within a string, use one set for the inner and
the opposite set for the outer.
What these functions do is take the "formula" and just submits it to the job execution queue and then immediately returns which should almost
completely eliminate any delay. The ph_postformula function just submits the formula to the end of the job queue so other jobs ahead of it will
be executed first. The ph_postexequeue function is more advanced in that you are given control over where in the queue the job is posted. Since
I like voice commands to respond very quickly, I would either post the formula to the queue with either a priority of 1 or 2.
Hope this helps!
Dave.
|
Back to Top |
|
|
GCollins Groupie
Joined: March 27 2011 Location: United States
Online Status: Offline Posts: 54
|
Posted: March 15 2023 at 20:56 | IP Logged
|
|
|
gg102, I follow your thinking completely.
dhoward, This is advanced PH (to me) that I was not aware of, but I also follow. Thanks for the critical details on syntax.
Both approaches are interesting from various perspectives, and I think likely to help.
Due to some personal circumstances, it may be 2-3 weeks before I can report results, but I look forward. Thanks for your help.
__________________ PH2 Integr: JV Digital, Compose, Harmony, Insteon, Leviton, X10-Pro, DSC, Radio Shack, HA-Bridge/Alexa, UniFi Protect
Alexa Integr: Ecobee, Philips Hue, UniFi Protect, Sengled Zigbee, Kasa WiFi
|
Back to Top |
|
|
GCollins Groupie
Joined: March 27 2011 Location: United States
Online Status: Offline Posts: 54
|
Posted: January 07 2024 at 20:08 | IP Logged
|
|
|
@gg102, @smarty, @dhoward:
My 2-3 weeks of unavailability turned into almost a year, but I am back and this problem is solved!
The ph_postformula function worked perfectly. The only other trick required was the use of URL Encoding for the quote and double quotes, as required by HA-Bridge.
As an example, one command that was getting Alexa all in a wad over her false assumption of no response was:
http://192.168.66.10:81/ph-cgi/eval?formula=ph_macro(%22SCN_ KIT_TASK1%22)
The new command that keeps her happy is:
http://192.168.66.10:81/ph-cgi/eval?formula=ph_postformula(% 27ph_macro(%22SCN_KIT_TASK1%22)%27)
Thank you for the tips. It is far more impressive for our house guests when Alexa keeps her mouth shut as my extensive automation scenes play out at the mere utterance of spoken command.
Edited by GCollins - January 07 2024 at 20:11
__________________ PH2 Integr: JV Digital, Compose, Harmony, Insteon, Leviton, X10-Pro, DSC, Radio Shack, HA-Bridge/Alexa, UniFi Protect
Alexa Integr: Ecobee, Philips Hue, UniFi Protect, Sengled Zigbee, Kasa WiFi
|
Back to Top |
|
|
gg102 Senior Member
Joined: January 29 2013 Location: United States
Online Status: Offline Posts: 245
|
Posted: January 07 2024 at 20:31 | IP Logged
|
|
|
Congratulations!
You could only have done this in PH.
I can't tell you how many of these types of things that I
run into that could only be solved in PH.
|
Back to Top |
|
|
GCollins Groupie
Joined: March 27 2011 Location: United States
Online Status: Offline Posts: 54
|
Posted: January 10 2024 at 12:15 | IP Logged
|
|
|
gg102 wrote:
Congratulations!
You could only have done this in PH.
I can't tell you how many of these types of things that I
run into that could only be solved in PH. |
|
|
Walt, go tell this guy:
github.com/bwssytems/ha-bridge/issues/1213#issuecomment-1880 436073
__________________ PH2 Integr: JV Digital, Compose, Harmony, Insteon, Leviton, X10-Pro, DSC, Radio Shack, HA-Bridge/Alexa, UniFi Protect
Alexa Integr: Ecobee, Philips Hue, UniFi Protect, Sengled Zigbee, Kasa WiFi
|
Back to Top |
|
|
gg102 Senior Member
Joined: January 29 2013 Location: United States
Online Status: Offline Posts: 245
|
Posted: January 10 2024 at 12:41 | IP Logged
|
|
|
GCollins-
Great thought but seems someone beat me to it.
|
Back to Top |
|
|
smarty Super User
Joined: May 21 2006 Location: United States
Online Status: Offline Posts: 728
|
Posted: January 15 2024 at 13:06 | IP Logged
|
|
|
The few Alexa "timeouts" that I was having are now gone.
Very nice/informative thread!
Thanks guys!!!
__________________ Elk - Insteon - BlueIris - DMC1 - PowerHome - XLobby - HA_Bridge w/Dots - Brultech
|
Back to Top |
|
|
gg102 Senior Member
Joined: January 29 2013 Location: United States
Online Status: Offline Posts: 245
|
Posted: January 15 2024 at 20:17 | IP Logged
|
|
|
Great News!
Thanks for sharing
|
Back to Top |
|
|
GCollins Groupie
Joined: March 27 2011 Location: United States
Online Status: Offline Posts: 54
|
Posted: January 16 2024 at 20:41 | IP Logged
|
|
|
Yes, glad it helped! The forum sure helped me!
__________________ PH2 Integr: JV Digital, Compose, Harmony, Insteon, Leviton, X10-Pro, DSC, Radio Shack, HA-Bridge/Alexa, UniFi Protect
Alexa Integr: Ecobee, Philips Hue, UniFi Protect, Sengled Zigbee, Kasa WiFi
|
Back to Top |
|
|
|
|