From f469796260a1dcf51ccf87600973cd40f43fb486 Mon Sep 17 00:00:00 2001 From: Mikko Ahlroth Date: Sat, 14 Jan 2023 00:51:41 +0200 Subject: [PATCH] Fix Elixir integration record mistake --- lib/geo_therminator/pump_api/auth/server.ex | 4 +++- lib/geo_therminator/pump_api/device/server.ex | 10 ++++++---- lib/geo_therminator_web/live/main/index.ex | 4 +++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/geo_therminator/pump_api/auth/server.ex b/lib/geo_therminator/pump_api/auth/server.ex index 6662abd..ccbfd79 100644 --- a/lib/geo_therminator/pump_api/auth/server.ex +++ b/lib/geo_therminator/pump_api/auth/server.ex @@ -121,7 +121,9 @@ defmodule GeoTherminator.PumpAPI.Auth.Server do {:ok, state} else - _ -> :error + err -> + Logger.error("Could not auth or fetch installations! #{inspect(err)}") + :error end end end diff --git a/lib/geo_therminator/pump_api/device/server.ex b/lib/geo_therminator/pump_api/device/server.ex index c91f222..c0466a4 100644 --- a/lib/geo_therminator/pump_api/device/server.ex +++ b/lib/geo_therminator/pump_api/device/server.ex @@ -1,10 +1,12 @@ defmodule GeoTherminator.PumpAPI.Device.Server do + require Logger + require GeoTherminator.PumpAPI.Auth.InstallationInfo + use GenServer import GeoTherminator.TypedStruct alias GeoTherminator.PumpAPI.Device alias GeoTherminator.PumpAPI.Auth.InstallationInfo alias GeoTherminator.PumpAPI.Auth.Server, as: AuthServer - require Logger defmodule Options do deftypedstruct(%{ @@ -26,7 +28,7 @@ defmodule GeoTherminator.PumpAPI.Device.Server do @spec start_link(Options.t()) :: GenServer.on_start() def start_link(opts) do GenServer.start_link(__MODULE__, opts, - name: {:via, Registry, {Device.Registry, opts.installation.id}} + name: {:via, Registry, {Device.Registry, InstallationInfo.record(opts.installation, :id)}} ) end @@ -119,7 +121,7 @@ defmodule GeoTherminator.PumpAPI.Device.Server do Task.async_stream( [&Device.API.status/2, &Device.API.register_info/2, &Device.API.opstat/2], & &1.(user, state.device), - timeout: Application.get_env(:geo_therminator, :api_timeout) + timeout: Application.fetch_env!(:geo_therminator, :api_timeout) ) |> Enum.map(fn {:ok, val} -> val end) @@ -133,7 +135,7 @@ defmodule GeoTherminator.PumpAPI.Device.Server do Process.send_after( self(), :refresh_status, - Application.get_env(:geo_therminator, :api_refresh) + Application.fetch_env!(:geo_therminator, :api_refresh) ) end end diff --git a/lib/geo_therminator_web/live/main/index.ex b/lib/geo_therminator_web/live/main/index.ex index f8159c7..66a35b2 100644 --- a/lib/geo_therminator_web/live/main/index.ex +++ b/lib/geo_therminator_web/live/main/index.ex @@ -1,4 +1,5 @@ defmodule GeoTherminatorWeb.MainLive.Index do + require Logger use GeoTherminatorWeb, :live_view @impl Phoenix.LiveView @@ -55,7 +56,8 @@ defmodule GeoTherminatorWeb.MainLive.Index do ) end - _ -> + err -> + Logger.debug("Error starting auth server: #{inspect(err)}") assign(socket, error: true) end end