Siri Control of Apex (SCA) without HomeBridge

shih87

Active Member
View Badges
Joined
Aug 24, 2012
Messages
156
Reaction score
256
Location
Taiwan
Seawitch submitted a new Article:

Siri Control of Apex (SCA) without HomeBridge

For a while I have thought that I would have to learn HomeBridge (for a HomeBridge version “how-to” please refer to @blazeby's R2R article) to be able to use Siri to control my Neptune Apex. But this changed after Apple in 2018 bought WorkFlows and renamed it to Shortcuts.

First, I sincerely appreciate @afhtan, who in Aug 2017 published an article called “Guide: How to control Neptune Apex using Google Home” in the R2R forum here. He did all the hard work including using Wireshark to sniff Apex messages. It is now an open Pandora's Box and makes possible all voice-assist tools to talk to Apex.

Before a detailed step-by-step of how I make SCA (Siri Control Apex) work, here are two YouTube clips I posted a while ago, here and here, to give you some idea of SCA. I'm sorry that it has taken me much longer than expected to publish “SCA how-to” article that I had promised.

r2r1.png

Part I: Write Apex

Let’s start with the easy one--“write” Apex first. Yes, it is actually more steps if we try to “read” Apex, which I will addressed in Part II in this article.

Step 0: Build your environment

Install Shortcuts (Fig. 1). It is a free APP that you can easily install from the Apple APP store.

Figure 1
r2r3.png

Step 1: Understand Apex command

As addressed in Afhtan’s article, the Apex controller will follow your command if the following message is received.

Figure 2
r2r4.png

If you would like to understand more detail about state option 0, 1, and 2, please refer to Afhtan’s article (here is that link again.)

Step 2: Get access to Apex and issue your command

In the Shortcuts design, unlike simply opening a command line window and issuing a command, you need first (fig.3) to wrap your password in Text format and use a Base64 Encode library. Then put them into your URL. (Note: I omitted my Apex password and my Apex URL, but it should be straightforward by following Afhtan's provided Apex command example.)

Figure 3
r2r5.png

Last step in the Shortcuts design is just simply call “Get Contents of URL” library (Fig. 4) and select “POST” method (default), and don’t forget to change Authorization from “Basic” to “Base64 Encode” in the header section.

Figure 4
r2r6.png

And that is it. You just completed your first Shortcuts.

Don’t forget to give your new Shortcuts a name and an icon. I won’t cover this in detail here but there are a lot of YouTube videos that cover it.

Step 3 Put all your new Shortcuts into one

Ok, now you have your first Shortcuts ready, but usually we would like Siri to do multiple things with a single command. For that, you may use Step 2 to create as many Shortcuts as you need first. For example, when I do a water change, I want (a) all wavemakers to stop and all reactors to stop, (b) two main pumps to stop, and (c) a LED light in sump to turn ON. For (a), I decide to use Apex feeder mode to trigger them off, so all I need to do is a Shortcut to turn ON feeder mode. (Note: If you are not familiar with Apex’s programming logic, please check the Apex user manual). You can use step 2 to easily get this done. For (b), and (c), I create a few more Shortcuts to turn pumps OFF and LED ON separately.

Once all these Shortcuts are ready, simply create a “water change mode” Shortcut to put all of them into one Shortcut. (see Fig. 5). You can also add a “Show Result” (Fig. 6) library to allow Siri say something reflect the results.

Figure 5
r2r7.png


Figure 6
r2r8.png

Step 4: Train your Siri to recognize your new Shortcuts

Once I put all Shortcuts into one “Water Change Mode” Shortcuts, I would like to train my Siri to recognize my voice. To do so, please go to Name and Icon set-up page, under Siri Phrase (Fig. 7), train your Siri to recognize your vocal commands.

Figure 7
r2r9.png

That's it. Now you can ask Siri to issue command(s) to manage your Neptune Apex. My water change mode YouTube video is available here.

Part II: Read Apex

As mentioned, Read Apex is a few steps more when compare to Write Apex. However, step 0 to step 2 are exactly the same.

Step 3: Parsing your target value by Regex

There may be many better approaches to find the value you are looking for: I choose parsing and retrieving from Apex HTML message. Let’s take tank's ORP value as an example.

By checking the entire Apex HTML message, I found my tank's ORP value 429 is located in a particular section (Fig. 8).

Figure 8
r2r10.png

The rest is straightforward. I first run a “Make HTML from Rich Text” library in Shortcuts to dump all HTML messages to Shortcuts; and then convert <BR> to space for some text clean up; at the end, run a Regex in “Match Text” library to get my ORP value (Fig. 9).

Figure 9
r2r11.png

Step 4: Let Siri tell you the value

Please refer to Step 3 to get other Apex probe values (PH, Temp, etc..). Now you can create new Shortcuts such as “Tank Status”, add “Run Shortcuts” library, map those Shortcuts you created in Step 3, and follow with a “Set Variable” library to give the variable a name (e.g. ORP), and at the end, add a “Show Result” to reflect the results. (Fig.10)

Figure 10
r2r12.png

Don’t forget to train your Siri to recognize your new Shortcuts command as Step 4 in Part I.

That's it. Here is a YouTube video of my tank status.


~~~~~~~~~~~~~~~~~~~~

Note from the Editor: This article was written by someone for whom English is not his first language. I have tried to improve its readability, but I'm limited by not being an expert either on Apex or computer programming. Any errors are likely mine. All images are courtesy of @shih87.

~~~~~~~~~~~~~~~~~~~~

We encourage all our readers to join the Reef2Reef forum. It’s easy to register, free, and reefkeeping is much easier and more fun in a community of fellow aquarists. We pride ourselves on a warm and family-friendly forum where everyone is welcome. You will also find lots of contests and giveaways with our sponsors.

~~~~~~~~~~~~~~~~~~~~

Author Profile: @shih87

@shih87 is one of our forum members living in Taiwan. The build thread for his beautiful high-tech tank can be found here.
 
Top Shelf Aquatics

Nep2nRev1

Active Member
View Badges
Joined
Jan 13, 2019
Messages
237
Reaction score
372
Location
Timberlake, NC
I truly wish I had the patience/aptitude to utilize these technologies. The end result for me trying to work with any type of programming is handfuls of hair in the floor and a trip to the liquor cabinet. Having said that this is a great article and I can see it as be very useful and tool for those who do utilize this equipment.
 

Seawitch

Water, water everywhere,
View Badges
Joined
Nov 3, 2018
Messages
1,740
Reaction score
4,378
Location
Vancouver Island
I truly wish I had the patience/aptitude to utilize these technologies. The end result for me trying to work with any type of programming is handfuls of hair in the floor and a trip to the liquor cabinet. Having said that this is a great article and I can see it as be very useful and tool for those who do utilize this equipment.

I totally agree. As far as I know, Apex is the only controller that will control everything, and it doesn't look all that user friendly to me. I think automation is a great idea, but I can't imagine myself using Apex.
 

Nep2nRev1

Active Member
View Badges
Joined
Jan 13, 2019
Messages
237
Reaction score
372
Location
Timberlake, NC
Having said that this is a great article and I can see it as be very useful and tool for those who do utilize this equipment.
Oh geeze....<sigh>.....I should really proofread my posts better. Looks as if I was already elbow deep in the liquor cabinet.
I have an Apex Jr. and DOS system I purchased strictly to perform automated water changes. Hope to get it running this weekend but that has been a big enough challenge for me!! I've considered installing the high end Apex controller but I would have to get the folks from the LFS to do the install. Way above my head. My hat's off to @shih87.
 
Top Shelf Aquatics

Dimmy007

Well-Known Member
View Badges
Joined
Jun 23, 2018
Messages
905
Reaction score
4,940
Location
Waukesha, WI
Thanks for all your hard work. Having an issue or maybe I am misunderstanding.
After the Get Content URL the default is GET
Under Header this is no Authorization or Basic. Do we just Type that in?
 
OP
shih87

shih87

Active Member
View Badges
Joined
Aug 24, 2012
Messages
156
Reaction score
256
Location
Taiwan
Thanks for all your hard work. Having an issue or maybe I am misunderstanding.
After the Get Content URL the default is GET
Under Header this is no Authorization or Basic. Do we just Type that in?
Oops....Thanks for the correction.
Yes, the default actually is "GET". I used "POST" too often and thought it is the default one. Sorry.
Yes, you need to type "Authorization" in, and then from click Variables, choose "Base64 Encoded"...
I miss the detail sub steps in my set-to-step guide. Hope others can pick from your findings here.
 
Last edited:

scriptmonkey

Valuable Member
View Badges
Joined
Mar 22, 2017
Messages
1,677
Reaction score
4,524
Location
Baltimore, MD
This is awesome, thanks for the hard work!

While I love home automation and have some in my house I want to just warn people to some of the pitfalls. A good friend of mine went full on Alexa with his entire house, electronic door locks, lights, thermostats, everything. This one day I come over and I showed him a big downfall, I went to his window in the front of his house from outside yelled "Alexa, open front door" and it unlocked.

You really might not want main pumps and total control of your tank on these things because if you make your neighbor or a neighborhood kid mad and they heard your commands before (we all yell at those things like they are hard of hearing) what's to stop them from crashing your tank?
 
OP
shih87

shih87

Active Member
View Badges
Joined
Aug 24, 2012
Messages
156
Reaction score
256
Location
Taiwan
Oh geeze....<sigh>.....I should really proofread my posts better. Looks as if I was already elbow deep in the liquor cabinet.
I have an Apex Jr. and DOS system I purchased strictly to perform automated water changes. Hope to get it running this weekend but that has been a big enough challenge for me!! I've considered installing the high end Apex controller but I would have to get the folks from the LFS to do the install. Way above my head. My hat's off to @shih87.

Don't worry about it. My SW developer background may help me a bit of using Apex. Once understood Apex syntax and coding structure/logic, it become easy. However, there are still lots out of text book details to make Apex more powerful.

Honestly, the world without Apex could be better for many reefers, but since I travel a lot, remote control my tank for risk handling become crucial (my wife don't want to touch my tank and help AT ALL..<sigh>...
 
OP
shih87

shih87

Active Member
View Badges
Joined
Aug 24, 2012
Messages
156
Reaction score
256
Location
Taiwan
This is awesome, thanks for the hard work! While I love home automation and have some in my house I want to just warn people to some of the pitfalls. A good friend of mine went full on Alexa with his entire house, electronic door locks, lights, thermostats, everything. This one day I come over and I showed him a big downfall, I went to his window in the front of his house from outside yelled "Alexa, open front door" and it unlocked.
You really might not want main pumps and total control of you tank on these things because if you make your neighbor or a neighborhood kid mad and they heard your commands before (we all yell at those things like they are hard of hearing) what's to stop them from crashing your tank?
Haha...You absolutely right. I disable "hi Siri" function and only long press iPhone button now can trigger siri into listen mode for coming voice commands. Anyhow, it is a big debate to have a simple common turn off main pump, even I have alert trigger when main pump off.
 

scriptmonkey

Valuable Member
View Badges
Joined
Mar 22, 2017
Messages
1,677
Reaction score
4,524
Location
Baltimore, MD
Haha...You absolutely right. I disable "hi Siri" function and only long press iPhone button can trigger voice commands. Anyhow, it is a big debate to have a simple common turn off main pump, even I have alert trigger when main pump off.

Like I said awesome article, when I get my new tank set up and the Apex out the giant pile of parts I have, you convinced me that I may do some of the "gets" like Temp, PH, and Salinity. I may enable being able to turn on under stand lights.

Good thinking on press to talk. Thanks again
 

Dimmy007

Well-Known Member
View Badges
Joined
Jun 23, 2018
Messages
905
Reaction score
4,940
Location
Waukesha, WI
Hi when I input
curl -X POST --user admin:xxxx http://xx.x.x.xxx:80/status.sht?Skimmer_state=0&Update=Update
is not working but when I remove every thing before http it's working (curl -X POST --user admin:xxxx )
but I still have to manual log in, what I'm I missing ?
This is where I am stuck as well. Are we suppose to type "curl -X POST -- user admin:XXXXX ? We can not put spaces in a url.

When I run mine I get a 401 Unauthorized error
 

Dimmy007

Well-Known Member
View Badges
Joined
Jun 23, 2018
Messages
905
Reaction score
4,940
Location
Waukesha, WI
Oops....Thanks for the correction.
Yes, the default actually is "GET". I used "POST" too often and thought it is the default one. Sorry.
Yes, you need to type "Authorization" in, and then from click Variables, choose "Base64 Encoded"...
I miss the detail sub steps in my set-to-step guide. Hope others can pick from your findings here.
Is the Base 64 encode as text or do we change that to something else?
 
Lazys Coral House
OP
shih87

shih87

Active Member
View Badges
Joined
Aug 24, 2012
Messages
156
Reaction score
256
Location
Taiwan
Also what’s the URL to get the status or how do I get the Apex HTML message?

Also what’s the URL to get the status or how do I get the Apex HTML message?

My fault did not state clearly :(

in URL field... you just need to do the following...

http://[your apex ip:port]/status.sht?FEEDER_12_1_state=1&Update=Update

Those hearer such as " curl -X POST --user admin:xxxx" already took care in previous steps.
Please also note that "FEEDER_12_1" should be changed and reflect to whatever your items name in Apex, "FEEDER_12_1" is my Apex item name only.
 

tyreef

New Member
View Badges
Joined
Jun 8, 2014
Messages
23
Reaction score
10
Location
Miami
My fault did not state clearly :(

in URL field... you just need to do the following...

http://[your apex ip:port]/status.sht?FEEDER_12_1_state=1&Update=Update

Those hearer such as " curl -X POST --user admin:xxxx" already took care in previous steps.
Please also note that "FEEDER_12_1" should be changed and reflect to whatever your items name in Apex, "FEEDER_12_1" is my Apex item name only.

I still don't understand in the TEXT box do I put login and password admin:1234 ?

Also what’s the URL to get the status or how do I get the Apex HTML message?
 
OP
shih87

shih87

Active Member
View Badges
Joined
Aug 24, 2012
Messages
156
Reaction score
256
Location
Taiwan
Also what’s the URL to get the status or how do I get the Apex HTML message?

r2r11.png

In above step, just don't add "Replace Text" and "Match Text" library, let "Make HTML from Rich Text" become the last shortcut library, then your Shortcuts will dump Apex message when you run your Shortcuts.
 

Dimmy007

Well-Known Member
View Badges
Joined
Jun 23, 2018
Messages
905
Reaction score
4,940
Location
Waukesha, WI
r2r11.png

In above step, just don't add "Replace Text" and "Match Text" library, let "Make HTML from Rich Text" become the last shortcut library, then your Shortcuts will dump Apex message when you run your Shortcuts.
Thanks for taking your time to help us out. I keep getting 401 unauthorized. If you could take a look and see if I m missing anything.


this is my url line http://10.0.1.162:80/status.sht?ATO_state1&Update=Update

ATO is the name only in my Apex. username:password I change to what I log in with on my apex.
IMG_0501.png
IMG_0502.png
 

Would you love to have a super cool anemone? (these are the best)

  • YES

    Votes: 343 82.1%
  • NO

    Votes: 68 16.3%
  • Other (please explain)

    Votes: 7 1.7%

Online statistics

Members online
1,742
Guests online
4,917
Total visitors
6,659
Top