I’ve got an application which controls my electric shades through a TCPSocket. My goal is to be able to control them with Siri voice commands. I believe I can do this using Apple Shortcuts using an SSH script. I have my app running on a server on my LAN.
I need some help with methods to talk to my application from SSH using arguments which I can configure to control the various shades. I can figure out the protocol once I’m able to just tunnel into my application.
Any suggestions for getting this happening would be appreciated. Thanks.
Edit: Oops, I misunderstood and got that backwards. You’re looking for System.CommandLine to get the arguments.
Thanks, Tim. I’ll have to experiment with this. At first glance, it looks like these arguments are passed when an application is launched. My app is always running. I guess I’ll need to study terminal commands a bit more. I need to figure out how to send commands to my app while it’s running. Thanks.
Console applications have StandardInputStream which can be read, but desktop applications do not have this ability.
I’m now looking at IPCSocket as a possible solution.
Another possibility would be to have a companion console app that communicates with your app through a socket (IPC or TCP) or through a shared document folder where you pass in a formatted file like JSON.
I just did some testing using the TCP Server example. I was able to Telnet into it from the Mac terminal. This sounds like the solution I can implement easily, logging in remotely using SSH. I’ll let you know how things work out. Thanks for the suggestions.
I solved my problem using a TCP server with the “Listen” method. It only takes a few lines of code. The “Run Script over SSH” shortcut sends commands using nc:
echo Hallway,Up | nc -w 1 127.0.0.1 8235
The 8235 is just a random port number. My App receives the command and moves the shade, in this case the Hallway shade goes up.
Thanks for your help.