Skip to content
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

Add support for WS-1938 indoor CO2 sensor #161

Merged
merged 1 commit into from
Jun 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,7 @@ And here's an example with lightning:
And here's an example with AQIN data:

`/data/?tempf=76.3&date=2023-09-28T16%3A15%3A00.000Z&aqi_pm25_24h_aqin=5&batt_25=1&tz=America%2FChicago&pm25_in_aqin=0.9&co2_in_24h_aqin=988&feelsLikein=74.9&aqi_pm25=38&lastRain=2023-09-23T21%3A22%3A00.000Z&pm10_in_24h_aqin=1.9&dewPointin=50.3&monthlyrainin=3.043&dailyrainin=0&aqi_pm25_aqin=4&pm25_in_24h_aqin=1.2&solarradiation=68.02&pm25_24h=3&humidityin=41&aqi_pm25_24h=13&humidity=69&pm_in_humidity_aqin=46&pm10_in_aqin=1.2&maxdailygust=6.93&pm_in_temp_aqin=74.1&uv=0&windspeedmph=0&yearlyrainin=7.752&winddir=184&hourlyrainin=0&eventrainin=0&baromabsin=28.969&battin=1&dewPoint=65.36&tempinf=75.7&battout=1&feelsLike=76.87&dateutc=1695917700000&windgustmph=1.12&macAddress=C8%3AC9%3AA3%3A55%3A93%3A17&pm25=9&co2_in_aqin=964&baromrelin=28.969&batt_co2=1&winddir_avg10m=195&weeklyrainin=0`

And here's an example with indoor CO2 data:

`/data/?tempf=76.3&date=2023-09-28T16%3A15%3A00.000Z&aqi_pm25_24h_aqin=5&batt_25=1&tz=America%2FChicago&pm25_in_aqin=0.9&co2_in_24h_aqin=988&feelsLikein=74.9&aqi_pm25=38&lastRain=2023-09-23T21%3A22%3A00.000Z&pm10_in_24h_aqin=1.9&dewPointin=50.3&monthlyrainin=3.043&dailyrainin=0&aqi_pm25_aqin=4&pm25_in_24h_aqin=1.2&solarradiation=68.02&pm25_24h=3&humidityin=41&aqi_pm25_24h=13&humidity=69&pm_in_humidity_aqin=46&pm10_in_aqin=1.2&maxdailygust=6.93&pm_in_temp_aqin=74.1&uv=0&windspeedmph=0&yearlyrainin=7.752&winddir=184&hourlyrainin=0&eventrainin=0&baromabsin=28.969&battin=1&dewPoint=65.36&tempinf=75.7&battout=1&feelsLike=76.87&dateutc=1695917700000&windgustmph=1.12&macAddress=C8%3AC9%3AA3%3A55%3A93%3A17&pm25=9&co2_in_aqin=964&baromrelin=28.969&batt_co2=1&winddir_avg10m=195&weeklyrainin=0&co2_in=1447&co2_in_24h=1289`
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ The following sensors are supported. Note that weather stations will only report
| batteryPM25Ok | State of the PM25 device battery, `0` for not ok, `100` for ok | Yes | No | percent |
| batteryLightning | State of the lightning device battery, `0` for not ok, `100` for ok | Yes | No | percent |
| co2 | CO2 meter reading | Yes | No | ppm |
| co2_in | Indoor CO2 meter reading | Yes | No | ppm |
| co2_in_24h | Indoor CO2 meter 24 hour average | Yes | No | ppm |
| dewpoint | Outdoor dewpoint temperature | No | Yes | °F |
| eventDate | Date of the latest measurements | Yes | Yes | date |
| humidity1..10 | Humidity sensors 1 through 10 | Yes | No | percent |
Expand Down
2 changes: 2 additions & 0 deletions src/controllers/weatherDataController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ export async function processWeatherData(req: express.Request, res: express.Resp
setDataPayload(EntityNames.BATTERYPM25OK, convertBatteryValue(req.query.batt_25 as string));
setDataPayload(EntityNames.BATTERYLIGHTNING, convertBatteryValue(req.query.batt_lightning as string));
setDataPayload(EntityNames.CO2, +req.query.co2);
setDataPayload(EntityNames.CO2_IN, +req.query.co2_in);
setDataPayload(EntityNames.CO2_IN_24H, +req.query.co2_in_24h);
// Only available in Weather Underground updates. For Ambient Weather stations
// this is a calculated sensor, handled farther down in this function.
setDataPayload(EntityNames.DEWPOINT, +req.query.dewptf);
Expand Down
8 changes: 8 additions & 0 deletions src/entityManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,14 @@ export function initialize(): void {
),
);
entities.set(EntityNames.CO2, new Sensor(EntityNames.CO2, deviceId, SensorUnit.partsPerMillion, DeviceClass.CO2));
entities.set(
EntityNames.CO2_IN,
new Sensor(EntityNames.CO2_IN, deviceId, SensorUnit.partsPerMillion, DeviceClass.CO2),
);
entities.set(
EntityNames.CO2_IN_24H,
new Sensor(EntityNames.CO2_IN_24H, deviceId, SensorUnit.partsPerMillion, DeviceClass.CO2),
);
entities.set(EntityNames.DEWPOINT, new Sensor(EntityNames.DEWPOINT, deviceId, SensorUnit.F, DeviceClass.TEMPERATURE));
entities.set(
EntityNames.EVENTDATE,
Expand Down
2 changes: 2 additions & 0 deletions src/entityNames.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ enum EntityNames {
BATTERYPM25OK = "batteryPM25Ok",
BATTERYLIGHTNING = "batt_lightning",
CO2 = "co2",
CO2_IN = "co2_in",
CO2_IN_24H = "co2_in_24h",
/**
* @deprecated Replaced with eventDate
*/
Expand Down