#Using Variables for field in Script
1 messages · Page 1 of 1 (latest)
Well, need to see real data to be of help
So you need us to format it so it's valid yaml?
No becasue I don't have the damn vacuum but I've helped tens of people setup generic scripts for vacuums to clean rooms
So I'm trying to figure out what you're asking for
Can you just write what your endgoal is with the script, not this pointed question
and post a valid roborock.vacuum_clean_segment action filled out with multiple rooms
Well, it looks like you removed all the data
can you please post the service call for roborock.vacuum_clean_segment popluated with data?
in yaml
try this
alias: Clean Rooms
fields:
rooms:
description: The room(s) to vacuum
required: True
selector:
select:
multiple: True
options:
- Laundry
- Entry
- Office
- Bedroom
- Shower
- Workshop
- Hallway
- Living room
- WC
- Kitchen
- Bathroom
repeats:
description: repeats
required: False
default: 1
selector:
number:
min: 1
max: 5
variables:
config:
Laundry: 16
Entry: 17
Office: 18
Bedroom: 19
Shower: 21
Workshop: 22
Hallway: 22
Living room: 23
WC: 24
Kitchen: 25
Bathroom: 26
repeat: "{{ repeats | default(1) }}"
segments: >
{% if rooms is defined %}
{% if rooms is list %}
{{ config.items() | selectattr('0', 'in', rooms) | map(attribute='1') | list }}
{% else %}
{% set room = config.get(rooms) %}
{{ [room] if room else [] }}
{% endif %}
{% else %}
[]
{% endif %}
sequence:
- condition: template
value_template: "{{ segments | count > 0 }}"
- action: roborock.vacuum_clean_segment
target:
entity_id: vacuum.roborock_s7
data:
segments: "{{ segments }}"
repeats: "{{ repeat }}"
did you copy/paste?
my yaml does not have data['fields']['rooms']['selector']['mulitple']
it has data['fields']['rooms']['selector']['select']['mulitple']
yeah but I don't think you copy/pasted
cause it's missing the word select
anyways, correct the spelling on multiple instead of removing it if you just copy/pasted
I'm going off your error
data['fields']['rooms']['selector']['mulitple']
the error points to the yaml code
the red box is missing from the error message, that's all I'm saying
I don't know if the error outputs the correct object hierarchy or if you copy/pasted it wrong. I can't tell. If correcting the spelling worked, then my assumption is that the error isn't outputting the correct hierarchy.