Skip to content

Conversation

@johnmph
Copy link
Contributor

@johnmph johnmph commented Aug 29, 2025

Added the card_set service which can be used like that :

startup_action:                                  <- Here it is called at startup but you can call the service on a normal tap_action or other actions
  - action: call-service
     service: floorplan.card_set                 <- The new service
     service_data:
       container_id: CardContainer               <- The ID of the foreignObject tag inside your SVG
       config:                                   <- If you put this, you will set a card inside foreignObject tag, if you don't, you remove any card that may be in foreignObject
         type: map                               <- The type of the card you want to set (mandatory)
         entities:                               <- All that follows is the config for the card (here the config for the map card)
            - zone.home
          aspect_ratio: "2"

service_data:
  - container_id: CardContainer                  <- You can also set multiple cards at once by using array
     config:
       type: map
       entities:
         - zone.home
       aspect_ratio: "2"
  - container_id: CardContainer2
     config:
       type: weather-forecast
       entity: weather.forecast_maison
       forecast_type: daily

Example of a foreignObject tag inside a SVG file :

<foreignObject id="CardContainer" x="996" y="920" width="484" height="242"></foreignObject>

Why this feature ?

Of course, you can add a card normally and use CSS to move card above the SVG but there are at least two caveats :

  • The relative position is hard to keep correct when resizing
  • In case of a floorplan used as a main card inside a custom ha-dashboard, you can have only one card

@exetico
Copy link
Member

exetico commented Sep 1, 2025

Thank you for the effort! 😀

I need to find a bit of time, in order to review it, but I noticed a few things, and also have a few requirements. Maybe I've checked it too fast, but I'll share it.

  • Why are config set with ?, but also used in a spread operation in the code
  • I spotted a todo in the code: Is that necessary?
  • All features needs to be well documented, in order to be merged. We have a history, where the documentation didn't cover all features.
  • Are you able to introduce tests in order to test your functionality?
  • What HA function did you test this in, and with what cards? Have you personally seen it break, with specific cards?
  • Does it handle multiple floorplans, without messing things up?
  • Have you tested whether ha-floorplan loosen up the memory footprint, while browsing around, and not spawning cards, over and over again, on state change, or similar?

Let me know what you think. I'd appreciate the input aren't processed by a random LLM agent 👍😁.

@johnmph
Copy link
Contributor Author

johnmph commented Sep 2, 2025 via email

@johnmph
Copy link
Contributor Author

johnmph commented Sep 3, 2025

Just added doc and test ;)

@exetico exetico merged commit 7f3d9d3 into ExperienceLovelace:master Sep 14, 2025
3 checks passed
@exetico
Copy link
Member

exetico commented Sep 14, 2025

Thank you for adding this. I'll need to test a few things, but expect it to get part of a pre-release in near future.

@OzGav If you have time, it would be helpful to have the following build tested:
https://github.com/ExperienceLovelace/ha-floorplan/actions/runs/17712110372/artifacts/4006502583

You only need to overwrite the floorplan.js file in your setup. But pay attention to caching, as always 😄!

@johnmph
Copy link
Contributor Author

johnmph commented Sep 14, 2025

Thank you very much

@OzGav
Copy link
Contributor

OzGav commented Sep 16, 2025

@exetico I don't see anything obviously adverse... All is working fine for me.

@exetico
Copy link
Member

exetico commented Sep 26, 2025

Thank you for testing, @OzGav .

@exetico
Copy link
Member

exetico commented Sep 26, 2025

Released as part of https://github.com/ExperienceLovelace/ha-floorplan/releases/tag/v1.1.4

@johnmph: Thank you, for your contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants