Parses Shelly device status payloads into a flat status map — one parser for every transport (legacy v1 API, v2 API, OAuth account API, websocket events) and every hardware shape:
- Gen2/3/4 RPC components, per channel, in resolution order:
switch:N(relays, with or without power metering — Plus 1PM meters, Shelly 1 Gen4 and Pro 3 don't),cover:N(roller shutters),light:N(dimmers),pm1:N(metering-only PM Mini),em1:N/em:0(Pro 3EM class energy meters — measure, can't switch). - Gen1 arrays:
relays/meters(Watt-minute counters!),lights,rollers,emeters.
Besides the live values, the parse reports what it found:
:component ("switch", "cover", "light", "pm", "em", "relay", …,
"unknown") and :metered (the payload actually carries a power
measurement — a 0 W reading from an unmetered relay is not data).
has_component?/2 guards partial payloads: websocket events may
carry only the piece that changed (sys, an input), and parsing
those as a full status would wrongly report the device off.
Summary
Functions
Which component the payload carries for this channel ("switch",
"cover", "light", "pm", "em", "relay", "flood", "smoke", "presence",
"sensor") or nil when none — use it to guard event deltas against a
device's known component before applying parse/4.
Normalize the v2 API's gen strings ("G1".."G4") to integers.
Does this payload carry actual data for the device's channel?
Partial payloads (websocket deltas with only sys or an input
update) must be skipped, not parsed into a false "off".
Parse a device_status map for one channel. online is supplied by the
caller (it lives outside device_status in every transport). extra
merges transport-level fields (model/gen) over the parsed defaults.
Functions
Which component the payload carries for this channel ("switch",
"cover", "light", "pm", "em", "relay", "flood", "smoke", "presence",
"sensor") or nil when none — use it to guard event deltas against a
device's known component before applying parse/4.
Normalize the v2 API's gen strings ("G1".."G4") to integers.
Does this payload carry actual data for the device's channel?
Partial payloads (websocket deltas with only sys or an input
update) must be skipped, not parsed into a false "off".
Parse a device_status map for one channel. online is supplied by the
caller (it lives outside device_status in every transport). extra
merges transport-level fields (model/gen) over the parsed defaults.