Using a homeassistant sensor value as a variable

There is a homeassistant device attribute I’d like to use to set a value. I’m really beating my head over how to do this.

I’m importing the value from HA:

sensor:
  - platform: homeassistant
    id: my_team_id
    entity_id: sensor.team_tracker_browns
    attribute: team_id

I think I have that part right.
I’d like to use it on the “range_to” line:

binary_sensor:
  - platform: homeassistant
    name: "Turn on 5 leds"
    entity_id: input_boolean.turn_on_leds
    on_press:
      then:
        - light.addressable_set: 
            id: my_light
            range_from: 0
            range_to: {{ my_team_id.team_id }}
            red: 100%
            green: 0%
            blue: 0%
    on_release:
      then:
        - light.addressable_set: 
            id: my_light
            range_from: 0
            range_to: 5
            red: 0%
            green: 0%
            blue: 0%

How do I get that “team_id” attribute to be the value for range_to?

You have to use lambdas.

range_to: !lambda  "return id(my_team_id).state ;"
1 Like