Hm, I tried with:
service: vacuum.send_command
data:
entity_id: vacuum.pitbull
command: zoned_cleanup
params:
zone_ids:
- kitchen
and (like HA suggests with sample data)
service: vacuum.send_command
data:
entity_id: vacuum.pitbull
command: zoned_cleanup
params:
zone_ids: kitchen
Does not work. What is wrong?
Something is no yes I have followed all steps:
python script created:
entity_id = data.get('entity_id')
command = data.get('command')
params = str(data.get('params'))
parsedParams = []
for z in params.replace(' ', '').replace('],[', '|').replace('[', '').replace(']', '').split('|'):
rect = []
for c in z.split(','):
rect.append(int(c))
parsedParams.append(rect)
if command in ["app_segment_clean"]:
parsedParams = parsedParams[0]
hass.services.call('vacuum', 'send_command',
{'entity_id': entity_id, 'command': command, 'params': parsedParams}, True)
groups created:
room_input_booleans:
entities:
- input_boolean.kuchnia
- input_boolean.salon
- input_boolean.korytarz
- input_boolean.pokoj_leny
- input_boolean.lazienka
- input_boolean.sypialnia
New attribute for input_boolean
created:
editable: true
friendly_name: Korytarz
icon: 'mdi:wall'
room_number: 19
Automation created:
- id: '1600287204887'
alias: odkurzanie_selektywne
description: ''
trigger:
- entity_id: input_boolean.slij_mariusza
from: 'off'
platform: state
to: 'on'
condition: []
action:
- data_template:
command: app_segment_clean
entity_id: vacuum.xiaomi_vacuum_cleaner
params: "{{ ''group.room_input_booleans'' | expand | selectattr(''state'', ''equalto'', ''on'') | map(attribute=''attributes.room_number'') | list }"
service: python_script.vacuum_send_command
- delay: 00:00:05
- data: {}
entity_id: input_boolean.slij_mariusza
service: input_boolean.turn_off
mode: single
And got an error when checking configuration:
Invalid config for [automation]: invalid template (TemplateAssertionError: no filter named 'expand') for dictionary value @ data['action'][0]['data_template']['params']. Got None. (See /config/configuration.yaml, line 155).
Any idea what went wrong?
3_14
(Piotr Machowski)
September 17, 2020, 4:43pm
145
I am not sue if quotes in params
are correctā¦
Try something like this:
- data_template:
command: app_segment_clean
entity_id: vacuum.xiaomi_vacuum_cleaner
params: "{{ 'group.room_input_booleans' | expand | selectattr('state', 'equalto', 'on') | map(attribute='attributes.room_number') | list }"
Problem solved!
I have pasted an error into google and it guided me to:
https://community.home-assistant.io/t/how-to-use-expand-function-in-sensor-template-to-sum-all-state-of-a-group/136791/5
Iām not that good with coding but idea to use expand ('group.room_input_booleans')
instead of 'group.room_input_booleans' | expand |
is solving the issue. My automation is now working. Thanks for your effort @3_14 ( Piotr) You are my HERO!
@EdwardEnglish where you able to solve this issue?
I am trying to corner the issue piece by piece. First I wanted to see if vacuum.send_command is working correctly. If I use Developer Tools to call a service.
vacuum.start for example works perfectly fine.
Shouldnāt I get the same result using
service vacuum.send_command
entity_id: vacuum.rockrobo
command: start
Happy for any input.
1 Like
Unfortunately notā¦never found the time to give it more tries. But if anybody ever finds a solution please post it!
hagenuck1
(Hagenuck1)
November 5, 2020, 3:17pm
149
Have a look here, I solved it using the new 0.117 template as list feature and can send it directly to the vacuum without using any python script at all.
https://community.home-assistant.io/t/a-list-generated-by-a-template-is-it-possible-help/111239/35?u=hagenuck1
dapuzz
(dapuzz)
November 19, 2020, 4:04pm
150
And also in 0.118 with Native types support for templates
benm7
(Ben M)
March 31, 2021, 9:48am
151
Do you mind sharing the final code for this please?
I have tried using the python script method but get the following error:
File "vacuum_send_command.py", line 9, in <module>
ValueError: invalid literal for int() with base 10: "'19'"
Seems like an issue with the room_number attribute, which I can confirm exists for the room I am trying to clean.
benm7
(Ben M)
March 31, 2021, 10:13am
152
Ignore, got it to work by mapping to integers first.
here is the code, seems to work well now!
- service: python_script.vacuum_send_command
data_template:
command: app_segment_clean
entity_id: vacuum.robomac
params: "{{ expand('group.vc_rooms') | selectattr('state', 'equalto', 'on') | map(attribute='attributes.room_number') | map('int') | list }}"
With the latest valetudo update it broke my vacuum.send_command
stuff but I was able to get it working using MQTT publish like so.
service: mqtt.publish
data:
topic: valetudo/robovacDown/MapSegmentationCapability/clean/set
payload: '20'
One thing Iāve not been able to figure out yet is how to provide a payload of multiple segments to be cleaned though. Say like payload: ['20', '21', '22']
.
EDIT: Figured it out. 2021.06 - Home Assistant segment clean help Ā· Discussion #989 Ā· Hypfer/Valetudo Ā· GitHub