Hello,
Awesome thread, I used it to create custom trigger for my Dreame L20 Ultra Complete.
I used Dreame HACS custom component dev branch from Tasshack.
here is my sensor in configuration.yaml:
sensor:
- platform: "template"
sensors:
dreame_cleaning_settings:
value_template: "CHECK ATTRIBUTES"
attribute_templates:
selected_rooms: >-
{% set result = namespace (selectedRooms=[]) %}
{% set rooms = [
{ "roomId": 6, "friendlyName": "SdB RdC", "inputEntityId": "input_boolean.sdb_rdc"},
{ "roomId": 1, "friendlyName": "Chambre", "inputEntityId": "input_boolean.chambre"},
{ "roomId": 2, "friendlyName": "Salon", "inputEntityId": "input_boolean.salon"},
{ "roomId": 4, "friendlyName": "Salle à Manger", "inputEntityId": "input_boolean.salle_a_manger"},
{ "roomId": 3, "friendlyName": "Entrée", "inputEntityId": "input_boolean.entree"},
{ "roomId": 5, "friendlyName": "Cuisine", "inputEntityId": "input_boolean.cuisine"},
] %}
{% for room in rooms %}
{% if is_state(room.inputEntityId, 'on') %}
{% set result.selectedRooms = result.selectedRooms + [room] %}
{% endif %}
{% endfor %}
{{ result.selectedRooms }}
display in the UI with this card:
type: entities
entities:
- sensor.dreame_cleaning_settings
I used to add the corresponding input_boolean as well in configuration.yaml:
input_boolean:
sdb_rdc:
name: SdB RdC
chambre:
name: Chambre
salon:
name: Salon
salle_a_manger:
name: Salle a Manger
entree:
name: Entree
cuisine:
name: Cuisine
So I displayed in the UI the corresponding card.
type: entities
entities:
- entity: input_boolean.chambre
- entity: input_boolean.cuisine
- entity: input_boolean.entree
- entity: input_boolean.salle_a_manger
- entity: input_boolean.salon
- entity: input_boolean.sdb_rdc
Then I created the script with the following instruction:
alias: Vacuum Selected Room
sequence:
- service: dreame_vacuum.vacuum_clean_segment
data:
segments: >
{% set result = namespace(roomIds=[]) %} {% for roomId in
state_attr('sensor.dreame_cleaning_settings', 'selected_rooms') |
map(attribute='roomId') %}
{% set result.roomIds = result.roomIds + [roomId] %}
{% endfor %} {{ result.roomIds }}
target:
entity_id: vacuum.dreamebot_l20_ultra_complete
mode: single
icon: mdi:robot-vacuum
I just removed the number of time cleaning a room, as I want to use the default controls coming with the Dreame HACS custom component.
Then I created a card to mock the default vacuum call to service button and have direct access in the UI instead of using the Entity button:
type: horizontal-stack
cards:
- show_name: false
show_icon: true
type: button
icon_height: 60px
tap_action:
action: toggle
entity: script.vacuum_selected_room
show_state: false
icon: mdi:play
- show_name: false
show_icon: true
type: button
icon_height: 60px
tap_action:
action: call-service
service: vacuum.start_pause
target:
entity_id: vacuum.dreamebot_l20_ultra_complete
icon: mdi:play-pause
entity: vacuum.dreamebot_l20_ultra_complete
- show_name: false
show_icon: true
type: button
icon_height: 60px
tap_action:
action: call-service
service: vacuum.stop
target:
entity_id: vacuum.dreamebot_l20_ultra_complete
icon: mdi:stop
entity: vacuum.dreamebot_l20_ultra_complete
- show_name: false
show_icon: true
type: button
icon_height: 60px
tap_action:
action: call-service
service: vacuum.return_to_base
target:
entity_id: vacuum.dreamebot_l20_ultra_complete
icon: mdi:home-import-outline
entity: vacuum.dreamebot_l20_ultra_complete
- show_name: false
show_icon: true
type: button
icon_height: 60px
tap_action:
action: call-service
service: vacuum.locate
data: {}
target:
entity_id: vacuum.dreamebot_l20_ultra_complete
icon: mdi:map-marker-radius
entity: vacuum.dreamebot_l20_ultra_complete
In the end I created 3 cards, can be optimized.
#1 is to set default params from Dreame HACS custom component like cleanning mode, suction level, path, mop humidity etc.
#2 is to select the room user wants to clean
#3 is direct control of the robot start, resume, stop, home and locate.
Everything works well thanks to this thread
I am sure we can do better (like using custom cards) but it was fun to do and learn.