Skip to content

Instantly share code, notes, and snippets.

@CodeZombie
Last active February 6, 2024 20:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CodeZombie/b9ba1bde5b36d8366eada1a90cbb975c to your computer and use it in GitHub Desktop.
Save CodeZombie/b9ba1bde5b36d8366eada1a90cbb975c to your computer and use it in GitHub Desktop.
CozyLife Smart Bulb with Home Assistant

How To: Set Up your Stupid Fucking 4 Dollar "Cozy-Life" Wi-Fi Smart Bulb with Home Assistant with Minimal Hair-Pulling

Installing Home Assistant with Docker Compose

This parts simple enough, but requires some adjusting of the official instructions to get working. Most instructions online tell you that your docker-compose.yml file needs to have a network_mode: host in there. I dunno about that! Works fine for me without that, so we're going to not.

version: '3'
services:
  homeassistant:
    container_name: homeassistant
    image: "ghcr.io/home-assistant/home-assistant:stable"
    ports:
      - 8123:8123
    volumes:
      - ./config:/config
      - /etc/localtime:/etc/localtime:ro
      - /run/dbus:/run/dbus:ro
    restart: unless-stopped
    privileged: true

Run this and set up Home Assistant. This will create a ./config folder in the directory with the docker compose file.

Installing the CozyLife custom component

Next, let's pull the custom component repo into the ./config folder. https://github.com/yangqian/hass-cozylife Assuming /docker/homeassistant/docker-compose.yml is the structure of your system, we want to clone the repo so that it looks like /docker/homeassistant/config/custom_components/cozylife

Run a docker compose up and check to make sure its happy with that custom component.

If it is, let's set up the bulb.

Setting up the fucking bulb

This part had me pulling my hair out. There are a dozen "different" cheap-o bulb manufacturers and they all have their own apps which are, by all accounts, identical. You would think they're all interoperable, but they are not. You must use the specific cozylife app to setup the bulb, but unfortunnately for you, the app has been pulled from the play store. Cool right? So you're going to have to find a rip of it somewhere online. There's lots of sources. All of the sketchy. Use at your own risk.

Once you have the bulb set up on your local network, lets find its IP address. Yangqian's repo has a getconfig.py file in it. You can run the script from where you cloned the repo on your server, or run it on your local computer The format is python3 getconfig.py 192.168.1.193 192.168.1.194 Make sure you adjust the ip range so that its actually in your subnet, and is much wider than 193 to 194. Scanning is quick so I ran 192.168.2.1 192.168.2.255 and it found it in 30 seconds.

There's a bug in this script that outputs the first key of the yaml as lights:. Change this to light:

now copy this to the bottom of your configuration.yaml in the ./config folder of your home assistant docker folder.

Importantly, you should go into your router settings and change the ip of the bulb you just found to be static so that it doesnt change after the DHCP lease expires.

Restart home assistant and you should have a new bulb in your Devices that you can play with. Yay!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment