Control Your Apex with Siri

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

Carlos@CoralVue

Active Member
View Badges
Joined
Dec 2, 2013
Messages
227
Reaction score
359
Location
Chicago, IL
Rating - 0%
0   0   0
Here's a way to activate the real feed modes:
Code:
"on_cmd": "/usr/bin/curl -X POST --retry 5 --max-time 2 --retry-connrefused --fail --silent --show-error --user username:pw 'http://apex/status.sht?FeedSel=0&FeedCycle=Feed'",
"off_cmd": "/usr/bin/curl -X POST --retry 5 --max-time 2 --retry-connrefused --fail --silent --show-error --user username:pw http://apex/status.sht?FeedCycle=Feed%20Cancel",
"state_cmd": "/usr/bin/curl --retry 5 --max-time 2 --retry-connrefused --fail --silent --show-error http://apex/cgi-bin/status.xml | grep -i '<name>Feeding</name>' -A2 | grep -E -i 'ON'"

FeedSel=0 for FeedA
FeedSel=1 for FeedB
FeedSel=2 for FeedC
FeedSel=3 for FeedD

One detail is that in order for the state_cmd to work, I had to make a virtual outlet called "Feeding" that turns on whenever any of the feed modes are on. I couldn't find a way to query for the feed status without making an extra outlet. The programming is just:
Code:
Set Off
If FeedA 000 Then On
If FeedB 000 Then On
If FeedC 000 Then On
If FeedD 000 Then On

Yes, I had to do the Virtual Outlet as well. Once I created that, activating feed was easy. I also created a virtual outlet for water changes and it sure makes my life way easier! The only thing is you need to program HomeKit to turn the Feed outlet back OFF after you are done. Otherwise you have to manually remember to ask Siri.

This is a far better solution. Thank you!!!
 
Last edited:

Joe Carioti

Active Member
View Badges
Joined
Aug 18, 2017
Messages
130
Reaction score
74
Rating - 0%
0   0   0
Yes, I had to do the Virtual Outlet as well. Once I created that, activating feed was easy. I also created a virtual outlet for water changes and it sure makes my life way easier! The only thing is you need to program HomeKit to turn the Feed outlet back OFF after you are done. Otherwise you have to manually remember to ask Siri.

This is a far better solution. Thank you!!!

No problem! There's no way I would have remembered to turn off feed mode each time :)

You can always use scenes/automation to automate turning a switch back off after a certain amount of time, just FYI.
 

kdtfd5

New Member
View Badges
Joined
Mar 10, 2018
Messages
2
Reaction score
0
Rating - 0%
0   0   0
Hey all - this is incredibly amazing and I badly want this functionality for my tank. After hours and hours of googling I now know about 0.0001% more programming language than I did before. I've got the home bridge and cmdswitch2 plugin installed. After a million syntax errors, I can finally get the home bridge and outlet to show up on HomeKit and actually respond, the switch clicks on and off on home kit. But my return (the device I decided to start with) is not influenced by the home kit switch at all.

Here's the example of what I loaded: I've been confused about how to actually load the username and password exactly into the command line, want to make sure I'm doing it right, don't need any < >. In this example I'm using the user name: ken Password: 1234

"platforms": [{
"platform": "cmdSwitch2",
"name": "CMD Switch",
"switches": [{
"name": "Return",
"on_cmd": "usr/bin/curl -X POST --ken:1234 http://10.0.0.219:80/status.sht?Return_state=0&Update=Update",
"off_cmd": "usr/bin/curl -X POST --ken:1234 http://10.0.0219:80/status.sht?Return_state=1&Update=Update"

Of note, when I cut and paste the http link in my command line into my browser, it does shut off or turn on my return, so I think it's something with the first part that is screwing it up.

Thanks for the help!!!
 

Breadman03

Valuable Member
View Badges
Joined
Jun 30, 2015
Messages
2,249
Reaction score
2,022
Location
Luzerne County, PA
Rating - 0%
0   0   0
I think I'm going to do this...but I've got to let my BAC come down a bit first :) It's not often I down a few quickly. I'm more of a sipper.
 

Joe Carioti

Active Member
View Badges
Joined
Aug 18, 2017
Messages
130
Reaction score
74
Rating - 0%
0   0   0
Hey all - this is incredibly amazing and I badly want this functionality for my tank. After hours and hours of googling I now know about 0.0001% more programming language than I did before. I've got the home bridge and cmdswitch2 plugin installed. After a million syntax errors, I can finally get the home bridge and outlet to show up on HomeKit and actually respond, the switch clicks on and off on home kit. But my return (the device I decided to start with) is not influenced by the home kit switch at all.

Here's the example of what I loaded: I've been confused about how to actually load the username and password exactly into the command line, want to make sure I'm doing it right, don't need any < >. In this example I'm using the user name: ken Password: 1234

"platforms": [{
"platform": "cmdSwitch2",
"name": "CMD Switch",
"switches": [{
"name": "Return",
"on_cmd": "usr/bin/curl -X POST --ken:1234 http://10.0.0.219:80/status.sht?Return_state=0&Update=Update",
"off_cmd": "usr/bin/curl -X POST --ken:1234 http://10.0.0219:80/status.sht?Return_state=1&Update=Update"

Of note, when I cut and paste the http link in my command line into my browser, it does shut off or turn on my return, so I think it's something with the first part that is screwing it up.

Thanks for the help!!!

Try this instead:
Code:
usr/bin/curl -X POST --user ken:1234 http://10.0.0.219:80/status.sht?Return_state=0&Update=Update
 

kdtfd5

New Member
View Badges
Joined
Mar 10, 2018
Messages
2
Reaction score
0
Rating - 0%
0   0   0
Thanks for the help Joe! I tried that, adding the user in there. No such luck. Any other suggestions?
 

Joe Carioti

Active Member
View Badges
Joined
Aug 18, 2017
Messages
130
Reaction score
74
Rating - 0%
0   0   0
Thanks for the help Joe! I tried that, adding the user in there. No such luck. Any other suggestions?

I just realize I was missing the leading "/" in my last reply. The command should look identical to this:
Code:
/usr/bin/curl -X POST --user ken:1234 http://10.0.0.219:80/status.sht?Return_state=0&Update=Update

If this doesn't work, send me a PM.
 

CableGuy

New Member
View Badges
Joined
Nov 23, 2011
Messages
1
Reaction score
1
Location
SCS, MI
Rating - 0%
0   0   0
Hey, sold off my reef due to wanting to move about a year ago but kept my Apex for my next tank... In the mean time, I used your post #15 to figure out the current state with Home Assistant. So thank you!!
 

Ryan Hunter

Community Member
View Badges
Joined
Jan 28, 2016
Messages
90
Reaction score
60
Location
Vancouver BC Canada
Rating - 0%
0   0   0
Got everything working great as far as the Apex goes, thanks guys. Has anybody messed around trying to add an ATI wifi powermodule? Trying to see if I can get that going.
 

codyderrick

New Member
View Badges
Joined
Jul 21, 2015
Messages
24
Reaction score
7
Location
Dallas, TX
Rating - 0%
0   0   0
Has anyone tried to do this on a Windows machine? It took me way longer to get the `state_cmd` working than it should have, but I think I finally have it.

Code:
"name": "Return Pump",
"on_cmd": "curl -X POST --user admin:1234 http://apex.local/status.sht?VSR-9000_state=0",
"off_cmd": "curl -X POST --user admin:1234 http://apex.local/status.sht?VSR-9000_state=1",
"state_cmd": "powershell \"& { invoke-webrequest -usebasicparsing http://apex.local/cgi-bin/status.xml | select-xml -xpath \\\"//outlet[name/text()='VSR-9000']/state\\\" | %{ if ($_ -match 'OFF') {  exit 1 }} } \" "
 

444rich

Community Member
View Badges
Joined
Mar 7, 2018
Messages
38
Reaction score
13
Rating - 0%
0   0   0
Hey all - this is incredibly amazing and I badly want this functionality for my tank. After hours and hours of googling I now know about 0.0001% more programming language than I did before. I've got the home bridge and cmdswitch2 plugin installed. After a million syntax errors, I can finally get the home bridge and outlet to show up on HomeKit and actually respond, the switch clicks on and off on home kit. But my return (the device I decided to start with) is not influenced by the home kit switch at all.

Here's the example of what I loaded: I've been confused about how to actually load the username and password exactly into the command line, want to make sure I'm doing it right, don't need any < >. In this example I'm using the user name: ken Password: 1234

"platforms": [{
"platform": "cmdSwitch2",
"name": "CMD Switch",
"switches": [{
"name": "Return",
"on_cmd": "usr/bin/curl -X POST --ken:1234 http://10.0.0.219:80/status.sht?Return_state=0&Update=Update",
"off_cmd": "usr/bin/curl -X POST --ken:1234 http://10.0.0219:80/status.sht?Return_state=1&Update=Update"

Of note, when I cut and paste the http link in my command line into my browser, it does shut off or turn on my return, so I think it's something with the first part that is screwing it up.

Thanks for the help!!!

having same issue, ever got it to work?
 

wshinji

New Member
View Badges
Joined
Oct 29, 2018
Messages
10
Reaction score
0
Rating - 0%
0   0   0
Hello and bump,

Can anyone confirm if this is still currently working with latest AOS? I cannot seem to get apex to access curl POST http requests anymore. Coming back with 401 Unauthorized Error even when the correct --user details has been defined. Works directly in a browser but not from curl. Any ideas?

Only road block at the moment. If someone can be so kind to confirm if this is working for them for those who have previously successfully got apex voice commands to work via curl.
thank you.
 

Greg's 6.6 Pico

New Member
View Badges
Joined
Jul 8, 2017
Messages
19
Reaction score
22
Location
Orlando
Rating - 0%
0   0   0
Hi all I seem to be getting a error myself and it is driving me up the wall, any help would be appriciated.

Rrror code -

Code:
Last login: Sun Jun 30 20:04:16 on ttys000
Gregs-MBP-2:~ GregGilbert$ homebridge
[6/30/2019, 8:06:06 PM] There was a problem reading your config.json file.
[6/30/2019, 8:06:06 PM] Please try pasting your config.json file here to validate it: http://jsonlint.com
[6/30/2019, 8:06:06 PM]
/usr/local/lib/node_modules/homebridge/lib/server.js:218
    throw err;
    ^

SyntaxError: Unexpected token } in JSON at position 151
    at JSON.parse (<anonymous>)
    at Server._loadConfig (/usr/local/lib/node_modules/homebridge/lib/server.js:212:19)
    at new Server (/usr/local/lib/node_modules/homebridge/lib/server.js:56:38)
    at module.exports (/usr/local/lib/node_modules/homebridge/lib/cli.js:32:16)
    at Object.<anonymous> (/usr/local/lib/node_modules/homebridge/bin/homebridge:17:22)
    at Module._compile (internal/modules/cjs/loader.js:776:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
Gregs-MBP-2:~ GregGilbert$

and this is the json code im trying out

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

  },
  "accessories": [
    }
  ],

  "platforms": [
     {
         "platforms": [{
         "platform": "cmdSwitch2",
         "name": "CMD Switch",
         "switches": [{
         "name": "Return",
         "on_cmd": "usr/bin/curl -X POST --admin:1234 http://192.168.1.75:80/status.sht?Return_state=0&Update=Update",
         "off_cmd": "usr/bin/curl -X POST --admin:1234 http://192.168.1.75:80/status.sht?Return_state=1&Update=Update"
 

CoralVue

Community Member
View Badges
Joined
Mar 12, 2019
Messages
28
Reaction score
29
Rating - 0%
0   0   0
Your JSON file does not have the correct syntax. Try this...

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

    },
    "accessories": [],

    "platforms": [{
        "platforms": [{
            "platform": "cmdSwitch2",
            "name": "CMD Switch",
            "switches": [{
                "name": "Return",
                "on_cmd": "usr/bin/curl -X POST --admin:1234 http://192.168.1.75:80/status.sht?Return_state=0&Update=Update",
                "off_cmd": "usr/bin/curl -X POST --admin:1234 http://192.168.1.75:80/status.sht?Return_state=1&Update=Update"
            }]
        }]
    }]
}
 

Greg's 6.6 Pico

New Member
View Badges
Joined
Jul 8, 2017
Messages
19
Reaction score
22
Location
Orlando
Rating - 0%
0   0   0
Thank you that worked but now i am getting a plug in error, Any ideas on that one?

Code:
Last login: Sun Jun 30 20:05:24 on ttys000
Gregs-MBP-2:~ GregGilbert$ homebridge
[7/1/2019, 1:22:55 AM] Loaded config.json with 0 accessories and 1 platforms.
[7/1/2019, 1:22:55 AM] ---
[7/1/2019, 1:22:55 AM] No plugins found. See the README for information on installing plugins.
[7/1/2019, 1:22:55 AM] Loading 1 platforms...
[7/1/2019, 1:22:55 AM] TypeError: Cannot read property 'indexOf' of undefined
    at API.platform (/usr/local/lib/node_modules/homebridge/lib/api.js:120:12)
    at Server._loadPlatforms (/usr/local/lib/node_modules/homebridge/lib/server.js:327:45)
    at Server.run (/usr/local/lib/node_modules/homebridge/lib/server.js:90:36)
    at module.exports (/usr/local/lib/node_modules/homebridge/lib/cli.js:59:10)
    at Object.<anonymous> (/usr/local/lib/node_modules/homebridge/bin/homebridge:17:22)
    at Module._compile (internal/modules/cjs/loader.js:776:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
[7/1/2019, 1:22:55 AM] Got SIGTERM, shutting down Homebridge...
 

Greg's 6.6 Pico

New Member
View Badges
Joined
Jul 8, 2017
Messages
19
Reaction score
22
Location
Orlando
Rating - 0%
0   0   0
Hey there still trying to figure this out. whenever I run the install comand I end up this.

Code:
Gregs-MBP-2:~ GregGilbert$ npm install -g homebridge-cmdswitch2
Unhandled rejection Error: EACCES: permission denied, mkdir '/Users/GregGilbert/.npm/_cacache/index-v5/fe/94'

npm ERR! cb() never called!

npm ERR! This is an error with npm itself. Please report this error at:
npm ERR!     <https://npm.community>

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/GregGilbert/.npm/_logs/2019-07-02T02_20_03_967Z-debug.log
Gregs-MBP-2:~ GregGilbert$
 
OP
OP
blazeby

blazeby

Active Member
View Badges
Joined
Feb 11, 2017
Messages
144
Reaction score
49
Rating - 0%
0   0   0
try this:

sudo npm install -g --unsafe-perm homebridge-cmdswitch2
 

Greg's 6.6 Pico

New Member
View Badges
Joined
Jul 8, 2017
Messages
19
Reaction score
22
Location
Orlando
Rating - 0%
0   0   0
Ok, that worked but now ive run into this.


Code:
Gregs-MBP-2:~ GregGilbert$ sudo npm install -g --unsafe-perm homebridge-cmdswitch2
Password:
+ [email protected]
added 1 package from 1 contributor in 1.307s
Gregs-MBP-2:~ GregGilbert$ homebridge
[7/2/2019, 9:25:36 PM] Loaded config.json with 0 accessories and 1 platforms.
[7/2/2019, 9:25:36 PM] ---
[7/2/2019, 9:25:36 PM] Loaded plugin: homebridge-cmdswitch2
[7/2/2019, 9:25:36 PM] Registering platform 'homebridge-cmdswitch2.cmdSwitch2'
[7/2/2019, 9:25:36 PM] ---
[7/2/2019, 9:25:36 PM] Loading 1 platforms...
[7/2/2019, 9:25:36 PM] TypeError: Cannot read property 'indexOf' of undefined
    at API.platform (/usr/local/lib/node_modules/homebridge/lib/api.js:120:12)
    at Server._loadPlatforms (/usr/local/lib/node_modules/homebridge/lib/server.js:327:45)
    at Server.run (/usr/local/lib/node_modules/homebridge/lib/server.js:90:36)
    at module.exports (/usr/local/lib/node_modules/homebridge/lib/cli.js:59:10)
    at Object.<anonymous> (/usr/local/lib/node_modules/homebridge/bin/homebridge:17:22)
    at Module._compile (internal/modules/cjs/loader.js:776:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
[7/2/2019, 9:25:36 PM] Got SIGTERM, shutting down Homebridge...

Here is my config.json

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

    },
    "accessories": [],

    "platforms": [{
        "platforms": [{
            "platform": "cmdSwitch2",
            "name": "CMD Switch",
            "switches": [{
                "name": "Return",
                "on_cmd": "usr/bin/curl -X POST --admin:1234 http://192.168.1.75:80/status.sht?Return_state=0&Update=Update",
                "off_cmd": "usr/bin/curl -X POST --admin:1234 http://192.168.1.75:80/status.sht?Return_state=1&Update=Update"
            }]
        }]
    }]
}
 

Reefing threads: Do you wear gear from reef brands?

  • I wear reef gear everywhere.

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

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

    Votes: 1 0.5%
  • I wear reef gear primarily to relax where I live.

    Votes: 27 13.0%
  • I don’t wear gear from reef brands.

    Votes: 119 57.5%
  • Other.

    Votes: 14 6.8%
Back
Top