Merge pull request #41 from FuzzysTodd/SA#42
Merged
Conversation
There was a problem hiding this comment.
Copilot wasn't able to review any files in this pull request.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
FuzzysTodd
commented
Dec 3, 2025
FuzzysTodd
left a comment
Owner
Author
There was a problem hiding this comment.
@FuzzysTodd make this bot for scripting scripts/issueBot.mjs scripts/issueBot.mjs import {execSync} from "node:child_process";Add a comment on lines R1 to R13Add diff commentMarkdown input: edit mode selected.WritePreviewHeadingBoldItalicQuoteCodeLinkUnordered listNumbered listTask listMentionReferenceSaved repliesAdd FilesPaste, drop, or click to add filesCancelCommentexport async function newDeviceSupport(github, core, context, zhcDir) { const issue = context.payload.issue; // Hide previous bot comments const comments = await github.rest.issues.listComments({ owner: context.repo.owner, repo: context.repo.repo, issue_number: issue.number, }); for (const comment of comments.data) { if (comment.user.type === "Bot" && comment.user.login === "github-actions[bot]") { await github.graphql(mutation { minimizeComment(input: {subjectId: "${comment.node_id}", classifier: OUTDATED}) { clientMutationId }}); } } // Check if Tuya manufacturer name is already supported. const tuyaManufacturerNameRe = /'"['"]/g; const tuyaManufacturerNames = Array.from(issue.body.matchAll(tuyaManufacturerNameRe), (m) => [m[1], m[2]]); if (tuyaManufacturerNames.length > 0) { for (const [fullName, partialName] of tuyaManufacturerNames) { const fullMatch = (() => { try { return execSync(grep -r --include="*.ts" "${fullName}" "${zhcDir}", {encoding: "utf8"}); } catch { return undefined; } })(); if (fullMatch) { await github.rest.issues.createComment({ owner: context.repo.owner, repo: context.repo.repo, issue_number: issue.number, body:
Hi there! The Tuya device with manufacturer name \${fullName}` is already supported in the latest dev branch.See this guide on how to update, after updating you can remove your external converter.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.For instructions on how to create a pull request see the docs.If you need help with the process, feel free to ask here and we'll be happy to assist., }); await github.rest.issues.update({ owner: context.repo.owner, repo: context.repo.repo, issue_number: issue.number, state: "closed", }); return; } const partialMatch = (() => { try { return execSync(grep -r --include="*.ts" "${partialName}" "${zhcDir}", {encoding: "utf8"}); } catch { return undefined; } })(); if (partialMatch) { const candidates = Array.from(partialMatch.matchAll(tuyaManufacturerNameRe), (m) => m[1]); await github.rest.issues.createComment({ owner: context.repo.owner, repo: context.repo.repo, issue_number: issue.number, body:
Hi there! A similar Tuya device of which the manufacturer name also ends with `${partialName}` is already supported.This means the device can probably be easily be supported by re-using the existing converter.I found the following matches: ${candidates.map((c) => \${c}`).join(", ")}Try to stop Z2M, change all occurrences of \${fullName}` in the `data/database.db` to one of the matches above and start Z2M.Let us know if it works so we can support this device out-of-the-box!, }); return; } } } else { // Check if zigbee model is already supported. const zigbeeModelRe = /zigbeeModel: \[['"](.+)['"]\]/g; const zigbeeModels = Array.from(issue.body.matchAll(zigbeeModelRe), (m) => m[1]); if (zigbeeModels.length > 0) { for (const zigbeeModel of zigbeeModels) { const fullMatch = (() => { try { return execSync(grep -r --include="*.ts" '"${zigbeeModel}"' "${zhcDir}", {encoding: "utf8"}); } catch { return undefined; } })(); if (fullMatch) { await github.rest.issues.createComment({ owner: context.repo.owner, repo: context.repo.repo, issue_number: issue.number, body:
Hi there! The device with zigbee model `${zigbeeModel}` is already supported in the latest dev branch.Se...
Hi there! The Tuya device with manufacturer name \${fullName}` is already supported in the latest dev branch.See this guide on how to update, after updating you can remove your external converter.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.For instructions on how to create a pull request see the docs.If you need help with the process, feel free to ask here and we'll be happy to assist., }); await github.rest.issues.update({ owner: context.repo.owner, repo: context.repo.repo, issue_number: issue.number, state: "closed", }); return; } const partialMatch = (() => { try { return execSync(grep -r --include="*.ts" "${partialName}" "${zhcDir}", {encoding: "utf8"}); } catch { return undefined; } })(); if (partialMatch) { const candidates = Array.from(partialMatch.matchAll(tuyaManufacturerNameRe), (m) => m[1]); await github.rest.issues.createComment({ owner: context.repo.owner, repo: context.repo.repo, issue_number: issue.number, body:
Hi there! A similar Tuya device of which the manufacturer name also ends with `${partialName}` is already supported.This means the device can probably be easily be supported by re-using the existing converter.I found the following matches: ${candidates.map((c) => \${c}`).join(", ")}Try to stop Z2M, change all occurrences of \${fullName}` in the `data/database.db` to one of the matches above and start Z2M.Let us know if it works so we can support this device out-of-the-box!, }); return; } } } else { // Check if zigbee model is already supported. const zigbeeModelRe = /zigbeeModel: \[['"](.+)['"]\]/g; const zigbeeModels = Array.from(issue.body.matchAll(zigbeeModelRe), (m) => m[1]); if (zigbeeModels.length > 0) { for (const zigbeeModel of zigbeeModels) { const fullMatch = (() => { try { return execSync(grep -r --include="*.ts" '"${zigbeeModel}"' "${zhcDir}", {encoding: "utf8"}); } catch { return undefined; } })(); if (fullMatch) { await github.rest.issues.createComment({ owner: context.repo.owner, repo: context.repo.repo, issue_number: issue.number, body:
Hi there! The device with zigbee model `${zigbeeModel}` is already supported in the latest dev branch.Se...
|
-- | --
FuzzysTodd
commented
Jun 19, 2026
FuzzysTodd
left a comment
Owner
Author
There was a problem hiding this comment.
please show todd the changessss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
self