Clock code working, need some help with minor fixes

I finally have the code for my 7-segment clock working, but there are a few things I don’t know how to fix. If anyone could point me in the right direction, I would appreciate it. This is using Fastled with framework version 2.7.4.

First, I am noticing that when fading the brightness, anything under 50% or so just turns the LEDs off. Is there a way to set the low limit so that 100% is full brightness and it fades down to zero?

Second, I am noticing that some of the colors in the LED string don’t always match the color selected on the color picker…for instance, orange is basically red. Is there a setting to better color match the LEDs to the picker?

Lastly, in this code, the dots between the hours and minutes are flashing. I am not sure how to change that, but I would prefer that the dots stay lit.

I’ll put the code below.

Thank you,
David

substitutions:
  displayname: poolclock

preferences:
  flash_write_interval: 5min

esphome:
  name: poolclock
  friendly_name: ${displayname}
  on_boot:
    - light.turn_on:
        id: led_strip
        brightness: 50%
        red: 50%
        green: 50%
        blue: 0%
        effect: "${displayname} Time effect"

esp8266:
  board: d1_mini
  framework:
    version: 2.7.4
  restore_from_flash: true

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: !secret hassio_api_key
  reboot_timeout: 0s

ota:
  password: ota_password

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Test Fallback Hotspot"
    password: wifi_fallback_ap_password

text_sensor:
  - platform: wifi_info
    ip_address:
      name: "${displayname} IP Address"
      id: ipAddress

globals:
  - id: hours_red_value
    type: int
    restore_value: yes
    initial_value: '0'

  - id: hours_green_value
    type: int
    restore_value: yes
    initial_value: '0'

  - id: hours_blue_value
    type: int
    restore_value: yes
    initial_value: '0'

  - id: minutes_red_value
    type: int
    restore_value: yes
    initial_value: '0'

  - id: minutes_green_value
    type: int
    restore_value: yes
    initial_value: '0'

  - id: minutes_blue_value
    type: int
    restore_value: yes
    initial_value: '0'

  - id: dots_red_value
    type: int
    restore_value: yes
    initial_value: '0'

  - id: dots_green_value
    type: int
    restore_value: yes
    initial_value: '0'

  - id: dots_blue_value
    type: int
    restore_value: yes
    initial_value: '0'

output:
  #======== Hours ============
  - platform: template
    id: hours_red_output
    type: float
    write_action:
      lambda: |-
        id(hours_red_value) = 255.0 * state;

  - platform: template
    id: hours_green_output
    type: float
    write_action:
      - lambda: |-
          id(hours_green_value) = 255.0 * state;

  - platform: template
    id: hours_blue_output
    type: float
    write_action:
      lambda: |-
        id(hours_blue_value) = 255.0 * state;

  #========= Minutes ===========
  - platform: template
    id: minutes_red_output
    type: float
    write_action:
      lambda: |-
        id(minutes_red_value) = 255.0 * state;

  - platform: template
    id: minutes_green_output
    type: float
    write_action:
      lambda: |-
        id(minutes_green_value) = 255.0 * state;

  - platform: template
    id: minutes_blue_output
    type: float
    write_action:
      lambda: |-
        id(minutes_blue_value) = 255.0 * state;

  #========= dots ===========
  - platform: template
    id: dots_red_output
    type: float
    write_action:
      lambda: |-
        id(dots_red_value) = 255.0 * state;

  - platform: template
    id: dots_green_output
    type: float
    write_action:
      lambda: |-
        id(dots_green_value) = 255.0 * state;

  - platform: template
    id: dots_blue_output
    type: float
    write_action:
      lambda: |-
        id(dots_blue_value) = 255.0 * state;

time:
  - platform: sntp
    id: sntp_time
    timezone: "America/Los_Angeles"
    servers:
      - 0.pool.ntp.org
      - 1.pool.ntp.org
      - 2.pool.ntp.org      

light:
  - platform: rgb
    name: "${displayname} hours lights"
    id: hours_lights
    restore_mode: RESTORE_DEFAULT_ON
    red: hours_red_output
    green: hours_green_output
    blue: hours_blue_output

  - platform: rgb
    name: "${displayname} minutes lights"
    id: minutes_lights
    restore_mode: RESTORE_DEFAULT_ON
    red: minutes_red_output
    green: minutes_green_output
    blue: minutes_blue_output

  - platform: rgb
    name: "${displayname} dots lights"
    id: dots_lights
    red: dots_red_output
    green: dots_green_output
    blue: dots_blue_output

  #--------- LED strip ----------------
  - platform: fastled_clockless
    id: led_strip
    name: "Led strip"
    internal: True
    pin: GPIO2
    num_leds: 86
    chipset: WS2812B
    rgb_order: GRB

    effects:
    - addressable_lambda:
        name: "${displayname} Time effect"
        update_interval: 500ms
        lambda: |-
          const int ledsInDigitCount = 21;
          const int digitsCount = 4;  

          //Array of which LEDs need to be on for a given digit. 0-9
          int digitsLeds[10][ledsInDigitCount] = {
            {0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, // 0
            {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0}, // 1
            {1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1}, // 2
            {1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0}, // 3
            {1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0}, // 4
            {1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0}, // 5
            {1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1}, // 6
            {0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0}, // 7
            {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, // 8
            {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0}, // 9
          };

          //LED address of each digit's first LED - HHMM
          int ledOffsets[digitsCount] = {65, 44, 21, 0};

          //Get the time from sntp 
          auto time = id(sntp_time).now();

          //Create array of colour values to use.
          int colors[4][3] = {
            {id(hours_red_value), id(hours_green_value), id(hours_blue_value)},
            {id(hours_red_value), id(hours_green_value), id(hours_blue_value)},
            {id(minutes_red_value), id(minutes_green_value), id(minutes_blue_value)},
            {id(minutes_red_value), id(minutes_green_value), id(minutes_blue_value)}
          };

          //Do some maths to get each digit - 12 hour time
          int values[digitsCount] = {};
                   
          values[0] = 1;  //Preset the hour digits to 12 for the case of being 0 hours
          values[1] = 2;  //This saves doing extra maths and just throwing away the answer

          int twelvehour = time.hour % 12;
          if(twelvehour > 0) {
            values[0] = twelvehour / 10;
            values[1] = twelvehour % 10;
          }
            values[2] = time.minute / 10;
            values[3] = time.minute % 10;
          

          //Clear all LEDs (I think). This may actually not be needed since the digit updates are also writing zeroes to the LEDs, right?
          it.all() = Color(0,0,0);

          //Flash the dots - Dot LED addresses are fixed here.
          //Should probably be moved to a constant and perhaps changed to a loop to make it possible to use a variable number of LEDs as the dots
          if ((time.second % 2) > 0) {
            it[42] = Color(id(dots_red_value), id(dots_green_value), id(dots_blue_value));
            it[43] = Color(id(dots_red_value), id(dots_green_value), id(dots_blue_value));
          }
          
          // Loop over digits - start from "1 - values[0]" so that we skip over the leading zero on the hours
          for (int valueI = 1 - values[0]; valueI < digitsCount; valueI++) {
            int ledsOffset = ledOffsets[valueI];
            int timeValue = values[valueI];
            int *color = colors[valueI];
            int *leds = digitsLeds[timeValue];

            for (int ledI = 0; ledI < ledsInDigitCount; ledI++) {
              if(leds[ledI] > 0) {
                int ledIndex = ledI + ledsOffset;
                it[ledIndex] = Color(color[0], color[1], color[2]);
              }
            }
          }

Light Component — ESPHome see color_correct

The flashing: isn’t that what the code starting at line 262 is doing? ie the lines starting with

//Flash the dots - Dot LED addresses are fixed here.

I think that is what min_power does - see Output Component — ESPHome

Yes, Im sure you are right, but I am not clear what the code on line 264 does and how to change it from flashing to solid on.

I will check out the other two resources you sent. Thank you for those!!

All I can tell is that the if statement does something every second.