Skip to content

Commit

Permalink
Handle alarm v1 support flag not 0 in alarm_type_supported_report
Browse files Browse the repository at this point in the history
  • Loading branch information
jfcloutier committed Nov 26, 2024
1 parent 89bffc2 commit d8d9304
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/grizzly/zwave/commands/alarm_type_supported_report.ex
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ defmodule Grizzly.ZWave.Commands.AlarmTypeSupportedReport do

@impl Grizzly.ZWave.Command
@spec decode_params(binary()) :: {:ok, [param()]} | {:error, DecodeError.t()}
def decode_params(<<0x00::3, number_of_masks::5, bitmasks::binary-size(number_of_masks)>>) do
def decode_params(
<<_v1_support::3, number_of_masks::5, bitmasks::binary-size(number_of_masks)>>
) do
with {:ok, types} <- decode_alarm_types(bitmasks) do
{:ok, [types: types]}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,12 @@ defmodule Grizzly.ZWave.Commands.AlarmTypeSupportedReportTest do
assert Enum.sort([:smoke_alarm, :home_security, :siren, :gas_alarm]) ==
Enum.sort(Keyword.get(params, :types))
end

test "decodes params correctly with alarm v1 support" do
binary_params = <<0x01::3, 0x03::5, 0b10000010, 0b01000000, 0b00000100>>
{:ok, params} = AlarmTypeSupportedReport.decode_params(binary_params)

assert Enum.sort([:smoke_alarm, :home_security, :siren, :gas_alarm]) ==
Enum.sort(Keyword.get(params, :types))
end
end

0 comments on commit d8d9304

Please sign in to comment.