Vacuum template problems

Hello all, i have setup below code but i’m stucked.
partially it works but if i press one of the command button i have this error appearing on botton of the page “Vacuum/stop service invocation failed. Template rendered invalid entity IDs: cleaning”. what’s my error?

homeassistant:
  customize:
    package.node_anchors:
      customize: &customize
        package: "Centro Controllo Vacuum 1.0"
      setting:
        Dispositivo Vacuum: &dispositivo_vacuum_2 "{{ states('vacuum.k2t') }}"
vacuum:
  - platform: template
    vacuums:
      vacuum_2:
        friendly_name: "Vacuum 2"
        battery_level_template: "{{ state_attr('vacuum.k2t', 'battery_level') | int }}"
        value_template: *dispositivo_vacuum_2 
        start:
          service: vacuum.start
          data: {}
          target:
            entity_id: *dispositivo_vacuum_2
        pause:
          service: script.vacuum_pause
          data: {}
          target:
            entity_id: *dispositivo_vacuum_2
        stop:
          service: script.vacuum_stop
          data: {}
          target:
            entity_id: *dispositivo_vacuum_2
        return_to_base:
          service: script.vacuum_return_to_base
          data: {}
          target:
            entity_id: *dispositivo_vacuum_2
        clean_spot:
          service: script.vacuum_clean_spot
          data: {}
          target:
            entity_id: *dispositivo_vacuum_2
        locate:
          service: script.vacuum_locate_vacuum
          data: {}
          target:
            entity_id: *dispositivo_vacuum_2
        fan_speeds:
          - Low
          - Medium
          - High

Surely:

        Dispositivo Vacuum: &dispositivo_vacuum_2 "vacuum.k2t"

Otherwise, your anchor resolves to:

        start:
          service: vacuum.start
          data: {}
          target:
            entity_id: "{{ states('vacuum.k2t') }}"

which makes no sense unless the state of that entity is an entity ID. You want, I assume:

            entity_id: vacuum.k2t

now the vacuum_2 is not able anymore to see the correct status (“cleaning” in this case) and if i press one of the button i have this error message: “The script.vacuum_pause service called the vacuum.pause service which was not found.” :frowning:

Do you understand the code or have you copy/pasted it? You need to also change the state value_template:

      vacuum_2:
        friendly_name: "Vacuum 2"
        battery_level_template: "{{ state_attr('vacuum.k2t', 'battery_level') | int }}"
        value_template: "{{ states('vacuum.k2t') }}"

I don’t understand why you are using a YAML anchor when you refer to the entity directly in the battery level template…

1 Like

solved 99.5%! there was errors on the code which i post below if anyone needs :slight_smile:
now, for my roomba it works 100%, for the OKP it works 99%… only the button return_to_base is not wokring… i get this error
“Vacuum/return_to_base service invocation failed. Entity vacuum.k2t does not support this service.” i guess there is a problem on the configuration of my localtuya device because if i try to execute follow code on development services it work.

service: vacuum.return_to_base
data: {}
target:
  entity_id: vacuum.k2

The only differences are:

  • vacuum.k2 → become from the official tuya integration
  • vacuum.k2t → become from localtuya integration (but reffering same device)

here the condifuration of localtyua:


Code if anyone needs:

homeassistant:
  customize:
    package.node_anchors:
      customize: &customize
        package: "Centro Controllo Vacuum 1.0"
      setting:
        Dispositivo Vacuum: &dispositivo_vacuum_2 "vacuum.k2t"
vacuum:
  - platform: template
    vacuums:
      vacuum_2:
        friendly_name: "Vacuum 2"
        battery_level_template: "{{ state_attr('vacuum.k2t', 'battery_level') | int }}"
        value_template: "{{ states('vacuum.k2t') }}"
        start:
          service: vacuum.start
          data: {}
          target:
            entity_id: *dispositivo_vacuum_2
        pause:
          service: vacuum.pause
          data: {}
          target:
            entity_id: *dispositivo_vacuum_2
        stop:
          service: vacuum.stop
          data: {}
          target:
            entity_id: *dispositivo_vacuum_2
        return_to_base:
          service: vacuum.return_to_base
          data: {}
          target:
            entity_id: *dispositivo_vacuum_2
        clean_spot:
          service: vacuum.clean_spot
          data: {}
          target:
            entity_id: *dispositivo_vacuum_2
        locate:
          service: vacuum.locate
          data: {}
          target:
            entity_id: *dispositivo_vacuum_2