Giter VIP home page Giter VIP logo

esp8266-mqtt-json-lights's Introduction

ESP8266 MQTT JSON Lights Build Status

ESP8266 MQTT JSON Lights. Supports brightness, effects, speed and OTA uploads. Based on https://github.com/bruhautomation/ESP-MQTT-JSON-Digital-LEDs

Showcase Video

Showcase Video

Known working devices

  • WS2812 5v LED Ring
  • WS2811 5v LED String (Required NEO_GRB to be changed to NEO_RGB on line 56 in main.cpp for my set of lights)

This is not a comprehensive list by any means. Just devices that I or others have tested are working. Feel free to try uploading to your own device and add a pull request if your device works also.

Hardware Setup

Hardware is your choice of course. My examples however only requires a 5v power supply (which could just be USB) with high enough amperage to drive the LEDs.

USB Neopixel WS2812 Ring/Strip Version

USB Neopixel WS2812 Ring Version

A 5V power supply may be required if your lights draw too much current. If this happens or you are planning to use more than 30 leds or so, use the below method.

5v PSU Neopixel WS2811 String/Strip Version

5v PSU Neopixel WS2811 String/Strip Version

The diode / zenner diode isn't required, but I added it to avoid any reverse current issues.

You can drive over 100 LEDs without issues on this method. You may however have to add a wire from the PSU +5v to sections of the wire if you experience dimming along the string/strip.

Software Setup

  • Using Atom or VS Code, install Platform IO

  • Once setup, install the esp8266 embedded platform

  • Rename src/setup-template.h to src/setup.h and add your network, MQTT and lighting setup information. Take note of the deviceName you set. You will need this later to send MQTT messages.

  • Build the project (Ctrl+Alt+B) and check for any errors

    If the build produces an error referencing dependencies, You will need to manually install these libraries:

    • Adafruit NeoPixel
    • ArduinoJson
    • PubSubClient
    • WS2812FX
  • Upload to your board of choice (Ctrl+Alt+U). This project was created specifically for the NodeMCU but can be configured to work with another WiFi board with some tinkering.

Example Home Assistant Configuration

light:
  platform: mqtt_json
  name: 'LED Lights'
  state_topic: 'light/led'
  command_topic: 'light/led/set'
  availability_topic: 'light/led/LWT'
  payload_available: 'Online'
  payload_not_available: 'Offline'
  effect: true
  effect_list:
    - static
    - blink
    - breath
    - color wipe
    - color wipe inverted
    - color wipe reverse
    - color wipe reverse inverted
    - color wipe random
    - random color
    - single dynamic
    - multi dynamic
    - rainbow
    - rainbow cycle
    - scan
    - dual scan
    - fade
    - theater chase
    - theater chase rainbow
    - running lights
    - twinkle
    - twinkle random
    - twinkle fade
    - twinkle fade random
    - sparkle
    - flash sparkle
    - hyper sparkle
    - strobe
    - strobe rainbow
    - multi strobe
    - blink rainbow
    - chase white
    - chase color
    - chase random
    - chase rainbow
    - chase flash
    - chase random
    - chase rainbow white
    - chase blackout
    - chase blackout rainbow
    - color sweep random
    - running color
    - running red blue
    - running random
    - larson scanner
    - comet
    - fireworks
    - fireworks random
    - merry christmas
    - fire flicker
    - fire flicker soft
    - fire flicker intense
    - circus combustus
    - halloween
    - bicolor chase
    - tricolor chase
    - icu
  brightness: true
  rgb: true
  optimistic: false
  qos: 0

input_number:
  led_effect_speed:
    name: 'LED Effect Speed'
    initial: 50 # This is the default speed
    mode: slider
    min: 10  # ######################################
    max: 1000 # Feel Free to adjust these as you like
    step: 10 # ######################################

automation:
  - action:
      - alias: Set LED Lights Effect Speed
        service: mqtt.publish
        data_template:
          topic: light/led/set
          payload: '{"speed":{{ trigger.to_state.state | int }}}'
    alias: LED Light Effect Speed
    trigger:
      - platform: state
        entity_id: input_number.led_effect_speed

The speed of the lights will be slower the higher the slider value and faster the lower the value. Treat this more as a delay slider than a speed slider.

Sample MQTT Payload

{
  "brightness": 120,
  "color": {
    "r": 255,
    "g": 255,
    "b": 255
  },
  "effect": "rainbow cycle",
  "speed": 60,
  "state": "ON"
}

esp8266-mqtt-json-lights's People

Contributors

renovate[bot] avatar timmo001 avatar zewelor avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.