Allow override of sunset_time in Flux integration

I live at a higher latitude, and during winter the sun sets at a very early time. I want to be able to override the sunset_time in the config, so that it will start the transition from cooler to warmer light at a static time (say 7PM), rather than the very early time that the sun actually sets!

Same issue here! I don’t want sunset colors at 4pm in winter and would also appreciate an override. On my computer, I’ve used a workaround by manually telling flux that I’m at the equator (and tweaked my longitude to get sunset at 7pm). But on HA, it draws the location from HA’s central configuation, so that workaround would mess up other things.

As a workaround -

This is what I do, because I suffer from SAD, and I want to get ~8 of “daylight” regardless of the time of the year.

service: input_number.set_value
target:
  entity_id: input_number.daylight_colour_temperature
data_template:
  value: >-
    {% set k_end = 5200 %} {% set k_start = 2500 %} {% set t_start =
    today_at('07:30') %} {% set t_end = today_at('10:30') %} {% set cv =
    ((now()|as_timestamp) - t_start|as_timestamp)|int %} {{ k_start + (cv/4)|int
    }}

that runs from 7:28am to 10:34am every 3 minutes or so.

then in the evening

service: input_number.set_value
target:
  entity_id: input_number.daylight_colour_temperature
data_template:
  value: >-
    {% set k_start = 5200 %} {% set k_end = 2500 %} {% set t_start =
    today_at('18:00') %} {% set t_end = today_at('21:00') %} {% set cv =
    ((now()|as_timestamp) - t_start|as_timestamp)|int %} {{ k_start - (cv/4)|int
    }}

Each room has an automation that reacts to the input_number changing, to set the kelvin temperature of the lights in that room, as long as various conditions are met - such as the room is not in movie mode, and the light being changed is NOT in colour mode.

example:

variables:
  daylight_light_list: >-
    {% set x = area_entities('bedroom') %} {{
    expand(states.light)|selectattr('entity_id','in',
    x)|selectattr('state','==','on')|selectattr('attributes.supported_color_modes','contains','color_temp')|selectattr('attributes.color_mode','eq','color_temp')|map(attribute='entity_id')|list
    }}
  daylight_light_count: "{{ daylight_light_list|count }}"

then in the template test:

{{ daylight_light_count > 0 }}

and finally:

service: light.turn_on
data:
  transition: 10
  kelvin: "{{ states('input_number.daylight_colour_temperature')|int(2000) }}"
target:
  entity_id: "{{ daylight_light_list }}"

Feel free to take it or leave it.

1 Like