I’m trying to use a input number to dynamically set the number repeats my vacuum do but it doesn’t work, it just makes vacuum go to wrong places.
‘235651221561231’:
alias: 'Vacuum kitchen ’
sequence:
service: vacuum.send_command
data:
entity_id: vacuum.robby
command: app_zoned_clean
params:
26335
27029
29785
28379
3 #{{ states.input_number.vacuum_repeats.state | int }}
service: input_boolean.turn_off
data:
entity_id: input_boolean.robby_is_empty
123
(Taras)
February 7, 2020, 5:10am
2
Try it like this:
params:
- 26335
- 27029
- 29785
- 28379
- "{{ states.input_number.vacuum_repeats.state | int }}"
All ready did that. No luck.
123
(Taras)
February 7, 2020, 2:50pm
4
I thought it might be worth trying but the underlying reason why it fails to work is because the integration doesn’t support it.
Jinja templates return strings. Not much you can do about it. Usually this isn’t an issue because the service schema will coerce certain parameters to int or float or whatever. However, I just looked at the vacuum service handler, and it doesn’t do this for send_command’s “params” parameter, probably because it can be various types.
Probably the only way to resolve this is to change the platform code. What vacuum platform are you using?
Same problem, with no available workaround, reported here:
Hello guys! How are you today?
I was wondering if any of you could help me out with scripting a zone cleaning of Xiaomi Vacuum.
As you know, the last number, after the last comma, is the number of passes the vacuum should do on this coordinates:
[[23746,23540,25096,25240,1]]
So, I tough it would be nice to set this myself, before sending the parameter to the vacuum. The solution was supposed to be very simple: create an input_number from 1 to 3 and set the last digit of the parameter with th…
petro
(Petro)
February 7, 2020, 3:05pm
5
but you didn’t try it with data_template
service: vacuum.send_command
data_template:
entity_id: vacuum.robby
command: app_zoned_clean
params:
- 26335
- 27029
- 29785
- 28379
- "{{ states.input_number.vacuum_repeats.state | int }}"
EDIT:
@123 appears to be onto a totally separate issue with the component. Making data_template less likely to work. But data_template is always required when templating fields inside data.
123
(Taras)
February 7, 2020, 3:17pm
6
I missed that one (because reading unformatted YAML is never fun). Use of data:
will definitely prevent any template from being evaluated!
FWIW, in the posted link, a solution offered by tom_I used data_template
but the suggested template failed to be evaluated correctly. The OP reported the error message showed the params
list had all its items in quotes, indicating they had all been converted to strings.
2018-08-11 10:58:12 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=vacuum, service=send_command, service_data=command=app_zoned_clean, entity_id=vacuum.xiaomi_vacuum_cleaner, params=[[‘25850’, ‘26750’, ‘28750’, ‘30550’, ‘1’]] >
1 Like
petro
(Petro)
February 7, 2020, 3:26pm
7
Amen to that. That’s why I chimed in… but then read your response after. Probably should have reversed that order! My b.
1 Like
What vacuum platform are you using?
If xiaomi_miio
then you should use the xiaomi_miio.vacuum_clean_zone
service instead.
Thanks, this was the solution.
1 Like
123
(Taras)
February 7, 2020, 7:47pm
10
Lateral-thinking Phil strikes again!
Good job!
1 Like