Template help? Light brightness

Hello

I’ve had a couple of automations that have worked flawlessly for years, till recently. 1 is my landing hue light is on low, till motion is detected when it goes brighter, then after a certain time with no motion, it dims down. Recently it has stopped getting brighter when motion is detected. Does anyone know what could have changed please?

I have started to get this error

2022-02-16 16:01:33 ERROR (MainThread) [homeassistant.components.automation.landing_light_back_to_normal_brightness] Landing light back to normal brightness: Error executing script. Error for call_service at pos 1: Error rendering data template: TypeError: 'int' object is not iterable
2022-02-16 16:01:33 ERROR (MainThread) [homeassistant.components.automation.landing_light_back_to_normal_brightness] Error while executing automation automation.landing_light_back_to_normal_brightness: Error rendering data template: TypeError: 'int' object is not iterable

- alias: Landing Light Bright on motion
  initial_state: 'on'
  trigger:
    platform: state
    entity_id: binary_sensor.stairs

    from: 'off'
    to: 'on'
  condition:
    - condition: state
      entity_id: light.landing 
      state: 'on'
  action:
    - service: light.turn_on
      entity_id: light.landing
      data_template:
        brightness: '{{ ((states.light.landing.attributes.brightness or 0) + 150) | min(255) }}'

The min filter has changed.

min([x, y, ...]) will obtain the smallest item in a sequence. Uses the same parameters as the built-in min filter.

I suggest you change the action to this:

    - service: light.turn_on
      target:
        entity_id: light.landing
      data:
        brightness: "{{ [(state_attr('light.landing', 'brightness') or 0) + 150, 255] | min }}"

In addition, some of the syntax you’re using in the service call is old-school so I updated it for you.

2 Likes

thank you so much. Some of my automations are from 4 years ago and I haven’t really kept up with it all recently and it does get overwhelming :smiley:

1 Like

You’re welcome!

Please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has been resolved. This helps users find answers to similar questions. For more information, refer to guideline 21 in the FAQ.

1 Like