-
Notifications
You must be signed in to change notification settings - Fork 9
/
humidity_control_setpoint_scale_supported_report.ex
53 lines (42 loc) · 1.29 KB
/
humidity_control_setpoint_scale_supported_report.ex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
defmodule Grizzly.ZWave.Commands.HumidityControlSetpointScaleSupportedReport do
@moduledoc """
HumidityControlSetpointScaleSupportedReport
## Parameters
* `:scales`
"""
@behaviour Grizzly.ZWave.Command
import Grizzly.ZWave.Encoding
alias Grizzly.ZWave.{Command, DecodeError}
alias Grizzly.ZWave.CommandClasses.HumidityControlSetpoint
@type param :: {:scales, [HumidityControlSetpoint.scale()]}
@impl Grizzly.ZWave.Command
@spec new([param()]) :: {:ok, Command.t()}
def new(params) do
command = %Command{
name: :humidity_control_setpoint_scale_supported_report,
command_byte: 0x07,
command_class: HumidityControlSetpoint,
params: params,
impl: __MODULE__
}
{:ok, command}
end
@impl Grizzly.ZWave.Command
@spec encode_params(Command.t()) :: binary()
def encode_params(command) do
command
|> Command.param!(:scales)
|> Enum.map(&HumidityControlSetpoint.encode_scale/1)
|> encode_bitmask()
end
@impl Grizzly.ZWave.Command
@spec decode_params(binary()) :: {:ok, [param()]} | {:error, DecodeError.t()}
def decode_params(binary) do
scales =
binary
|> decode_bitmask()
|> Enum.map(&HumidityControlSetpoint.decode_scale/1)
|> Enum.reject(&(&1 == :unknown))
{:ok, [scales: scales]}
end
end