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 WH32 outdoor temperature and humidity sensor #18

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
7 changes: 7 additions & 0 deletions src/EcowittPlatform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { PLATFORM_NAME, PLUGIN_NAME } from './settings';
import { GW1000 } from './GW1000';
import { WH25 } from './WH25';
import { WH31 } from './WH31';
import { WH32 } from './WH32';
import { WH41 } from './WH41';
import { WH51 } from './WH51';
import { WH55 } from './WH55';
Expand Down Expand Up @@ -214,6 +215,8 @@ export class EcowittPlatform implements DynamicPlatformPlugin {
this.addSensorType(dataReport[`batt${channel}`] !== undefined, 'WH31', channel);
}
}

this.addSensorType(dataReport.wh26batt !== undefined, 'WH32');

if (!this.config?.pm25?.hide) {
for (let channel = 1; channel <= 4; channel++) {
Expand Down Expand Up @@ -291,6 +294,10 @@ export class EcowittPlatform implements DynamicPlatformPlugin {
case 'WH31':
sensor.accessory = new WH31(this, accessory, sensor.channel);
break;

case 'WH32':
sensor.accessory = new WH32(this, accessory);
break;

case 'WH41':
sensor.accessory = new WH41(this, accessory, sensor.channel);
Expand Down
37 changes: 37 additions & 0 deletions src/WH32.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { PlatformAccessory } from 'homebridge';
import { EcowittPlatform } from './EcowittPlatform';
import { ThermoHygroSensor } from './ThermoHygroSensor';


export class WH32 extends ThermoHygroSensor {

constructor(
protected readonly platform: EcowittPlatform,
protected readonly accessory: PlatformAccessory,
) {
super(platform, accessory);

this.setModel(
'WH32',
'Outdoor Temperature and Humidity Sensor');

this.setName(this.temperatureSensor, 'Outdoor Temperature');
this.setName(this.humiditySensor, 'Outdoor Humidity');
}

update(dataReport) {
this.platform.log.info('WH32 Update');
// The data report labels the WH32 battery as wh26batt.
this.platform.log.info(' wh26batt:', dataReport.wh26batt);
this.platform.log.info(' tempf:', dataReport.tempf);
this.platform.log.info(' humidity:', dataReport.humidity);

const lowBattery = dataReport.wh26batt === '1';

this.updateTemperature(dataReport.tempf);
this.updateStatusLowBattery(this.temperatureSensor, lowBattery);

this.updateHumidity(dataReport.humidity);
this.updateStatusLowBattery(this.humiditySensor, lowBattery);
}
}