matterbridge-zigbee2mqtt 2.5.0-dev.5 → 2.5.0-dev.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/entity.js CHANGED
@@ -134,6 +134,10 @@ export class ZigbeeEntity extends EventEmitter {
134
134
  this.updateAttributeIfChanged(this.bridgedDevice, undefined, WindowCovering.Cluster.id, 'currentPositionLiftPercent100ths', value * 100);
135
135
  }
136
136
  if (key === 'moving' && this.isDevice) {
137
+ const reversed = this.lastPayload.motor_direction === 'reversed';
138
+ if (reversed && (value === 'UP' || value === 'DOWN')) {
139
+ value = reversed ? (value === 'UP' ? 'DOWN' : 'UP') : value;
140
+ }
137
141
  if (value === 'UP') {
138
142
  const status = WindowCovering.MovementStatus.Opening;
139
143
  this.updateAttributeIfChanged(this.bridgedDevice, undefined, WindowCovering.Cluster.id, 'operationalStatus', { global: status, lift: status, tilt: status });
@@ -1193,21 +1197,24 @@ export class ZigbeeDevice extends ZigbeeEntity {
1193
1197
  });
1194
1198
  }
1195
1199
  if (zigbeeDevice.bridgedDevice.hasClusterServer(WindowCoveringCluster.id)) {
1200
+ const reversed = zigbeeDevice.lastPayload.motor_direction === 'reversed';
1201
+ if (reversed)
1202
+ zigbeeDevice.log.debug(`Device ${zigbeeDevice.ien}${device.friendly_name}${rs}${db} has reversed motor direction. Commands will be reversed.`);
1196
1203
  zigbeeDevice.bridgedDevice.addCommandHandler('upOrOpen', async () => {
1197
1204
  zigbeeDevice.log.debug(`Command upOrOpen called for ${zigbeeDevice.ien}${device.friendly_name}${rs}${db}`);
1198
- if (zigbeeDevice.isDevice && zigbeeDevice.propertyMap.has('position'))
1199
- await zigbeeDevice.bridgedDevice?.setAttribute(WindowCoveringCluster.id, 'targetPositionLiftPercent100ths', 0, zigbeeDevice.log);
1205
+ if (zigbeeDevice.propertyMap.has('position'))
1206
+ await zigbeeDevice.bridgedDevice?.setAttribute(WindowCoveringCluster.id, 'targetPositionLiftPercent100ths', reversed ? 10000 : 0, zigbeeDevice.log);
1200
1207
  else
1201
- await zigbeeDevice.bridgedDevice?.setWindowCoveringTargetAndCurrentPosition(0);
1202
- zigbeeDevice.publishCommand('upOrOpen', device.friendly_name, { state: 'OPEN' });
1208
+ await zigbeeDevice.bridgedDevice?.setWindowCoveringTargetAndCurrentPosition(reversed ? 10000 : 0);
1209
+ zigbeeDevice.publishCommand('upOrOpen', device.friendly_name, { state: reversed ? 'CLOSE' : 'OPEN' });
1203
1210
  });
1204
1211
  zigbeeDevice.bridgedDevice.addCommandHandler('downOrClose', async () => {
1205
1212
  zigbeeDevice.log.debug(`Command downOrClose called for ${zigbeeDevice.ien}${device.friendly_name}${rs}${db}`);
1206
- if (zigbeeDevice.isDevice && zigbeeDevice.propertyMap.has('position'))
1207
- await zigbeeDevice.bridgedDevice?.setAttribute(WindowCoveringCluster.id, 'targetPositionLiftPercent100ths', 10000, zigbeeDevice.log);
1213
+ if (zigbeeDevice.propertyMap.has('position'))
1214
+ await zigbeeDevice.bridgedDevice?.setAttribute(WindowCoveringCluster.id, 'targetPositionLiftPercent100ths', reversed ? 0 : 10000, zigbeeDevice.log);
1208
1215
  else
1209
- await zigbeeDevice.bridgedDevice?.setWindowCoveringTargetAndCurrentPosition(10000);
1210
- zigbeeDevice.publishCommand('downOrClose', device.friendly_name, { state: 'CLOSE' });
1216
+ await zigbeeDevice.bridgedDevice?.setWindowCoveringTargetAndCurrentPosition(reversed ? 0 : 10000);
1217
+ zigbeeDevice.publishCommand('downOrClose', device.friendly_name, { state: reversed ? 'OPEN' : 'CLOSE' });
1211
1218
  });
1212
1219
  zigbeeDevice.bridgedDevice.addCommandHandler('stopMotion', async () => {
1213
1220
  zigbeeDevice.log.debug(`Command stopMotion called for ${zigbeeDevice.ien}${device.friendly_name}${rs}${db}`);
@@ -1215,8 +1222,10 @@ export class ZigbeeDevice extends ZigbeeEntity {
1215
1222
  zigbeeDevice.publishCommand('stopMotion', device.friendly_name, { state: 'STOP' });
1216
1223
  });
1217
1224
  zigbeeDevice.bridgedDevice.addCommandHandler('goToLiftPercentage', async ({ request: { liftPercent100thsValue } }) => {
1225
+ if (reversed)
1226
+ liftPercent100thsValue = 10000 - liftPercent100thsValue;
1218
1227
  zigbeeDevice.log.debug(`Command goToLiftPercentage called for ${zigbeeDevice.ien}${device.friendly_name}${rs}${db} request liftPercent100thsValue: ${liftPercent100thsValue}`);
1219
- if (zigbeeDevice.isDevice && zigbeeDevice.propertyMap.has('position'))
1228
+ if (zigbeeDevice.propertyMap.has('position'))
1220
1229
  await zigbeeDevice.bridgedDevice?.setAttribute(WindowCoveringCluster.id, 'targetPositionLiftPercent100ths', liftPercent100thsValue, zigbeeDevice.log);
1221
1230
  else
1222
1231
  await zigbeeDevice.bridgedDevice?.setWindowCoveringTargetAndCurrentPosition(liftPercent100thsValue);
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "matterbridge-zigbee2mqtt",
3
- "version": "2.5.0-dev.5",
3
+ "version": "2.5.0-dev.7",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "matterbridge-zigbee2mqtt",
9
- "version": "2.5.0-dev.5",
9
+ "version": "2.5.0-dev.7",
10
10
  "license": "Apache-2.0",
11
11
  "dependencies": {
12
12
  "moment": "2.30.1",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "matterbridge-zigbee2mqtt",
3
- "version": "2.5.0-dev.5",
3
+ "version": "2.5.0-dev.7",
4
4
  "description": "Matterbridge zigbee2mqtt plugin",
5
5
  "author": "https://github.com/Luligu",
6
6
  "license": "Apache-2.0",