Wled: Segments lost after reboot

Created on 7 Jan 2020  路  12Comments  路  Source: Aircoookie/WLED

I am trying to implement a toilet door occupancy indicator using three WS2812B LEDs attached to a Wemos D1 Mini

To control each single LED, I have created 3 segments and from the gui I can control each individual LED:
Segments:
1) LED 0 -1
2) LED 1 -2
3) LED 2 -3

However, when I reboot the D1 mini, my segments are reset.
How do I configure the segments to survive a reboot please?

Also, does anyone know how I can get Home Assistant to push the lights on each segment to go Green, Yellow or Red?

question stale

Most helpful comment

There are three toilets and so I require 3 leds to indicate their use:
Red - Occupied
Green - Free
Yellow - Possible Bio Hazard - Previous occupant has been in for more than 15 mins. This will change to green after 5 minutes.

All 12 comments

Hi @AlphaJosh with Home Assistant you can send a JSON object to WLED.
(see https://github.com/Aircoookie/WLED/wiki/JSON-API)

E.g. setting the three segments to different colors would be (the colors are in the col" object):

{
  "state": {
    "on": true,
    "bri": 255,
    "seg": [
      {
        "start": 0,
        "stop": 1,
        "len": 1,
        "col": [
          [
            255,
            0,
            0,
            0
          ]
        ],
        "fx": 0
      },
      {
        "start": 1,
        "stop": 2,
        "len": 1,
        "col": [
          [
            255,
            255,
            0,
            0
          ]
        ],
        "fx": 0
      },
      {
        "start": 2,
        "stop": 3,
        "len": 1,
        "col": [
          [
            0,
            255,
            0,
            0
          ]
        ],
        "fx": 0
      }
    ]
  }
}

But: why do you use three LEDs ? You could use a single one displaying either RED, YELLOW or GREEN 馃槃

As a colour-blind person, I'm quite satisfied to have traffic lights with 3 positions, in addition to the 3 colours. ;)
Now the real question is: what is the meaning of the color yellow in the context of a toilet door occupancy indicator? :D
BTW, this is probably the tiniest project based on WLED, which illustrates how versatile this fantastic tool is.

@AlphaJosh you can save one complete segment config in Preset slot 16. Then you can set that as boot preset in LED settings :) I'm working to increase the number of presets that can save segments in 0.10.0!

@CosmicMac it's close to the tiniest! I have an electronic candle running just a single LED with WLED :D

"Now the real question is: what is the meaning of the color yellow in the context of a toilet door occupancy indicator? :D"...

"Exercise caution upon entering confined space."

There are three toilets and so I require 3 leds to indicate their use:
Red - Occupied
Green - Free
Yellow - Possible Bio Hazard - Previous occupant has been in for more than 15 mins. This will change to green after 5 minutes.

@Aircoookie

@AlphaJosh you can save one complete segment config in Preset slot 16. Then you can set that as boot preset in LED settings :) I'm working to increase the number of presets that can save segments in 0.10.0!

I have tried to add them to the Presets and added the preset to the start up but found the segments were not present after rebooting.

@Def3nder - Can I use the JSON and segments to control a single LED independently from the others in Home Assistant? As one door indicator changes, it shouldnt change the others.

@AlphaJosh did you try Preset number 16 specifically? Only that one is capable of saving segments.

Oooo I didnt realise that. Testing now...

@Aircoookie Thank you for that. I misread it as saying you can save in the 16 presets and not specifically preset 16.
Thank you for clarifying.

Any chance you might have the code for Home Assistant or JSON that would change segment 1 colour and not affect any of the others please?

For public reference:

Note: Using Xiaomi Door Sensors + ZigbeeMQTT (out of scope of this document)

In WLED:
1) set up multiple segments
2) Saved Profile to slot 16
3) In Config set boot to load profile 16
4) In Config set LED number to 3
Note: MQTT not used

In Home Assistant:
1) Remove any previous WLED intergration (so old segments to be refreshed)
2) Add WLED integration
3) In configuration:

automation:
  - alias: South Door 1 - Open
    trigger:
      - platform: state
        entity_id: binary_sensor.0x00158d0003589e7c_contact
        to: 'on'
        from: 'off'
    action:
      - service: light.turn_on
        data_template:
          entity_id: light.wled_1
          rgb_color:
            - 0
            - 255
            - 0
          brightness: 255        

  - alias: South Door 1 - Close
    trigger:
      - platform: state
        entity_id: binary_sensor.0x00158d0003589e7c_contact
        to: 'off'
        from: 'on'
    action:
      - service: light.turn_on
        data_template:
          entity_id: light.wled_1
          rgb_color:
            - 255
            - 0
            - 0
          brightness: 255
      - service: counter.increment
        entity_id: counter.hour_sth_door1
      - service: counter.increment
        entity_id: counter.day_sth_door1          

@Def3nder - Can I use the JSON and segments to control a single LED independently from the others in Home Assistant? As one door indicator changes, it shouldnt change the others.

yes, you can either use a specific segment in the JSON or send a JSON with all segments.

So I would suggest to have 2 JSONs:

  • one with seg1 in RED / seg2 in black
  • one with seg1 in black / seg in green

Hey! This issue has been open for quite some time without any new comments now. It will be closed automatically in a week if no further activity occurs.
Thank you for using WLED!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jwingefeld picture jwingefeld  路  3Comments

djhampson picture djhampson  路  3Comments

brausepaule picture brausepaule  路  3Comments

athlon1900 picture athlon1900  路  3Comments

Brausmith picture Brausmith  路  4Comments