-
Notifications
You must be signed in to change notification settings - Fork 0
Add absolute humidity calculation in g/m³ #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Add absolute_humidity_g_m3() function to conv.py using Magnus-Tetens approximation - Export humidity_abs field in both InfluxDB and MQTT outputs - Update README Home Assistant integration with absolute humidity sensor - Calculation uses temperature (°C) and relative humidity (%) from Aranet sensor Co-Authored-By: Chris Dzombak <chris@dzombak.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
- Wrap long function calls across multiple lines in influx.py and mqtt.py - Addresses CI lint failure in PR #7 Co-Authored-By: Chris Dzombak <chris@dzombak.com>
return mbar * 0.02952998751 | ||
|
||
|
||
def absolute_humidity_g_m3(temp_celsius: float, relative_humidity_pct: float) -> float: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add some test cases for this function that are easily human-readable for a quick sanity check.
- Add comprehensive docstring with human-readable test cases - Include typical room conditions, cold conditions, and warm humid examples - Addresses GitHub comment requesting sanity check examples Co-Authored-By: Chris Dzombak <chris@dzombak.com>
- Remove trailing whitespace from docstring - Addresses CI lint failure after adding test cases Co-Authored-By: Chris Dzombak <chris@dzombak.com>
Test cases for quick sanity check: | ||
20°C, 60% RH → 10.37 g/m³ (typical room conditions) | ||
0°C, 50% RH → 2.42 g/m³ (cold conditions) | ||
25°C, 80% RH → 18.42 g/m³ (warm, humid conditions) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add standard Python unit tests for these cases.
- Create test_conv.py with unittest framework - Test all three documented test cases with proper assertions - Addresses GitHub comment requesting standard Python unit tests - All tests pass locally Co-Authored-By: Chris Dzombak <chris@dzombak.com>
- Apply Ruff formatting to test_conv.py - Addresses CI lint failure after adding unit tests - All tests continue to pass locally Co-Authored-By: Chris Dzombak <chris@dzombak.com>
Add absolute humidity calculation in g/m³
Summary
Adds absolute humidity calculation to Aranet4 sensor readings, exported alongside existing sensor values in both InfluxDB and MQTT outputs. The implementation uses the Magnus-Tetens approximation to calculate absolute humidity in g/m³ from temperature (°C) and relative humidity (%) readings.
Key Changes:
absolute_humidity_g_m3()
function inconv.py
using standard meteorological formulahumidity_abs
field in both InfluxDB and MQTT data streamsReview & Testing Checklist for Human
AH = (6.112 × e^[(17.67 × T)/(T+243.5)] × rh × 2.1674)/(273.15+T)
humidity_abs
field appears correctly in InfluxDB with reasonable valueshumidity_abs
field is present in MQTT messages and matches InfluxDB valuesRecommended test plan: Run the application with
--print
flag and verify the new absolute humidity values appear reasonable across different temperature/humidity conditions. Check both InfluxDB and MQTT outputs contain the new field.Diagram
Notes
humidity_pct
,temp_c
,pressure_mbar
)Link to Devin run: https://app.devin.ai/sessions/0efbf12ab70747d2baeff9d5f30717e5
Requested by: Chris Dzombak (@cdzombak)