Passing entity_id to template from script to script

Hi guys! I need your help as I‘m totally lost right now.
Context: We have an Ecovacs vacuum integrated via „deebot for hassio“ from And3rsl. The Problem is, the vacuum is loosing or moving rooms, renaming them constantly, every week etc. Cleans good, but software is just annoying… So changing every automation now and then is not an option. Further the rooms in the ecovacs app are named by letters whereas in home assistant there are room numbers. So I was thinking about this:

input_text in lovelace where I could easily enter the letters, if something changes
script 1: for every room, available in lovelace to click, turns on main cleaning script
this one is basically just passing the area as entity to the main script: input_text.saugi_xx
#saugi=little vacuum in german

service: script.turn_on
target:
  entity_id: script.clean_spot
data:
  entity: input_text.saugi_xx

main script (2):

service: vacuum.send_command
target:
  entity_id: vacuum.saugi
data:
  params:
    rooms: {% if is_state(area, 'A') %}
  1
{% elif is_state(area, 'B') %}
  2
{% endif %}
#this is checking and translating the room from letter to number for HA, goes much further

The problem for me here is to pass the entity_id, the input_text from script 1 into the template for rooms in the main script.
I was thinking about something like this:

{% set area = {{entity_id}} %}

But this arrangement seems not to be possible, but I have no idea how i could bring the entity_id into the template. I hope I was clear enough…
Is there a way?

Ok, just in case somebody is interested: I got it.
In script 1 I declared a variable

saug_in_kuche:
  sequence:
    - service: script.turn_on
      target:
        entity_id: script.saugi_command_spot_area
      data:
        variables:
          raum: input_text.saugi_kuche
  mode: single
  alias: Saugi in Küche

in the main script I forgot these guys: " or ’ before and after the template

saugi_command_spot_area:
  alias: Saugi Command spot area
  sequence:
    - service: vacuum.send_command
      target:
        entity_id: vacuum.saugi
      data:
        command: spot_area
        params:
          rooms: "{% if is_state(raum, 'A') %} 0 
          {% elif is_state(raum, 'B') %} 1 
          {% elif is_state(raum, 'C') %} 2 
          {% elif is_state(raum, 'D') %} 3
          {% elif is_state(raum, 'E') %} 4 
          {% elif is_state(raum, 'F') %} 5 
          {% elif is_state(raum, 'G') %} 6 
          {% elif is_state(raum, 'H') %} 7 
          {% elif is_state(raum, 'I') %} 8 
          {% elif is_state(raum, 'J') %} 9 
          {% elif is_state(raum, 'K') %} 10 
#list goes on

works now!

by the way could someone tell me please where they got their knowledge from? I was reading a lot of posts and people recommend things, that are definitely not on general HA website. I read something about date_template and service_template. Found nothing official about it. Or some rules, that are nowhere to read or what exactly the "data: " part is for in general words. Like is there a hidden handbook somewhere? Or am I that stupid to find the things?

greetings, have a nice day

1 Like