HA + EspHome = WS2812B stairs project - delay error

Hello All,

I’ve combined a small project including HA, EspHome, WS2812B Led strips and Aqara motion sensors to light my 14step stairs. Everything work good except lightning each step that is taking 1second. Cant make it like 400ms. Below is my code, I know it’s chaotic but it works.

My automation:

- id: '15857734476143'
  alias: Sch_down
  description: swiatła dół góra
  trigger:
  - entity_id: binary_sensor.0x00158d0004058359_occupancy
    platform: state
    from: 'off'
    to: 'on'
  condition: 
    - condition: state
      entity_id: input_boolean.notify_schody_up
      state: 'off'
    - condition: state
      entity_id: input_boolean.notify_schody_down
      state: 'off'
    - condition: time
      after: '19:00:00'
      before: '07:00:00'
  action:
  - service: input_boolean.turn_on
    data:
      entity_id: input_boolean.notify_schody_down
  - service: light.turn_on
    entity_id: light.step14
    data:
      brightness: 60
      rgb_color:
      - 120
      - 0
      - 0
  - delay:
      milliseconds: 100
  - service: light.turn_on
    entity_id: light.step13
    data:
      brightness: 60
      rgb_color:
      - 120
      - 0
      - 0
  - delay:
      milliseconds: 100
  - service: light.turn_on
    entity_id: light.step12
    data:
      brightness: 60
      rgb_color:
      - 120
      - 0
      - 0
  - delay:
      milliseconds: 100
  - service: light.turn_on
    entity_id: light.step11
    data:
      brightness: 60
      rgb_color:
      - 120
      - 0
      - 0
  - delay:
      milliseconds: 100
  - service: light.turn_on
    entity_id: light.step10
    data:
      brightness: 60
      rgb_color:
      - 120
      - 0
      - 0
  - delay:
      milliseconds: 100
  - service: light.turn_on
    entity_id: light.step9
    data:
      brightness: 60
      rgb_color:
      - 120
      - 0
      - 0
  - delay:
      milliseconds: 100
  - service: light.turn_on
    entity_id: light.step8
    data:
      brightness: 60
      rgb_color:
      - 120
      - 0
      - 0
  - delay:
      milliseconds: 100
  - service: light.turn_on
    entity_id: light.step7
    data:
      brightness: 60
      rgb_color:
      - 120
      - 0
      - 0
  - delay:
      milliseconds: 100
  - service: light.turn_on
    entity_id: light.step6
    data:
      brightness: 60
      rgb_color:
      - 120
      - 0
      - 0
  - delay:
      milliseconds: 100
  - service: light.turn_on
    entity_id: light.step5
    data:
      brightness: 60
      rgb_color:
      - 120
      - 0
      - 0
  - delay:
      milliseconds: 100
  - service: light.turn_on
    entity_id: light.step4
    data:
      brightness: 60
      rgb_color:
      - 120
      - 0
      - 0
  - delay:
      milliseconds: 100
  - service: light.turn_on
    entity_id: light.step3
    data:
      brightness: 60
      rgb_color:
      - 120
      - 0
      - 0
  - delay:
      milliseconds: 100
  - service: light.turn_on
    entity_id: light.step2
    data:
      brightness: 60
      rgb_color:
      - 120
      - 0
      - 0
  - delay:
      milliseconds: 100
  - service: light.turn_on
    entity_id: light.step1
    data:
      brightness: 60
      rgb_color:
      - 120
      - 0
      - 0

Congiguration on EspHome is making how many leds are on each step.

While the documents say that milliseconds are valid (and they are) they don’t tell you that the minimum possible delay resolution is 1 second (1000ms). It’s just the way home assistant works.

Hmmm in that way i will be faster on top of the stairs than the light.
Maybe other solution for it like Lambdas in EspHome? But this is black magic for me…

I’m pretty sure ESPHome can do sub 1sec delays.

1 Like

I don’t know what your esphome.yaml looks like, but maybe you could work with a Template Switch inside ESPHome and then do the automation for the lights in there.

Something like this (just a rough example to get the idea):

# Example configuration entry
substitutions:
  delay_value: 100ms

switch:
  - platform: template
    name: "Template Switch (schody_down)"
    turn_on_action:
      - light.turn_on: step14
      - delay: ${delay_value}
      - light.turn_on: step13
      - delay: ${delay_value}
      - light.turn_on: step12
      - delay: ${delay_value}
      ...

So in a simple way it could work without lambdas…

1 Like

My configuration.yaml on EspHome looks like this:

light:
  - platform: fastled_clockless
    chipset: WS2812B
    pin: GPIO2
    num_leds: 420
    rgb_order: BRG
    name: "Schody"
    id: stairs
  - platform: partition
    name: "step1"
    id: step1
    segments:
      - id: stairs
        from: 0
        to: 29
  - platform: partition
    name: "step2"
    id: step2
    segments:
      - id: stairs
        from: 30
        to: 59
  - platform: partition
    name: "step3"
    id: step3
    segments:
      - id: stairs
        from: 60
        to: 89
  - platform: partition
    name: "step4"
    id: step4
    segments:
      - id: stairs
        from: 90
        to: 119
  - platform: partition
    name: "step5"
    id: step5
    segments:
      - id: stairs
        from: 120
        to: 149
  - platform: partition
    name: "step6"
    id: step6
    segments:
      - id: stairs
        from: 150
        to: 179
  - platform: partition
    name: "step7"
    id: step7
    segments:
      - id: stairs
        from: 180
        to: 209
  - platform: partition
    name: "step8"
    id: step8
    segments:
      - id: stairs
        from: 210
        to: 239
  - platform: partition
    name: "step9"
    id: step9
    segments:
      - id: stairs
        from: 240
        to: 269
  - platform: partition
    name: "step10"
    id: step10
    segments:
      - id: stairs
        from: 270
        to: 299
  - platform: partition
    name: "step11"
    id: step11
    segments:
      - id: stairs
        from: 300
        to: 329
  - platform: partition
    name: "step12"
    id: step12
    segments:
      - id: stairs
        from: 330
        to: 359
  - platform: partition
    name: "step13"
    id: step13
    segments:
      - id: stairs
        from: 360
        to: 389
  - platform: partition
    name: "step14"
    id: step14
    segments:
      - id: stairs
        from: 390
        to: 429
switch:
  - platform: template
    name: "Template Switch (schody_down)"
    turn_on_action:
      - light.turn_on:
          id: step1
          brightness: 20%
          red: 100%
          green: 100%
          blue: 0%
      - delay: 500ms
      - light.turn_on:
          id: step2
          brightness: 20%
          red: 100%
          green: 100%
          blue: 0%

And the switch does nothing… I can light any step from Home Assistant but using EspHome cant do anything… Really need help

In addition i recive in log:

WARNING Disconnected from API: Timeout while waiting for message response!
INFO Connecting to schody.local:6053 (192.168.0.135)
INFO Successfully connected to schody.local
[18:12:58][D][api.connection:583]: Client 'Home Assistant 0.107.7 (192.168.0.114)' connected successfully!