Fix for new version of pump firmware
This commit is contained in:
parent
54d6e38b23
commit
13f3a1167c
4 changed files with 33 additions and 9 deletions
|
@ -58,6 +58,19 @@ config :geo_therminator,
|
||||||
# "REG_VALUE_STATUS_OFF" => 100
|
# "REG_VALUE_STATUS_OFF" => 100
|
||||||
100 => :off
|
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:
|
api_device_reg_set_url:
|
||||||
get_env(
|
get_env(
|
||||||
"API_DEVICE_REG_SET_URL",
|
"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_device_reg_set_client_id: get_env("API_DEVICE_REG_SET_CLIENT_ID"),
|
||||||
api_refresh: 10_000
|
api_refresh: 10_000
|
||||||
|
|
||||||
# config/runtime.exs is executed for all environments, including
|
if config_env() == :dev do
|
||||||
# during releases. It is executed after compilation and before the
|
config :geo_therminator, GeoTherminatorWeb.Endpoint,
|
||||||
# system starts, so it is typically used to load production configuration
|
http: [
|
||||||
# and secrets from environment variables or elsewhere. Do not define
|
port: String.to_integer(System.get_env("PORT") || "4000")
|
||||||
# any compile-time configuration in here, as it won't be applied.
|
]
|
||||||
# The block below contains prod specific runtime configuration.
|
end
|
||||||
|
|
||||||
if config_env() == :prod do
|
if config_env() == :prod do
|
||||||
# The secret key base is used to sign/encrypt cookies and other secrets.
|
# 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
|
# A default value is used in config/dev.exs and config/test.exs but you
|
||||||
|
|
|
@ -103,10 +103,18 @@ defmodule GeoTherminator.PumpAPI.Device.API do
|
||||||
end)
|
end)
|
||||||
|
|
||||||
priority_register = find_register(registers, "REG_OPERATIONAL_STATUS_PRIO1")
|
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{
|
%Device.OpStat{
|
||||||
priority: Map.fetch!(mapping, priority_register.register_value)
|
priority: Map.get(mapping, register.register_value, :unknown)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,8 @@ defmodule GeoTherminator.PumpAPI.Device do
|
||||||
| :standby
|
| :standby
|
||||||
| :idle
|
| :idle
|
||||||
| :off
|
| :off
|
||||||
|
| :defrost
|
||||||
|
| :unknown
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
2
mix.exs
2
mix.exs
|
@ -4,7 +4,7 @@ defmodule GeoTherminator.MixProject do
|
||||||
def project do
|
def project do
|
||||||
[
|
[
|
||||||
app: :geo_therminator,
|
app: :geo_therminator,
|
||||||
version: "0.1.0",
|
version: "0.2.0",
|
||||||
elixir: "~> 1.12",
|
elixir: "~> 1.12",
|
||||||
elixirc_paths: elixirc_paths(Mix.env()),
|
elixirc_paths: elixirc_paths(Mix.env()),
|
||||||
compilers: [:gettext] ++ Mix.compilers(),
|
compilers: [:gettext] ++ Mix.compilers(),
|
||||||
|
|
Loading…
Reference in a new issue