Skip to content

Commit

Permalink
CHAD-10239 Add emit event in handling chime (#563)
Browse files Browse the repository at this point in the history
* add emit event in handling chime

* fix tests

* cleanup

* fix in test
  • Loading branch information
NikitaKuchta authored Feb 17, 2023
1 parent a571e8b commit 4c6ccd8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,17 @@ local function chime_off(self, device)
end

local function handle_chime(self, device)
sendAlarmChimeCommand(device, CHIME)
-- this comment was taken from a former DTH:
-- Chime is kind of special as the alarm treats it as momentary
-- and thus sends no updates to us, so we'll send this event and then send an off event soon after.
device:emit_event(capabilities.chime.chime.chime())
device.thread:call_with_delay(
CHIME_OFF_DELAY,
function(d)
chime_off(self,device)
end
)
sendAlarmChimeCommand(device, CHIME)
end

local function deactivateTamper(device)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ test.register_message_test(
inner_block_ordering = "relaxed"
}
)

test.register_coroutine_test(
"Chime capability / chime command should evoke the correct Z-Wave Notification commands",
function()
Expand All @@ -261,7 +262,11 @@ test.register_coroutine_test(
mock_siren.id,
{ capability = "chime", component = "main", command = "chime", args = {} }
})


test.socket.capability:__expect_send(
mock_siren:generate_test_message("main", capabilities.chime.chime.chime())
)

test.socket.zwave:__expect_send(
zw_test_utils.zwave_test_build_send_command(
mock_siren,
Expand All @@ -271,6 +276,7 @@ test.register_coroutine_test(
})
)
)

test.wait_for_events()
test.mock_time.advance_time(1)
test.socket.capability:__expect_send(
Expand Down

0 comments on commit 4c6ccd8

Please sign in to comment.