Skip to content

Commit

Permalink
fix(wirepas): shorten floats
Browse files Browse the repository at this point in the history
  • Loading branch information
coderbyheart committed Feb 26, 2024
1 parent 4aeaaad commit a34f0c0
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions wirepas-5g-mesh-gateway/gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,21 +182,28 @@ client.on('message', (_, message) => {
// Regularly send buffered updates
setInterval(() => {
void Promise.all(
Object.entries(nodes).map(async ([gwId, nodes]) => {
Object.entries(nodes).map(async ([gwId, nodes]): Promise<void> => {
Object.entries(nodes).forEach(([nodeId, data]) => {
console.debug(gwId, nodeId, JSON.stringify(data))
})

return iotDataClient.send(
await iotDataClient.send(
new UpdateThingShadowCommand({
thingName: gwId,
payload: JSON.stringify({
state: {
reported: {
nodes,
payload: JSON.stringify(
{
state: {
reported: {
nodes,
},
},
},
}),
(_, v) => {
if (typeof v === 'number' && !Number.isInteger(v))
return parseFloat(v.toFixed(2))
return v
},
),
}),
)
}),
Expand Down

0 comments on commit a34f0c0

Please sign in to comment.