Control Your Apex with Siri

Users Who Are Viewing This Thread (Total: 1, Members: 0, Guests: 1)

blazeby

Active Member
View Badges
Joined
Feb 11, 2017
Messages
144
Reaction score
49
Rating - 0%
0   0   0
Hi all,

Thanks to a free framework called Homebridge I've been able to control my tank with Siri voice commands.

I find this useful for when my hands are wet and the touch screen on my tablet won't work to turn things on and off via my Apex. Now I just say "Hey Siri, turn off the skimmer" or "Hey Siri, turn off the aquarium alarm".

Homebridge is an open source framework that allows us to add none HomeKit devices to HomeKit and this allow Siri control of those devices.

First thing you need to do is install Homebridge, it's free and instructions are here: https://github.com/nfarina/homebridge

In the Mac terminal: npm install -g homebridge

I used to run it on my Mac but nowadays have it running on a Raspberry Pi - works well on either platform. It also works on Windows machines although I have never tried that.

Next install a Homebridge plug-in called cmdSwitch2 with npm install -g homebridge-cmdswitch2

Now you have to edit your Homebridge config file (config.json) to add the control params for your Apex.

The Apex can be controlled by simple HTTP POST commands and we're going to use them. Your cmdswitch2 entries in your Homebridge config file should look something like this:

"platform": "cmdSwitch2",
"name": "CMD Switch",
"switches": [
{
"name" : "Skimmer",
"on_cmd": "/usr/bin/curl -X POST --user admin:<adminPassword> http://<apexIPaddress>:<apexPortNumber>/status.sht?Skimmer_state=2&Update=Update",
"off_cmd": "/usr/bin/curl -X POST --user admin:<adminPassword> http://<apexIPaddress>:<apexPortNumber>/status.sht?Skimmer_state=1&Update=Update",
}

The state (apexDevice_state) is 0 for Auto, 1 for OFF, and 2 for ON.

And thats it!

Thanks to this thread for the HTTP POST info: https://www.reef2reef.com/threads/guide-how-to-control-neptune-apex-using-google-home.319864/

I may spend sometime to get Siri to be able to report the current state of devices and probes and possibly write a dedicate Apex Homebridge plug-in if time permits.
 

Joe Carioti

Active Member
View Badges
Joined
Aug 18, 2017
Messages
130
Reaction score
74
Rating - 0%
0   0   0
This looks great! If Homebridge allows for it, you might be able to get outlets or VDM controllability in the Home app as well as controllable by Siri commands.
 

Carlos@CoralVue

Active Member
View Badges
Joined
Dec 2, 2013
Messages
227
Reaction score
359
Location
Chicago, IL
Rating - 0%
0   0   0
Nice! That's super powerful. Do you mind sharing your Homebridge configuration?

Sure thing...

Code:
{
    "bridge": {
        "name": "Homebridge",
        "username": "CC:22:3D:E3:CE:30",
        "port": 123456,
        "pin": "031-45-154"
    },

    "description": "This is an example configuration file with one fake accessory and one fake platform. You can use this as a template for creating your own configuration file containing devices you actually own.",

    "accessory": [],

    "platforms": [
    {
        "platform": "cmdSwitch2",
        "name": "CMD Switch",
        "switches": [
        {
            "name": "Water Change",
            "on_cmd": "/usr/bin/curl -X POST --user <<username>>:<<password>> http://<<ip address>>:<<port>>/status.sht?Return_Pump_state=1&Update=Update",
            "off_cmd": "/usr/bin/curl -X POST --user <<username>>:<<password>> http://<<ip address>>:<<port>>/status.sht?Return_Pump_state=0&Update=Update"
        },
        {
            "name": "Lights",
            "on_cmd": "/usr/bin/curl -X POST --user <<username>>:<<password>> http://<<ip address>>:<<port>>/status.sht?Lights_state=0&Update=Update",
            "off_cmd": "/usr/bin/curl -X POST --user <<username>>:<<password>> http://<<ip address>>:<<port>>/status.sht?Lights_state=1&Update=Update"
        },
        {
            "name": "Skimmer",
            "on_cmd": "/usr/bin/curl -X POST --user <<username>>:<<password>> http://<<ip address>>:<<port>>/status.sht?Skimmer_state=0&Update=Update",
            "off_cmd": "/usr/bin/curl -X POST --user <<username>>:<<password>> http://<<ip address>>:<<port>>/status.sht?Skimmer_state=1&Update=Update"
        },
        {
            "name": "Gyre Left",
            "on_cmd": "/usr/bin/curl -X POST --user <<username>>:<<password>> http://<<ip address>>:<<port>>/status.sht?XF280_Left_state=0&Update=Update",
            "off_cmd": "/usr/bin/curl -X POST --user <<username>>:<<password>> http://<<ip address>>:<<port>>/status.sht?XF280_Left_state=1&Update=Update"
        },
        {
            "name": "Gyre Right",
            "on_cmd": "/usr/bin/curl -X POST --user <<username>>:<<password>> http://<<ip address>>:<<port>>/status.sht?XF280_Right_state=0&Update=Update",
            "off_cmd": "/usr/bin/curl -X POST --user <<username>>:<<password>> http://<<ip address>>:<<port>>/status.sht?XF280_Right_state=1&Update=Update"
        },
        {
            "name": "Smart ATO",
            "on_cmd": "/usr/bin/curl -X POST --user <<username>>:<<password>> http://<<ip address>>:<<port>>/status.sht?ATO_state=0&Update=Update",
            "off_cmd": "/usr/bin/curl -X POST --user <<username>>:<<password>> http://<<ip address>>:<<port>>/status.sht?ATO_state=1&Update=Update"
        },
        {
            "name": "Fans",
            "on_cmd": "/usr/bin/curl -X POST --user <<username>>:<<password>> http://<<ip address>>:<<port>>/status.sht?Cooling_Fans_state=0&Update=Update",
            "off_cmd": "/usr/bin/curl -X POST --user <<username>>:<<password>> http://<<ip address>>:<<port>>/status.sht?Cooling_Fans_state=1&Update=Update"
        },
        {
            "name": "Feed",
            "on_cmd": "/usr/bin/curl -X POST --user <<username>>:<<password>> http://<<ip address>>:<<port>>/status.sht?Feed_state=0&Update=Update",
            "off_cmd": "/usr/bin/curl -X POST --user <<username>>:<<password>> http://<<ip address>>:<<port>>/status.sht?Feed_state=1&Update=Update"
        }
        ]
    }]
}

BTW, I could not figure out the call for FeedX so I ended up creating a virtual outlet that allows me to do the same. The catch is that I have to remember to turn it OFF or the feed will never stop. So if you can figure out the call for FeedA, let me know!
 

Joe Carioti

Active Member
View Badges
Joined
Aug 18, 2017
Messages
130
Reaction score
74
Rating - 0%
0   0   0
Sure thing...

Code:
{
    "bridge": {
        "name": "Homebridge",
        "username": "CC:22:3D:E3:CE:30",
        "port": 123456,
        "pin": "031-45-154"
    },

    "description": "This is an example configuration file with one fake accessory and one fake platform. You can use this as a template for creating your own configuration file containing devices you actually own.",

    "accessory": [],

    "platforms": [
    {
        "platform": "cmdSwitch2",
        "name": "CMD Switch",
        "switches": [
        {
            "name": "Water Change",
            "on_cmd": "/usr/bin/curl -X POST --user <<username>>:<<password>> http://<<ip address>>:<<port>>/status.sht?Return_Pump_state=1&Update=Update",
            "off_cmd": "/usr/bin/curl -X POST --user <<username>>:<<password>> http://<<ip address>>:<<port>>/status.sht?Return_Pump_state=0&Update=Update"
        },
        {
            "name": "Lights",
            "on_cmd": "/usr/bin/curl -X POST --user <<username>>:<<password>> http://<<ip address>>:<<port>>/status.sht?Lights_state=0&Update=Update",
            "off_cmd": "/usr/bin/curl -X POST --user <<username>>:<<password>> http://<<ip address>>:<<port>>/status.sht?Lights_state=1&Update=Update"
        },
        {
            "name": "Skimmer",
            "on_cmd": "/usr/bin/curl -X POST --user <<username>>:<<password>> http://<<ip address>>:<<port>>/status.sht?Skimmer_state=0&Update=Update",
            "off_cmd": "/usr/bin/curl -X POST --user <<username>>:<<password>> http://<<ip address>>:<<port>>/status.sht?Skimmer_state=1&Update=Update"
        },
        {
            "name": "Gyre Left",
            "on_cmd": "/usr/bin/curl -X POST --user <<username>>:<<password>> http://<<ip address>>:<<port>>/status.sht?XF280_Left_state=0&Update=Update",
            "off_cmd": "/usr/bin/curl -X POST --user <<username>>:<<password>> http://<<ip address>>:<<port>>/status.sht?XF280_Left_state=1&Update=Update"
        },
        {
            "name": "Gyre Right",
            "on_cmd": "/usr/bin/curl -X POST --user <<username>>:<<password>> http://<<ip address>>:<<port>>/status.sht?XF280_Right_state=0&Update=Update",
            "off_cmd": "/usr/bin/curl -X POST --user <<username>>:<<password>> http://<<ip address>>:<<port>>/status.sht?XF280_Right_state=1&Update=Update"
        },
        {
            "name": "Smart ATO",
            "on_cmd": "/usr/bin/curl -X POST --user <<username>>:<<password>> http://<<ip address>>:<<port>>/status.sht?ATO_state=0&Update=Update",
            "off_cmd": "/usr/bin/curl -X POST --user <<username>>:<<password>> http://<<ip address>>:<<port>>/status.sht?ATO_state=1&Update=Update"
        },
        {
            "name": "Fans",
            "on_cmd": "/usr/bin/curl -X POST --user <<username>>:<<password>> http://<<ip address>>:<<port>>/status.sht?Cooling_Fans_state=0&Update=Update",
            "off_cmd": "/usr/bin/curl -X POST --user <<username>>:<<password>> http://<<ip address>>:<<port>>/status.sht?Cooling_Fans_state=1&Update=Update"
        },
        {
            "name": "Feed",
            "on_cmd": "/usr/bin/curl -X POST --user <<username>>:<<password>> http://<<ip address>>:<<port>>/status.sht?Feed_state=0&Update=Update",
            "off_cmd": "/usr/bin/curl -X POST --user <<username>>:<<password>> http://<<ip address>>:<<port>>/status.sht?Feed_state=1&Update=Update"
        }
        ]
    }]
}


Awesome! Thanks Carlos. I had the config.json syntax messed up a bit. I just got this working with my system. That was easier than I expected for sure.
 

Joe Carioti

Active Member
View Badges
Joined
Aug 18, 2017
Messages
130
Reaction score
74
Rating - 0%
0   0   0
So, one thing that adds a nice touch here is to populate the "state_cmd" value so Homekit can report back the proper outlet state (on or off). The trick here is how we handle the fact that the cmdSwitch2 library only supports on and off and Apex supports on, off, and auto. Here are the two variations that I can't decide between...

Config 1
Use this configuration to report "ON" when the outlet is in either in AUTO or ON mode (If the outlet is in AUTO-OFF mode, it will report "ON" in Homekit):
Code:
"state_cmd": "/usr/bin/curl --fail --silent --show-error --user admin:{{YOUR_APEX_PASSWORD}} http://{{YOUR_APEX_IP}}:{{YOUR_APEX_PORT}}/cgi-bin/status.xml | grep -i '<name><{{YOUR_APEX_OUTLET_NAME}}</name>' -A2 | grep -E -i 'AO|ON'"
I prefer this config because I rarely ever turn my outlets to full ON. I always consider OFF = OFF and ON = AUTO. So when the outlet is in AUTO mode, I want Homekit to tell me that the outlet is turned ON.


Config 2
Use this configuration to report "ON" if the outlet is getting electrical power (If the outlet is in AUTO-OFF mode, it will report "OFF" in Homekit):
Code:
"state_cmd": "/usr/bin/curl --fail --silent --show-error --user admin:{{YOUR_APEX_PASSWORD}} http://{{YOUR_APEX_IP}}:{{YOUR_APEX_PORT}}/cgi-bin/status.xml | grep -i '<name><{{YOUR_APEX_OUTLET_NAME}}</name>' -A2 | grep -i 'ON'"
This configuration might be what you guys would expect to see. If your skimmer is turned on by any means (ON, or AUTO-ON), you'll see "ON" in HomeKit. If your skimmer is turned off by any means (OFF, or AUTO-OFF), you'll see "OFF" in HomeKit.
 

Carlos@CoralVue

Active Member
View Badges
Joined
Dec 2, 2013
Messages
227
Reaction score
359
Location
Chicago, IL
Rating - 0%
0   0   0
I think Config 1 makes total sense to me. That is how I have some of my switches set. At the end of the day, this is for me and not someone else. I understand the logic of it and it is something that makes sense.

The only issue I see is if something is set to OFF automatically. Like the fans... The fans could be set to AUTO but the default state is OFF. That is where this would get a little tricky.
 
Last edited:

Carlos@CoralVue

Active Member
View Badges
Joined
Dec 2, 2013
Messages
227
Reaction score
359
Location
Chicago, IL
Rating - 0%
0   0   0
Love it when things come together!!!
IMG_0285.png
 
OP
OP
blazeby

blazeby

Active Member
View Badges
Joined
Feb 11, 2017
Messages
144
Reaction score
49
Rating - 0%
0   0   0
You guys have done a great job! I use a combo of config 1 and config 2 depending on whether or not Auto is set to ON or OFF.

For the FeedX not turning off problem this is where HomeKit will help you out - you can set a timer to automatically turn a device on or off via the Home app.

IMG_9D0CD68E8A81-1.jpeg
 

Joe Carioti

Active Member
View Badges
Joined
Aug 18, 2017
Messages
130
Reaction score
74
Rating - 0%
0   0   0
You guys have done a great job! I use a combo of config 1 and config 2 depending on whether or not Auto is set to ON or OFF.

For the FeedX not turning off problem this is where HomeKit will help you out - you can set a timer to automatically turn a device on or off via the Home app.

IMG_9D0CD68E8A81-1.jpeg

Great idea. I might look into forking that cmd2switch library to allow for on, off, and auto states. It would need a different UI than the standard HomeKit “switch” UI. I’ll report back if I find anything useful.
 
OP
OP
blazeby

blazeby

Active Member
View Badges
Joined
Feb 11, 2017
Messages
144
Reaction score
49
Rating - 0%
0   0   0
Thinking about forking it myself to provide temperature sensor support so we can retrieve temp, pH, ORP etc via Homebridge.
 

High pressure shells: Do you look for signs of stress in the invertebrates in your reef tank?

  • I regularly look for signs of invertebrate stress in my reef tank.

    Votes: 39 32.5%
  • I occasionally look for signs of invertebrate stress in my reef tank.

    Votes: 28 23.3%
  • I rarely look for signs of invertebrate stress in my reef tank.

    Votes: 23 19.2%
  • I never look for signs of invertebrate stress in my reef tank.

    Votes: 30 25.0%
  • Other.

    Votes: 0 0.0%
Back
Top