Skip to content

Commit 02618fd

Browse files
committed
Alarm event 0x00 must always decode as :state_idle even when the alarm type is not known
1 parent 0be92bd commit 02618fd

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/grizzly/zwave/notifications.ex

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,9 @@ defmodule Grizzly.ZWave.Notifications do
384384
Encode a notification event.
385385
"""
386386
@spec event_to_byte(type(), event()) :: byte()
387+
# :state_idle is always encoded as 0x00 no matter the type
388+
def event_to_byte(_type, :state_idle), do: 0x00
389+
387390
def event_to_byte(type, event) do
388391
with nil <- get_in(@event_to_byte, [type, event]) do
389392
raise KeyError, "Unknown notification event: #{inspect(type)} / #{inspect(event)}"
@@ -406,6 +409,9 @@ defmodule Grizzly.ZWave.Notifications do
406409
Decode a notification event.
407410
"""
408411
@spec event_from_byte(type(), byte()) :: {:ok, event()} | {:error, :invalid_event_byte}
412+
# Event 0x00 is always :state_idle even if the type is not known
413+
def event_from_byte(_type, 0), do: {:ok, :state_idle}
414+
409415
def event_from_byte(type, byte) do
410416
with v when not is_nil(v) <- get_in(@event_from_byte, [type, byte]) do
411417
{:ok, v}

0 commit comments

Comments
 (0)