Skip to content

Commit

Permalink
Merge pull request #66 from Luligu/dev
Browse files Browse the repository at this point in the history
Release 2.1.16
  • Loading branch information
Luligu authored Sep 4, 2024
2 parents f2c6005 + fc7d6f2 commit 54f5b8a
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 16 deletions.
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,18 @@ All notable changes to this project will be documented in this file.

### Breaking Changes

- Unless you are using docker (in that case all is already updated), please update Matterbridge to 1.5.3 to work with matterbridge-zigbee2mqtt 2.1.15. This is a one time issue due to the update to matter.js 0.10.0.
- Unless you are using docker (in that case all is already updated), please update Matterbridge to 1.5.3 to work with matterbridge-zigbee2mqtt 2.1.16. This is a one time issue due to the update to matter.js 0.10.0.

## [2.1.16] - 2024-09-04

### Changed

- [package]: Final update to matter.js 0.10.0.
- [package]: Updated dependencies.

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

## [2.1.15] - 2024-09-03

Expand Down
81 changes: 81 additions & 0 deletions create-release.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/* eslint-disable no-console */

/*
Add the following scripts to package.json file:
"prepublishOnly": "npm run lint && npm run test && npm run cleanBuild",
"npmPublish": "npm publish",
"gitPublish": "npm run lint && npm run test && npm run cleanBuild && node create-release.js",
"preversion": "npm run lint && npm run test && npm run cleanBuild",
"postversion": "git push && git push --tags && node create-release.js",
"version:patch": "npm version patch",
"version:minor": "npm version minor",
"version:major": "npm version major",
*/

import { execSync } from 'child_process';
import { readFileSync, writeFileSync, unlinkSync } from 'fs';
import path from 'path';
import readline from 'readline';

// Get the latest tag
let tag = execSync('git describe --tags --abbrev=0').toString().trim();
if (tag.startsWith('v')) {
tag = tag.substring(1);
}

// Read the changelog file
const changelogPath = path.join(process.cwd(), 'CHANGELOG.md');
const changelog = readFileSync(changelogPath, 'utf8');

// Extract the relevant section from the changelog
const changelogSection = extractChangelogSection(changelog, tag);

const title = `Release ${tag}`;
const notes = `Release notes for version ${tag}\n\n## [${tag}] ${changelogSection}`;

// Log the release details
console.log(`Creating release ${tag} with the following details:\nTitle:\n${title}\nNotes:\n${notes}`);

// Write the release notes to a temporary file
const notesFilePath = path.join(process.cwd(), 'release-notes.md');
writeFileSync(notesFilePath, notes);

// Wait for user input before proceeding
await pressAnyKey();

// Create the release using the temporary file
execSync(`gh release create ${tag} -t "${title}" -F "${notesFilePath}"`, { stdio: 'inherit' });

// Clean up the temporary file
unlinkSync(notesFilePath);

/**
* Extracts the relevant section from the changelog for the given tag.
* Assumes that each version section in the changelog starts with a heading like "## [tag]".
* @param {string} changelog - The content of the changelog file.
* @param {string} tag - The tag for which to extract the changelog section.
* @returns {string} - The extracted changelog section.
*/
function extractChangelogSection(changelog, tag) {
const regex = new RegExp(`## \\[${tag}\\](.*?)(## \\[|$)`, 's');
const match = changelog.match(regex);
return match ? match[1].trim() : 'No changelog entry found for this version.';
}

/**
* Waits for the user to press any key.
* @returns {Promise<void>}
*/
function pressAnyKey() {
return new Promise((resolve) => {
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});

rl.question('Press any key to continue...', () => {
rl.close();
resolve();
});
});
}
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "matterbridge-zigbee2mqtt",
"version": "2.1.15",
"version": "2.1.16",
"description": "Matterbridge zigbee2mqtt plugin",
"author": "https://github.com/Luligu",
"license": "Apache-2.0",
Expand Down Expand Up @@ -92,10 +92,10 @@
"@eslint/js": "^9.9.1",
"@types/eslint__js": "^8.42.3",
"@types/jest": "29.5.12",
"@types/node": "22.5.2",
"@types/node": "22.5.3",
"eslint": "^9.9.1",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-jest": "28.8.2",
"eslint-plugin-jest": "28.8.3",
"eslint-plugin-prettier": "5.2.1",
"jest": "29.7.0",
"prettier": "3.3.3",
Expand Down
15 changes: 11 additions & 4 deletions src/entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,15 @@ import {
AttributeInitialValues,
powerSource,
bridgedNode,
AirQuality,
TotalVolatileOrganicCompoundsConcentrationMeasurement,
CarbonDioxideConcentrationMeasurement,
CarbonMonoxideConcentrationMeasurement,
FormaldehydeConcentrationMeasurement,
Pm1ConcentrationMeasurement,
Pm25ConcentrationMeasurement,
Pm10ConcentrationMeasurement,
} from 'matterbridge';
import { AirQuality, TvocMeasurement, CarbonDioxideConcentrationMeasurement, CarbonMonoxideConcentrationMeasurement, FormaldehydeConcentrationMeasurement, Pm1ConcentrationMeasurement, Pm25ConcentrationMeasurement, Pm10ConcentrationMeasurement } from 'matterbridge/cluster';
import { EveHistory } from 'matterbridge/history';
import { AnsiLogger, TimestampFormat, gn, dn, ign, idn, rs, db, wr, debugStringify, hk, zb, or, nf, LogLevel } from 'matterbridge/logger';
import { deepCopy, deepEqual } from 'matterbridge/utils';
Expand Down Expand Up @@ -529,7 +536,7 @@ export const z2ms: ZigbeeToMatter[] = [
{ type: '', name: 'soil_moisture', property: 'soil_moisture', deviceType: DeviceTypes.HUMIDITY_SENSOR, cluster: RelativeHumidityMeasurement.Cluster.id, attribute: 'measuredValue', converter: (value) => { return Math.round(value * 100) } },
{ type: '', name: 'pressure', property: 'pressure', deviceType: DeviceTypes.PRESSURE_SENSOR, cluster: PressureMeasurement.Cluster.id, attribute: 'measuredValue', converter: (value) => { return value } },
{ type: '', name: 'air_quality', property: 'air_quality', deviceType: airQualitySensor, cluster: AirQuality.Cluster.id, attribute: 'airQuality', valueLookup: ['unknown', 'excellent', 'good', 'moderate', 'poor', 'unhealthy', 'out_of_range'] },
{ type: '', name: 'voc', property: 'voc', deviceType: airQualitySensor, cluster: TvocMeasurement.Cluster.id, attribute: 'measuredValue', converter: (value) => { return Math.min(65535, value) } },
{ type: '', name: 'voc', property: 'voc', deviceType: airQualitySensor, cluster: TotalVolatileOrganicCompoundsConcentrationMeasurement.Cluster.id, attribute: 'measuredValue', converter: (value) => { return Math.min(65535, value) } },

{ type: '', name: 'co', property: 'co', deviceType: airQualitySensor, cluster: CarbonMonoxideConcentrationMeasurement.Cluster.id, attribute: 'measuredValue', converter: (value) => { return Math.round(value) } },
{ type: '', name: 'co2', property: 'co2', deviceType: airQualitySensor, cluster: CarbonDioxideConcentrationMeasurement.Cluster.id, attribute: 'measuredValue', converter: (value) => { return Math.round(value) } },
Expand Down Expand Up @@ -874,12 +881,12 @@ export class ZigbeeDevice extends ZigbeeEntity {
if (this.bridgedDevice.hasClusterServer(Thermostat.Complete)) {
this.bridgedDevice.addCommandHandler('setpointRaiseLower', async ({ request: request, attributes: attributes }) => {
this.log.debug(`Command setpointRaiseLower called for ${this.ien}${device.friendly_name}${rs}${db}`, request);
if (request.mode === /* Thermostat.SetpointRaiseLowerMode.Heat*/ 0 && attributes.occupiedHeatingSetpoint) {
if (request.mode === Thermostat.SetpointRaiseLowerMode.Heat && attributes.occupiedHeatingSetpoint) {
const setpoint = Math.round(attributes.occupiedHeatingSetpoint.getLocal() / 100 + request.amount / 10);
this.publishCommand('OccupiedHeatingSetpoint', device.friendly_name, { current_heating_setpoint: setpoint });
this.log.debug('Command setpointRaiseLower sent:', debugStringify({ current_heating_setpoint: setpoint }));
}
if (request.mode === /* Thermostat.SetpointRaiseLowerMode.Cool*/ 1 && attributes.occupiedCoolingSetpoint) {
if (request.mode === Thermostat.SetpointRaiseLowerMode.Cool && attributes.occupiedCoolingSetpoint) {
const setpoint = Math.round(attributes.occupiedCoolingSetpoint.getLocal() / 100 + request.amount / 10);
this.publishCommand('OccupiedCoolingSetpoint', device.friendly_name, { current_cooling_setpoint: setpoint });
this.log.debug('Command setpointRaiseLower sent:', debugStringify({ current_cooling_setpoint: setpoint }));
Expand Down

0 comments on commit 54f5b8a

Please sign in to comment.