Live PV data comes from the Hare module of Canopy. Set
VITE_CANOPY_API_BASE_URL (default http://localhost:8050) and VITE_CANOPY_API_KEY (default
dev, sent as X-API-Key). The key ends up in the browser, so only use a read-only key. In the cluster it comes from a
Secret instead.
The Canopy code in src/api/canopy/ follows the same three-layer pattern as the
lume-model-api code: getPv/describePv, hareKeys/hareQueries, and the hooks in
src/hooks/useHare.ts. Errors are thrown as the same LumeApiError.
const { data: meta } = usePvMeta('TEST:SINE'); // units, precision, limits, enum labels
const { data: pv } = usePv('TEST:SINE', { refetchInterval: 1000 }); // value, severity, tsNs
For values that update continuously, use the stream instead of polling usePv. Hare sends each
PV’s value and metadata once it connects, then batches changes every 100 ms.
src/api/canopy/stream.ts: hareStream(pvNames) is a shared subscription over one WebSocket
(/hare/v1/ws/pvs).
subscribe message.src/hooks/useHare.ts: usePvStream(pv) for one PV, and useHareStream(pvNames) for several.const { status, value, meta, rejected, backend } = usePvStream('TEST:SINE');
const { pvs } = useHareStream(['TEST:SINE', 'TEST:WF']); // pvs['TEST:WF'].value?.value
status takes the same values as useLiveStream’s (idle, connecting, open,
reconnecting, closed), and both return reconnect().
value is the latest PVValue and meta is its PVMeta. meta can
arrive after the first value, and a PV that doesn’t connect within about 2 s first arrives with
connected: false.rejected is set when Hare refuses a PV name. The PV’s other fields stay
empty and the rest of the list subscribes normally.?api_key=. They also report a refused key as a plain dropped connection. When a connection
fails to open, the hook checks the key with GET /hare/v1/health/summary. On a 401 or 403 it
sets status to closed with that LumeApiError instead of retrying.backend comes from the heartbeat and is simulation or epics. Use it to warn
when the data is simulated.