Skip to content

Commit

Permalink
unified topic to area_count
Browse files Browse the repository at this point in the history
  • Loading branch information
J2thatsme committed Jan 9, 2025
1 parent 07a9890 commit 4a0d6a9
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 28 deletions.
18 changes: 18 additions & 0 deletions types/vergeSense/cloudConnector/area_count.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"$id": "https://akenza.io/vergeSense/cloudConnector/area_count.schema.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"processingType": "uplink_decoder",
"topic": "area_count",
"title": "Area count",
"properties": {
"peopleCount": {
"title": "People count",
"description": "People in Area",
"type": "integer"
}
},
"required": [
"peopleCount"
]
}
2 changes: 1 addition & 1 deletion types/vergeSense/cloudConnector/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"outputTopics": [
"occupancy",
"space_availability",
"space_report"
"area_count"
],
"encoding": "JSON",
"connectivity": "HTTP"
Expand Down
18 changes: 0 additions & 18 deletions types/vergeSense/cloudConnector/space_report.schema.json

This file was deleted.

6 changes: 3 additions & 3 deletions types/vergeSense/cloudConnector/uplink.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ function consume(event) {
const payload = {};

if (event.data.event_type === 'space_report') {
topic = 'space_report';
payload.personCount = event.data.person_count;
topic = 'area_count';
payload.peopleCount = event.data.person_count;

if (payload.personCount > 0) {
if (payload.peopleCount > 0) {
emit('sample', { data: { "occupancy": 2, "occupied": true }, topic: "occupancy" });
} else {
emit('sample', { data: { "occupancy": 0, "occupied": false }, topic: "occupancy" });
Expand Down
12 changes: 6 additions & 6 deletions types/vergeSense/cloudConnector/uplink.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ describe("Verge Sense Uplink", () => {
});
});

let spaceReportSchema = null;
let areaCountReportSchema = null;
before((done) => {
utils
.loadSchema(`${__dirname}/space_report.schema.json`)
.loadSchema(`${__dirname}/area_count.schema.json`)
.then((parsedSchema) => {
spaceReportSchema = parsedSchema;
areaCountReportSchema = parsedSchema;
done();
});
});
Expand Down Expand Up @@ -86,10 +86,10 @@ describe("Verge Sense Uplink", () => {
assert.isNotNull(value);
assert.typeOf(value.data, "object");

assert.equal(value.topic, "space_report");
assert.equal(value.data.personCount, 0);
assert.equal(value.topic, "area_count");
assert.equal(value.data.peopleCount, 0);

utils.validateSchema(value.data, spaceReportSchema, {
utils.validateSchema(value.data, areaCountReportSchema, {
throwError: true,
});
});
Expand Down

0 comments on commit 4a0d6a9

Please sign in to comment.