Skip to content

feat(devices): integration coverage map + speed-proportional spin animation - #13

Draft
wimpie70 wants to merge 9 commits into
tinkersoder:mainfrom
wimpie70:feat/device-coverage-map
Draft

wimpie70 wants to merge 9 commits into
tinkersoder:mainfrom
wimpie70:feat/device-coverage-map

Conversation

@wimpie70

@wimpie70 wimpie70 commented Nov 7, 2026

Copy link
Copy Markdown

Summary

Resolves #12 (stacked on #11, #9, and #7).

  • coversIntegrations + Integration Coverage Map:
    • Adds DeviceSourceProvider.coversIntegrations?: string[] and getCoveredIntegrations() in src/plugins/registry.ts.
    • Adds a collapsible Integrations (N) coverage map in DevicePanel showing all HA integrations with devices, their device counts, and plugin (green) vs registry badges. Clicking a covered row selects that plugin's source; clicking an uncovered row selects that integration's devices in the HA registry source.
  • Speed-proportional spin animation:
    • Adds 'spin' to StateRule['animation'] and StateRuleEditor.
    • ruleSpinDuration() scales rotation duration inversely with numeric entity state (2.4s at low speed down to 0.55s at 100%) and applies it to the icon <g> so the text label beneath stays stationary.

Test plan

  • tsc --noEmit, vitest run (35 tests including getCoveredIntegrations and ruleSpinDuration)
  • npm run build & npm run build:hacs

Willem added 9 commits November 4, 2026 13:02
window.floorplanStudio.registerPlugin({id, apiVersion, provides}) lets
third-party integrations contribute device sources, toolbar actions and
style defaults without integration-specific code in this repo:

- deviceSources: live fetch(ws)/offline parse providers shown in the
  generic Devices modal (was the RAMSES modal). The bundled ramses
  source registers through the same public API as the reference impl.
- actions: toolbar items emitting floorplan-studio:action CustomEvents
  ({pluginId, actionId, projectId, floorId, selection}) — documented,
  bubbles+composed so they escape the card shadow root.
- iconMap / markerDefaults / stateRulePresets (role-bound): merged as
  plugin < user opts < device hints; css injected once, re-attached to
  the card's shadow root in HACS mode.
- apiVersion + ignored-unknown-provides-keys for independent versioning.

importProject() merges a project fragment in one undo step and
projects.* (active/list/get/save/remove/open) replace the direct
IndexedDB pokes integrations needed before. callWS() exposes the active
HA link; documented events: action / project-imported / plugins-changed.

Also: registry fallback now reads parent_device_id alongside via_device
(HA 2026.9 child devices), and devices carry suggested=false for
gateways instead of a hardcoded group check in the planner.
The editor ships zero integration-specific code — the plugin API is
the contract, and integrations own their mapping in their own repo.
Ramses Extras ships its provider as a Lovelace resource from
floorplan_helper (wimpie70/ramses_extras), registered under the same
plugin id so it supersedes nothing and is versioned with the
integration it talks to.

src/examples/mqtt.ts is the new bundled reference implementation:
entity-registry platform filter → device grouping → neutral
ImportDevice shape. It is deliberately generic — change PLATFORM and
it is a zwave/zigbee/ble source.

haimport's WsCall/liveWsCaller imports move to ../ha/wsCaller where
the helper actually lives (fetch.ts only re-exported it).
Flat per-action toolbar buttons do not scale once several
integrations register — one "Integrations" dropdown now lists every
toolbar-located plugin action grouped by plugin id. The location
contract stays: 'toolbar' renders here, 'marker-menu'/'room-menu'
remain reserved for contextual menus.
The example source now reads the device + entity registries — every
HA instance has devices, so the reference implementation always has
something to show, even where mqtt/zwave/etc. aren't configured.
Devices are grouped by integration (entity platform), which doubles
as the foundation for a "coverage map" showing which integrations
have registered providers.
The device import moves from a modal wizard into the editor's
"things to place" palette, as a tab next to Entities and Layers:

- Devices tab: source picker + refresh (auto-fetches on open), a
  checklist with inline placement badges (room name / staged / on
  plan), select-by-group buttons, a collapsed Options details, and
  one "Place N markers" commit. Paste / file / project merge stays
  in the modal, reachable via "More…".
- "Import card" leaves the toolbar for the Projects modal as
  "New from HA card…" — it produces a project, so it belongs with
  project lifecycle next to New / Import JSON.
- New store field leftTab tracks the active palette section.

The Devices toolbar button remains as a shortcut that selects the
Devices tab.
Preview now behaves like an exported card: tap, hold (500ms) and
double (cancels the pending tap) fire the marker's actions — toggle,
more-info (hass-more-info event), call-service with YAML-parsed
serviceData, navigate (location-changed), url. Service calls resolve
to the hass object in card mode or HaClient standalone; with no HA
link they log instead of silently dropping.
…eometry

Adds `provides.roomSources` (`RoomSourceProvider`) to the plugin manifest API:
integrations return floor/room polygons only (`{ floors: [{ name, canvas, rooms }] }`),
while Floorplan Studio owns room merging (`planRoomSourceMerge` / `applyRoomSourceMerge`)
and runs its single client-side marker placement planner (`planDeviceImport`) over the
merged geometry.

In `DevicePanel`, when the active plugin offers a `roomSource`, an
"Also import rooms from source" checkbox previews device room-match badges
against the incoming rooms and commits both new rooms and markers in a
single undo step.
…mation

- `DeviceSourceProvider.coversIntegrations?: string[]` + `getCoveredIntegrations()`
  in the plugin registry map HA integration domains to registered rich
  device providers.
- `DevicePanel` includes a collapsible `Integrations (N)` coverage map
  listing every HA integration owning devices with its device count and a
  `plugin` (green) vs `registry` badge. Clicking a covered row switches to
  that plugin's source; clicking an uncovered row switches to the HA
  registry source and selects that integration's devices.
- Adds `spin` to `StateRule.animation`: `ruleSpinDuration()` scales the
  icon rotation period inversely with numeric entity state (e.g. fan speed
  percentage 0..100 -> 2.4s..0.55s) without rotating the marker's label.
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.

feat(devices): Integration coverage map in Devices palette + speed-proportional spin animation

1 participant