Lamp Brightness Increasing Until Brightness is Maxed

Hi All,
I was attempting to create a morning routine that turns on bedroom lamps at a certain time and the brightness increases up to its max.

Can anyone where my research and what is written below is wrong?

Thanks in advance.

- id: test
  alias: "Brian lamp turned on at specific time"
    - at: "21:51:00"
      platform: time
    - service: light.turn_on
      entity_id: light.graham_lamp
          { { states.light.graham_lamp.attributes.brightness | int + 10 } }

This is what I use to fade on my deck light at sunset:

      - service: light.turn_on
          entity_id: light.deck_light_0a4c
          brightness: 5
      - repeat:
            - service: light.turn_on
                entity_id: light.deck_light_0a4c
                brightness: "{{ state_attr('light.deck_light_0a4c', 'brightness') | int + 1 }}"
            - delay: 2
            condition: or
              - condition: template
                value_template: "{{ state_attr('light.deck_light_0a4c', 'brightness') | int >= 254 }}"
              - condition: state
                entity_id: light.deck_light_0a4c
                state: 'off'

it fades on at 1 unit every 2 seconds until it reaches max brightness.

Really helpful. Thank you for the help @finity !

You need to define your default.

Brightness: "{{ state_attr('light.deck_light_0a4c', 'brightness') | int(default=0) + 1}}"

Why is that?

To cut down on log spam, and to account for situations where the brightness attribute is unavailable. Although it is unlikely to be in a situation where this case will arise for this particular automation - it helps to get into a routine where you use a default out of habit, for those situations where the value might indeed be ‘Unknown’

The reason I asked is that there is a common misconception that many people have that the “default” is an absolute requirement at all times. But it’s not. If you set up the system to not ever be in a state where the thing you are testing is unavailable then it’s not needed.

Like in my automation above it’s very unlikely that the brightness attribute will ever be unavailable since the first thing that I do is turn on the light so it will always have a brightness attribute. And if the light becomes unavailable then the log error saying “no default was specified” will be the least of my concerns at that point.

And TBH, there are times when I would actually want to not have a default value and therefore let the automation/sensor/etc fail instead of acting incorrectly based on some default (but invalid) data. So I never put in default values by…well…default. :wink:

Just to clarify I’m not necessarily responding to you since from your post you likely already know what I’m saying. This is for others who may pop by and are misled by that statement.