[OBSOLETE] Magic Home WiFi LED Control

not a bad way to do it. I would perhaps suggest adding an ampersand at the end of the parameters so that it is

-l -c “tcptunnel/tcptunnel --local-port=5577 --remote-port=5577 --remote-host=172.16.2.53 --log --fork&”

This will make sure it runs in the background of the cygwin process. Not likely perhaps, but it prevents that if someone presses Ctrl+C on that session that it doesn’t stop the instance.

Another way:

Create a batch script and add: bash.exe -c "/home/homeUser/LEDController.sh ; /bin/bash"
Add batch script in windows startup (or use scheduler)
Create a script in Linux with proper permission (for ex: LEDController.sh)
Add all your controllers or lights (also can control Magic Home color lights). EX:

#!/bin/bash
/home/homeUser/tcptunnel/tcptunnel --local-port=XXXX1 --remote-port=5577 --remote-host=10.x.x.x --log --stay-alive &
/home/homeUser/tcptunnel/tcptunnel --local-port=XXXX2 --remote-port=5577 --remote-host=10.x.x.x --log --stay-alive &
/home/homeUser/tcptunnel/tcptunnel --local-port=XXXX3 --remote-port=5577 --remote-host=10.x.x.x --log --stay-alive &


That’s it.

When windows boot, it will execute the batch file which will run the controller script with the BASH window open and always active.

1 Like

Hey, Im just starting out with your API and I do have a question, is there anyway for me to redirect the audio source used in the app to direct audio from my PC? And is there anyway for me to activate specific effects when a specific sound or cue is played?

Unfortunately, it is not my API and at this time it is not possible to use an audio source for the dance party lights other than the microphone on a phone or table that is running the Magic Home App.

This one should be doable, since most of the animations and states are exposed as functions you can create a scene or a rule in something like WebCORE.

I have been using this for the 3 strips in my kitchen for a while. I had to reset the strips today to change my WiFi network, and as I was testing it after I was done I noticed that if I set the level to 100% in smartthings they aren’t at full brightness. If I go over to the Magic Home app it shows them at 51%, and I can increase further to 100%
Is there something I am missing?

I’ve seen this a couple of times before, if you fix the smartthing brightness and then change colors it should stay. It appears to be something with how smartthings tracks the brightness setting.

Does this allow access to the custom user defined functions?

2018-11-11 06:40:32 tcptunnel: Valid Options Read
2018-11-11 06:40:32 tcptunnel: Server Built
Still doesnt work
I tried opening a server with my rooted galaxy and got no where both with cygwin and phones port forwarder, i did get a device network id…

Hi @Exit2studios, I’m not 100% clear what functionality you are mentioning? If you are referring to the 3 “User” buttons that may appear at the bottom, they currently do nothing. I had an idea for them, due to a use case I thought that I had personally, but abandoned it due to time and it not being worth the time.

Hi @BaRaD5, this appears to be your first post here on this thread. I am happy to help in a DM and we can see about getting your configuration up and working. I’m not sure what you are trying to do with the phone, but it may just be a misunderstanding about which IP goes where, as that logging from CygWin looks good for a start-up, but that it hasn’t received a message from SmartThings yet to forward to your light.

Great guy, helped me figure out what was wrong and even offered to go as far as team viewer to help, In SmartThings under the gears for the device I created I had to use the computers IP instead of the controllers…
Works perfectly fine now and hope to get more led strips soon!

1 Like

@ph4r In the Magic Home app, you are able to create custom scenes, which it labels as “Functions”. I was trying to determine if there is a way to access those via the API.

Not at this point, I’m pretty sure I could make it doable that you enter a string which would be used for the custom buttons, but you would need to know what the string looks like… I’d need someone to packetsniff an example, I think a custom animation would be something like

51ff00000000ff0000ff00000000ff0000ff00000000ff0000ff00000000ff00ff00000000ff0000ff00000000ff0000ff00000000ff0000ff00000000ff0000193bff0fa3

Here is how I have my Windows Machine running my lights via Cygwin automatically on login.

[C:\cygwin64\home(your windows username)\LED.bat]

bash C:\cygwin64\home\(your windows username)\runTunnel.sh&

[C:\cygwin64\home(your windows username)\runTunnel.sh]

#!/bin/bash          
cd ~/tcptunnel
./tcptunnel --local-port=5577 --remote-port=5577 --remote-host=10.10.10.62 --log --fork&
./tcptunnel --local-port=5578 --remote-port=5577 --remote-host=10.10.10.63 --log --fork&

With those two files in place, I use Windows Task Scheduler to start the LED.bat file on login

Hello, Thanks again ph4r for this fantastic script. It has been working flawlessly for the past year! I am using these LED Controllers to run my upper and under cabinet lights separately with two controllers. I am running docker on my NAS and inside of docker I am loading a centos 7 container exposing the necessary ports and running a script at startup that launches the tcptunnel service.

One issue I have ran into is I can’t launch more than one instance of the tcptunnel service in the same terminal. Once you execute the command it starts reporting events as commands are sent from smartthings and will not allow you to launch it again for a different controller. I have gotten around this by deploying a completely separate centos container which works fine.

Just checking if anyone has any better ideas for me or if there is a way to stop the verbose logging of tcptunnel in order to input another instance of the tcptunnel service. I am considering adding 2 more of these controllers and it might be a little overkill to have 4 instances of centos running just to control my lights.

-JO

1 Like

Are you not able to start the program with the & at the end as in the .sh script just above? Also, to turn off the logging, omit the --log parameter.

I knew it would be simple… I over-think things way to often. Thanks!

1 Like

Hello, and thanks to ph4r on his work with this app.

I managed to get TCP tunnel going. However, when I use the SmartThings app to turn it on or off, I get on the Cygwin console several dozens of:
“2018-12-28 15:48:04 tcptunnel: request from 192.168.1.40”
which ends with:
“build_tunnel: connect(): Address already in use”
And, the lights do not turn on or off.

I’m on Windows PC. Any suggestion? Thank you.

Sounds like a firewall issue, or that you put the wrong IP Address in when you started the tunnel. I can help you diagnose over a DM if you need.

So, I made some changes to how I use this at my own home now and I now run the TCPTunnel on a Raspberry Pi 3B+ in the background on startup. It isn’t even a blip on the resource monitor, so I’m pretty sure it would run on a PiZeroW as well. I might just pick one of them up soon to try it out.

The more important change was something that has been in there since day one. I have reduced lag significantly for this background task by swapping out the --keep-alive for --fork! It now appears to keep the connection between the tunnel app and the LED Controller, so that commands are send directly as received. Where this is most obvious is sending multiple commands in a row such as when trying to tweak a color, brightness, or fast On/Off cycles. It is NOT night and day, but it is a noticeable improvement that I felt worth sharing.

2 Likes