Adding TCP Connected (Greenwave Reality) support to Home Assistant

I recently did a job for someone, and as part of my payment, they gave me an old Internet of Things lighting system. It’s made by TCP Connected, leased from Greenwave Reality. TCP disabled the cloud functionality and local web access, which left many people in the dark.

The tinkerers out there just couldn’t let their bulbs sit and just be regular bulbs, they wanted their remote control back. So people built things like the TCP Connected Web Interface. It worked, but it was quite basic. And it was standalone, I couldn’t integrate it with anything. So i set out to get these bulbs working better than new.

I found the Home Assistant project, which was a fully developed Home Automation ecosystem, allowing you to control smart devices from many different brands, all in one place. And its written in Python! I chose Home Assistant to be the host for my new lighting system.

I looked through the source for the TCP Connected Web Interface to extract the commands to turn the bulbs on and off, and to set brightness. I then used these to build a basic component for Home Assistant.

The bigger issue was the newer firmwares, beginning with 3.0, used HTTPS, self signed certs, and required you to fetch a token before being able to issue commands. I again used bren1818’s code to figure out how to fetch a token.

The most recent edition of the code works with both firmware versions 2 and 3, and gives you all the functionality from the app (except for naming bulbs). In the future, I’ll add autodiscovery of the gateway, discovery of new bulbs without the need to restart Home Assistant, and probably more that I’ll think of later.

I submitted the code to become a part of Home Assistant itself, you can watch how that goes here. If you’d like to use the code before then, you can find it here. And if you’d like to build your own python application that interfaces with the bulbs, you can use my GreenwaveReality python module, found here,  and can be installed with pip install greenwavereality.

Let me know if you have any ideas or improvements for the code, or if you;re going to use it!

9 Replies to “Adding TCP Connected (Greenwave Reality) support to Home Assistant”

  1. Looking forward to trying this after Christmas is over. I have the gateway still plugged in and the remote still works with the lights that I have installed. I have at least another 6 that have never been used that I purchased for $4 before I found out that the cloud was going away.

    How do you tell what firmware is loaded?

    Thanks for all the work that you have done with this project.

    1. Easy way to tell, is point a web browser at it. If you get a nice Web UI, youre on version 2.something. Connection refused? Version 3. Try HTTPS.

      1. dflel, I am still trying to connect to my TCP Connected Lights. I took a break for working on the lights.

        I did find out and do a few things:
        1. Locked the IP address for the TCP gateway to 192.168.0.3 on the router.
        2. Found that the firmware is 3.0.80
        3. I am getting “ERROR (SyncWorker_8) [homeassistant.components.light.greenwave] The Gateway Is Not In Sync Mode.
        4. Removed power from the RPi 3 running hassio, pressed the sync button and repowered the RPi 3, but can’t seem to get the gateway token.
        5. The remote does control the 3 lights that I have setup on the gateway.

        Can I reduce the python code from your greenwave file so that it will pull just the gateway token and save it?

        Thanks for your work on this.

  2. Hi, thanks for working on this. I also have one and have been getting by by hacking the rest switch component just to turn light on and off.

    Always wanted to write a custom component but I don’t know python at all and unfortunately have no time to learn :

    Thus I was excited to see this on reddit. Unfortunately it didnt work for me, throwing an error upon start up after parsing the xml.

    dict = dict[‘gwrcmds’][‘gwrcmd’][‘gdata’][‘gip’][‘room’][‘device’]
    TypeError: list indices must be integers, not str

    After a bit of debugging I think this is related to the fact that I set up multiple rooms on the TCP unit, and thus the parse return a list of rooms not a single room.

    Unfortunately I dont know enough python at the moment to make this work. Hopefully it would be much quicker for you to add in support for multiple rooms.

    Thanks

  3. Great effort and will surely make a lot of light owners happy.

    Just wanted to add to the above that also this is not working for me. I have these lights (4) already working by using python scripts in the backend called from HA with “command_line” switches.

    Also tried on brand new install and same errors. I am using the raspbian virtual env install method.

    I will add some logs later on as my laptop battery is almost dead.

    1. Hello Johnny,

      I have done a lot of work on the code since this post, adding multi-room support and better performance. Please check the repository again. There is an older version of the code now shipping with Home Assistant, which does not contain the multi-room code.

      Good Luck,
      dfiel

  4. Dfiel thanks for this. I’m heavily invested in TCP stuff. Around 15 bulbs in use and 20 spares plus another 4-5 to be installed. (plus like 3 spare gateways)
    I’ve been using Bren1818’s interface since it first came out and it was a godsend. Probably just after you did all this he flushed out an api for us so we could use IFTTT. It let me make some ESP8266 buttons for it.

    Glad to see the multi-room fix is coming soon in Home Assistant as it’s my current hold back from implementing your solution. I use rooms and scenes heavily. Are scenes supported as on/off triggers in your implementation?

    Also Bren1818 added bulb pairing in a recent update which I can see from the Home Assistant github you don’t currently have. So maybe you can scoop that code.

    Thanks again

    1. Hello Paul,

      I have finished up multi-room support, the updated code is at the same repository. I don’t believe I’ll add support for scenes, at least not now. I don’t know how the bulb pairing would integrate with Home Assistant, I’ll have to look at that.

      Happy Automating,
      dfiel

      1. dfiel,

        thanks for the reply. I guess the builtin scenes really won’t be needed if I move those automations to Home Assistant.

        Paul

Leave a Reply

Your email address will not be published. Required fields are marked *