Floorplan visible, but no matter what I try it does not UPDATE ANY SVG ELEMENT

Hello everyone,

in the last few days I spent a few hours trying to make my floorplan work in HA, but failed … even with the help of GPT and Gemini. So I need the help of real humans, not AI in this :smiley:

I installed floorplan from HACS, in my browser console when I load my floorplan dashboard I see it loads:

Floorplan for Home Assistant (ha-floorplan)
Version 1.1.3
floorplan.js?hacstag=188323494114:54

The svg floorplan is disaplyed in my dashboard, I also added just for testing a small card to display my grid voltage, under the floorplan, just to see an value that updates every few seconds, so I know HA works, and it updates that value every few seconds, but in the svg floorplan I’m not able to make any update, the only way I can push an update in my floorplan svg is if I run some commands in console

In the svg I made in Inkskape and also checked in Notepad++ have an text element with this ID and a few rect elements with a different ID:

  • a blue one that act’s as a background for the temperature text when HVAC_state is COOLING
  • an orange one when the state is HEATING
  • and an IDLE gray background
<rect
       style="opacity:0;fill:#4f5963;fill-opacity:1;stroke:none;stroke-width:0.0323243;stroke-dasharray:none;stroke-opacity:1"
       id="temperature-kitchen-background-idle"
       width="36.77013"
       height="16.953259"
       x="54.706646"
       y="100.7277"
       rx="1.1891836"
       ry="1.4058295" /><rect
       style="display:inline;opacity:0;fill:#ed8a12;fill-opacity:1;stroke:none;stroke-width:0.0323243;stroke-dasharray:none;stroke-opacity:1"
       id="temperature-kitchen-background-heating"
       width="36.77013"
       height="16.953259"
       x="54.70665"
       y="100.7277"
       rx="1.1891836"
       ry="1.4058295" /><rect
       style="display:inline;opacity:0;fill:#12a5ed;fill-opacity:0;stroke:none;stroke-width:0.0323243;stroke-dasharray:none;stroke-opacity:1"
       id="temperature-kitchen-background-cooling"
       width="36.77013"
       height="16.953259"
       x="54.70665"
       y="100.7277"
       rx="1.1891836"
       ry="1.4058295" />

First I tried to use display:none in original svg, for each background and from YAML we wanted to set display:block when the state changes. It didn’t work, the last try was to ditch the display:none and use opacity to 0 by default, and change that to 1 in YAML when the state changes.

My YAML for the floorplan is this bellow … there ware so many versions but it doesn’t matter, the root problem is probably the fact that I get this undefined element in the source code

Here are the first few lines in my dashboard source code when I use Inspect element on the svg file displayed in my dashboard page:

<floorplan-card><template shadowrootmode="open"><!---->
      <ha-card class="type-custom-floorplan-card"><template shadowrootmode="open"><!----> <!--?lit$560518135$--> <slot></slot> </template>
        <!--?lit$478753728295$-->

        <div class="content" style="dummy:;">
          <floorplan-element data-floorplan-ref="element-undefined"><template shadowrootmode="open"><!---->
      <div id="floorplan-container">
        <div id="floorplan"><svg width="100%" height="100%" viewBox="0 0 386.46384 357.58038" version="1.1" id="svg5" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="height: 100%; width: 100%; margin: auto; cursor: default; opacity: 1; display: block;">
   <script>console.log("SVG DOM Loaded");</script>
   <defs id="defs2">

In console log I donțt see any log message inserted in the SVG (as you can see above) or in the YAML code as you can see bellow, no other messages are logged in the console except the ones with all the cards loaded by HA.

But manual DOM manipulation via the console works (the IDs in my SVG are correct).

The card is rendering the SVG but data-floorplan-ref is staying undefined.

The YAML I use now … showing the SVG but not updating any value in the temperature text or the background of that temperature text, none update when I change the state of my thermostat from heating to idle to heating or cooling…

type: custom:floorplan-card
config:
  image: /local/floorplan/binder-penthouse-plan-v1.8.svg?v=1.8
  full_update: true
  on_ready:
    - service: floorplan.execute
      service_data:
        code: |
          console.log("--- FLOORPLAN INITIALIZED AND READY ---");
  rules:
    - name: Kitchen Master Control
      entities:
        - climate.kitchen_thermostat
      element: temperature-kitchen
      state_action:
        action: call-service
        service: floorplan.execute
        service_data:
          code: >
            console.log("--- STATE CHANGE DETECTED ---");

            const entityObj = entity; // Provided by floorplan

            const action = entityObj.attributes.hvac_action || 'idle';

            const currentTemp = entityObj.attributes.current_temperature ||
            '--';


            console.log(`Action: ${action}, Temp: ${currentTemp}`);


            // 1. Update Temperature Text

            floorplan.text_set('temperature-kitchen', currentTemp + '°');


            // 2. Logic for background elements

            const bgMapping = {
              'heating': 'temperature-kitchen-background-heating',
              'cooling': 'temperature-kitchen-background-cooling',
              'idle': 'temperature-kitchen-background-idle'
            };


            Object.entries(bgMapping).forEach(([key, elementId]) => {
              const targetOpacity = (action === key) ? 1 : 0;
              // Use direct style_set
              floorplan.style_set(elementId, `opacity: ${targetOpacity}; display: inline !important;`);
            });
      tap_action:
        action: more-info

Anyone around that can point me in the right direction ? WHy that undefined element is shown there ? Probably that is the reason everything I tried in YAML doesn’t work.

Thank you in advance :slight_smile:

Why are you using floorplan_execute?

I have tried many more versions, the one above is one of the last ones that used the service floorplan_execute, but the code bellow is an previously used YAML that still didn’t update any value or activate the background of that temperature

type: custom:floorplan-card
column_span: 4
config:
  image: /local/floorplan/binder-penthouse-plan-v1.3.svg
  rules:

    # 🔹 Temperature text (updates whenever climate updates)
    - name: Kitchen temperature text
      entity: climate.kitchen_thermostat
      element: temperature-kitchen
      state_action:
        action: call-service
        service: floorplan.text_set
        service_data:
          element: temperature-kitchen
          text: "${entity.attributes.current_temperature}°"

    # 🔥 Heating background
    - name: Kitchen heating background
      entity: climate.kitchen_thermostat
      state_action:
        action: call-service
        service: floorplan.style_set
        service_data:
          element: temperature-kitchen-background-heating
          style: |
            display: ${
              entity.attributes.hvac_action === 'heating'
                ? 'block'
                : 'none'
            }

    # ⚪ Idle background
    - name: Kitchen idle background
      entity: climate.kitchen_thermostat
      state_action:
        action: call-service
        service: floorplan.style_set
        service_data:
          element: temperature-kitchen-background-idle
          style: |
            display: ${
              entity.attributes.hvac_action === 'idle'
                ? 'block'
                : 'none'
            }

With the code above I still get this undefined in my sourcecode:

<floorplan-card><template shadowrootmode="open"><!---->
      <ha-card class="type-custom-floorplan-card"><template shadowrootmode="open"><!----> <!--?lit$100868196$--> <slot></slot> </template>
        <!--?lit$916371716$-->

        <div class="content" style="dummy:;">
          <floorplan-element data-floorplan-ref="element-undefined"><template shadowrootmode="open"><!---->
      <div id="floorplan-container">
        <div id="floorplan"><svg width="100%" height="100%" viewBox="0 0 386.46384 357.58038" version="1.1" id="svg5" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="height: 100%; width: 100%; margin: auto; cursor: default; opacity: 1; display: block;"><defs id="defs2"><filter style="color-interpolation-filters:sRGB" id="filter25" x="-0.020720643" y="-0.02259915" width="1.0529528" height="1.0577534"><feFlood result="flood" in="SourceGraphic" flood-opacity="0.498039" flood-color="rgb(0,0,0)" id="feFlood24"></feFlood><feGaussianBlur result="blur" in="SourceGraphic" stdDeviation="3.000000" id="feGaussianBlur24"></feGaussianBlur><feOffset result="offset" in="blur" dx="4.000000" dy="4.000000" id="feOffset24"></feOffset><feComposite result="comp1" operator="in" in="flood" in2="offset" id="feComposite24"></feComposite><feComposite result="comp2" operator="atop" in="comp1" in2="comp1" id="feComposite25"></feComposite></filter>

Even with an much simpler YAML like this bellow I still get the undefined element in source code

type: custom:floorplan-card
column_span: 4
config:
  image: /local/floorplan/binder-penthouse-plan-v1.5.svg

Here is the rendered source code with the undefinied element, the svg is visible in the dashboard

<floorplan-card><template shadowrootmode="open"><!---->
      <ha-card class="type-custom-floorplan-card"><template shadowrootmode="open"><!----> <!--?lit$041889632$--> <slot></slot> </template>
        <!--?lit$438558931$-->

        <div class="content" style="dummy:;">
          <floorplan-element data-floorplan-ref="element-undefined"><template shadowrootmode="open"><!---->
      <div id="floorplan-container">
        <div id="floorplan"><svg width="100%" height="100%" viewBox="0 0 386.46384 357.58038" version="1.1" id="svg5" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="height: 100%; width: 100%; margin: auto; cursor: default; opacity: 1; display: block;"><defs id="defs2"><filter style="color-interpolation-filters:sRGB" id="filter25" x="-0.020720643" y="-0.02259915" width="1.0529528" height="1.0577534"><feFlood result="flood" in="SourceGraphic" flood-opacity="0.498039" flood-color="rgb(0,0,0)" id="feFlood24"></feFlood><feGaussianBlur result="blur" in="SourceGraphic" stdDeviation="3.000000" id="feGaussianBlur24"></feGaussianBlur><feOffset result="offset" in="blur" dx="4.000000" dy="4.000000" id="feOffset24"></feOffset><feComposite result="comp1" operator="in" in="flood" in2="offset" id="feComposite24"></feComposite><feComposite result="comp2" operator="atop" in="comp1" in2="comp1" id="feComposite25"></feComposite></filter>

I don;t know if this helps, but while trying to find a sollution using Gemini I tried to run this in my console log to see if the element is findable in DOM (I could see it in the rendered source code, but it wasn’t “visible” for scripts)

const fpCard = document.querySelector('floorplan-card');

undefined

I got Undefined result, than I run this code in console to search for that element recursively:

function findElementRecursive(root, selector) {
  const n = root.querySelector(selector);
  if (n) return n;
  const shadowRoots = [...root.querySelectorAll('*')].filter(e => e.shadowRoot);
  for (const sr of shadowRoots) {
    const found = findElementRecursive(sr.shadowRoot, selector);
    if (found) return found;
  }
  return null;
}

// Now find your card and drill into the floorplan
const fpCard = findElementRecursive(document, 'floorplan-card');
const svg = fpCard.shadowRoot.querySelector('floorplan-element').shadowRoot.querySelector('#floorplan svg');

// Test update
svg.querySelector('#temperature-kitchen').textContent = "99°";

And I got an good result in console: “99°”

And also the svg file displayed in my dashboard was updated, now I can see 99° in the temperature element with ID temperature-kitchen

Thank you for your quick reply

Are full_update: and on_ready: even valid config options? I can’t find it in the docs and I’ve never seen that anywhere else.

Yeah are these AI hallucinations? That is crazy complex for just trying to get some text on the floorplan…

Regardless have you watched the videos? Quick Start - Floorplan for Home Assistant

Also you dont pass the element in the service_data. Home Example - Floorplan for Home Assistant

Additionally to what OzGav said…

Are you clearing your image cache when you change the YAML config? That’s kind of critical.

The <floorplan-element data-floorplan-ref="element-undefined"> is normal.

Whenever I update anything in my SVG file I save it with a new name, this is how I reached to this name

image: /local/floorplan/binder-penthouse-plan-v1.8.svg

I always reload using CTRL+SHIFT+R or CTRL+F5 just to be sure.

Regarding @OzGav link with that example, ofcorse I have seen them but I don’t wanted to have many svg images for each light in my house.

I just want to hide and show those elements in my initial svg. Is this not possible ?

I wanted to display/hide elements in my svg (using either class name, or style opacity) that I use as backgrounds with icons for my temperature/humidity texts. Is it possible?

Also can I inject text in my svg using text ID … I have tried this but failed

rules:
  - name: Kitchen Temperature
    entities:
      - climate.kitchen_thermostat
    element: temperature-kitchen
    state_action:
      action: call-service
      service: floorplan.text_set
      service_data:
        text: "${entity.attributes.current_temperature}°"

I tried using entity.attributes.temperature instead of entity.attributes.current_temperature as the temperature is a value I can change easily when moving the thermostat temperature in my main dashboard, but no matter what I tried I haven’t seen an update in my svg … this is how I reached Gemini and complex code

Thank you again for your help.

PS: This is how I created my SVG in Inkskape, using multiple background colors for each rect, each color representing an hvac_action cooling - heating - idle - fan

Yes you can apply CSS to an element, Just start with one simple thing and work on that.
Remove all the AI slop.
Add the log_level key Usage - Floorplan for Home Assistant
Your text_set code should work. In my experience issues are from trying to modify something that isn’t a text object. Also using Inkscape, select the object then TEXT >> UNFLOW can also help

I tried to add log level but it did not show anything :frowning: , and I’m showing you again an simple code, not AI generated, that should just add the temperature in that svg element, I made a video maybe you can spot what might be wrong if you see my workflow

Here is the YAML, no AI bloat just a few lines of code but I can’t figure out what I’m doing wrong:

type: custom:layout-card
layout_type: grid
max_columns: 4
cards:
  - type: custom:floorplan-card
    column_span: 4
    console_log_level: debug
    log_level: debug
    config:
      image: /local/floorplan/binder-penthouse-plan-v1.5.svg
      rules:
        - name: Kitchen temperature text
          entity: climate.kitchen_thermostat
          element: temperature-kitchen
          state_action:
            action: call-service
            service: floorplan.text_set
            service_data:
              text: ${entity.attributes.temperature}°
grid_options:
  columns: 36
  rows: auto

UPDATE: In the video I haven’t removed the element inside the service_data but in reality, in my actual code, I don’t have that line of code, is exactly like in the code section above, not like in the video.

Your text_set code should work. In my experience issues are from trying to modify something that isn’t a text object.

The element I’m trying to modify is indeed an text element, here is the code, if it helps I could upload the entire svg … I have no problem with that, I made it line by line in inkscape, and cleaned a few tags in notepad++

<text
       xml:space="preserve"
       style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.264583"
       x="70.101418"
       y="113.29118"
       id="temperature-kitchen">__°</text>

I haven’t tried the UNFLOW trick but I will try it now.

Again, I’m just trying to make simple things but it seems not a single basic update in my svg works, nor I could see anything in my logs/console, this is why I looked for help even in the AI tools.

The code initially was basic… and it did not work

Thanks. Any more help, I’m here to try anything

In so far as I know Climate entities do not provide an actual temperature, and they have no attribute named either temperature or current_temperature… you’re trying to display something that doesn’t exist. You need to use the sensor that’s actually providing the temperature to display it.

rules:
  - name: Kitchen Temperature
    entities:
      - sensor.your_kitchen_temperature_sensor # this
    element: temperature-kitchen
    state_action:
      action: call-service
      service: floorplan.text_set
      service_data:
        text: "${entity.state}°" # is the entity this refers to

I used templates to list my climate entities, bellow you can see the details, it has both temperature and current_temperature entities … but I spoted something that I was doing wrong, the name of the kitchen climate has an “_2” at the end and I missed that :sob: ohhh … and I lost so many hours because of this stupid mistake :rage:
All other rooms have clean names, it seems for the kitchen I didn’t respected that rule, to have clean simple names.

Entity ID: climate.kitchen_thermostat_2
State: heat
Attributes:
  - hvac_modes: [<HVACMode.HEAT: 'heat'>, <HVACMode.OFF: 'off'>]
  - min_temp: 10.0
  - max_temp: 27.0
  - target_temp_step: 0.1
  - preset_modes: ['none', 'away', 'comfort', 'eco', 'home', 'sleep', 'activity']
  - current_temperature: 17.8
  - temperature: 18.4
  - hvac_action: heating
  - preset_mode: none
  - friendly_name: Kitchen Thermostat
  - supported_features: 401

Now if I changed the climate name I could see instantly the temperature in the svg :smiley:

Thank you guys!

I now move to the next part, changing the opacity of some elements to display the correct background.

FYI your log level key is at the wrong level. It should be under config.

Thank you, I have corrected it now

config:
  console_log_level: debug

This is how my dashboard looks now, any suggestions for the left and right sides of the floor plan, as I want to have some buttons there, outside of the floorplan, just something that I could set a general thermostat (to set the temperature for all rooms) or an ON / OFF for the ventilation system, or some options for ambiental lighting, to turn it on/off for each room … there will be some small buttons on each side and I’m not sure if the correct way or best way is to add an Grid card as I did on both sides? Are there other better options for the side buttons ?

Thank you

Why not use the floorplan for everything?

Well, I don’t know exactly what buttons I will add or what optionsso for now I just wanted to split the screen in 3 sections, if there are elements ready made in HA I don’t want to recreate them in Inkskape just so I can than manipulate via YAML, for example I want to integrate a big clock, but very simple big clock … I haven’t found yet an perfect spot for it … the main problem is that I can’t easily split my screen in 3 sections, one left 10%, center 80% (floorplan) and another one in the right side (10%)

maybe the percents will be different, maybe it will be 15% on the side and smaller in the middle … but I wanted to easily insert any buttons on the sides

Something shows in the UI Editor, but than it looks different when looking at my dashboard on tablet

I’m open to any suggestions :slight_smile: Maybe it’s better to have just 2 columns, one 70% for the floorplan in the rigthside, and one 30% in the left side for the clock and other buttons. is the Grid card best for this ?

LOL, that was my first 4 months of HA experience.

@ovisopa my ha-floorplan big clock

1 Like

These are HA specific questions. I use floorplan for everything.

and how you do the clock in floorplan, do you draw a big text in inkskape so you have an text ID and than inject the text second by second ?

To me it seems I complicate things if I just need to draw everything in inkskape, I include some sample button… I don’t really like the buttons, are to large for my taste but I think it will be simple to modify them via css or use a different card instead o fthe mushroom one

I’m going to sleep as it’s quite late. Thank you again, I made what I wanted so far … tomorrow I will go to that location to test if the window elements in my svg work, I have 6 attic windows and mounted sensors in each one (a little problematic in winter time as the Duracel battery seems to not last very long when the weather is around 0degC), I also made some code so it displays the window as open if the sensor is ON. Later I will add some automation if the rain sensor activates and any of the window is open to send some notification as the rain will pour on the walls if the windows won’t be closed (I’m not that rich to have electric actuated attic windows :smiley: )