Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comments, Questions, open forum (2) #6

Open
bren1818 opened this issue Dec 5, 2016 · 278 comments
Open

Comments, Questions, open forum (2) #6

bren1818 opened this issue Dec 5, 2016 · 278 comments

Comments

@bren1818
Copy link
Owner

bren1818 commented Dec 5, 2016

Closed the last topic as it had gotten really lengthy. Opening this one for more questions

@merrickw
Copy link

merrickw commented Dec 6, 2016

Thanks Bren for your previous responses; looking forward to any IFTTT or SmartThings development to keep these bulbs alive into the future ...

@merrickw
Copy link

Hi Bren,

Happy New Year!

Just curious if you have any thing in the works for IFTTT or SmartThings? Ultimately I'd love to get Google Home to control these bulbs.

Regards,
Merrick

@bren1818
Copy link
Owner Author

Hey @merrickw - nothing yet. Smart things requires me to have the Samsung Bridge which I dont have. I did look into the IFTTT. They have an applet for 'Connect Greenwave Systems' which of course doesnt work since it's tied to the Greenwave servers they took down... So I have 'applied' to be a maker:
image
Which is still labelled as 'coming soon'. I mean all we really need is an applet which allows http requests, so it shouldn't be hard, but its likely harder than what IFTTT wants for the average user...

I have been re-writing some of the code, so I can support more than one bridge at a time and control HUE lights too (inc colour). It's not really ready for prime time... Needs some polish, but if you want to experiment it is in the non master branch.

Cheers

@merrickw
Copy link

Thanks for the update. The IFTTT sounds the most interesting, but I guess it can only work if you have your local web server running... which makes sense, you wouldn't want the cloud turning off your lights, with all the hacking going on .... I haven't bought any Hue lights yet ... my TCP's got me covered ...

@k8gg
Copy link

k8gg commented Jan 28, 2017

Now that the Greenwave link got sacked, the clock resides in my TCP gateway is drifting away every single day. So over last 6 months or so, mine is now like 20-30 minutes ahead. Sunrise/sunset schedule would be way off also.

So, quick questions: Is there a way to correct the clock in gateway via some UI on local web server? Or better yet, get the clock to sync with local web server automatically/periodically?

Count this as a feature request. :)

Oh BTW, I was talking about the clock inside the gateway. I understand that the scheduler on local web server would trigger just fine.

And, great work Bren! I'm excited!!

@bren1818
Copy link
Owner Author

@k8gg Hey there - I'm guessing you're looking at the regular branch versus dev? I'll look into time setting. I'm fairly certain it will be possible. Stay tuned...

@k8gg
Copy link

k8gg commented Jan 28, 2017

Yes, branch.
Great work you've got so far! Also the IFTTT idea sounds awesome. :)

@bren1818
Copy link
Owner Author

@k8gg - Done - pull master, should have 3 updates, index.php, setDateTime.php and a JS file. I have made the new screen to set date and time. I kinda whipped it together... so hope it works. Pretty simple. There appears to be functions to set time zone too, but this should do the trick... I don't use the built in Bridge functions so please let me know. Thanks!

image

@sktaylortrash
Copy link
Collaborator

This date tweak worked awesome for me thanks so much

@bren1818
Copy link
Owner Author

@sktaylortrash - Awesome glad to hear it. I just need to find some time to finish the build I have in progress in Dev which has Hue integration and hooks for multiple bridges. Not enough hours in a day :)

@k8gg
Copy link

k8gg commented Jan 31, 2017

Yup. The date/time update interface worked. Thanks a lot @bren1818 !

@sktaylortrash
Copy link
Collaborator

@bren1818 forgive my asking but what would the use case for multiple bridges be?

@k8gg
Copy link

k8gg commented Feb 1, 2017 via email

@sktaylortrash
Copy link
Collaborator

Oh I get multiple brands I meant multiple TCP bridges

@bren1818
Copy link
Owner Author

bren1818 commented Feb 1, 2017

@sktaylortrash - reason for multiple TCP bridges is two fold. I bought up some of the bridge packs when they were clearing them out. At one point I accidentally messed up my bridge, which required me to re-flash it and downgrade the firmware. Before I got it to work again, I got kind of frustrated and started setting up a second bridge so I could continue development on this project and so I could control my bulbs via a web interface. This meant re-setting up all my existing bulbs on the new bridge. Its a lengthy thing to do, so I was tackling it room by room, every few days. When I eventually got my initial bridge working again, I had half my bulbs on one bridge and the other half on the other bridge. I was going to migrate all the bulbs back to one bridge, however - by having two bridges it offered one advantage, since I use remotes, having one bridge meant I only had 4 buttons to control all the lights in my house, both upstairs and downstairs. By having a second bridge, I could pair half my remotes with the downstairs, and half the remotes with the upstairs, meaning I had 8 buttons to control the house. Not a huge deal, but comes in handy when you're fumbling around in the dark, so you dont turn on the whole house but half of it :)

@k8gg is also right. I wanted to extend my project to work with at least Hue since I have some Hue lights, and by having two TCP bridges, it allows me to test code compatibility with multiple hubs.

Hope that answers your question 👍

@sktaylortrash
Copy link
Collaborator

@bren1818 so I totally should have thought of the remote thing. I have 3 in a drawer I'll never use for that reason. May need to pickup another bridge or two. It's not like I now have 24 bulbs running or anything :)

@merrickw
Copy link

merrickw commented Feb 1, 2017

Another way to use 2 remotes and have 8 zones is to keep 4 bulbs off the gateway, and connect to a remote directly. I did this so one remote controls 4 bulbs in my upstairs bedroom, off the gateway. The main floor is on the gateway. This works perfectly since I don't need scheduling or remote access for my bedroom lights, just the handy remote. The support guys at TCP walked me through how to set that up.

@bren1818
Copy link
Owner Author

bren1818 commented Feb 1, 2017

@sktaylortrash haha, I can't say I have that many either... but in the bedroom, we have two lamps on either side of the bed and 3 bulbs acting as one appliance in the ceiling fan, so it's nice to have the remote to turn on/off and dim the lights that way. I stuck some Velcro on the back of the remotes (I have 5 of them) and stuck them to the wall to use as a switch too. They're handy but at the same time, remotes... remotes everywhere haha

@merrickw makes a very good point too. You don't necessarily need to bridges to accomplish this. It just sorta worked out that way for me.

@vijimaini
Copy link

Hi Bren,
I read about this project and am excited that I can possibly now remotely connect to my bulbs from outside the house. I have setup IIS on windows machine with web application addons for php. My problem is I cannot get token from tcp box. I press the Sync button on the TCP box with green leds blinking around and then on the windows machine browser I type http://localhost/index.php. The browser connects to tcp box and says waiting for local host. Finally it says with error "Firefox has detected that server is redirecting the request for this address in a way that will never complete"
I have added ip adresss in the include.php. The version of firmware on the tcp box is 3.0.80. Could this version be causing issues.
Please advise how I can get token. My tcp app on iPad and iPhone work fine when I am at home on local LAN

Thanks
Viji

@bren1818
Copy link
Owner Author

Hi @vijimaini - shouldn't be an issue, I'm pretty sure my bridges have the latest firmware. The more likely issue is you're using IIS. - I cant say I have tested with IIS.

In your IIS folder, could you create a simple php file like: <?php echo "Hello World"; ?> and see if you can load that? It could also be that with IIS you do not have the curl library being loaded.

I recommend you download XAMPP and try the project in there first. Let me know if that helps.

Cheers!

@vijimaini
Copy link

Bren, I installed XAMPP and it works perfectly.
Thanks for your help.

@bren1818
Copy link
Owner Author

@vijimaini Glad to hear that. When you use IIS, you'd likely have needed to enable some php extensions which come pre-enabled on xampp. Fortunately you can use Apache and IIS simultaneously.

Cheers,

Bren

@shrms
Copy link

shrms commented Mar 15, 2017

Hi Bren,
I am newbie to development, could you please me setting this up. I am NAS storage.
Is there any documentation that can help me seeting up from scratch, as i ddon't have development background.
Regards

@bren1818
Copy link
Owner Author

@shrms - Sure, its pretty straightforward and you wont need any development experience. You will however need to have a bit of knowledge about home networking.

So first things first, download yourself XAMPP: https://www.apachefriends.org/index.html its free. I suggest getting the version with PHP 5.6.3
image

Install the application, if you use the defaults, it will set you up an htdocs folder in: C:\xampp\htdocs

this is the folder you want to download this project into. So download the zip
image

and extract its contents into the folder, the htdocs folder should look something like this:

image

now the tricky part, using a text editor of your choice, (I suggest Notepad++) and edit the include.php file.

You can leave pretty much everything as is, with one exception - edit LINE 8, and replace the IP address with the local IP address of your lighting bridge.

image

You can usually find this in your routers DHCP/client listing. Once you have the IP in there, save the file,.

Press the Sync button on your bridge, and then open up localhost. (go to a browser and type: http://localhost)

In theory, that's it, it should display your pre-setup bulbs and allow you to control them. Let me know if you have any problems. There should also be some documentation here:
#3 and #1 which may be of use.

Best of luck!

@shrms
Copy link

shrms commented Mar 16, 2017

Hi Bren,
Thanks for sending the instructions, i follwed the same and updated the IP address aswell.
I got below message

'If you are seeing this, you haven't generated your token yet.
Could not fetch token. Ensure you have the correct IP for your bridge and that you have hit the sync button before running this.
Since you ae not using the token file option, ensure you paste your token in the include.php.

Regards

@bren1818
Copy link
Owner Author

@shrms - are you sure you pressed the sync button and have the correct IP of your bridge? As for the token file, did a "tcp.token" file get generated in the htdocs folder?

If you have the right IP for you bridge, in theory you can navigate to: https://{BRIDGE-IP}/gwr/

If you get a "privacy error" (this is from the Bridge, not my code) just allow it and see if the page resolves. If the request times out, you likely have the wrong IP.

You can also try changing the LIGHTING_PORT (line 9) to 80 instead of 443, but most bridges will be on 443.

@vijimaini
Copy link

Hi @bren1818 - is there a way to setup sunset and sunrise time. This feature using IOS app does not work. The tcp device must have been getting this information from the Gwr server, before it shutdown. The feature to adjust time is great. The time on my device was out by 35 minutes. Thanks

@bren1818
Copy link
Owner Author

@vijimaini I haven't developed code yet to work with the sunrise/sunset natively, but I did develop a scheduler which triggers the lights at programmed times using the underlying API for this app. I'll have a look to see if I can emulate or develop that function, but I never used it.

Cheers

@vijimaini
Copy link

@bren1818 Ok, I was wondering if the sunset / sunrise values were stored on device that was updated daily from cloud. The API test script shows value to be sunset, which means it may be stored somewhere on device. Thanks

@crutchre-source
Copy link

crutchre-source commented Apr 26, 2020

Ok making tons of progress.
Removing .htaccess allows me to control the lights using Alexa via IFTTT.
Hurray!!!

Now I'm just trying to figure out how to properly use Apache directives to stop any ol' person from controlling the lights.

According to the apache docs, it sounds like I should try and make the changes within the apache.conf file rather than using a .htaccess file.. So here is what I currently have:

<Directory />
        Options FollowSymLinks
        AllowOverride None
        Require all denied
</Directory>

<Directory /usr/share>
        AllowOverride None
        Require all granted
</Directory>

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>

#<Directory /var/www/html>
#        Options -Indexes
#        RewriteEngine On
#        Order deny,allow
#        Deny from all
#        Allow from 192.168.1.0/24
#</Directory>

<Files /var/www/html/api.php>
            Allow from all
</Files>

If I uncomment that the block above, I can still access the page within the local LAN, and I get a 403 error if I try to access from outside the LAN (great!)- BUT it seems that api.php becomes inaccessible as well and breaks the IFTTT web hook. (boo!).

Any idea on how to properly format the directives to keep api.php accessible by all?

As always- thanks!

@bren1818
Copy link
Owner Author

bren1818 commented Apr 26, 2020 via email

@crutchre-source
Copy link

Ok all done! Thanks for all the help!!

@sktaylortrash The thing that I ended up doing different from the Wiki besides PHP 7.3 was using Bren's posted .htaccess file here:

Options -Indexes
RewriteEngine On


Order deny,allow
Deny from all
Allow from 192.168.1.0/24

<Files api.php>
        Allow from all
</Files>

This .htacess file which is included in the download doesn't work for me:

Options -Indexes

Order deny,allow
Deny from all
Allow from 127.0.0.1            #localhost
Allow from ::1                          #localhost
Allow from 192.168.1.1/24   #Local Network


<Files api.php>
        Order deny,allow
        deny from all
        allow from all
</Files>

The only other watch-out was that I had to make the query that was automatically generated a secure one:
http://{myurl}/api.php?fx=toggle&type=room&uid=0&val=1&password={pw}
needed to be:
https://{myurl}/api.php?fx=toggle&type=room&uid=0&val=1&password={pw}

Thanks again! I finally don't have to search around in the dark for wherever the kids left the TCP lighting remote....

@bren1818
Copy link
Owner Author

bren1818 commented Apr 26, 2020 via email

@merrickw
Copy link

Hi Bren,

Just want to say your interface is still working like a charm 3 years in.

Plus, I have a question. I've renewed my interest on getting SmartThings to recognize these bulbs.
There's a custom SmartThings app and device handler written by the community.
The catch is the bridge needs downgraded firmware to 2.47.

So here's my question, I followed your Word doc on downgrading the firmware, and I get the result of seeing the Python console handling the firmware update.
When I check the version (in the TCP Lighting app) , it still says 3.80.

Any idea why it's not downgrading? It appears to be pulling from my laptop file. I'm stumped.

Regards,
Merrick

@bren1818
Copy link
Owner Author

bren1818 commented Oct 30, 2020 via email

@merrickw
Copy link

merrickw commented Oct 30, 2020 via email

@sktaylortrash
Copy link
Collaborator

@merrickw if you can't get the downgrade working. I never could and I tried on all 4 of my hubs.
I have forked to project to include MQTT support - https://github.com/sktaylortrash/TCPLightingWebInterface-MQTT
This allows integration with pretty much anything that supports MQTT. It's been tested heavily with Node-Red and Home Assitant but there's no reason it shouldn't work with Smartthings using the MQTT Bridge https://github.com/sgupta999/mqtt-bridge-smartthings

@merrickw
Copy link

merrickw commented Oct 30, 2020 via email

@sktaylortrash
Copy link
Collaborator

Technically you should be able to run it in parallel. But I set it up a direct drop-in replacement. So if you never configure the MQTT stuff it works exactly like the main branch

@merrickw
Copy link

merrickw commented Oct 30, 2020 via email

@jadakin
Copy link

jadakin commented Oct 30, 2020

Another suggestion: I set up a Raspberry Pi as a simple proxy to convert the HTTPS calls from the Smartthings plugin to HTTP ones the TCPConnected hub understands. It's been working happily for many months. The Rpi also runs Homebridge and Domoticz so I have quite a lot of options!

James

@sktaylortrash
Copy link
Collaborator

Another suggestion: I set up a Raspberry Pi as a simple proxy to convert the HTTPS calls from the Smartthings plugin to HTTP ones the TCPConnected hub understands. It's been working happily for many months. The Rpi also runs Homebridge and Domoticz so I have quite a lot of options!

James

Oh that's an elegant solution as well if you just need smartthings

@merrickw
Copy link

merrickw commented Oct 30, 2020 via email

@jadakin
Copy link

jadakin commented Oct 30, 2020

I was afraid you'd ask me that! I'm not an expert either and after I set it up quite a while ago it has run unattended ever since, so basically, I've forgotten. I know it involved installing Apache and then the configuration of the proxy was pretty simple. I'll have a root around this evening and try and jog my memory.

James

@sktaylortrash
Copy link
Collaborator

Actually nginx is basically designed for this. There are a million tutorials on setting it up as a reverse proxy which is what James is describing.

@jadakin
Copy link

jadakin commented Oct 30, 2020

Actually nginx is basically designed for this. There are a million tutorials on setting it up as a reverse proxy which is what James is describing.

Happy to believe you. I was stabbing in the dark a bit, as going through my bash history for the time shows. It's been on my mind for a while that I might have to rebuild this sometime, and I should really work out what I did in the end. I will look into nginx myself next time!

James

@jadakin
Copy link

jadakin commented Oct 30, 2020

Having looked back at this, I think the relevant parts of what I did were apt-get installing apache2 and apache2-utils then editing (or creating) an 000-default.conf file in /etc/apache2/sites_available to look like this:

NameVirtualHost *:80
<VirtualHost :80>
ServerName gwproxy.com
SSLProxyEngine On
SSLProxyCheckPeerName off
SSLProxyCheckPeerExpire off
RequestHeader set Front-End-Https "On"
CacheDisable /

ProxyPass /gwr https://192.168.1.29:443/gwr
ProxyPassReverse /gwr https://192.168.1.29:443/gwr
RedirectMatch ^/$ http://gwproxy.com/gwr

Sorry this is not much of a "Howto" but it may save you some work. I would certainly look into Paul's suggestion of nginx, though.

James

@merrickw
Copy link

merrickw commented Oct 31, 2020 via email

@merrickw
Copy link

merrickw commented Oct 31, 2020 via email

@merrickw
Copy link

merrickw commented Oct 31, 2020 via email

@jadakin
Copy link

jadakin commented Oct 31, 2020

Thanks James. I've been tinkering with this, but now I'm confused. My tcp bridge is 192.168.0.80 My Raspberry Pi with Apache, is 192.168.0.90 So, I'm not sure how I am redirecting traffic from the SmartThings app to use Apache on the Pi for the Proxy. I assume all this traffic is internal, so I'm not clear on how to configure this. This sounds like a good idea, but I'm missing some concepts here. Regards, Merrick

Yes, all internal. My broadband speed is woeful so I avoid external traffic as much as possible (which is why I can't practically use IFTT, sadly).
Once the proxy is working it's just a question of using the pi's address as the "TCP Gateway ID" when setting up the "TCP Bulbs (Connect)" smartapp in the Smarthings app. The actual address of the TCP hub goes in the proxy configuration, as above. Smarthings talks to the Pi, thinking it's the real hub, but the Pi is actually just relaying traffic to the real hub (and vice-versa).

It would be beneficial for me to set this up again from scratch. I might try if we (UK) are in lockdown again soon, as threatened!

James

@merrickw
Copy link

merrickw commented Oct 31, 2020 via email

@merrickw
Copy link

merrickw commented Oct 31, 2020 via email

@sktaylortrash
Copy link
Collaborator

Also, what does the gwproxy.com represent?

You don't want that in there or the apache server will only respond if you have a local DNS server that resolves gwproxy.com to your pi

@jadakin
Copy link

jadakin commented Oct 31, 2020

Also, what does the gwproxy.com represent?

As Paul says, it's not necessary, just use the the IP address.
This might be helpful:
[https://www.digitalocean.com/community/tutorials/how-to-use-apache-as-a-reverse-proxy-with-mod_proxy-on-debian-8(url)
You can ignore the bits about load balancing setup, but ISTR enabling the mod_proxy and mod_proxy_http modules as it describes - that may be what you're missing?
The rest of my conf files relates to running Bren's TCP control on port 85. I can't see it will help, but for what it's worth: (sorry, also not an expert at Git - don't know why it's formatting it oddly!)

'''

<VirtualHost *:85>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com

ServerAdmin webmaster@localhost
DocumentRoot /var/www/html

# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf

NameVirtualHost *:80
<VirtualHost :80>
ServerName gwproxy.com
SSLProxyEngine On
SSLProxyCheckPeerName off
SSLProxyCheckPeerExpire off
RequestHeader set Front-End-Https "On"
CacheDisable /

ProxyPass /gwr https://192.168.1.29:443/gwr
ProxyPassReverse /gwr https://192.168.1.29:443/gwr
RedirectMatch ^/$ http://gwproxy.com/gwr

'''

James

@jadakin
Copy link

jadakin commented Oct 31, 2020

Well that went even more wrong than I thought!! Sorry :)

James

@merrickw
Copy link

merrickw commented Oct 31, 2020 via email

@jadakin
Copy link

jadakin commented Oct 31, 2020

What went wrong? I see I need to install mod_proxy for this to work. I'll check out the tutorials. (I think your link was broken. No big deal, job for Google).

The quoting and formatting got all screwed up, but you've got the gist.
Turns out we are in lockdown again from Thursday, so if you haven't got it sorted by then, I'll have time to rebuild it from scratch.

James

sktaylortrash added a commit that referenced this issue Jan 28, 2023
Enable Home Assistant Birth Message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests