ESPhome - WS2812b / Neopixels individual status leds

Tried to figure this out, but can’t find any approach to solve this… Hope the collective brain can help :wink:

Idea: Have a WS2812b / Neopixel strip with 8 LEDs for visual indication on the status of some of my Home Assistant binary sensors (Heating, Utility Meter, NAS, Solar inverter, Internet-connection cpu, disk and memory in HA - Probably more to come) Each LED represent a sensor - If everything is OK, all green, if Heating-sensor and NAS is disconnected (Boolean=FALSE), the LEDs would read: Red-Green-Red-Green-Green-Green-Green-Green

The initial idea is to use a binary representation like 01011111 (representing Red-Green-Red-Green-Green-Green-Green-Green) then use an logical OR when status is TRUE, and a XOR if FALSE
Example:
10000000 Heating
01000000 Utility Meter
00100000 NAS
00010000 Solar inverter
00001000 Internet
00000100 cpu
00000010 disk
00000001 memory

Start - All status unknown, assume FALSE: Status=00000000
NAS becomes available (TRUE) : 00000000 OR 00100000 = 00100000
Solar becomes available (TRUE): 00100000 OR 00010000 = 00110000
Mem becomes available (TRUE): 00110000 OR 00000001 = 00110001
NAS is UNavailable (FALSE) : 00110001 XOR 00100000= 00010001

How do i reflect this with the LEDs - Could I use Fastled, or another thing ??? an example would be GREAT :wink:

(For version 2: gradient color for Power consumption etc.)

The other option is to partition your LED strip into 8 segments. That way you can turn each light on or off individually:

That sounds like a “not so over-complicated” solution, to a basic problem… I’ll try it out… Thanks Tom to point out the obvious :wink:

Had a little problem with Home Assistant not discovered new ESPhome devices, but luckily the update was there after an hour of search…
Thanks again @tom_l - This is the result… Works great. I used 16 LEDs, because they exactly fit the with of a 19" rack, and my leftover strip was exactly 16 LEDs :wink:
Implemented and Tested version of ESPhome code:

esphome:
  name: esp-status-led
  platform: ESP8266
  board: d1_mini

#  8<   8<   8<   8<   8<   8<   8<   8<   8<   8< 
#         Wifi and password stuff omitted. 
#  >8   >8   >8   >8   >8   >8   >8   >8   >8   >8

light:
  - platform: fastled_clockless
    name: status_fastled
    id: status_fastled
    chipset: WS2812B
    pin: D4
    num_leds: 16
    rgb_order: GRB
    internal: false

  - platform: partition
    name: "status_led_1"
    id: section1
    segments:
      - id: status_fastled
        from: 0
        to: 1
        
  - platform: partition
    name: "status_led_2"
    id: section2
    segments:
      - id: status_fastled
        from: 2
        to: 3
        
  - platform: partition
    name: "status_led_3"
    id: section3
    segments:
      - id: status_fastled
        from: 4
        to: 5
        
  - platform: partition
    name: "status_led_4"
    id: section4
    segments:
      - id: status_fastled
        from: 6
        to: 7
        
  - platform: partition
    name: "status_led_5"
    id: section5
    segments:
      - id: status_fastled
        from: 8
        to: 9
        
  - platform: partition
    name: "status_led_6"
    id: section6
    segments:
      - id: status_fastled
        from: 10
        to: 11
        
  - platform: partition
    name: "status_led_7"
    id: section7
    segments:
      - id: status_fastled
        from: 12
        to: 13
        
  - platform: partition
    name: "status_led_8"
    id: section8
    segments:
      - id: status_fastled
        from: 14
        to: 15

1 Like