Skip to content

@mega-yfue/eufy-sdk / EventMapping

Interface: EventMapping ​

A declarative inbound-event mapping — the dual of DetectionSpec for events. A capability lists which push eventTypes / poll paramTypes belong to it and the semantic event name each emits. The barrel folds all modules' mappings into one lookup index (built once), so dispatch is a direct id→event lookup — no per-module decode code for the common case.

Properties ​

claim? ​

ts
claim?: EventClaim;

Evidence that this device deals in the classification the id names, for an id whose presence in the wire vocabulary does not prove it.

The AI-detection ids are shared verbatim across the camera families, so the id space says what an integer MEANS and never which units classify that way. A claim is how a mapping states the evidence that separates them, and it narrows the DESCRIPTION only: EventMapping stays in the dispatch index unclaimed, so a device that sends the push still gets the event. Under-reporting what a device is expected to emit is recoverable; dropping an event it did emit is not.

Every field must hold — the AND to DetectionSpec's OR, because a claim rules a family OUT rather than finding one more reason to say yes. A fact the context does not carry rules nothing out: only evidence that positively contradicts the claim withdraws the event.


emit ​

ts
emit: string;

The semantic SDK event name to emit (e.g. "motion", "doorbellPress", "lockState").


match ​

ts
match: number | [number, number];

An exact id, or an inclusive [lo, hi] range (e.g. lock push events 257..771).


payload? ​

ts
payload?: Record<string, unknown>;

Static fields folded into the emitted event payload — lets several ids emit the same event name with a discriminator (e.g. battery pushes 6/7/11 all → batteryAlert with {state:"low"|"hot"|"full"}). Merged OVER the signal's own fields, so a raw wire key can't overwrite a discriminator.


source ​

ts
source: "push" | "poll";

Which source this id comes from. (p2p-frame decoding uses CapabilityModule.decodeEvent.)

Methods ​

derive()? ​

ts
derive?(signal): Record<string, unknown>;

Fields DERIVED from the signal — for state a push carries under an opaque single-letter wire key. Merged last, over both the raw body and payload.

Same evidence bar as everything else: only map a key whose meaning is confirmed in the V6 app or a capture. Return {} when this signal doesn't carry the field, so nothing is invented.

Parameters ​

signal ​

InboundSignal

Returns ​

Record<string, unknown>

Independent and unofficial. Not affiliated with, endorsed by, or sponsored by Anker Innovations, Anker eufy, or eufy. "Anker eufy", "eufy" and "Anker" are trademarks of their respective owners. Use responsibly — rapid or failed logins can trigger captcha or temporary cooldowns.