What exactly are you trying to do? It doesn’t make sense to me. Seems like you’re using way too many input_numbers for a button. Also, if you want to pass a number OR a value from an entity, you have to adjust your template in your script to account for that.
testscript:
alias: testscript
sequence:
- service: cover.set_cover_position
data:
entity_id: cover.eg_ez_roll_esphome
position: >
{{ states(position_var) | int or position_var | int }}
- service: input_number.set_value
data:
entity_id: input_number.helfer_testnummer
value: >
{{ states(position_var) | int or position_var | int }}
mode: single
So the final goal of this is to have one script that can be called for all my blinds.
The frontend will have a template cover for lovelace. The lovelace cover buttons as well as my wall switches will start automations that will call the script. Also giving it the corrosponding “window open” switch and a “default position” to the script, which then acts accordingly.
In my example, I was trying to debug where I loose the actual number and therefore I did the second sevice call, sending the number sent into the script to a input number displaying its outcome. Finally the “service: input_number.set_value” will be gone.
@Burningstone: changing the code to your proposal results in the same error:
“Fehler beim Aufrufen des Diensts script/testscript. expected int for dictionary value @ data[‘position’]”
Why is the script using “states(‘position_var’)” as if “position_var” is an entity? Is that a new thing or has it always been that way and I just missed it or is it not really an entity and they shouldn’t be using it as such?
The variable was being transmitted as data to the script. It’s not an entity as far as I know.
ok, taking your input into account, I need to feed the variable as int into the script. This means, that the cast float -> int must happen in the call of the script.
So if I use the templating development tools, this:
He hands over the entity_id as a variable to the script and not the state of the entity_id, that’s why he needs states(position_var) to get the state of the entity_id passed to the script.
@CeeCee
You can’t just use a template in lovelace like you tried, you need something like this.