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

Extend normalized payload #800

Merged
merged 36 commits into from
Sep 17, 2024

Conversation

LDannijs
Copy link
Contributor

@LDannijs LDannijs commented Jul 8, 2024

Summary

Extend the normalized payload function to 20 devices.

Changes

  • add a normalized payload and output to 20 of the most popular devices
  • Add Dragino LWL03A

Checklist for Reviewers

  • Title and description should be descriptive (Not just a serial number for example).
  • profileIDs should not be vendorID and should be a unique value for every profile.
  • All devices should be listed in the vendor's index.yaml file.
  • Firmware versions can not be changed.
  • At least 1 image per device and should be transparent.

lib/payload.json Outdated Show resolved Hide resolved
lib/payload.json Outdated Show resolved Hide resolved
lib/payload.json Outdated Show resolved Hide resolved
lib/payload.json Outdated Show resolved Hide resolved
lib/payload.json Outdated Show resolved Hide resolved
lib/payload.json Outdated Show resolved Hide resolved
lib/payload.json Outdated Show resolved Hide resolved
lib/payload.json Outdated Show resolved Hide resolved
lib/payload.json Outdated Show resolved Hide resolved
Copy link
Member

@johanstokking johanstokking left a comment

Choose a reason for hiding this comment

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

Great stuff already, few comments

lib/payload.json Outdated Show resolved Hide resolved
lib/payload.json Outdated Show resolved Hide resolved
lib/payload.json Outdated Show resolved Hide resolved
lib/payload.json Outdated Show resolved Hide resolved
@@ -49,7 +49,7 @@ function normalizeUplink(input) {
return {
data: {
action: {
contactState: input.data.door.toUpperCase()
contactState: input.data.door ? "OPEN":"CLOSED"
Copy link
Member

Choose a reason for hiding this comment

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

So is it a boolean? Before you assumed it was a string?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah i think so, im basically copying what is used above:

decoded.door = bytes[i] === 0 ? "close" : "open";

Copy link
Member

@johanstokking johanstokking Aug 29, 2024

Choose a reason for hiding this comment

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

So in this case input.data.door is either close or open. Not CLOSE or OPEN and not a boolean.

To convert close or open to CLOSED or OPEN respectively, you need to contactState: input.data.door === "close" ? "CLOSED" : input.data.door === "open ? "OPEN" : undefined

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I finally see how it should work now, apologies.

lib/payload.json Outdated Show resolved Hide resolved
vendor/dragino/lwl03a.js Outdated Show resolved Hide resolved
@johanstokking johanstokking merged commit 76f4658 into TheThingsNetwork:master Sep 17, 2024
2 checks passed
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.

2 participants