PiotrMachowski/lovelace-xiaomi-vacuum-map-card

Tile internal_variable is not taken into consideration

lageorgem opened this issue · 1 comments

Checklist

  • I have updated the card to the latest version available
  • I have cleared the cache of my browser
  • I have checked if the problem is already reported

The problem

I am trying to create a tile that displays a value from internal_variables, as documented in the readme.
It seems, however, that a tile cannot display values from internal_variables, as they cannot be rendered without an entity_id, and will not display the internal_variable value with an entity_id.

At this line you can see the code will not continue without an entity, but at this line you can see the branch of the code that looks up internal_variables cannot be reached with an entity set.

What version of a card has described problem?

v2.2.2

What was the last working version card?

No response

What vacuum model do you have problems with?

roborock.vacuum.s5e

Which integration do you use to control your vacuum (link)?

https://www.home-assistant.io/integrations/xiaomi_miio/

What browser (browsers/apps) does have this problem?

Chrome

What version of Home Assistant do you use?

core-2024.5.5

What type of installation are you running?

Home Assistant OS

Card's configuration

type: vertical-stack
title: Abuelita
cards:
  - type: custom:xiaomi-vacuum-map-card
    internal_variables:
      bathroom_label: Bathroom
      balcony_label: Balcony
      home_label: Home
    map_source:
      camera: camera.abuelita
    calibration_source:
      camera: true
    entity: vacuum.abuelita
    vacuum_platform: default
    conditions:
      - entity: sensor.floor_sensor
        value: home
    append_icons: true
    append_tiles: true
    tiles:
      - label: Change map
        icon: mdi:shower
        internal_variable: bathroom_label
        tooltip: Change map to Bathroom
        order: 1
        tap_action:
          action: call-service
          service: script.change_vacuum_map
          service_data:
            map_id: 1
      - label: Current map
        icon: mdi:map
        entity: sensor.floor_sensor
        tooltip: Change map to Bathroom
        order: 2
      - label: Change map
        icon: mdi:balcony
        internal_variable: balcony_label
        tooltip: Change map to Balcony
        order: 3
        tap_action:
          action: call-service
          service: script.change_vacuum_map
          service_data:
            map_id: 2
    icons:
      - icon: mdi:shower
        icon_id: bathroom_map
        tap_action:
          action: call-service
          service: script.change_vacuum_map
          service_data:
            map_id: 1
      - icon: mdi:balcony
        icon_id: balcony_map
        tap_action:
          action: call-service
          service: script.change_vacuum_map
          service_data:
            map_id: 2
    map_modes:
      - template: vacuum_clean_segment
        predefined_selections:
          - id: '16'
            icon:
              name: mdi:sleep
              x: 31825
              'y': 23175
            label:
              text: Master Bedroom
              x: 31825
              'y': 23175
              offset_y: 35
            outline:
              - - 30050
                - 21500
              - - 33600
                - 21500
              - - 33600
                - 24850
              - - 30050
                - 24850
          - id: '17'
            icon:
              name: mdi:food
              x: 27700
              'y': 26475
            label:
              text: Kitchen
              x: 27700
              'y': 26275
              offset_y: 35
            outline:
              - - 24913
                - 25090
              - - 28150
                - 25090
              - - 28150
                - 24750
              - - 27800
                - 24750
              - - 27800
                - 23450
              - - 30050
                - 23450
              - - 30050
                - 23870
              - - 30050
                - 29400
              - - 24900
                - 29400
          - id: '18'
            icon:
              name: mdi:broom
              x: 26275
              'y': 23000
            label:
              text: Bedroom
              x: 26275
              'y': 23000
              offset_y: 35
            outline:
              - - 24800
                - 21850
              - - 27750
                - 21850
              - - 27750
                - 24750
              - - 24800
                - 24750
          - id: '20'
            icon:
              name: mdi:broom
              x: 32900
              'y': 25875
            label:
              text: Living Room
              x: 32900
              'y': 25875
              offset_y: 35
            outline:
              - - 30200
                - 24850
              - - 35600
                - 24850
              - - 35600
                - 29150
              - - 30200
                - 29150
      - template: vacuum_clean_zone
      - template: vacuum_goto
    map_locked: true
    two_finger_pan: true
    additional_presets:
      - preset_name: Bathroom
        map_source:
          camera: camera.abuelita
        calibration_source:
          camera: true
        entity: vacuum.abuelita
        vacuum_platform: default
        conditions:
          - entity: sensor.floor_sensor
            value: bath
        append_icons: true
        icons:
          - icon: mdi:home
            tap_action:
              action: call-service
              service: script.change_vacuum_map
              service_data:
                map_id: 0
          - icon: mdi:balcony
            tap_action:
              action: call-service
              service: script.change_vacuum_map
              service_data:
                map_id: 2
        map_modes:
          - template: vacuum_clean_segment
            predefined_selections:
              - id: '16'
                icon:
                  name: mdi:shower
                  x: 25775
                  'y': 25475
                label:
                  text: Bathroom
                  x: 25775
                  'y': 25475
                  offset_y: 35
                outline:
                  - - 24850
                    - 24450
                  - - 26750
                    - 24450
                  - - 26750
                    - 26450
                  - - 24850
                    - 26450
          - template: vacuum_clean_zone
          - template: vacuum_goto
      - preset_name: Balcony
        map_source:
          camera: camera.abuelita
        calibration_source:
          camera: true
        entity: vacuum.abuelita
        vacuum_platform: default
        append_icons: true
        icons:
          - icon: mdi:home
            tap_action:
              action: call-service
              service: script.change_vacuum_map
              service_data:
                map_id: 0
          - icon: mdi:shower
            tap_action:
              action: call-service
              service: script.change_vacuum_map
              service_data:
                map_id: 1
        conditions:
          - entity: sensor.floor_sensor
            value: balcony
        map_modes:
          - template: vacuum_clean_segment
            predefined_selections:
              - id: '16'
                icon:
                  name: mdi:balcony
                  x: 25250
                  'y': 25875
                label:
                  text: Balcony
                  x: 25250
                  'y': 25875
                  offset_y: 35
                outline:
                  - - 23450
                    - 25200
                  - - 27100
                    - 25200
                  - - 27100
                    - 26500
                  - - 23450
                    - 26500
          - template: vacuum_clean_zone
          - template: vacuum_goto

Javascript errors shown in the browser's console (if applicable)

No response

Additional information

No response

Well, unfortunately you are correct. I broke this functionality in the last refactoring, thank you for reporting it.

You can use the following workaround until this issue is fixed:

tiles:
  - label: Change map
    icon: mdi:shower
    entity: script.change_vacuum_map
    tooltip: Change map to Bathroom
    order: 4
    translations:
      "off": Bathroom
      "on": Bathroom
    tap_action:
      action: call-service
      service: script.change_vacuum_map
      service_data:
        map_id: 1