TM1637 Clock dimm from 20:00 to 07:00

Hi!
How can i dim TM1637 from time to time (night)?
Or from sun entity?

time:
  - platform: homeassistant
    id: homeassistant_time

display:
  platform: tm1637
  clk_pin: D6
  dio_pin: D5
  update_interval: 500ms
  lambda: |-
      static int i = 0;
      i++;
      if ((i % 2) == 0)
        it.strftime("%H.%M", id(homeassistant_time).now());
      else
        it.strftime("%H%M", id(homeassistant_time).now());
        

I assume the code you have already displays the time?

If so, this may work. The set_intensity function exists in the API, the code compiles, but It don’t have a display to test:

  lambda: |-
      static int i = 0;
      i++;
      if ((i % 2) == 0)
        it.strftime("%H.%M", id(homeassistant_time).now());
      else
        it.strftime("%H%M", id(homeassistant_time).now());
      if (id(homeassitant_time).now().hour < 7)  {
        it.set_intensity(2);
      } else if ((id(homeassitant_time).now().hour >= 7) && (id(homeassitant_time).now().hour < 20)) {
        it.set_intensity(7); 
      } else {
        it.set_intensity(2);
      }