Skip to content
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
16 changes: 16 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,7 @@ export declare const DEVICE_FEATURE_CATEGORIES: {
readonly BATTERY_STORAGE: 'battery-storage';
readonly BUTTON: 'button';
readonly CAMERA: 'camera';
readonly CHARGING_STATION: 'charging-station';
readonly CUBE: 'cube';
readonly CURRENCY: 'currency';
readonly CO_SENSOR: 'co-sensor';
Expand Down Expand Up @@ -651,6 +652,7 @@ export declare const DEVICE_FEATURE_CATEGORIES: {
readonly VACUUM_CLEANER: 'vacuum-cleaner';
readonly TEXT: 'text';
readonly INPUT: 'input';
readonly WATER_HEATER: 'water-heater';
readonly WATER_VALVE: 'water-valve';
};

Expand Down Expand Up @@ -697,6 +699,10 @@ export declare const DEVICE_FEATURE_TYPES: {
readonly CAMERA: {
readonly IMAGE: 'image';
};
readonly CHARGING_STATION: {
readonly CONNECTOR_STATUS: 'connector-status';
readonly CHARGING_STATE: 'charging-state';
};
readonly DOORBELL: {
readonly RING: 'ring';
};
Expand Down Expand Up @@ -938,6 +944,8 @@ export declare const DEVICE_FEATURE_TYPES: {
};
readonly THERMOSTAT: {
readonly TARGET_TEMPERATURE: 'target-temperature';
readonly MODE: 'mode';
readonly OPERATING_STATE: 'operating-state';
};
readonly AIRQUALITY_SENSOR: {
readonly AQI: 'aqi';
Expand All @@ -962,6 +970,14 @@ export declare const DEVICE_FEATURE_TYPES: {
readonly LIQUID_LEVEL_PERCENT: 'liquid-level-percent';
readonly LIQUID_DEPTH: 'liquid-depth';
};
readonly WATER_HEATER: {
readonly BINARY: 'binary';
readonly MODE: 'mode';
readonly TARGET_TEMPERATURE: 'target-temperature';
readonly REMAINING_HOT_WATER: 'remaining-hot-water';
readonly HEATING: 'heating';
readonly BOOST: 'boost';
};
readonly WATER_VALVE: {
readonly CURRENT_DEVICE_STATUS: 'current-device-status';
readonly FLOW: 'flow';
Expand Down
26 changes: 26 additions & 0 deletions lib/device-constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const DEVICE_FEATURE_CATEGORIES = {
BATTERY_STORAGE: 'battery-storage',
BUTTON: 'button',
CAMERA: 'camera',
CHARGING_STATION: 'charging-station',
CUBE: 'cube',
CURRENCY: 'currency',
CO_SENSOR: 'co-sensor',
Expand Down Expand Up @@ -88,6 +89,7 @@ const DEVICE_FEATURE_CATEGORIES = {
VACUUM_CLEANER: 'vacuum-cleaner',
TEXT: 'text',
INPUT: 'input',
WATER_HEATER: 'water-heater',
WATER_VALVE: 'water-valve',
};

Expand Down Expand Up @@ -133,6 +135,10 @@ const DEVICE_FEATURE_TYPES = {
CAMERA: {
IMAGE: 'image',
},
CHARGING_STATION: {
CONNECTOR_STATUS: 'connector-status',
CHARGING_STATE: 'charging-state',
},
DOORBELL: {
RING: 'ring',
},
Expand Down Expand Up @@ -374,6 +380,8 @@ const DEVICE_FEATURE_TYPES = {
},
THERMOSTAT: {
TARGET_TEMPERATURE: 'target-temperature',
MODE: 'mode',
OPERATING_STATE: 'operating-state',
},
AIRQUALITY_SENSOR: {
AQI: 'aqi',
Expand All @@ -399,6 +407,24 @@ const DEVICE_FEATURE_TYPES = {
LIQUID_LEVEL_PERCENT: 'liquid-level-percent',
LIQUID_DEPTH: 'liquid-depth',
},
// Domestic hot water appliances: electric storage tanks, heat-pump water heaters,
// gas-fired water heaters. Scope is limited to producing and storing hot water.
// Boundary with neighboring categories: the water temperature measured in the tank
// is a temperature-sensor/decimal feature, electrical consumption is energy-sensor,
// and room heating stays in heater/thermostat — a water heater device carries those
// features alongside its water-heater ones.
// Value conventions: all commands are non-negative integers; `mode` is an index into
// WATER_HEATER_MODE, `binary`/`heating`/`boost` are 0/1. Boosting exists both as a
// mode value and as the `boost` command: an integration maps whichever form its
// appliance natively reports, never both for the same function.
WATER_HEATER: {
BINARY: 'binary', // appliance on/off (command)
MODE: 'mode', // operating mode, WATER_HEATER_MODE (command)
TARGET_TEMPERATURE: 'target-temperature', // hot water setpoint (command)
REMAINING_HOT_WATER: 'remaining-hot-water', // hot water available, % or litres V40 (sensor)
HEATING: 'heating', // actively heating water or not (sensor)
BOOST: 'boost', // forced heating on/off (command)
},
WATER_VALVE: {
// Types used by the SONOFF SWV in Zigbee2mqtt
CURRENT_DEVICE_STATUS: 'current-device-status',
Expand Down
8 changes: 8 additions & 0 deletions test/device-constants.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ describe('device constants', () => {
assert.equal(DEVICE_FEATURE_CATEGORIES.BATTERY_STORAGE, 'battery-storage');
assert.equal(DEVICE_FEATURE_CATEGORIES.WATER_VALVE, 'water-valve');
assert.equal(DEVICE_FEATURE_CATEGORIES.DOORBELL, 'doorbell');
assert.equal(DEVICE_FEATURE_CATEGORIES.CHARGING_STATION, 'charging-station');
assert.equal(DEVICE_FEATURE_CATEGORIES.WATER_HEATER, 'water-heater');
});

it('should expose the canonical type strings, grouped by category', () => {
Expand All @@ -59,6 +61,12 @@ describe('device constants', () => {
assert.equal(DEVICE_FEATURE_TYPES.AIR_CONDITIONING.FAN_SPEED, 'fan-speed');
assert.equal(DEVICE_FEATURE_TYPES.AIR_CONDITIONING.SWING_HORIZONTAL, 'swing-horizontal');
assert.equal(DEVICE_FEATURE_TYPES.AIR_CONDITIONING.SWING_VERTICAL, 'swing-vertical');
assert.equal(DEVICE_FEATURE_TYPES.CHARGING_STATION.CONNECTOR_STATUS, 'connector-status');
assert.equal(DEVICE_FEATURE_TYPES.CHARGING_STATION.CHARGING_STATE, 'charging-state');
assert.equal(DEVICE_FEATURE_TYPES.THERMOSTAT.MODE, 'mode');
assert.equal(DEVICE_FEATURE_TYPES.THERMOSTAT.OPERATING_STATE, 'operating-state');
assert.equal(DEVICE_FEATURE_TYPES.WATER_HEATER.REMAINING_HOT_WATER, 'remaining-hot-water');
assert.equal(DEVICE_FEATURE_TYPES.WATER_HEATER.BOOST, 'boost');
});

it('should expose the canonical unit strings', () => {
Expand Down
Loading