Dim lights based on the sun's elevation

I would like to get the debug log, so I can take a look at what is going on.

wow that’s some templating madness you did here, pretty impressive.

i created a similar blueprint, that I haven’t published yet. I saw you are using the sun evaluation to trigger your automation, i ran into really big problems doing this as at some times during the day the state only updated every ~10 minutes. this is pretty bad as the lights wont fade nicely then.
have you experienced this too?

Yes, that is why I added the fade option to not make it as noticable. I have also considered calculating the elevation manually minute by minute (since i are working on a version 2 that will be better for us living closer to the arctic circle and have varying daylight through out the year.

i am not so familiar with the sun movement and how it affects the lighting, so I would really like to read your explanation once you finished. I choose to calculate the percentage sun position based on the sunrise and sunset time. This won’t give information about the sun elevation but you’ll get pretty good values to work with.

Okay, I can see in Telldus that Home assistant is changing the dim value. But after around 5PM it stops to dim the lamp. I am pretty new to Home Assistant, should I look in the Configurations tab and then Load logs?

Found this as well:

Logger: homeassistant.components.automation.dim_lights_based_on_sun_elevation
Source: helpers/script.py:1147
Integration: Automation (documentation, issues)
First occurred: 18:24:55 (1 occurrences)
Last logged: 18:24:55

Dim lights based on sun elevation: Maximum number of runs exceeded

Interesting.

Can you try it one one light just to see if that works?

I only have one single light on this automation if it was your question?

Yes. What bugs me is the queue error.

Did you turn on debug in the automation? (Note, it requires the logger to be configured in configuration.yaml in order for the logger service to be available

Yes I did turn on debug and I added the logger in configuration.yaml. When I am trying to check the log file everything really slows down, the file seems to be enormous!

Did you turn on full debug or just in the automation?

My configuration.yaml look like this

logger:
  default: warning

And then I turn on debug in the automation only

I think I had full debug :open_mouth: I changed my config to the same as you, so let’s see tonight what’s going on :slight_smile:

Don’t forget to turn on debug in the automation and execute it manually one time.

Check the log that you get something (even before sunset you will get debug log)

Like this?:

2021-02-16 12:25:05 DEBUG (MainThread) [homeassistant.components.blueprint.dim_lights_based_on_sun_elevation] DEBUG:

skip_event: False

affected_entities: [‘light.lampa_koksfonster’]

elevation: 19.91 (-8, 6)

last elevation: 19.9

new brightness: 165

last brightness: 165

current_states: [{‘entity_id’: ‘light.lampa_koksfonster’, ‘state’: ‘off’, ‘brightness’: None}]

force_turn_on: False

force_turn_off: False

entities: [‘light.lampa_koksfonster’]

turn_on_entities: []

dim_entities: []

turn_off_entities: []

Triggered by: state

from: (elevation: 19.9, azimuth: 178.58)

to: (elevation: 19.91, azimuth: 179.62)

Yes. Do you have turn on enabled in the automation?

Yes i have done that :slight_smile:

This error appears several times:

2021-02-16 16:42:31 ERROR (MainThread) [frontend.js.latest.202101277] http://192.168.1.xxx:8123/frontend_latest/chunk.6b18c64ed740014d3f00.js:1:8122 YAMLException: unacceptable kind of an object to dump [object Undefined]

2021-02-16 18:16:21 DEBUG (MainThread) [homeassistant.components.blueprint.dim_lights_based_on_sun_elevation] DEBUG:

skip_event: False

affected_entities: [‘light.lampa_koksfonster’]

elevation: -8.66 (6, -25.5)

last elevation: -7.61

new brightness: 111

last brightness: 115

current_states: [{‘entity_id’: ‘light.lampa_koksfonster’, ‘state’: ‘on’, ‘brightness’: 138}]

force_turn_on: False

force_turn_off: False

entities: [‘light.lampa_koksfonster’]

turn_on_entities: []

dim_entities: []

turn_off_entities: []

Triggered by: state

from: (elevation: -7.61, azimuth: 259.88)

to: (elevation: -8.66, azimuth: 261.56)

I wonder why dim_entities are empty.

What is the value of the attribute supported_features on the entity light.lampa_koksfonster ?

I don’t know what you mean now? Where do I find supported_features?