Skip to content

Commit

Permalink
Merge pull request #63 from Jalle19/fix-filters
Browse files Browse the repository at this point in the history
Use map instead of for loop to apply data filters
  • Loading branch information
Jalle19 authored Jun 12, 2024
2 parents 714bf7b + b47fa15 commit 0eebc5c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/eachwatt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const mainPollerFunc = async (config: Config) => {
const characteristicsSensorData = await pollCharacteristicsSensors(now, config.characteristics)

// Post-process power sensor data
for (let data of powerSensorData) {
powerSensorData = powerSensorData.map((data) => {
if (data.power !== undefined) {
// Round all numbers to one decimal point
data.power = Number(data.power.toFixed(1))
Expand All @@ -65,7 +65,9 @@ const mainPollerFunc = async (config: Config) => {
data = applyFilters(data.circuit.sensor.filters, data)
}
}
}

return data
})

// Publish data
for (const publisher of config.publishers) {
Expand Down

0 comments on commit 0eebc5c

Please sign in to comment.