Trim an trigger_id in automation and use that as an input value help

so i am trying to usethis simple automation, but as you guess, i cant get it to work.

service: climate.set_temperature
data:
  temperature: states(input_number.home_{{ trigger.entity_id[8:] }} | float)
target:
  entity_id: "{{ trigger.entity_id }}"

for setting the temperature. i need to get the trigger.entity.id (which i can get cause it works for target)

but for the value i needs to trim the first 8 charachters of the trigger.entity_id.Do a joing with a string and use that string to get the state…

trigger.entity_id = climate.living_room_trv

input_number.home_living_room_trv exists (and has a state of 19.0)

This is to make the automation work for all the climate entities. Otherwise i have to add another if/then everPreformatted texty time a new climate entity arrives.
(I know i still have to declare the matching input variable)

Try this:

temperature: "{{ states('input_number.home_' ~ trigger.to_state.object_id) | float(0) }}"

By way of explanation it concatenates (~) the string ‘input_number.home_’ with the object_id of the entity that triggered the automation.

entity_id = domain.object_id
trigger.entity_id = climate.living_room_trv
trigger.to_state.domain = climate
trigger.to_state.object_id = living_room_trv

Works perfectly your solution.

and for the ones that need more string manipulation…you can also app python trunctating.

Like this also worls

service: climate.set_temperature
metadata: {}
data:
  temperature: "{{ states('input_number.home_' ~ trigger.entity_id[8:]) | float(0) }}"
target:
  entity_id: "{{ trigger.entity_id }}"

But yours is cleaner for sure, using actial HA variables in stead of cutting them together lol :smiley: