Closed patpac9 closed 2 years ago
It‘s hard to help you with this spare informations. You need to use the whole code and then it should work. At least the provided version I have in use.
Please share the complete config and create a gif of your error. I don‘t understand, where exactly is the problem
Ty for the fast reply! Hmmm.... Yeah i also thought it is my fault, but I tried copy and pasting it in 3 times. Here the gif recording from UI.
and here is the whole code:
UI Card:
type: vertical-stack
cards:
- type: custom:vacuum-card
entity: vacuum.saugstauberos
stats:
default:
- entity_id: sensor.saugstauberos_life_span_brush
unit: '%'
subtitle: Hauptbürste
- entity_id: sensor.saugstauberos_life_span_side_brush
unit: '%'
subtitle: Seitenbürsten
- entity_id: sensor.saugstauberos_life_span_filter
unit: '%'
subtitle: Filter
cleaning:
- entity_id: sensor.saugstauberos_stats_area
unit: m²
subtitle: Geputzte Fläche
- entity_id: sensor.saugstauberos_stats_time
unit: Minuten
subtitle: Reinigungsdauer
show_status: true
show_toolbar: false
compact_view: true
- type: custom:button-card
color: auto-no-temperature
name: Räume zum Putzen auswählen
styles:
card:
- font-size: 18px
- height: 30px
name:
- color: var(--primary-color)
- type: horizontal-stack
cards:
- type: custom:button-card
template: vacuum_room
entity: sensor.deebot_saugstauberos_queue_living_room
icon: mdi:sofa
name: Wohnzimmer
tap_action:
service_data:
room: living_room
- type: custom:button-card
template: vacuum_room
entity: sensor.deebot_saugstauberos_queue_kitchen
icon: mdi:silverware-variant
name: Küche
tap_action:
service_data:
room: kitchen
- type: custom:button-card
template: vacuum_room
entity: sensor.deebot_saugstauberos_queue_corridor
icon: mdi:shoe-print
name: Gang
tap_action:
service_data:
room: corridor
- type: horizontal-stack
cards:
- type: conditional
conditions:
- entity: vacuum.saugstauberos
state_not: cleaning
- entity: vacuum.saugstauberos
state_not: paused
card:
type: custom:button-card
template: vacuum_service
icon: mdi:play
name: Start
tap_action:
action: call-service
service: script.deebot_clean
variables:
enabled: |
[[[
return ((!states['variable.deebot_saugstauberos_queue'].state ||
states['variable.deebot_saugstauberos_queue'].state.length === 0)
&& ['docked', 'idle', 'error', 'returning'].includes(entity.state))
]]]
- type: conditional
conditions:
- entity: vacuum.saugstauberos
state: cleaning
card:
type: custom:button-card
color: auto
icon: mdi:pause
name: Pause
tap_action:
action: call-service
service: vacuum.pause
service_data:
entity_id: vacuum.saugstauberos
styles:
card:
- height: 80px
- background-color: var(-color)
- type: conditional
conditions:
- entity: vacuum.saugstauberos
state: paused
card:
type: custom:button-card
color: auto
icon: mdi:play-pause
name: Weiter
tap_action:
action: call-service
service: vacuum.start
service_data:
entity_id: vacuum.saugstauberos
styles:
card:
- height: 80px
- background-color: var(-color)
- type: custom:button-card
template: vacuum_service
icon: mdi:stop
name: Stop
tap_action:
service: vacuum.stop
variables:
enabled: |
[[[
return !(['cleaning', 'paused', 'returning'].includes(entity.state))
]]]
- type: horizontal-stack
cards:
- type: custom:button-card
template: vacuum_service
icon: mdi:home-map-marker
name: Zurück zur Ladestation
tap_action:
service: vacuum.return_to_base
variables:
enabled: |
[[[
return ['docked', 'returning'].includes(entity.state)
]]]
- type: custom:button-card
color: auto
icon: mdi:map-marker
name: Lokalisieren
tap_action:
action: call-service
service: vacuum.locate
service_data:
entity_id: vacuum.saugstauberos
styles:
card:
- height: 80px
- background-color: var(-color)
UI Template:
button_card_templates:
vacuum_service:
color: var(--text-color)
entity: vacuum.saugstauberos
tap_action:
action: call-service
service_data:
entity_id: vacuum.saugstauberos
lock:
enabled: |
[[[ return variables.enabled ]]]
exemptions: []
styles:
card:
- height: 80px
lock:
- color: var(--primary-text-color)
state:
- operator: template
value: |
[[[ return variables.enabled ]]]
styles:
card:
- color: var(--disabled-text-color)
vacuum_room:
color: var(--text-color)
variables:
lock_enabled: >
[[[ return ['cleaning',
'paused'].includes(states['vacuum.saugstauberos'].state) ]]]
state:
- operator: template
value: |
[[[ return variables.lock_enabled && entity.state == 0 ]]]
styles:
card:
- color: var(--disabled-text-color)
- styles:
card:
- background-color: var(--primary-color)
operator: '>='
value: 1
styles:
card:
- font-size: 12px
grid:
- position: relative
custom_fields:
order:
- display: |
[[[
if (entity.state == "0")
return "none";
return "block";
]]]
- position: absolute
- left: 5%
- top: 5%
- height: 20px
- width: 20px
- font-size: 20px
- font-weight: bold
- line-height: 20px
custom_fields:
order: |
[[[ return entity.state ]]]
tap_action:
action: call-service
service: script.deebot_room_queue
service_data:
queue: deebot_saugstauberos_queue
lock:
enabled: |
[[[ return variables.lock_enabled ]]]
exemptions: []
Config yaml:
script:
deebot_clean:
description: Start a deebot cleaning task
variables:
queue: variable.deebot_saugstauberos_queue # change me
vacuum_bot: vacuum.saugstauberos # change me
sequence:
- alias: Get room numbers
variables:
# See for appending to list
# https://github.com/home-assistant/core/issues/33678#issuecomment-609424851
rooms: >-
{%- set queue_split = states(queue).split(",") -%}
{%- set rooms = state_attr(vacuum_bot, "rooms")-%}
{%- set data = namespace(rooms=[]) -%}
{%- for room_name in queue_split -%}
{%- set data.rooms = data.rooms + [rooms[room_name]] -%}
{%- endfor -%}
{{ data.rooms | join(",") }}
- alias: Send cleaning job to vacuum
service: vacuum.send_command
data:
entity_id: "{{ vacuum_bot }}"
command: spot_area
params:
rooms: "{{ rooms }}"
cleanings: 1
deebot_room_queue:
description: Add/Remove a room from the queue
fields:
queue:
description: The queue variable
example: deebot_susi_queue
room:
description: Room, which should be removed or added
example: kitchen
sequence:
- service: variable.set_variable
data:
variable: "{{ queue }}"
value: >-
{%- set queue = states("variable.deebot_susi_queue").split(",") -%}
{%- if states("variable.deebot_susi_queue") | length == 0 -%}
{{ room }}
{%- elif room in queue -%}
{{ queue | reject("eq", room) | list | join(",")}}
{%- else -%}
{{ (queue + [room]) | join(",") }}
{%- endif -%}
recorder:
exclude:
entities:
- variable.deebot_saugstauberos_queue # change me
- script.deebot_room_queue
entity_globs:
- sensor.deebot_*_queue_*
variable:
deebot_saugstauberos_queue: # change me
name: Saugstauberos Raum Reihenfolge # change me
value: ""
restore: false
# Room name comes from the integration to match attribute names
template:
unique_id: deebot_saugstauberos_queue # change me
trigger:
- platform: homeassistant
event: start
- platform: state
entity_id: variable.deebot_saugstauberos_queue # change me
sensor:
# Add for each room the following. Change room_name accordingly
- unique_id: deebot_saugstauberos_queue_living_room # change me
name: deebot_saugstauberos_queue_living_room # change me
# room_name must match the room name provided by the vacuum
state: >
{% set room_name = "living_room" %}
{% set queue = trigger.to_state.state.split(",") if trigger.to_state is defined else "" %}
{{ queue.index(room_name)+1 if room_name in queue else 0 }}
- unique_id: deebot_saugstauberos_queue_kitchen # change me
name: deebot_saugstauberos_queue_kitchen # change me
# room_name must match the room name provided by the vacuum
state: >
{% set room_name = "kitchen" %}
{% set queue = trigger.to_state.state.split(",") if trigger.to_state is defined else "" %}
{{ queue.index(room_name)+1 if room_name in queue else 0 }}
- unique_id: deebot_saugstauberos_queue_corridor # change me
name: deebot_saugstauberos_queue_corridor # change me
# room_name must match the room name provided by the vacuum
state: >
{% set room_name = "corridor" %}
{% set queue = trigger.to_state.state.split(",") if trigger.to_state is defined else "" %}
{{ queue.index(room_name)+1 if room_name in queue else 0 }}
You see something I messed up? I also changed all queue entity states to "0". But did not help.
set queue = states("variable.deebot_susi_queue").split(",") -%} {%- if states("variable.deebot_susi_queue") | length == 0 -%}
Here you still use my „Susi“ queue
Ohh... Uff...
Thank you!!! Now it works!!! In your example, there is no "# change me" in this section. I was changing only the values where you say it in your code.
Nobody is perfect.
And also in the code it is specified, that most of the lines are highlighted with change me.
Sorry to hijack this, but it was driving me nuts because the new example did not work for me. I had the same issues as @patpac9. Then I found this github issue and reverted to pre #120 changes - and the problems were gone.
So after that I went back to the new example script _deebot_roomqueue and had to make the following changes (probably not the cleanest way to do it) to get the new example to work:
...
{%- set queue_state = states('variable.' + queue) -%}
...
@loopway Please open a PR with the fix :)
@edenhaus et voilà: #124
Hello :)
Nice work by the way! I lOVE "Deebot 4 Home Assistant"
Unfortunately the room selection does not work. https://deebot.readthedocs.io/integrations/home-assistant/examples/ui/advanced/
I copied everything and just replaced "Susi" with the name of my vacuum cleaner. No matter what I do, he always writes the value "2" in the UI queue and deselects the previously selected.
Here is the Template out of configurations yaml:
and here is my UI yaml:
Here some info about my env: HASS 2022.4.1. hass-variables 2.2.1 Button Card 3.4.2