Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Oct 13, 2025

  • Add comment about state roles in templates/main.js.ts (JavaScript template)
  • Add comment about state roles in templates/src/main.ts.ts (TypeScript template)
  • Add note about state roles in templates/README.md.ts
  • Run tests to update baselines
  • Verify changes
  • Address review feedback: Move comment into JSDoc block
  • Address review feedback: Add warning about custom role names

Summary

Added documentation about state roles to help developers choose the correct role for their state objects:

  1. Template Files: Moved the state roles documentation into the JSDoc comment block above setObjectNotExistsAsync, formatted with "IMPORTANT:" prefix as requested, and removed the decorative asterisk lines.

  2. README Template: Added a new "State Roles" section in the "Best Practices" area with an additional warning about not inventing custom role names, directing developers to contact the community for new role discussions.

  3. Test Baselines: Updated all 32 baseline test files to reflect the new documentation format.

All tests pass successfully and the changes follow the project's linting standards.

Original prompt

This section details on the original issue you should resolve

<issue_title>[enhancement] add comment for state roles</issue_title>
<issue_description>As I saw several adapters lately using role:indicator I assume that those setObjectNotExist code is simply copied from the 'online' state.

I suggest to add a hint as comment at source to use correct roles including a link to the documentation )(https://github.com/ioBroker/ioBroker.docs/blob/master/docs/en/dev/stateroles.md

LOW PRIOR</issue_description>

<agent_instructions>This refers to the generated code in main.js/main.ts - only adjust there.

Additionally find a good place in the default generated README to also add a not to use proper roles as defined in https://www.iobroker.net/#en/documentation/dev/stateroles.md

Use this link over the one provided in the issue: https://www.iobroker.net/#en/documentation/dev/stateroles.md</agent_instructions>

Comments on the Issue (you are @copilot in this section)

Fixes #1066


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@Copilot Copilot AI changed the title [WIP] Add comment for state roles in generated code Add state roles documentation to generated adapter templates Oct 13, 2025
@Copilot Copilot AI requested a review from Apollon77 October 13, 2025 14:51
Copilot finished work on behalf of Apollon77 October 13, 2025 14:51
native: {},
});
// **************************************************************************************************
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot move this block into the JSDoc block of the above setObjectNotExists call to make clear it belongs to this. In all places it was inserted.
And remove the "****" lines but start on extra line after an empty line with "IMPORTANT:..."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Moved the comment block into the JSDoc comment above setObjectNotExistsAsync, removed the asterisk lines, and formatted with "IMPORTANT:" prefix on a new line after an empty line. Changes applied in commit 53d6f5b.

@Copilot Copilot AI requested a review from Apollon77 October 14, 2025 07:14
Copilot finished work on behalf of Apollon77 October 14, 2025 07:14
@Apollon77 Apollon77 marked this pull request as ready for review October 14, 2025 07:17
@Apollon77 Apollon77 enabled auto-merge (squash) October 14, 2025 07:17
@Apollon77 Apollon77 merged commit df75416 into master Oct 14, 2025
6 checks passed
@Apollon77 Apollon77 deleted the copilot/add-comment-for-state-roles branch October 14, 2025 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[enhancement] add comment for state roles

2 participants