Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion vendor/laird/rs1xx-temp-rh-sensor-codec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ uplinkDecoder:
normalizedOutput:
data:
- air:
temperature: 98.67
temperature: 37.03888888888889
relativeHumidity: 52.33

- description: Send Temp and RH Aggregated Data Notification
Expand All @@ -36,6 +36,16 @@ uplinkDecoder:
numberOfReadings: 2
timestamp: { year: 2015, month: 'January', day: 1, hours: 0, minutes: 0, seconds: 0 }
readings: [{ temperature: 98.67, humidity: 52.33 }, { temperature: 99.68, humidity: 53.34 }]
normalizedOutput:
data:
- time: '2015-01-01T00:00:00.000Z'
air:
temperature: 37.03888888888889
relativeHumidity: 52.33
- time: '2015-01-01T00:00:00.000Z'
air:
temperature: 37.6
relativeHumidity: 53.34

- description: Send Backlog Message Notification
input:
Expand All @@ -48,6 +58,12 @@ uplinkDecoder:
timestamp: { year: 2015, month: 'January', day: 1, hours: 0, minutes: 0, seconds: 2 }
temperature: 107.76
humidity: 61.42
normalizedOutput:
data:
- time: '2015-01-01T00:00:02.000Z'
air:
temperature: 42.08888888888889
relativeHumidity: 61.42

- description: Send Backlog Messages Notification
input:
Expand All @@ -63,6 +79,16 @@ uplinkDecoder:
{ timestamp: { year: 2015, month: 'January', day: 1, hours: 0, minutes: 0, seconds: 0 }, temperature: 107.76, humidity: 61.42 },
{ timestamp: { year: 2015, month: 'January', day: 1, hours: 0, minutes: 0, seconds: 0 }, temperature: 107.76, humidity: 61.42 },
]
normalizedOutput:
data:
- time: '2015-01-01T00:00:00.000Z'
air:
temperature: 42.08888888888889
relativeHumidity: 61.42
- time: '2015-01-01T00:00:00.000Z'
air:
temperature: 42.08888888888889
relativeHumidity: 61.42

- description: Send Sensor Config Simple Notification
input:
Expand Down
51 changes: 45 additions & 6 deletions vendor/laird/rs1xx-temp-rh-sensor.js
Original file line number Diff line number Diff line change
Expand Up @@ -3482,12 +3482,51 @@ function decodeUplink(input) {
}

function normalizeUplink(input) {
return {
data: {
air: {
temperature: input.data.temperature,
relativeHumidity: input.data.humidity,
parseDecodedTimestamp = (t) => {
return new Date(Date.UTC(
t.year,
monthTypeEnum.list.map(kv => kv.key).indexOf(t.month),
t.day,
t.hours,
t.minutes,
t.seconds,
)).toISOString();
}

let rootTimestamp;
if ('timestamp' in input.data) {
rootTimestamp = parseDecodedTimestamp(input.data.timestamp);
}

if ('humidity' in input.data && 'temperature' in input.data) {
return {
data: {
...(rootTimestamp ? { time: rootTimestamp } : {}),
air: {
relativeHumidity: input.data.humidity,
temperature: (input.data.temperature - 32) * 5 / 9
}
}
}
}
}

if ('readings' in input.data) {
return {
data: input.data.readings.map(r => {
let timestamp = rootTimestamp;
if ('timestamp' in r) {
timestamp = parseDecodedTimestamp(r.timestamp);
}
return {
...(timestamp ? { time: timestamp } : {}),
air: {
relativeHumidity: r.humidity,
temperature: (r.temperature - 32) * 5 / 9
}
}
})
}
}

return;
}
Loading