Arduino Home Asstant

LED Strips in Home Assistant

Led strips are really cool. There is something about the light and the thing that you are in control of 60 small leds. And they are very inexpensive now to. I wanted to try them together with home assistant. I have based this post on the work done by Bruh. However some things has changed since he did his video. I had problems to get this working and it was hard to find the needed information on one place on the internet. Therefor I wrote this.

The original video is found here

When done you will have a ledstrip connected with MQTT and it is controlled within Home Assistant.

So lets get started. I have used the following:


  • Led Strip WS2812B from Banggood
  • Node MCU from Kjell
  • 5V Power adapter
  • USB Adapter
  • Some extra wires


  • Cloud MQTT broker
  • Home Assistant
  • Arduino sketch

Start by connecting the hardware. I have connected it like below. Note that I am no expert whatsoever in electronics. The colors may be wrong. You may also want to use a resistor before the first led in order to prevent spikes.

I had huge problems understanding why it behaved so strange with all the colors first. It was connected to my computer USB then. After putting a cable to GRN from the NodeMcu and using a separate power supply instead of it beeing conncted to my computer solved the problems.

It might also be possible to convert the 5v to 3v and power the nodemcu by the 5v adapter but I am happy with two power supplies.

Next up is the software and setting up the Nodemcu. The first thing you will have to do is to download the Arduino software. This is described in many places but there are some things you should do.

  • Check The board
  • Check the PORT (check your devicemanager)
  • Check the libraries in the top of the code. Choose tools-manage libraries and add them. I had problems with some new libraries and used some older. Test.

I have modified some things and used this sketch. The thing you should change is:

WIFI and MQTT Information (type your info here)
define NUM_LEDS 120  (Count your leds)
define DATA_PIN 5 (The datapin on your Nodemcu)
define CHIPSET WS2812B (This is the model of your ledstrip. Migt be WS2811 or similar)
define COLOR_ORDER GRB (This will cause confusion and strange behavior if wrong. Try RGB, BRG or GRB)


Ok, On to Home Assistant. Add the following to your configuration.yaml

Depending if you use groups.yaml you may want to add the entities here as well-

Now restart Home Assistant. If successfull you should be able to control the leds like below!