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

Added WaterLevel (depth) for SmartMi Humidifier - model: zhimi.humidifier.ca1 #144

Open
wants to merge 4 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
6 changes: 4 additions & 2 deletions lib/devices/capabilities/sensor.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ const {
Illuminance,
AtmosphericPressure,
PowerLoad,
PowerConsumed
PowerConsumed,
WaterLevel
} = require('abstract-things/sensors');

function bind(Type, updateName, property) {
Expand All @@ -29,7 +30,8 @@ module.exports.Illuminance = bind(Illuminance, 'updateIlluminance', 'illuminance
module.exports.AQI = bind(PM2_5, 'updatePM2_5', 'aqi');
module.exports.AtmosphericPressure = bind(AtmosphericPressure, 'updateAtmosphericPressure', 'atmosphericPressure');
module.exports.PowerLoad = bind(PowerLoad, 'updatePowerLoad', 'powerLoad');
module.exports.PowerConsumed = bind(PowerConsumed, 'updatePowerConsumed', 'poweConsumed');
module.exports.PowerConsumed = bind(PowerConsumed, 'updatePowerConsumed', 'powerConsumed');
module.exports.WaterLevel = bind(WaterLevel, 'updateWaterLevel', 'waterLevel');

/**
* Setup sensor support for a device.
Expand Down
9 changes: 7 additions & 2 deletions lib/devices/humidifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ const MiioApi = require('../device');
const Power = require('./capabilities/power');
const Buzzer = require('./capabilities/buzzer');
const LEDBrightness = require('./capabilities/changeable-led-brightness');
const { Temperature, Humidity } = require('./capabilities/sensor');
const { Temperature, Humidity, WaterLevel } = require('./capabilities/sensor');

/**
* Abstraction over a Mi Humidifier.
*
*/
module.exports = class extends Humidifier
.with(MiioApi, Power, SwitchableMode,
AdjustableTargetHumidity, Temperature, Humidity,
AdjustableTargetHumidity, Temperature, Humidity, WaterLevel,
Buzzer, LEDBrightness)
{
static get type() {
Expand Down Expand Up @@ -49,6 +49,11 @@ module.exports = class extends Humidifier
});

this.defineProperty('humidity');

// Water Level (depth)
this.defineProperty('depth', {
name: 'waterLevel',
});

// Buzzer and beeping
this.defineProperty('buzzer', {
Expand Down
1 change: 1 addition & 0 deletions lib/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ module.exports = {
'zhimi.airpurifier.ma2': AirPurifier,

'zhimi.humidifier.v1': Humidifier,
'zhimi.humidifier.ca1': Humidifier,

'chuangmi.plug.m1': PowerPlug,
'chuangmi.plug.v1': require('./devices/chuangmi.plug.v1'),
Expand Down