Skip to content

Commit

Permalink
Reworked 'get-event' to throw error on 'no event' or 'overwritten eve…
Browse files Browse the repository at this point in the history
…nt' (cf. cf. uhppoted/uhppote-cli#7)
  • Loading branch information
twystd committed Jan 11, 2022
1 parent 8209d27 commit 938ede0
Show file tree
Hide file tree
Showing 6 changed files with 3,138 additions and 5,127 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
### v0.7.2: Minor bug fixes

1. Update NodeRED dependency to v2.1.4
2. Updated associated NodeRED components
3. Throws an 'no event' error if `get-event` retrieves an event that does not exist
4. Throws an 'overwritten event' error if `get-event` retrieves an event that has been overwritten
(cf. https://github.com/uhppoted/uhppote-cli/issues/7)

### v0.7.1: Implements the task list management functions from the extended API

1. Added nodes for managing a controller task list:
Expand Down
8 changes: 2 additions & 6 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
## v0.7.1
## v0.7.2

- [x] Publish to NPM
- [x] Update README
- [x] `clear-task-list`
- [x] `add-task`
- [x] `refresh-task`
- [x] Throw error on `get-event` for overwritten event

## TODO

Expand Down
2 changes: 1 addition & 1 deletion examples/examples.json

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion nodes/get-event.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ module.exports = function (RED) {
const index = msg.payload.index

const emit = function (object) {
if (object.index !== 0) {
if (object.event.index === 0 && object.event.type.code === 0xff) {
common.error(node, new Error(`event for ${deviceId}/${index} has been overwritten`))
} else if (object.event.index === 0) {
common.error(node, new Error(`no event for ${deviceId}/${index}`))
} else {
common.emit(node, t, object)
}
}
Expand Down
Loading

0 comments on commit 938ede0

Please sign in to comment.