Skip to content

Commit 961265a

Browse files
committed
chore: extend external converter/new device bot to detected already support zigbee model
1 parent 5b844ea commit 961265a

File tree

1 file changed

+35
-4
lines changed

1 file changed

+35
-4
lines changed

.github/workflows/new_device_external_converter_bot.yml

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ jobs:
4444
}
4545
}
4646
47+
// Checkout the repo and grep for the manufacturer name
48+
const execSync = require('child_process').execSync;
49+
execSync(`git clone https://github.com/Koenkk/zigbee-herdsman-converters.git zhc`, {stdio: 'ignore'});
50+
4751
// Check if Tuya manufacturer name is already supported.
4852
const tuyaManufacturerNameRe = /['"](_T\w+_(\w+))['"]/g;
4953
const tuyaManufacturerNames = Array.from(issue.body.matchAll(tuyaManufacturerNameRe), m => [m[1], m[2]]);
5054
if (tuyaManufacturerNames.length > 0) {
51-
// Checkout the repo and grep for the manufacturer name
52-
const execSync = require('child_process').execSync;
53-
execSync(`git clone https://github.com/Koenkk/zigbee-herdsman-converters.git zhc`, {stdio: 'ignore'});
54-
5555
for (const [fullName, partialName] of tuyaManufacturerNames) {
5656
const fullMatch = (() => { try { return execSync(`grep -r --include="*.ts" "${fullName}" zhc`, {encoding: 'utf8'}); } catch { return undefined; } })();
5757
if (fullMatch) {
@@ -98,6 +98,37 @@ jobs:
9898
}
9999
}
100100
101+
// Check if zigbee model is already supported.
102+
const zigbeeModelRe = /zigbeeModel: \[['"](.+)['"]\]/g;
103+
const zigbeeModels = Array.from(issue.body.matchAll(zigbeeModelRe), m => m[1]);
104+
if (zigbeeModels.length > 0) {
105+
for (const zigbeeModel of zigbeeModels) {
106+
const fullMatch = (() => { try { return execSync(`grep -r --include="*.ts" '"${zigbeeModel}"' zhc`, {encoding: 'utf8'}); } catch { return undefined; } })();
107+
if (fullMatch) {
108+
await github.rest.issues.createComment({
109+
owner: context.repo.owner,
110+
repo: context.repo.repo,
111+
issue_number: issue.number,
112+
body: [
113+
`👋 Hi there! The device with zigbee model \`${zigbeeModel}\` is already supported in the latest dev branch.`,
114+
"See this [guide](https://www.zigbee2mqtt.io/advanced/more/switch-to-dev-branch.html) on how to update, after updating you can remove your external converter.",
115+
"",
116+
"In case you created the external converter with the goal to extend or fix an issue with the out-of-the-box support, please submit a pull request.",
117+
"For instructions on how to create a pull request see the [docs](https://www.zigbee2mqtt.io/advanced/support-new-devices/01_support_new_devices.html#_4-create-a-pull-request).",
118+
"If you need help with the process, feel free to ask here and we'll be happy to assist."
119+
].join('\n')
120+
});
121+
await github.rest.issues.update({
122+
owner: context.repo.owner,
123+
repo: context.repo.repo,
124+
issue_number: issue.number,
125+
state: "closed",
126+
});
127+
return;
128+
}
129+
}
130+
}
131+
101132
// Create a request to pull request comment
102133
await github.rest.issues.createComment({
103134
owner: context.repo.owner,

0 commit comments

Comments
 (0)