Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add valueId, node and logger to parse functions #319

Merged
merged 11 commits into from
Jan 25, 2021

Conversation

ahochsteger
Copy link
Collaborator

@ahochsteger ahochsteger commented Jan 22, 2021

This PR makes the following objects available to the send and receive parse functions:

  • logger: The logger object of the gateway
  • valueId: The valueId object that contains more information about the affected value
  • node: The node object that contains all information about the affected node

It allows something like this which was not possible before:

// Some debugging:
logger.debug('Got the following arguments:')
logger.debug('- value: ' + value)
logger.debug('- valueId: ' + JSON.stringify(valueId))
logger.debug('- node: ' + JSON.stringify(node))

// Check for invalid values:
if (value < -1) {
  // Log a warning if invalid value reports have been fixed:
  logger.warn('Invalid value ' + value + ' detected - setting to -1.')
  value = -1
}
return value

* add logger param to parse function
* update description in the UI
* unrelated: change 'Save' to 'Update' (no save done here
@robertsLando
Copy link
Member

@ahochsteger I would also add the node object, before the logger :) ALso remember to update docs

@ahochsteger
Copy link
Collaborator Author

@ahochsteger I would also add the node object, before the logger :) ALso remember to update docs

Good idea, will add it and have a look at the docs ...

Copy link
Member

@robertsLando robertsLando left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dito

@ahochsteger
Copy link
Collaborator Author

@ahochsteger I would also add the node object, before the logger :)

How would I get the node object in evalFunction() as it just has access to code, valueId and value?
Or did you mean the valueId object?

@ahochsteger
Copy link
Collaborator Author

Ok, I can add it to evalFunction as 4th argument.
Does it make sense to provide valueId as well as it may contain more interesting information?

@robertsLando
Copy link
Member

@ahochsteger Yep I would add in order (value, valueId, node, logger)

@ahochsteger
Copy link
Collaborator Author

@ahochsteger Yep I would add in order (value, valueId, node, logger)

Done locally.
What about the receive parse function?
There doesn't seem to be a node object available in parsePayload(payload, valueId, valueConf).
Should I pass an empty object ({}) or null?

@ahochsteger ahochsteger changed the title feat: add logger to parse functions feat: add valueId, node and logger to parse functions Jan 22, 2021
@coveralls
Copy link

coveralls commented Jan 22, 2021

Pull Request Test Coverage Report for Build 509782018

  • 1 of 12 (8.33%) changed or added relevant lines in 1 file are covered.
  • 4 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.007%) to 23.369%

Changes Missing Coverage Covered Lines Changed/Added Lines %
lib/Gateway.js 1 12 8.33%
Files with Coverage Reduction New Missed Lines %
lib/Gateway.js 4 18.14%
Totals Coverage Status
Change from base Build 509745234: -0.007%
Covered Lines: 2009
Relevant Lines: 8798

💛 - Coveralls

@ahochsteger
Copy link
Collaborator Author

I'm using an empty object for node for now at the receive part.

lib/Gateway.js Outdated Show resolved Hide resolved
lib/Gateway.js Outdated Show resolved Hide resolved
src/components/dialogs/DialogGatewayValue.vue Outdated Show resolved Hide resolved
@robertsLando robertsLando merged commit e9583fa into master Jan 25, 2021
@robertsLando robertsLando deleted the add-logger-to-parsefn branch January 25, 2021 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants