Skip to content

Commit

Permalink
Add calculated sensors (#127)
Browse files Browse the repository at this point in the history
* Replicate AmbientWeather & Home Assistant calculated values.
Fixes #125

* Add LAST_RAIN

* Add heat index, wind chill, and feels like calculations

* Add more stuff

* Add dewpoint

* Bug fixing

* Clean up code comment

* Clean up code comments again

* Initial mocha test framework

* Add feels like unit tests, fix bugs

* Add comments and last unit test

* Update comment

* Add test running to PR build

* Address code review feedback

* Fix lastRain and add unit tests for it

* Add missing °
  • Loading branch information
neilenns committed Jan 18, 2024
1 parent 8f37578 commit bca7727
Show file tree
Hide file tree
Showing 17 changed files with 1,872 additions and 105 deletions.
34 changes: 0 additions & 34 deletions .eslintrc.json

This file was deleted.

28 changes: 0 additions & 28 deletions .github/workflows/node.js.yml

This file was deleted.

49 changes: 49 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js CI

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Use Node.js 14.x
uses: actions/setup-node@v3
with:
node-version: 14.x
cache: "npm"
cache-dependency-path: "package-lock.json"

- name: Install dependencies
run: npm ci

- name: Build
run: npm run build --if-present

test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Use Node.js 14.x
uses: actions/setup-node@v3
with:
node-version: 14.x
cache: "npm"
cache-dependency-path: "package-lock.json"

- name: Install dependencies
run: npm ci

- name: Test
run: npm run test
8 changes: 8 additions & 0 deletions .mocharc.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extensions": ["ts"],
"spec": "test/**/*.spec.*",
"node-option": [
"experimental-specifier-resolution=node",
"loader=ts-node/esm"
]
}
10 changes: 8 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,11 @@
"windgustmph",
"windspeedmph"
],
"markdown.extension.toc.levels": "2..6"
}
"markdown.extension.toc.levels": "2..6",
"mochaExplorer.logpanel": true,
"mochaExplorer.configFile": ".mocharc.jsonc",
"mochaExplorer.nodeArgv": [
"--loader=ts-node/esm",
"--no-warnings=ExperimentalWarning",
"--experimental-specifier-resolution=node"
]}
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ The following Ambient Weather station models are confirmed to work: WS-2902C.
- [Troubleshooting](#troubleshooting)
- [Advanced settings](#advanced-settings)
- [Supported sensors](#supported-sensors)
- [Calculated sensors](#calculated-sensors)

## Installation and configuration

Expand Down Expand Up @@ -157,3 +158,16 @@ The following sensors are supported. Note that weather stations will only report
| pm_in_temp_aqin | Indoor temperature | Yes | No | °F |
| co2_in_aqin | Indoor CO2 meter reading | Yes | No | ppm |
| co2_in_24h_aqin | Indoor CO2 meter reading 24 hour average | Yes | No | ppm |

## Calculated sensors

The following sensors are calculated using values from the weather station. Note that these will only be sent if the underlying values used for the calculation are available.

| Name | Description | Ambient Weather | Weather Underground | Unit |
| ----------------- | -------------------------------------------------------------- | --------------- | ------------------- | --------- |
| dewpoint | Outdoor dewpoint temperature | Yes | No | °F |
| dewpoint1..10 | Outdoor dewpoint temperature for sensors 1 through 10 | Yes | Yes | °F |
| feelsLike | Windchill, heat index, or temperature | Yes | Yes | °F |
| feelsLike1..10 | Windchill, heat index, or temperature for sensors 1 through 10 | Yes | Yes | °F |
| lastRain | Last time hourlyRain was > 0 | Yes | Yes | timestamp |
| solarRadiationLux | Solar radiation (in lux) | Yes | Yes | lx |
Loading

0 comments on commit bca7727

Please sign in to comment.