Skip to content

Commit

Permalink
Merge pull request #64 from Jalle19/more-fixes
Browse files Browse the repository at this point in the history
Apply filters before rounding values
  • Loading branch information
Jalle19 authored Jun 13, 2024
2 parents 0eebc5c + b11b23e commit 5bce450
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ to any number of different targets, such as databases or MQTT.
* [Installation and usage](#installation-and-usage)
+ [Running with Docker](#running-with-docker)
+ [Running as a systemd service](#running-as-a-systemd-service)
* [Caveats](#caveats)
* [Development](#development)
* [License](#license)

Expand Down Expand Up @@ -112,6 +113,10 @@ There is a skeleton systemd service available in [systemd/eachwatt.service](syst
project to `/opt/eachwatt`, copy the service file to `/etc/systemd/system/eachwatt.service`, modify it as necessary
and then start the service using `systemctl start eachwatt.service`.

## Caveats

* IotaWatt input sensors are always whole numbers, i.e. 2 watts. Output sensors don't have this limitation.

## Development

Install dependencies:
Expand Down
10 changes: 5 additions & 5 deletions src/eachwatt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ const mainPollerFunc = async (config: Config) => {

// Post-process power sensor data
powerSensorData = powerSensorData.map((data) => {
// Apply optional data filters
if (data.circuit.sensor.filters) {
data = applyFilters(data.circuit.sensor.filters, data)
}

if (data.power !== undefined) {
// Round all numbers to one decimal point
data.power = Number(data.power.toFixed(1))

// Apply optional data filters
if (data.circuit.sensor.filters) {
data = applyFilters(data.circuit.sensor.filters, data)
}
}

return data
Expand Down

0 comments on commit 5bce450

Please sign in to comment.