Control Your Apex with Siri

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

danR777

Active Member
View Badges
Joined
Oct 26, 2020
Messages
176
Reaction score
111
Location
South Florida
Rating - 100%
4   0   0
Is not possible anymore... ? status.sht always getting a <HTML><HEAD><TITLE>401 Unauthorized</TITLE></HEAD><BODY>401 Unauthorized</BODY></HTML> with curl
Nevermind I got it.. had to wrap the url in single quotes & also add the credentials inside of the url for some reason (example http://user:pass@ip in single quotes on Homebridge for macOS
 

zelik

New Member
View Badges
Joined
Apr 4, 2019
Messages
16
Reaction score
10
Rating - 0%
0   0   0
Hi all!

Old thread, but I had to share what I've been able to do, figure someone might be interested!
d6GW2ua.jpg
ztcZ0mD.png

I'm not sure if imgur linking is allowed? But here's the url to see these photos:

Combining all the efforts and useful information from previous posters, namely @blazeby, I was able to list all my sensors in homekit using homebridge and CMD4 plugin(see pic). Because homekit has some limitations to display numbers, you must hit the Lux button in the photo to see the individual sensors (other than temp which is displayed on the status bar utilizing a temp accessory emulation). What we are doing is using the CMD4 plugin to emulate light sensors and temperature sensors to display the sensor data. Because our sensor data number range can go up to a few thousand, light sensors are the best option.


I'm not great at documenting, but here goes. As mentioned before, you need homebridge installed. You also need a plugin installed in homebridge called CMD4. Warning: a little complicated ahead.

Install CMD4 by searching for the plugin Homebridge-CMD4. Install it.

Next, edit the config. You need to add
Code:
   {"platform": "Cmd4",
    "name": "Cmd4",
    "debug": "true",
    "Cmd4_Mode": "Polled",
then, your accessories.

For temperature, we will be emulating TemperatureSensor
Code:
"accessories": [
        {
            "Type": "TemperatureSensor",
            "CurrentTemperature": 22.2,
            "StatusActive": "TRUE",
            "StatusFault": "NO_FAULT",
            "StatusTampered": "NOT_TAMPERED",
            "StatusLowBattery": "BATTERY_LEVEL_NORMAL",
            "Name": "ReefTemp",
            "Manufacturer": "Apex",
            "Model": "Neptune",
            "SerialNumber": "12345",
            "StateChangeResponseTime": 3,
            "Polling": [
                {
                    "Characteristic": "CurrentTemperature",
                    "Interval": 50,
                    "Timeout": 8000
                }
            ],
            "State_cmd": "/homebridge/apextemp.sh"
        },

Note: The Polling is the number that will change by polling Apex. The rest are just values that the plugin will cache and give to homekit.
What you want to edit is: Name and State_cmd . Name to what you want the sensor to show up as in Homekit, and State_cmd is the script to poll Apex Neptune for the sensor values.

Here's my apextemp.sh script:
Code:
curl --fail --silent --show-error --user YOUR_APEX_LOGIN:YOUR_APEX_PASSWORD http://YOUR_APEX_IP_ADDRESS:YOUR_APEX_PORT_ADDRESS/cgi-bin/status.xml | grep -i '<name>YOUR_TEMP_SENSOR_NAME</name>' | grep '<value>' |  cut -f4 -d'>'| cut -f1 -d ' '

Note: the spacing is important in this script! Items in ALL CAPS are to be filled in by you for your system. My temp sensor was TMP so I put TMP there.

To get a list of your sensor names, refer to Apex app/website OR visit: http://YOUR_APEX_IP_ADDRESS/cgi-bin/status.xml in a webbrowser. If you aren't using the standard port 80, then change it to http://YOUR_APEX_IP_ADDRESS:YOUR_APEX_PORT_ADDRESS/cgi-bin/status.xml
For the other sensors that you have, we will be emulating LightSensor. This include SALT, ORP, pH, and if you have a trident, ALK, CA, MG .
Code:
{
            "Type": "LightSensor",
            "DisplayName": "ORP",
            "CurrentAmbientLightLevel": 1,
            "StatusActive": "TRUE",
            "StatusFault": "NO_FAULT",
            "StatusTampered": "NOT_TAMPERED",
            "StatusLowBattery": "BATTERY_LEVEL_NORMAL",
            "Name": "ORP",
            "Manufacturer": "Apex",
            "Model": "Neptune",
            "SerialNumber": "12345",
            "StateChangeResponseTime": 3,
            "State_cmd": "/homebridge/apexorp.sh",
            "Polling": [
                {
                    "Characteristic": "CurrentAmbientLightLevel",
                    "Interval": 50,
                    "Timeout": 8000
                }
            ]
        },

The associated scripts:
Code:
curl --fail --silent --show-error --user YOUR_APEX_LOGIN:YOUR_APEX_PASSWORD http://YOUR_APEX_IP_ADDRESS:YOUR_APEX_PORT_ADDRESS/cgi-bin/status.xml | grep -i '<name>YOUR_SENSOR_NAME</name>' | grep '<value>' |  cut -f4 -d'>'| cut -f1 -d ' '
So basically it's the same script as the temp sensor, but you change the sensor name. The cut -f1 -d ' ' could be replaced with a regex, which IS necessary for Apex Trident Calcium polling because the value has space around the number. Strange, I don't know why. For that, I used this modified script:

Code:
curl --fail --silent --show-error --user YOUR_APEX_LOGIN:YOUR_APEX_PASSWORD http://YOUR_APEX_IP_ADDRESS/cgi-bin/status.xml | grep -i '<name>YOUR_SENSOR_NAME</name>' | grep '<value>' |  cut -f4 -d'>'| sed 's/[^0-9]*//g'
Here's my full config as an example for you as reference. I am using port 80 so I omitted the port :

Code:
{
    "platform": "Cmd4",
    "name": "Cmd4",
    "debug": "true",
    "Cmd4_Mode": "Polled",
    "accessories": [
        {
            "Type": "TemperatureSensor",
            "CurrentTemperature": 22.2,
            "StatusActive": "TRUE",
            "StatusFault": "NO_FAULT",
            "StatusTampered": "NOT_TAMPERED",
            "StatusLowBattery": "BATTERY_LEVEL_NORMAL",
            "Name": "ReefTemp",
            "Manufacturer": "Apex",
            "Model": "Neptune",
            "SerialNumber": "12345",
            "StateChangeResponseTime": 3,
            "Polling": [
                {
                    "Characteristic": "CurrentTemperature",
                    "Interval": 50,
                    "Timeout": 8000
                }
            ],
            "State_cmd": "/homebridge/apextemp.sh"
        },
        {
            "Type": "LightSensor",
            "DisplayName": "ORP",
            "CurrentAmbientLightLevel": 1,
            "StatusActive": "TRUE",
            "StatusFault": "NO_FAULT",
            "StatusTampered": "NOT_TAMPERED",
            "StatusLowBattery": "BATTERY_LEVEL_NORMAL",
            "Name": "ORP",
            "Manufacturer": "Apex",
            "Model": "Neptune",
            "SerialNumber": "12345",
            "StateChangeResponseTime": 3,
            "State_cmd": "/homebridge/apexorp.sh",
            "Polling": [
                {
                    "Characteristic": "CurrentAmbientLightLevel",
                    "Interval": 50,
                    "Timeout": 8000
                }
            ]
        },
        {
            "Type": "LightSensor",
            "DisplayName": "Salinity",
            "CurrentAmbientLightLevel": 1,
            "StatusActive": "TRUE",
            "StatusFault": "NO_FAULT",
            "StatusTampered": "NOT_TAMPERED",
            "StatusLowBattery": "BATTERY_LEVEL_NORMAL",
            "Name": "Salinity",
            "Manufacturer": "Apex",
            "Model": "Neptune",
            "SerialNumber": "12345",
            "StateChangeResponseTime": 3,
            "State_cmd": "/homebridge/apexsalinity.sh",
            "Polling": [
                {
                    "Characteristic": "CurrentAmbientLightLevel",
                    "Interval": 50,
                    "Timeout": 8000
                }
            ]
        },
        {
            "Type": "LightSensor",
            "DisplayName": "pH",
            "CurrentAmbientLightLevel": 1,
            "StatusActive": "TRUE",
            "StatusFault": "NO_FAULT",
            "StatusTampered": "NOT_TAMPERED",
            "StatusLowBattery": "BATTERY_LEVEL_NORMAL",
            "Name": "pH",
            "Manufacturer": "Apex",
            "Model": "Neptune",
            "SerialNumber": "12345",
            "StateChangeResponseTime": 3,
            "State_cmd": "/homebridge/apexph.sh",
            "Polling": [
                {
                    "Characteristic": "CurrentAmbientLightLevel",
                    "Interval": 50,
                    "Timeout": 8000
                }
            ]
        },
        {
            "Type": "LightSensor",
            "DisplayName": "ALK",
            "CurrentAmbientLightLevel": 1,
            "StatusActive": "TRUE",
            "StatusFault": "NO_FAULT",
            "StatusTampered": "NOT_TAMPERED",
            "StatusLowBattery": "BATTERY_LEVEL_NORMAL",
            "Name": "ALK",
            "Manufacturer": "Apex",
            "Model": "Neptune",
            "SerialNumber": "12345",
            "StateChangeResponseTime": 3,
            "State_cmd": "/homebridge/apexalk.sh",
            "Polling": [
                {
                    "Characteristic": "CurrentAmbientLightLevel",
                    "Interval": 50,
                    "Timeout": 8000
                }
            ]
        },
        {
            "Type": "LightSensor",
            "DisplayName": "CA",
            "CurrentAmbientLightLevel": 1,
            "StatusActive": "TRUE",
            "StatusFault": "NO_FAULT",
            "StatusTampered": "NOT_TAMPERED",
            "StatusLowBattery": "BATTERY_LEVEL_NORMAL",
            "Name": "CA",
            "Manufacturer": "Apex",
            "Model": "Neptune",
            "SerialNumber": "12345",
            "StateChangeResponseTime": 3,
            "State_cmd": "/homebridge/apexca.sh",
            "Polling": [
                {
                    "Characteristic": "CurrentAmbientLightLevel",
                    "Interval": 50,
                    "Timeout": 8000
                }
            ]
        },
        {
            "Type": "LightSensor",
            "DisplayName": "MG",
            "CurrentAmbientLightLevel": 1,
            "StatusActive": "TRUE",
            "StatusFault": "NO_FAULT",
            "StatusTampered": "NOT_TAMPERED",
            "StatusLowBattery": "BATTERY_LEVEL_NORMAL",
            "Name": "MG",
            "Manufacturer": "Apex",
            "Model": "Neptune",
            "SerialNumber": "12345",
            "StateChangeResponseTime": 3,
            "State_cmd": "/homebridge/apexmg.sh",
            "Polling": [
                {
                    "Characteristic": "CurrentAmbientLightLevel",
                    "Interval": 50,
                    "Timeout": 8000
                }
            ]
        }
    ],
    "_bridge": {
        "username": "0E:D5:C9:C9:5D:2D",
        "port": 47821
    }
}

**The _bridge is optional, that utilized homebridge's new child bridge feature. Please read up on that if you want to use that.
 

fpizart

Community Member
View Badges
Joined
Dec 22, 2019
Messages
88
Reaction score
104
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.
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.
Hi! I know this is a super old post! But did you ever write an official plug-in? I can’t get it to work
 

Beazy

Community Member
View Badges
Joined
May 15, 2021
Messages
36
Reaction score
13
Location
MA, USA
Rating - 0%
0   0   0
I'm been checking out this post a few times this year before I started using homebridge. Just bought a home this past summer and really dove deep with it to make all my devices work well. At first it didn't seem worth the effort to me but I made some home made fish food and now its a PITA to start my feed cycles when I forget my phone upstairs lol.

All that to say, I'm making a plugin. Went hard today and yesterday and I'm pretty much done. The config is quite verbose, yet it should be able to get you everything you need. I'm still testing and my trident is out for service, once it comes back I'll try to wrap it up and publish it (prob gonna be around Thanksgiving). Hopefully you guys or anyone else is around to share some ideas

Features:

- Full support for all probes. I tried to future proof the plugin(I only have 1 of each probe and 1 apex) by having each probe type have its own individual settings. Tbh, temp is the only one that needed it since apex gives temp in C
- Full support for any outlet. I tried to leave it up to the user for customization. There are 4 states for apex outlets - on, off, auto on and auto off. The config will let you specify if you want Auto Off to show Off or On and if you want the default On state to be On instead of Auto
- The trident looks like it uses the same logic as probes. I plan to support this as well if this is the case
- Feed Modes on and off. This is the main reason I made the post, was hoping you guys can share ideas. Carlos mentioned he used a virtual outlet to show whether feed mode was activated or not. I would have gone that route since its smooth except that would force anyone who wanted to use feed modes to have the outlet. For now, my plan is just to have a timer on each outlet and have them shut off after the time elapses. The timer will be adjustable in the config
- Last bit, its all modular. You only add what you want and aren't forced to add anything extra


Considering also adding in energy monitoring too. I got really into the weeds with this and will prob take a break once I release all of the initial stuff up above. Atm its all implemented except feed modes (working on the timeout logic or if I need the virtual outlet) and the trident

Big shoutout to everyone who shared their journey in setting this up, it made this very easy for me... well sort of. I always wanted to publish a plugin for something and boy was that a good chunk of reading for homebridge
 

Beazy

Community Member
View Badges
Joined
May 15, 2021
Messages
36
Reaction score
13
Location
MA, USA
Rating - 0%
0   0   0
It’s been a hot minute since I added an update. The holidays were quite long for me and I just got back into my groove this weekend.

I added support for the trident and now all that’s left is testing the outlets and feed mode again. If I remembered correctly I think I was having connectivity issues from hitting the apex api too frequently. That being said homebrew hasn’t been playing nicely with my desktop for some reason. My dev station won’t display any of the accessories once connected anymore. Not sure if it’s a homebrew issue or an issue with my setup.

If I do figure it out, I’ll update this thread again next month with a beta link. Would be nice to get some feedback on it, especially the probes since I won’t be using that. I’d be using it for 3 feed modes plus the 2 outlets I use for weekly maintenance
 

Reefing threads: Do you wear gear from reef brands?

  • I wear reef gear everywhere.

    Votes: 17 16.5%
  • I wear reef gear primarily at fish events and my LFS.

    Votes: 6 5.8%
  • I wear reef gear primarily for water changes and tank maintenance.

    Votes: 0 0.0%
  • I wear reef gear primarily to relax where I live.

    Votes: 17 16.5%
  • I don’t wear gear from reef brands.

    Votes: 55 53.4%
  • Other.

    Votes: 8 7.8%
Back
Top