Skip to content

Commit

Permalink
Zigbee2mqtt: Add pilot wire mode (#2140)
Browse files Browse the repository at this point in the history
  • Loading branch information
William-De71 authored Oct 25, 2024
1 parent 749cfe1 commit 35864b5
Show file tree
Hide file tree
Showing 9 changed files with 128 additions and 0 deletions.
2 changes: 2 additions & 0 deletions front/src/components/boxs/device-in-room/DeviceRow.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import NumberDeviceFeature from './device-features/NumberDeviceFeature';
import CoverDeviceFeature from './device-features/CoverDeviceFeature';
import ThermostatDeviceFeature from './device-features/ThermostatDeviceFeature';
import AirConditioningModeDeviceFeature from './device-features/AirConditioningModeDeviceFeature';
import PilotWireModeDeviceFeature from './device-features/PilotWireModeDeviceFeature';
import LMHVolumeDeviceFeature from './device-features/LMHVolumeDeviceFeature';

const ROW_TYPE_BY_FEATURE_TYPE = {
Expand All @@ -29,6 +30,7 @@ const ROW_TYPE_BY_FEATURE_TYPE = {
[DEVICE_FEATURE_TYPES.THERMOSTAT.TARGET_TEMPERATURE]: ThermostatDeviceFeature,
[DEVICE_FEATURE_TYPES.AIR_CONDITIONING.MODE]: AirConditioningModeDeviceFeature,
[DEVICE_FEATURE_TYPES.AIR_CONDITIONING.TARGET_TEMPERATURE]: ThermostatDeviceFeature,
[DEVICE_FEATURE_TYPES.HEATER.PILOT_WIRE_MODE]: PilotWireModeDeviceFeature,
[DEVICE_FEATURE_TYPES.SIREN.LMH_VOLUME]: LMHVolumeDeviceFeature,
[DEVICE_FEATURE_TYPES.SIREN.MELODY]: NumberDeviceFeature,
[DEVICE_FEATURE_TYPES.DURATION.DECIMAL]: MultiLevelDeviceFeature
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const SUPPORTED_FEATURE_TYPES = [
DEVICE_FEATURE_TYPES.THERMOSTAT.TARGET_TEMPERATURE,
DEVICE_FEATURE_TYPES.AIR_CONDITIONING.MODE,
DEVICE_FEATURE_TYPES.AIR_CONDITIONING.TARGET_TEMPERATURE,
DEVICE_FEATURE_TYPES.HEATER.PILOT_WIRE_MODE,
DEVICE_FEATURE_TYPES.SIREN.LMH_VOLUME,
DEVICE_FEATURE_TYPES.SIREN.MELODY,
DEVICE_FEATURE_TYPES.DURATION.DECIMAL
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import get from 'get-value';
import { Text } from 'preact-i18n';

import { DeviceFeatureCategoriesIcon } from '../../../../utils/consts';
import { PILOT_WIRE_MODE } from '../../../../../../server/utils/constants';

const PilotWireModeDeviceFeature = ({ children, ...props }) => {
const { deviceFeature } = props;
const { category, type } = deviceFeature;

function updateValue(e) {
props.updateValueWithDebounce(deviceFeature, e.currentTarget.value);
}

return (
<tr>
<td>
<i class={`fe fe-${get(DeviceFeatureCategoriesIcon, `${category}.${type}`, { default: 'sliders' })}`} />
</td>
<td>{props.rowName}</td>

<td class="py-0">
<div class="justify-content-end">
<div class="form-group mb-0">
<select value={props.deviceFeature.last_value} onChange={updateValue} class="form-control form-control-sm">
<option value={PILOT_WIRE_MODE.OFF}>
<Text id={`deviceFeatureAction.category.${category}.${type}.off`} />
</option>
<option value={PILOT_WIRE_MODE.FROST_PROTECTION}>
<Text id={`deviceFeatureAction.category.${category}.${type}.frost-protection`} />
</option>
<option value={PILOT_WIRE_MODE.ECO}>
<Text id={`deviceFeatureAction.category.${category}.${type}.eco`} />
</option>
<option value={PILOT_WIRE_MODE.COMFORT_2}>
<Text id={`deviceFeatureAction.category.${category}.${type}.comfort_-2`} />
</option>
<option value={PILOT_WIRE_MODE.COMFORT_1}>
<Text id={`deviceFeatureAction.category.${category}.${type}.comfort_-1`} />
</option>
<option value={PILOT_WIRE_MODE.COMFORT}>
<Text id={`deviceFeatureAction.category.${category}.${type}.comfort`} />
</option>
</select>
</div>
</div>
</td>
</tr>
);
};

export default PilotWireModeDeviceFeature;
14 changes: 14 additions & 0 deletions front/src/config/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -2758,6 +2758,16 @@
"heating": "Heizen"
}
},
"heater": {
"pilot-wire-mode": {
"comfort": "Komfort",
"eco": "Öko",
"off": "Aus",
"frost-protection": "Frostschutz",
"comfort_-1": "Komfort -1°C",
"comfort_-2": "Komfort -2°C"
}
},
"siren": {
"lmh_volume": {
"low": "Niedrig",
Expand Down Expand Up @@ -3032,6 +3042,10 @@
"mode": "Modus",
"target-temperature": "Temperatur"
},
"heater": {
"shortCategoryName": "Heizung",
"pilot-wire-mode": "Modus"
},
"tamper": {
"shortCategoryName": "Manipulation",
"binary": "Manipulation (ja/nein)"
Expand Down
14 changes: 14 additions & 0 deletions front/src/config/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2758,6 +2758,16 @@
"heating": "Heat"
}
},
"heater": {
"pilot-wire-mode": {
"comfort": "Comfort",
"eco": "Eco",
"off": "Off",
"frost-protection": "Frost Protection",
"comfort_-1": "Comfort -1°C",
"comfort_-2": "Comfort -2°C"
}
},
"siren": {
"lmh_volume": {
"low": "Low",
Expand Down Expand Up @@ -3032,6 +3042,10 @@
"mode": "Mode",
"target-temperature": "Temperature"
},
"heater": {
"shortCategoryName": "Heating",
"pilot-wire-mode": "Mode"
},
"tamper": {
"shortCategoryName": "Tamper",
"binary": "Tamper (yes/no)"
Expand Down
14 changes: 14 additions & 0 deletions front/src/config/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -2758,6 +2758,16 @@
"heating": "Chauffage"
}
},
"heater": {
"pilot-wire-mode": {
"comfort": "Confort",
"eco": "Eco",
"off": "Off",
"frost-protection": "Hors Gel",
"comfort_-1": "Confort -1°C",
"comfort_-2": "Confort -2°C"
}
},
"siren": {
"lmh_volume": {
"low": "Faible",
Expand Down Expand Up @@ -3032,6 +3042,10 @@
"mode": "Mode",
"target-temperature": "Température"
},
"heater": {
"shortCategoryName": "Chauffage",
"pilot-wire-mode": "Mode"
},
"tamper": {
"shortCategoryName": "Détecteur de sabotage",
"binary": "Détection sabotage (Oui/Non)"
Expand Down
3 changes: 3 additions & 0 deletions front/src/utils/consts.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ export const DeviceFeatureCategoriesIcon = {
[DEVICE_FEATURE_TYPES.AIR_CONDITIONING.MODE]: 'settings',
[DEVICE_FEATURE_TYPES.AIR_CONDITIONING.TARGET_TEMPERATURE]: 'thermometer'
},
[DEVICE_FEATURE_CATEGORIES.HEATER]: {
[DEVICE_FEATURE_TYPES.HEATER.PILOT_WIRE_MODE]: 'thermometer'
},
[DEVICE_FEATURE_CATEGORIES.TELEVISION]: {
[DEVICE_FEATURE_TYPES.TELEVISION.BINARY]: 'power',
[DEVICE_FEATURE_TYPES.TELEVISION.SOURCE]: 'airplay',
Expand Down
14 changes: 14 additions & 0 deletions server/services/zigbee2mqtt/exposes/enumType.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const {
BUTTON_STATUS,
COVER_STATE,
SIREN_LMH_VOLUME,
PILOT_WIRE_MODE,
} = require('../../../utils/constants');

const WRITE_VALUE_MAPPING = {};
Expand Down Expand Up @@ -85,6 +86,13 @@ addMapping('volume', SIREN_LMH_VOLUME.LOW, 'low');
addMapping('volume', SIREN_LMH_VOLUME.MEDIUM, 'medium');
addMapping('volume', SIREN_LMH_VOLUME.HIGH, 'high');

addMapping('pilot_wire_mode', PILOT_WIRE_MODE.COMFORT, 'comfort');
addMapping('pilot_wire_mode', PILOT_WIRE_MODE.ECO, 'eco');
addMapping('pilot_wire_mode', PILOT_WIRE_MODE.FROST_PROTECTION, 'frost_protection');
addMapping('pilot_wire_mode', PILOT_WIRE_MODE.OFF, 'off');
addMapping('pilot_wire_mode', PILOT_WIRE_MODE.COMFORT_1, 'comfort_-1');
addMapping('pilot_wire_mode', PILOT_WIRE_MODE.COMFORT_2, 'comfort_-2');

module.exports = {
type: 'enum',
writeValue: (expose, value) => {
Expand Down Expand Up @@ -143,6 +151,12 @@ module.exports = {
type: DEVICE_FEATURE_TYPES.SIREN.MELODY,
},
},
pilot_wire_mode: {
feature: {
category: DEVICE_FEATURE_CATEGORIES.HEATER,
type: DEVICE_FEATURE_TYPES.HEATER.PILOT_WIRE_MODE,
},
},
},
getFeatureIndexes: (values = []) => {
const indexes = values
Expand Down
14 changes: 14 additions & 0 deletions server/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@ const AC_MODE = {
FAN: 4,
};

const PILOT_WIRE_MODE = {
OFF: 0,
FROST_PROTECTION: 1,
ECO: 2,
COMFORT_1: 3,
COMFORT_2: 4,
COMFORT: 5,
};

const MUSIC_PLAYBACK_STATE = {
PLAYING: 1,
PAUSED: 0,
Expand Down Expand Up @@ -443,6 +452,7 @@ const DEVICE_FEATURE_CATEGORIES = {
DISTANCE_SENSOR: 'distance-sensor',
DURATION: 'duration',
ENERGY_SENSOR: 'energy-sensor',
HEATER: 'heater',
HUMIDITY_SENSOR: 'humidity-sensor',
LEAK_SENSOR: 'leak-sensor',
LIGHT: 'light',
Expand Down Expand Up @@ -551,6 +561,9 @@ const DEVICE_FEATURE_TYPES = {
MODE: 'mode',
TARGET_TEMPERATURE: 'target-temperature',
},
HEATER: {
PILOT_WIRE_MODE: 'pilot-wire-mode',
},
SURFACE: {
DECIMAL: 'decimal',
},
Expand Down Expand Up @@ -1142,6 +1155,7 @@ module.exports.BUTTON_STATUS = BUTTON_STATUS;
module.exports.COVER_STATE = COVER_STATE;
module.exports.SIREN_LMH_VOLUME = SIREN_LMH_VOLUME;
module.exports.AC_MODE = AC_MODE;
module.exports.PILOT_WIRE_MODE = PILOT_WIRE_MODE;
module.exports.EVENTS = EVENTS;
module.exports.LIFE_EVENTS = LIFE_EVENTS;
module.exports.STATES = STATES;
Expand Down

0 comments on commit 35864b5

Please sign in to comment.