Skip to content

Commit

Permalink
Reworked get-status node (again) to return event with only index fiel…
Browse files Browse the repository at this point in the history
…d for replies without an event (cf. uhppoted/uhppote-core#18)
  • Loading branch information
twystd committed Nov 3, 2023
1 parent fd08609 commit c4013af
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 30 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
### Updated
1. Fixed input/output labels for renamed nodes.
2. Reworked `get-status` to return '' for zero value event timestamps.
3. Reworked `get-status` to explicitly set fields for response with no event.
3. Reworked `get-status` to explicitly handle response with no event.


## [1.1.5](https://github.com/uhppoted/node-red-contrib-uhppoted/releases/tag/v1.1.5) - 2023-08-30
Expand Down
13 changes: 1 addition & 12 deletions nodes/decoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,11 @@ module.exports = {
reason: lookup.reason(bytes, 27, translator)
}

// No event?
if (evt.index === 0) {
evt.type = lookup.noEventType(translator)
evt.granted = false
evt.door = 0
evt.direction = lookup.noEventDirection(translator)
evt.card = 0
evt.timestamp = ''
evt.reason = lookup.noEventReason(translator)
}

return {
deviceId: uint32(bytes, 4),
state: {
serialNumber: uint32(bytes, 4),
event: evt,
event: evt.index === 0 ? { index: 0 } : evt,
doors: {
1: bool(bytes, 28),
2: bool(bytes, 29),
Expand Down
18 changes: 1 addition & 17 deletions test/decoder_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,23 +85,7 @@ describe('decode', function () {
state: {
serialNumber: 405419896,
event: {
index: 0,
type: {
code: 0,
event: 'none'
},
granted: false,
door: 0,
direction: {
code: 0,
direction: 'unknown'
},
card: 0,
timestamp: '',
reason: {
code: 0,
reason: 'no reason'
}
index: 0
},
doors: {
1: false,
Expand Down

0 comments on commit c4013af

Please sign in to comment.