From 74a05a9dcefe300a9551a4308254c41456a3afd1 Mon Sep 17 00:00:00 2001 From: Alex McLain Date: Tue, 19 Aug 2025 21:43:05 -0700 Subject: [PATCH] Update readme with device shadow desired to reported transformation --- README.md | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 32f4646..8518de7 100644 --- a/README.md +++ b/README.md @@ -254,17 +254,26 @@ The new, unknown fields will be filtered out of `message` during the validation Using `meta`, the unknown fields can be selected with a filter, and they can be merged into the `reported` map to send to the shadow. ```elixir -reported = %{ - # Real data to report to the shadow ... +shadow = %{ + state: %{ + reported: %{ + # Real data to report to the shadow ... + } + } } meta |> Attribute.list |> Enum.filter(fn - {_path, :unknown, _value} -> true + # Only capture the device shadow state, not the metadata. + {["state" | _rest], :unknown, _value} -> true {_path, _status, _value} -> false end) -|> Attribute.merge(reported) +|> Enum.map(fn + {["state" | rest], status, value} -> + {["state", "reported"] ++ rest, status, value} +) +|> Attribute.merge(shadow) ``` ### Fields as actions