Home

Awesome

Alternative firmware for AI-Thinker RGBW bulbs

THIS REPOSITORY IS NOT MAINTAINED ANYMORE, SEE ESPHome AS AN ALTERNATIVE.

This is an alternative firmware for AI-Thinker RGBW LED bulbs, which uses MQTT instead of the default Chinese mobile application. The bulb is a cheap (~12-18$) product available on sites like Aliexpress (here) and eBay (here or here), which can be easily reprogrammed as it is based on the popular ESP8266 Wi-Fi chip.

Design

Features

Demonstration

Home Assistant + MQTT + 10$ RGBW Bulb

Last Will and Testament

The firmware will publish a MQTT Last Will and Testament at <chipID>/rgbw/status. When the device successfully connects it will publish alive to that topic and when it disconnects, dead will automatically be published.

Discovery

This firmware supports Home Assistant's MQTT discovery functionality, added in 0.40. This allows for instant setup and use of your device without requiring any manual configuration in Home Assistant. To get this working, discovery: true must be defined in your mqtt configuration in Home Assistant

configuration.yaml

mqtt:
  broker: 'm21.cloudmqtt.com'
  username: '[REDACTED]'
  password: '[REDACTED]'
  port: '[REDACTED]'
  discovery: true

MQTT JSON Light

This firmware supports on/off, brightness, RGB colors, color temperature, white values and effects. The messages sent to/from the light look similar to the example below, omitting fields when they aren’t needed.

{
  "brightness": 255,
  "color_temp": 155,
  "color": {
    "r": 255,
    "g": 255,
    "b": 255,
  },
  "effect": "Rainbow",
  "state": "ON",
  "white_value": 150
}
NameData TypeValuesDescription
brightnessInteger0-255The brightness to set to
colorObject-A dictionary with the below RGB values
color.rInteger0-255The red color to set to
color.gInteger0-255The green color to set to
color.bInteger0-255The blue color to set to
stateStringON/OFFThe state of the light to set to
white_valueInteger0-255The white color to set to
effectStringRainbow/BlinkThe effect to set to
color_tempInteger154-500The color temperature to set to

How to

  1. Install the Arduino IDE and the ESP8266 core for Arduino
  2. Rename config.example.hto config.h
  3. Define your WiFi SSID and password (#define WIFI_SSID "<SSID>"and #define WIFI_PASSWORD "<password>"in config.h)
  4. Define your MQTT settings (#define MQTT_USERNAME "<username>", #define MQTT_PASSWORD "<password>", #define MQTT_SERVER "<server>" and #define MQTT_SERVER_PORT <port>)
  5. Install the external libraries (PubSubClient, ArduinoJson and my9291)
  6. Define MQTT_MAX_PACKET_SIZE to 512instead of 128in Arduino/libraries/pubsubclient/src/PubSubClient.h
  7. Solder wires from (bulb) 3V3 to 3V3 (FTDI), GND to GND, RX to TX, TX to RX and ÌO0 to GND
  8. Flash the firmware (board Generic ESP8266 module, Upload Speed 115200 and Flash Size 1M (128K SPIFFS))

FOR SECURITY REASONS, IT'S HIGHLY RECOMMENDED TO HAVE A STRONG WI-FI PASSWORD, TO ENABLE TLS, TO DEACTIVATE THE DEBUGGING OUTPUT AND TO SET A PASSWORD FOR OTA.

Design

Licence

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

This firmware was graciously supported by DariBer, who had offered me a development bulb. If you like the content of this repo, please add a star! Thank you!