Skip to content

Commit

Permalink
Merge pull request #37 from Luligu/dev
Browse files Browse the repository at this point in the history
Release 2.1.5
  • Loading branch information
Luligu committed Jul 2, 2024
2 parents c1cb887 + e79dc08 commit c7a5131
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ If you like this project and find it useful, please consider giving it a star on

All notable changes to this project will be documented in this file.

## [2.1.5] - 2024-07-01

### Changed

- [zigbee]: Fixed WindowCovering.targetPositionLiftPercent100ths update.
- [z2m]: Added transition to ColorControl if the zigbee device supports it and the controller sends it. You can disable this globally adding transition to the featureBlackList or only for the single device adding transition to the deviceFeatureBlackList. (Thanks Stefan Schweiger).

<a href="https://www.buymeacoffee.com/luligugithub">
<img src="./yellow-button.png" alt="Buy me a coffee" width="120">
</a>

## [2.1.4] - 2024-06-30

### Changed
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "matterbridge-zigbee2mqtt",
"version": "2.1.4",
"version": "2.1.5",
"description": "Matterbridge zigbee2mqtt plugin",
"author": "https://github.com/Luligu",
"license": "Apache-2.0",
Expand Down
18 changes: 14 additions & 4 deletions src/entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,13 +246,15 @@ export class ZigbeeEntity extends EventEmitter {
/* WindowCovering */
if (key === 'position') {
this.updateAttributeIfChanged(this.bridgedDevice, undefined, WindowCovering.Cluster.id, 'currentPositionLiftPercent100ths', typeof value === 'number' ? 10000 - value * 100 : 0);
this.updateAttributeIfChanged(this.bridgedDevice, undefined, WindowCovering.Cluster.id, 'targetPositionLiftPercent100ths', typeof value === 'number' ? 10000 - value * 100 : 0);
}
if (key === 'moving') {
const status = value === 'UP' ? WindowCovering.MovementStatus.Opening : value === 'DOWN' ? WindowCovering.MovementStatus.Closing : WindowCovering.MovementStatus.Stopped;
this.updateAttributeIfChanged(this.bridgedDevice, undefined, WindowCovering.Cluster.id, 'operationalStatus', { global: status, lift: status, tilt: status });
if (value === 'STOP') {
const position = this.bridgedDevice.getClusterServerById(WindowCovering.Cluster.id)?.getCurrentPositionLiftPercent100thsAttribute();
this.updateAttributeIfChanged(this.bridgedDevice, undefined, WindowCovering.Cluster.id, 'currentPositionLiftPercent100ths', position);
this.updateAttributeIfChanged(this.bridgedDevice, undefined, WindowCovering.Cluster.id, 'targetPositionLiftPercent100ths', position);
}
}
/* ColorControl ColorTemperatureMired */
Expand Down Expand Up @@ -770,7 +772,9 @@ export class ZigbeeDevice extends ZigbeeEntity {
this.log.debug(`Command moveToColorTemperature called for ${this.ien}${device.friendly_name}${rs}${db} request: ${request.colorTemperatureMireds} attributes: ${attributes.colorTemperatureMireds?.getLocal()} colorMode ${attributes.colorMode.getLocal()}`);
this.log.debug(`Command moveToColorTemperature called for ${this.ien}${device.friendly_name}${rs}${db} colorMode`, attributes.colorMode.getLocal());
attributes.colorMode.setLocal(ColorControl.ColorMode.ColorTemperatureMireds);
this.publishCommand('moveToColorTemperature', device.friendly_name, { color_temp: request.colorTemperatureMireds });
const payload: Payload = { color_temp: request.colorTemperatureMireds };
if (this.transition && request.transitionTime && request.transitionTime / 10 >= 1) payload['transition'] = Math.round(request.transitionTime / 10);
this.publishCommand('moveToColorTemperature', device.friendly_name, payload);
});
}
if (this.bridgedDevice.hasClusterServer(ColorControl.Complete) && this.bridgedDevice.getClusterServer(ColorControlCluster)?.isAttributeSupportedByName('currentHue')) {
Expand All @@ -784,7 +788,9 @@ export class ZigbeeDevice extends ZigbeeEntity {
lastRequestTimeout = setTimeout(() => {
clearTimeout(lastRequestTimeout);
const rgb = color.hslColorToRgbColor((request.hue / 254) * 360, (lastRequestedSaturation / 254) * 100, 50);
this.publishCommand('moveToHue', device.friendly_name, { color: { r: rgb.r, g: rgb.g, b: rgb.b } });
const payload: Payload = { color: { r: rgb.r, g: rgb.g, b: rgb.b } };
if (this.transition && request.transitionTime && request.transitionTime / 10 >= 1) payload['transition'] = Math.round(request.transitionTime / 10);
this.publishCommand('moveToHue', device.friendly_name, payload);
}, 500);
});
this.bridgedDevice.addCommandHandler('moveToSaturation', async ({ request: request, attributes: attributes }) => {
Expand All @@ -794,7 +800,9 @@ export class ZigbeeDevice extends ZigbeeEntity {
lastRequestTimeout = setTimeout(() => {
clearTimeout(lastRequestTimeout);
const rgb = color.hslColorToRgbColor((lastRequestedHue / 254) * 360, (request.saturation / 254) * 100, 50);
this.publishCommand('moveToSaturation', device.friendly_name, { color: { r: rgb.r, g: rgb.g, b: rgb.b } });
const payload: Payload = { color: { r: rgb.r, g: rgb.g, b: rgb.b } };
if (this.transition && request.transitionTime && request.transitionTime / 10 >= 1) payload['transition'] = Math.round(request.transitionTime / 10);
this.publishCommand('moveToSaturation', device.friendly_name, payload);
}, 500);
});
this.bridgedDevice.addCommandHandler('moveToHueAndSaturation', async ({ request: request, attributes: attributes }) => {
Expand All @@ -803,7 +811,9 @@ export class ZigbeeDevice extends ZigbeeEntity {
);
attributes.colorMode.setLocal(ColorControl.ColorMode.CurrentHueAndCurrentSaturation);
const rgb = color.hslColorToRgbColor((request.hue / 254) * 360, (request.saturation / 254) * 100, 50);
this.publishCommand('moveToHueAndSaturation', device.friendly_name, { color: { r: rgb.r, g: rgb.g, b: rgb.b } });
const payload: Payload = { color: { r: rgb.r, g: rgb.g, b: rgb.b } };
if (this.transition && request.transitionTime && request.transitionTime / 10 >= 1) payload['transition'] = Math.round(request.transitionTime / 10);
this.publishCommand('moveToHueAndSaturation', device.friendly_name, payload);
});
}
if (this.bridgedDevice.hasClusterServer(WindowCovering.Complete)) {
Expand Down

0 comments on commit c7a5131

Please sign in to comment.