Skip to content

feat/import .svg files ? #4

Open

Description

@wimpie70

Your project looks very promising. Are you planning to add an import function to it ?

I'm investigating if this is a nice tool to be used with Ramses RF or more particular Ramses Extras (Extension on RF).

Activity

  1. tinkersoder commented on Oct 24, 2026

    @tinkersoder
    Owner

    Thanks for the feedback! Importing the external .svgs is currently work in progress. They can vary quite a bit so it's a bit tricky.
    Hopefully will get the next version out in upcoming week or two,

  2. tinkersoder commented on Nov 3, 2026

    @tinkersoder
    Owner

    Follow-up: opened #6 with both import paths.

    • RAMSES model: pulls RAMSES-II/evohome devices straight from Ramses Extras' get_topology (or the HA registries as fallback) and drops them as markers in the right room, with class icons, colours, and states
    • Import card model: imports a custom:floorplan-card or picture-elements card already running in your HA, including Ramses Extras-generated SVGs, pulling the markers/rooms/background back into an editable Studio project

    Would be great if you could try it against your Ramses Extras setup once it's merged/released — curious how it holds up on a real topology.

  3. wimpie70 commented on Nov 3, 2026

    @wimpie70
    Author

    Oh, this is more than I expected and had me thinking about the architecture and maintainability of this. I'll suggest to take this in a different direction, but let me first explain where I'm at currently with the Ramses projects and my roles:

    • Ramses rf (contributor) low lvl communications with the Ramses radio protocol, etc.
    • Ramses cc (contributor) HA integration exposing devices and entities that can be used for card, automations etc.
    • Ramses extras (maintainer) extension on Ramses RF repo's with extra features like cards, automations etc. including the floorplan helpers i'm currently working on.

    I noticed you work with Claude a lot. I use different models myself (claude, chatgtp, swe, gemini...depends what suits). If you plan to accept and merge any of my (possible) PR's, I'm sure claude will be able to review it properly to make sure it fits your goals.

    Since Floorplan editors/studios are quite a recent dev area (at least on HA) I am still betting on different horses. I don't know what editor will suit our Ramses purposes best. It depends on progress, features, adaptability, how likely is it going to be used by our users (Ramses) and how likely is it that it still is maintained in a few years from now...
    I actually started with plain floorplanner, then your studio, and also came across https://github.com/vespassassina/ha-floorplan-studio and maybe some other may show up.

    Now the technical part, since I actually tested your branch (built feat/ramses-import locally, ran it as a card on our dev instance against a real ramses_extras topology — 53 devices, messy orphans and all — and it works: room placement by area, staging row, state rules, the lot). A few notes:

    • the HA area is dropped after placement; showing 'in room X' in the marker inspector (you already have pointInPolygon) or keeping area_id on the marker would make the linkage visible and enable room→area sync later.
    • parent is in the payload and you parse it, but it's dropped before the marker — the plan has entity-bound icons, no topology. If you want it, a generic meta/links field on Marker is the smallest schema change; otherwise the listener hook lets integrations derive it live from get_topology without schema changes.
    • One more topology data point: HA 2026.9 introduced real parent/child devices (parent_device_id). ramses_cc already registers zones/DHW as child devices of the controller on ≥2026.9 — but only one level, since HA children can't have children, so TRV-in-zone stays flat. Meaning: your importer needs to read via_device and parent_device_id, and even then the full ramses tree (TCS→zone→actuators, FAN→bound devices) only exists in the ramses_rf schema — which is what get_topology exposes. One more reason topology belongs with the provider.

    Your PR splits cleanly in two, and the split point is the interesting part:

    • plan.ts — the placement planner (area→room matching, staging rows, idempotent re-import, single undo) is completely generic. It only sees device_id, area_id, entities[]. This is the valuable bit and it's editor territory.
    • src/ramses/topology.ts + fetch.ts — that's a second copy of our internals: it mirrors our ENTITY_ROLE_PATTERNS, _PRIMARY_DOMAIN_ORDER, icon map, class list and the literal ramses_extras/floorplan_helper/get_topology WS type. Ramses-domain knowledge living outside the ramses repos.

    And the drift is already real — on live data I hit two concrete mismatches:

    1. Your test fixture expects zone sub-devices (01:145038_02, class unknown) in get_topology's devices. We intentionally fold ctl_02/ctl_HW entities onto their physical sensor/actuator — zones only exist in heat_zones (name/sensor/actuators/class), which the importer ignores. Result: no zone markers when Ramses Extras is installed, while your ramses_cc-registry fallback does produce zones (they're real HA sub-devices there). Same modal, different result depending on which repo is installed.
    2. Our device_class: "SEN" hint beats your id-derived class, so 17 TRVs/thermostats imported as generic "Sensor" with a thermometer icon instead of radiator/thermostat. Also APP, HVC, unknown classes it has to guess around.

    That's exactly the maintenance trap: every change on our side (new device class, renamed field, folded entity) silently breaks or misleads your copy, and you'd have to track ramses_rf's device taxonomy forever — for an integration you (perhaps) don't use.

    So here's the proposal — same direction as what I suggested on vespassassina/ha-floorplan-studio#1: keep the editor generic and let integrations register their own providers, menus and defaults. Shape-wise I'd register a manifest, not a class:

    window.floorplanStudio.registerPlugin({
      id: 'ramses',
      apiVersion: 1,
      provides: {
        deviceSources: [
          { id: 'ramses-topology', title: 'RAMSES RF', fetch: (ws) => getTopology(ws) },
        ],
        actions: [
          { id: 'ramses.seed-devices', label: 'Add devices', icon: 'devices', location: 'toolbar' },
          { id: 'ramses.sync-areas', label: 'Sync areas', location: 'room-menu' },
        ],
        iconMap: { FAN: 'fan', TRV: 'radiator', /* … */ },
        markerDefaults: { size: 32, showState: true },
        stateRulePresets: [
          { entityRole: 'battery', match: 'on', color: '#ef4444', animation: 'blink' },
          { entityRole: 'heat_demand', mode: 'gradient', min: 0, max: 100 },
        ],
        css: '/local/ramses_extras/features/floorplan_helper/ramses-floorplan.css',
      },
    });
    • A manifest is data + functions the editor calls at defined points — no foreign code instantiated inside your component, you keep lifecycle control, plugins never get DOM refs.
    • Capability slots cover different kinds of things: device importers (deviceSources — "RAMSES" becomes "Import devices", hidden when none registered), menu/toolbar items (actions → clicks emit a bubbling CustomEvent with {id, floorId, selection}), and pure data contributions like iconMap or wall/door style defaults.
    • On the decoration side: don't give us listeners to patch the DOM after render — give us defaults we can override. iconMap, markerDefaults, stateRulePresets and a css URL, merged as user config > plugin > built-in, covers almost everything our overlay does imperatively today (spinning FAN icons, heat-demand colours, captions). All we'd need besides is stable CSS hooks (custom properties / ::part / data-entity attributes) so our stylesheet overrides your defaults rather than our JS injecting classes into your shadow DOM. Real listeners shrink to interactions only — selection, gestures, menu clicks — three or four documented events.
    • Versioning is one field: unknown provides keys are ignored by older editors, so both sides evolve independently. Z-wave, esphome, knx… can register the same way — that's the big win for you: you maintain the canvas/planner/renderer, integrations own their domain menus. And most of the contract is data you can validate in one place — less API to maintain, not more.

    Two more concrete things this fixes:

    • Right now our actions card literally writes to your IndexedDB projects store — fragile on both sides; an official importProject()/CustomEvent API kills that coupling in both directions.
    • For the fallback path: instead of ramses_cc-filtered registry scanning, make it generic — "import devices by integration" (pick a domain: ramses_cc, zwave_js, hue…). Same feature, zero ramses specifics, useful to everyone.

    Concrete way forward: no need to split or rework your PR — merge it as-is if you want, it works today. Then we create a PR on top that introduces the manifest registries/hooks and moves the ramses-specific half out into a provider, with our integration as the working example (PoC included). The diff itself documents the plugin API for other integrations. If you'd rather split it yourself first, that's fine too — but I'm happy to do the work.

    The neutral data contract is already there btw: your paste path accepts a studio project / floorplan_seed_studio response and merges it — project_json is the boundary. Our service already emits studio-native markers with icons/colours/labels/actions resolved server-side.

    Regards, Willem

  4. tinkersoder commented on Nov 4, 2026

    @tinkersoder
    Owner

    Thanks for actually running it against real hardware, that's exactly the kind of signal a solo side project can't generate on its own, and the two mismatches you found (zone folding, SEN beating id-derived class) are a pretty clean proof of the point you're making.

    Merged #6 as-is. It's live on main now.

    And yes, let's go with the plugin manifest direction. Agreed on the framing: plan.ts (area, room matching, staging, idempotent re-import, undo) is the part worth keeping generic in the editor; everything that has to track ramses_rf's device taxonomy belongs with you, not duplicated here. The registerPlugin() shape you sketched, deviceSources, actions, iconMap/markerDefaults/stateRulePresets, css, versioned via ignored-unknown-keys, looks like the right contract to commit to, including the "editor keeps lifecycle control, no DOM refs handed to plugins" constraint.

    Happy to have you drive the PR, with your ramses provider as the reference implementation, makes sense for the diff to double as the plugin API's documentation. A few things I'd want in that PR (or we can hash out on the PR itself):

    • stable event names/payload shape for the action click CustomEvents, documented once, not implied by one example
    • the importProject()/event-based replacement for the current direct-IndexedDB write, since that's a real bug risk today regardless of the rest
    • enough in CHANGELOG/USER_GUIDE for a second integration author (zwave_js, esphome, whoever) to register without reading your provider's source

    No need to touch the fallback registry-scan path in the same PR unless it's easy, generic "import by integration domain" can follow once the plugin surface settles.

    Go ahead whenever you're ready, I'll review promptly.

    -Joona

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions