diff --git a/lib/ha_handler/ha_proxy.ex b/lib/ha_handler/ha_proxy.ex index c7790b3..efb2b3c 100644 --- a/lib/ha_handler/ha_proxy.ex +++ b/lib/ha_handler/ha_proxy.ex @@ -40,11 +40,12 @@ defmodule HAHandler.HAProxy do case mapping do %{ "id" => id, + "proxyId" => proxy_id, "objType" => type, "field" => %{"name" => name}, "value" => %{"value" => value}, } -> - %{:id => id, :type => type, :field => name, :value => value} + %{:id => id, :proxy_id => proxy_id, :type => type, :field => name, :value => value} _ -> nil end @@ -54,15 +55,16 @@ defmodule HAHandler.HAProxy do extracted |> List.flatten() |> Enum.group_by( - fn mapping -> {mapping.type, mapping.id} end, + fn mapping -> {mapping.type, mapping.id, mapping.proxy_id} end, fn mapping -> %{mapping.field => mapping.value} end ) |> Enum.map( - fn {{type, id}, grouped_mappings} -> + fn {{type, id, proxy_id}, grouped_mappings} -> grouped_mappings |> Enum.reduce(fn l, r -> Map.merge(l,r) end) |> Map.put("type", type) |> Map.put("id", id) + |> Map.put("proxy_id", proxy_id) end ) |> Enum.group_by(