#I get this in the logs when the script
1 messages ยท Page 1 of 1 (latest)
Sounds like you've got a problem with
count: "{{ states('input_number.whale_count') }}"
You did create that entity, and give it a value?
What I did was creating a script in the UI with count number and delay then switching to YAML and replacing count and delay with that
states('input_number.whale_count') takes the state of input_number.whale_count - if you didn't create input_number.whale_count then there's nothing there... hence unknown
Similarly you need to have created input_number.second_delay and given it a valuue
A stupid question: How do I create an entity within the yaml for that
By following the docs for that integration
you can also create them in the GUI if you want
See the thing is when @storm thunder wrote count: "{{ states('input_number.whale_count') }}" the first time I pasted it into the script and ran it and it worked. I thought that was it.
But nowhere in helpers do I have the input number
And now it throws that error.
That's a #templates-archived and like all templates it needs the entities listed for it to work
The script also didn't work... you got that error ๐
Sorry I know how stupid I sound right now being newbie
Valid YAML != working
Eh, you're fine... you've been on the server long enough I assumed you'd an understanding of templates so that was my fault
That's right I joined some time back but haven't been able to keep following. I got homeassistant installed and properly setup only a few days ago. Moved over from Homekit/Homebridge to this as this has a lot to offer but there is much more to it than I thought.
Thanks for bearing here with me
do I need to add entities input_number and a delay in helpers?
You need to create both input_number entities
input_number.whale_count and input_number.second_delay
Or... created another two entities and used them in your automation/script
It doesn't need to be called whale_count does it?
No
ok
helpers defined and number input boxes
input_number.count and input_number.delay
Can I not send a screenshot here?
Please use imgur or other image sharing web sites, and share the link here.
Image posting is blocked in most channels to discourage people from sharing text as images. Sharing text as images assumes that everybody sees the world as you do, which isn't the case. Some people are colour blind, or have visual impairment that means they can't make sense of an image of text.
wow ok, a lot has changed since my last visit. OK
This is how it looks in the UI now https://imgur.com/Ex24AVB
Test the template in
-> Templates
show your template developer tools
That's expected - remove that line
(or turn {{ there into { { to stop it parsing that)
I will repeat:
Sharing text as images assumes that everybody sees the world as you do, which isn't the case. Some people are colour blind, or have visual impairment that means they can't make sense of an image of text.
which line are you talking about
I thought u wanted to see how the templates look on my side.
Right, but ... images of text are horrible
Correct
sorry
I know
repeat: count: "{{ states('input_number.count') }}" sequence: - delay: "{{ states('input_number.delay') | int }}" - service: notify.mobile_app_zenbook data: message: Seconds remain {{ count - repeat.index * delay }}
which line you said to remove
The last line
Sorry my HA is acting weird let me reboot
ok so I removed the last line and now I got the result
repeat: count: "10.0" sequence: - delay: "2" - service: notify.mobile_app_zenbook data:
Looks like the templates are good
You may need
count: "{{ states('input_number.count')|int }}"
repeat: count: "{{ states('input_number.count') | int }}" sequence: - delay: "{{ states('input_number.delay') | int }}" - service: notify.mobile_app_zenbook data:
@drifting apex When using Discord's Reply feature it defaults to pinging the person you reply to, which can get frustrating for the target. Use Shift + click on the Reply option, or click @ ON to @ OFF to stop this - on the right side of the compose bar.
You have to change this every time (thank the Discord devs for that).
You also need to add the last line back...
I will say that in a thread like this Reply is pretty pointless, doubly so when you're using it to respond to the previous post
OK. got it
Added the last line back: repeat: count: count "{{ states('input_number.count')|int }}" sequence: - delay: "{{ states('input_number.delay')|int }}" - service: notify.mobile_app_zenbook data: message: Seconds remain {{ count - repeat.index * delay }}
When run getting this: 2022-12-13 14:57:48.617 ERROR (MainThread) [homeassistant.helpers.script.websocket_api_script] websocket_api script: Error rendering websocket_api script repeat count template: invalid literal for int() with base 10: 'count "10"'
And also I still get code inside the box in the script, should it be that way? https://imgur.com/tt6vEI0
No, look at the YAML you posted here, and compare it to what you had before
oh wait
count: "{{ states('input_number.count') | int }}"
``` vs
count: count "{{ states('input_number.count')|int }}"
not only that
now I have this repeat: count: "{{ states('input_number.count')|int }}" sequence: - delay: "{{ states('input_number.delay')|int }}" - service: notify.mobile_app_zenbook data: message: Seconds remain {{ count - repeat.index * delay }}
- HAOS
ha core check - Container uses
dockercommands - Core requires you to activate the venv first
That command there will help you
I get error that delay is undefined
It'll spot most YAML errors, including the ones you've made there
Right... where did you define the variable delay?
Hint ||nowhere||
No, you didn't define delay there
You created the entity input_number.delay
At no point have you defined a variable called delay
in entities I opened the input_number.delay and set it to 2
same I did for the input_number.count and set it to 10
If I didn't define it how come templates showed the values?
Because delay != input_number.delay
count is defined automatically by the repeat loop, to the value of count: "{{ states('input_number.count')|int }}"
That you picked input_number.count is irrelevant - which is why I used input_number.whale_count
You are now heavily in #templates-archived territory though
repeat: count: "{{ states('input_number.count')|int }}" sequence: - delay: "00:00:0{{ states('input_number.delay')|int }}" - service: notify.mobile_app_zenbook data: message: Seconds remain {{ count - repeat.index * delay }}
this still throws delay undefined
Well, yes
Again...*** at no point do you define delay ***
Of course it's undefined, you've never defined it
input_number.delay is completely unrelated to delay
input_number.count is completely unrelated to count
Ok, take a step back
Ok..
input_number.count is an entity you created for this
yeah I created that entity
You could have called that input_number.banana
repeat:
count: "{{ states('input_number.banana')|int }}"
There is no banana
Ok I get that it's a variable so whatever name doesn't matter
Correct
Your repeat happens to create some variables automatically
At no point does a variable called delay get created - by you or HA
message: "Seconds remain {{ states('input_number.count')|int - repeat.index * states('input_number.delay')|int }}"
Ah ok
Now I get it
Thanks. It worked now. However I still see that code {{ states('input_number.count')|int }} in the count number box instead of a number should it be that way?
Yes, the whole point is that it's a #templates-archived and the results of that template is used when the template is encountered
If it was a number you'd have hard-coded the value
So if I wanted to create another script like this to control another device with different count number and delay I'd have to create another entities with other values?
If you want to make them variable, yes
Thanks so much for being patient and explaining this to me.
What I thought was I'd be able to use the count box in the UI to define the count and wait UI for the delay
But turns out it's much more complex than that
Well, if you want to set them to fixed values you can
It's only if you want to make them things that you can change "on the fly" that it becomes complicated
I want to set them to fixed values for a script but want to be able to read those values later on in the script so that if I did decide to change the value I change it in the box and that's it. That was the goal
Well, you can do that with variables
Those are then fixed until you edit the script
Ok. question then. I haven't defined any entity. I simply created a script. In actions I added the repeat function. The repeat count box say I put 5 or 10 or 20. Is that value available as a variable in the script? So I could read it as say for example : input_number.count_box_value ???
I think it's available as count
nope didn't work for me
Then no
Because input_number.count_box_value isn't a variable anyway
That's an entity - the give away clue is the .
Variables have no .
ok.
I mean I just started doing all this, I can only imagine what your templates look like ๐ฑ
Mine aren't special, mostly, except for a few crazy ones. The real experts lurk in #templates-archived and do things that make me 
Can you please tell me why first time when I asked you said count: "{{ states('input_number.whale_count') }}" why does that whale matter? Why I'm asking is because when I put it in the YAML and returned to UI I was seeing the number in the count box. THe delay was fixed set to 2 and I ran the script and it worked.
Well, whale didn't matter
What mattered was that you had input_number.whale_count in your system, with a value
but how if I never defined it. I want understand why first time I saw number in the box and now I'm seeing the code
I have no idea what you did...
right now I also have input_number.count in the system with value 10. THe box doesn't show 10 it shows {{ states('input_number.count')|int }}
right, because you'd basically said you wanted to use templates
Sorry maybe I'm not being very clear.
If you want to hard code values and use that information later use https://www.home-assistant.io/integrations/script#variables
script:
thingy:
alias: "thingy"
variables:
my_count: 10
my_delay: 2
sequence:
repeat:
count: "{{ my_count }}"
sequence:
- delay: "{{ my_delay }}"
- service: notify.mobile_app_zenbook
data:
message: "Seconds remain {{ ( my_count * my_delay ) - ( repeat.index * my_delay ) }}"
(probably)