Fix for new version of pump firmware

This commit is contained in:
Mikko Ahlroth 2022-02-17 20:46:26 +02:00
parent 54d6e38b23
commit 13f3a1167c
4 changed files with 33 additions and 9 deletions

View file

@ -58,6 +58,19 @@ config :geo_therminator,
# "REG_VALUE_STATUS_OFF" => 100
100 => :off
},
api_opstat_bitmask_mapping: %{
1 => :hand_operated,
2 => :defrost,
4 => :hot_water,
8 => :heating,
16 => :active_cooling,
32 => :pool,
64 => :anti_legionella,
128 => :passive_cooling,
512 => :standby,
1024 => :idle,
2048 => :off
},
api_device_reg_set_url:
get_env(
"API_DEVICE_REG_SET_URL",
@ -67,12 +80,13 @@ config :geo_therminator,
api_device_reg_set_client_id: get_env("API_DEVICE_REG_SET_CLIENT_ID"),
api_refresh: 10_000
# config/runtime.exs is executed for all environments, including
# during releases. It is executed after compilation and before the
# system starts, so it is typically used to load production configuration
# and secrets from environment variables or elsewhere. Do not define
# any compile-time configuration in here, as it won't be applied.
# The block below contains prod specific runtime configuration.
if config_env() == :dev do
config :geo_therminator, GeoTherminatorWeb.Endpoint,
http: [
port: String.to_integer(System.get_env("PORT") || "4000")
]
end
if config_env() == :prod do
# The secret key base is used to sign/encrypt cookies and other secrets.
# A default value is used in config/dev.exs and config/test.exs but you

View file

@ -103,10 +103,18 @@ defmodule GeoTherminator.PumpAPI.Device.API do
end)
priority_register = find_register(registers, "REG_OPERATIONAL_STATUS_PRIO1")
mapping = Application.get_env(:geo_therminator, :api_opstat_mapping)
priority_register_fallback = find_register(registers, "REG_OPERATIONMODE")
{mapping, register} =
if not is_nil(priority_register) do
{Application.get_env(:geo_therminator, :api_opstat_mapping), priority_register}
else
{Application.get_env(:geo_therminator, :api_opstat_bitmask_mapping),
priority_register_fallback}
end
%Device.OpStat{
priority: Map.fetch!(mapping, priority_register.register_value)
priority: Map.get(mapping, register.register_value, :unknown)
}
end

View file

@ -53,6 +53,8 @@ defmodule GeoTherminator.PumpAPI.Device do
| :standby
| :idle
| :off
| :defrost
| :unknown
})
end

View file

@ -4,7 +4,7 @@ defmodule GeoTherminator.MixProject do
def project do
[
app: :geo_therminator,
version: "0.1.0",
version: "0.2.0",
elixir: "~> 1.12",
elixirc_paths: elixirc_paths(Mix.env()),
compilers: [:gettext] ++ Mix.compilers(),