C by GE light local control via BLTE

What

This integration lets Home Assistant control C by GE Bluetooth lights.

Why

C by GE lights are cheap and often go on sales. You might see bad reviews all over the places because C by GE lights form a BLTE mesh and you could connect to only one device via bluetooth.

You could typically get one Bulb below $5.
For example, currently it is on sale 4 for $15.

That means, either only Google home or the C by GE app could connect to it at a time.

C by GE C-Reach Smart Bridge could help but it cost $50

This custom component let home assistant be the hub controller and help you save $50!

Tested devices

Soft white and tunable white bulbs.
https://www.gelighting.com/smart-home/led-bulbs/soft-white
https://www.gelighting.com/smart-home/led-bulbs/tunable-dimmable-white

I have tested for more than half a year.

Known Issues

  1. Dependends on bluepy and dimond. You might have to patch a bug in the dependence bluepy manually.

  2. The code does not conform to the Home assistant standards right now (api and home assistant interface does not yet separate).

  3. This code assumes the state instead obtain it from the mesh.

Pull requests are welcome

1 Like

I tried this on my raspberry pi 3b and I get the following. I’m not exactly sure what I’m doing wrong

Traceback (most recent call last):
  File "getconfig.py", line 57, in <module>
    for bulb in device_info['bulbsArray']:
KeyError: 'bulbsArray'

It lists information for my username and password, but nothing for my bulb I have associated and can see in my c by ge app

I don’t know why you are not able to obtain this info.
I could also look into more details if you could add a line

print(device_info)

before line 57 and paste the results here (mask your personal info).

Username and password are the info that you need to find out online. For the rest, you could also try to find out your config manually.

For me, the id of the devices range from 1,2,3,4.

What you need next is the mac and type of your bulbs.
using bluetoothctl on your terminal you could scan for you bluetooth devices.
Based on the RSSI (i.e., the signal strength), you should be able to find out the MAC address of your bulbs.
The MAC of the bulbs are there to help you connect to the devices, they do not need to be associate to the correct id. Any association would work fine.

Note that you need to convert your MACs to lower case chars.

Could you specify your bulb type?
For me, type 17 corresponds to bulbs that only the brightness can be changed and type 20 corresponds to bulbs that both the brightness and color temperature can be changed.

You can test if the config works once you put them together.

I can see the bulb if I scan from my pi and did get the mac. I tried it in my hassio installation. I think I have some issues with bluetooth on that install so I’m using a 2nd one to test. The 2nd one can see the lights via cmd.

The bulbs are just dimmable so type 17. I can see the bulb in my c by ge app and also my google home after integrating it there.

Here is the output from the line you wanted me to add

light:

  • platform: gelight
    password: xxx
    username: xxx
    lights:
    {‘error’: {‘msg’: ‘device property not exists’, ‘code’: 4041009}}
    Traceback (most recent call last):
    File “getconfig.py”, line 58, in
    for bulb in device_info[‘bulbsArray’]:
    KeyError: 'bulbsArray

Could you check if home assistant is working after you type the information manually?

Note that you should not link c by ge app with google home.
You should link home assistant with google home instead.

I also updated the code. But I suspect that the updated getconfig still won’t work for you.

I’m not able to see the bulb in HA after putting the information in manually. I was able to get the script to output some information by adding an extra print command. Here is the information on my 1 bulb in my C by GE account

'bulbsArray': [{'ambientLightSensorSensitivity': 5, 'motionSensorDelayTime': 0, 'nightLightBrightness': 100, 'displayName': 'SE Basement', 'motionSensorEnabled': True, 'loadSelection': 1, 'showOnHome': 0, 'mac': '13858438C1A4', 'lightIntensity': 0, 'pir': 0, 'humidity': 0, 'firmwareVersion': '3.4', 'followTheSun': False, 'deviceType': 9, 'wifiDisconnectedIndicator': False, 'fadeOff': 0, 'powerConsumption': 0, 'switchID': 0, 'ambientLightSensorEnabled': False, 'motionSensorDeactivationPeriod': 0, 'deviceID': '1308196157001', 'fadeOn': 0, 'otaType': 0, 'motionSensorSensitivity': 0, 'defaultBrightness': 0, 'wifiMac': '00:01:02:03:04:05', 'lightRingIndicator': 0, 'nightLightColor': 0}],

When I add the below to my configuration.yaml

light:
  - platform: gelight
    password: myPW
    username: myEmail
    lights:
      - id: '1'
        mac: '13858438c1a4'
        name: 'SE Basement'
        type: '9'

I get the following error starting Home Assistant.

Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py", line 199, in _async_setup_platform
    await asyncio.shield(task)
  File "/home/homeassistant/.homeassistant/custom_components/gelight/light.py", line 107, in async_setup_platform
    await hass.async_add_executor_job(mesh.connect)
  File "/usr/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/homeassistant/.homeassistant/custom_components/gelight/light.py", line 304, in connect
    raise Exception("Unable to connect to mesh %s" % self.address)
Exception: Unable to connect to mesh myemail

This has happened when I use 1,2, or the displayed deviceID from the getconfig.py script.

I’m sure its an issue with my device setup, just not sure where to look. My device also shows as type: 9 so I modified my light.py to add that device type in as well.

You need to separate your mac with “:” and invert the sequence like this

a4:c1:38:84:85:13

Changed the mac to what you provided (thank you very much!!) and I still get the same error. Pasting all the error code below as well. Thanks for your time helpoing me to figure this out!

2020-11-21 23:14:59 ERROR (MainThread) [homeassistant.components.light] Error while setting up gelight platform for light
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py", line 199, in _async_setup_platform
    await asyncio.shield(task)
  File "/home/homeassistant/.homeassistant/custom_components/gelight/light.py", line 107, in async_setup_platform
    await hass.async_add_executor_job(mesh.connect)
  File "/usr/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/homeassistant/.homeassistant/custom_components/gelight/light.py", line 304, in connect
    raise Exception("Unable to connect to mesh %s" % self.address)
Exception: Unable to connect to mesh 

Could you try to change

light:
  - platform: gelight
    password: myPW
    username: myEmail
    lights:
      - id: '1'
        mac: '13858438c1a4'
        name: 'SE Basement'
        type: '9'

to

light:
  - platform: gelight
    password: myPW
    username: myEmail
    lights:
      - id: 1
        mac: 13858438c1a4
        name: SE Basement
        type: 9

The error is saying that bluetooth cannot connect to your bulb.

You need to make sure that

  • bluepy is installed (you might need to patch it for arm64 devices)
  • you should see a process bluepy-helper running in the background when home assistant is up and running.
  • You have at least Bluetooth 4.0

Could you see the light bulb in

bluetoothctl

after you type

scan on

?

I tried the code change with no luck.

I can see the bulb in bluetoothctl. I think it is an issue with bluepy. I’m going to start with a fresh raspbian install and see if I get anywhere. I’m worried I have a conflicting library or something and want to rule that out.

I realized that I might confused you:

light:
  - platform: gelight
    password: myPW
    username: myEmail

Here myEmail should not be your email, instead, it is a strange string spit out by getconfig.py
myPW should be a list of numbers.

By the way, you could test by the following python code

#!/usr/bin/env python3
import dimond
#here username and password is not your email and password. They are obtained by getconfig.py
link=dimond.dimond(0x0211, mac,username, password)
link.connect()
#turn on light
link.send_packet(0, 0xd0, [1])
#turn off light
link.send_packet(0, 0xd0, [0])

Aah. I will see if I can get that script to work and plug those in. Again thanks for the tool and all the help with helping me get it working!

That was it. I used the strings provided by getconfig.py and it worked like a charm. This is an amazing piece of code for some cheap bulbs!

Thank you again!!!

You are welcome.

By the way, may I ask how you obtained the info for

'bulbsArray':

I could try to update getconfig.py if you are willing to provide a bit of details of the print statement you mentioned earlier.

I’ll send it to you in a message shortly.

Thank you for creating this.
I’ve tried to test this but can’t seem to get it to connect.
bluetoothctl scan shows my devices, and I see the bluepy helper task running in the background.

I copied what the getconfig.py script output, it correctly identified my 6 lamps mac addresses and types.

They are all A19 full color RGB lamps, which the script identifies as type 21 and 6 (even though they are the same, must be different hardware revisions)

The only thing I see in the logs pertaining to this is

2020-11-25 00:40:40 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for gelight which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant.

2020-11-25 00:40:50 WARNING (MainThread) [homeassistant.components.light] Setup of light platform gelight is taking over 10 seconds.

2020-11-25 00:41:40 ERROR (MainThread) [homeassistant.components.light] Setup of platform gelight is taking longer than 60 seconds. Startup will proceed without waiting any longer.

Let me know what information I can provide to identify problem.

edit:
Here is what I have in my config, with the values randomized for privacy

light:
  - platform: gelight
    password: 114782
    username: 09468793751B
    lights:
      - id: 1
        mac: f4:bc:da:3b:3b:2c
        name: Vanity 2
        type: 21
      - id: 2
        mac: f4:bc:da:3c:5b:0f
        name: Vanity 5
        type: 21
      - id: 3
        mac: f4:bc:da:3b:c1:2p
        name: Vanity 1
        type: 21
      - id: 4
        mac: f4:bc:da:3b:00:97
        name: Vanity 3
        type: 6
      - id: 5
        mac: f4:bc:da:3a:ee:7d
        name: Vanity 4
        type: 6
      - id: 6
        mac: f4:bc:da:3b:87:4a
        name: Vanity 6
        type: 21

I enabled debugging in my log and this is what I see upon boot (after it states it failed to connect to each mac address)

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 199, in _async_setup_platform
    await asyncio.shield(task)
  File "/config/custom_components/gelight/light.py", line 107, in async_setup_platform
    await hass.async_add_executor_job(mesh.connect)
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/gelight/light.py", line 303, in connect
    raise Exception("Unable to connect to mesh %s" % self.address)
Exception: Unable to connect to mesh 09468793751B

Hi zimmra,
I have tried to extended the functionality to RGB light. But I am not sure how it goes. Could you checkout the code again?

Your updated code fixed the issues.

I am now having the issue of inconsistent control. I have been testing this on a cluster of 6 lamps, and commands sent to the lights aren’t always responded to. It seems like a 50% response rate, I haven’t done much testing on this yet though. I see the commands sent to each in the debug log, but the lamps are often not doing anything.