defmodule GeoTherminator.PumpAPI.Device do import GeoTherminator.TypedStruct deftypedstruct(%{ id: integer(), device_id: integer(), is_online: boolean(), last_online: NaiveDateTime.t(), created_when: NaiveDateTime.t(), mac_address: String.t(), name: String.t(), model: String.t(), retailer_access: integer() }) defmodule Status do deftypedstruct(%{ heating_effect: integer(), is_heating_effect_set_by_user: boolean() }) end defmodule Register do deftypedstruct(%{ register_name: String.t(), register_value: integer(), timestamp: DateTime.t() }) end defmodule RegisterCollection do deftypedstruct(%{ outdoor_temp: Register.t(), supply_out: Register.t(), supply_in: Register.t(), desired_supply: Register.t(), brine_out: Register.t(), brine_in: Register.t(), hot_water_temp: Register.t() }) end defmodule OpStat do deftypedstruct(%{ priority: :hand_operated | :hot_water | :heating | :active_cooling | :pool | :anti_legionella | :passive_cooling | :standby | :idle | :off | :defrost | :unknown }) end @spec get_device_process(GenServer.name(), GeoTherminator.PumpAPI.Auth.InstallationInfo.t()) :: {:ok, GenServer.name()} | :error def get_device_process(auth_server, installation) do case DynamicSupervisor.start_child( __MODULE__.Supervisor, {__MODULE__.Server, %__MODULE__.Server.Options{ auth_server: auth_server, installation: installation }} ) do {:ok, pid} -> {:ok, pid} {:error, {:already_started, pid}} -> {:ok, pid} err -> IO.inspect(err) :error end end end