Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add WB-MIR v3 template, update WB-MIR v2 template #825

Open
wants to merge 39 commits into
base: master
Choose a base branch
from

Conversation

ad7718
Copy link
Contributor

@ad7718 ad7718 commented Oct 24, 2024

-Старый шаблон задепрекейтил
-Добавил новый шаблон v.2 с поддержкой нажатий на jinja
-Добавил новый шаблон v.3 на jinja
-Добавил поддержку кнопок
-Убрал subdevice, 1wire/input часть сделал как в шаблоне "config-wb-m1w2-buttons.json.jinja", имена каналов 1wire/discrete input оставил такими же как в MIR v.2

Summary by CodeRabbit

  • New Features
    • Introduced new templates for WB-MIR v.2 with button support and WB-MIR v.3.
  • Deprecation
    • Deprecated the WB-MIR v.2 template.
  • Configuration Updates
    • Added a deprecated property to the WB-MIR v.2 configuration.
    • New configuration templates for WB-MIR v.2 with buttons and WB-MIR v.3 are now available.

@ad7718 ad7718 requested review from a team, KraPete and sikmir as code owners October 24, 2024 03:10
debian/changelog Outdated
@@ -1,3 +1,10 @@
wb-mqtt-serial (2.145.1) stable; urgency=medium
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
wb-mqtt-serial (2.145.1) stable; urgency=medium
wb-mqtt-serial (2.146.0) stable; urgency=medium

Copy link
Contributor Author

Choose a reason for hiding this comment

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

поправил

Copy link
Contributor

@pgasheev pgasheev left a comment

Choose a reason for hiding this comment

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

Рановато аппрув

  1. имена топиков новых шаблонов должны быть в соответствии с инструкцией
  2. тесты не проходят

@KraPete
Copy link
Contributor

KraPete commented Oct 24, 2024

Рановато аппрув

1. имена топиков новых шаблонов должны быть в соответствии с инструкцией

2. тесты не проходят
  1. Мы сломаем обратную совместимость со старым шаблоном. У людей уже завязано всё на старые имена топиков, они выбрали новый шаблон, всё развалилось

@pgasheev
Copy link
Contributor

  1. Мы сломаем обратную совместимость со старым шаблоном. У людей уже завязано всё на старые имена топиков, они выбрали новый шаблон, всё развалилось

Обсудили в чатике, решили имена топиков оставить текущими, т.к. это новая версия устройства, а не не новое устройство

@ad7718 ad7718 requested a review from pgasheev October 24, 2024 11:24
Copy link
Contributor

@pgasheev pgasheev left a comment

Choose a reason for hiding this comment

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

У меня ещё есть глобальный вопрос. Тут я не увидел, чтобы было указано, что новые функции (нажатия) доступны с версии такой-то. И для v2 её надо указывать, а для v3 - нет. Может, всё-таки, для них сделать разные шаблоны? Обсуди с документацией и примите решение

templates/config-wb-mir_buttons.json.jinja Outdated Show resolved Hide resolved
@ad7718 ad7718 requested a review from pgasheev October 25, 2024 04:22
templates/config-wb-mir_v2_buttons.json.jinja Show resolved Hide resolved
templates/config-wb-mir_v2_buttons.json.jinja Outdated Show resolved Hide resolved
templates/config-wb-mir_v2_buttons.json.jinja Show resolved Hide resolved
templates/config-wb-mir_v2_buttons.json.jinja Outdated Show resolved Hide resolved
templates/config-wb-mir_v2_buttons.json.jinja Outdated Show resolved Hide resolved
templates/config-wb-mir_v2_buttons.json.jinja Outdated Show resolved Hide resolved
templates/config-wb-mir_v2_buttons.json.jinja Show resolved Hide resolved
templates/config-wb-mir_v3.json.jinja Outdated Show resolved Hide resolved
test/TDeviceTemplatesTest.Validate.dat Outdated Show resolved Hide resolved
templates/config-wb-mir_v3.json.jinja Show resolved Hide resolved
@ad7718 ad7718 requested a review from pgasheev October 29, 2024 06:05
Copy link
Contributor

@pgasheev pgasheev left a comment

Choose a reason for hiding this comment

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

Надо правильно задеприкейтить старый шаблон

@ad7718 ad7718 requested a review from pgasheev October 29, 2024 06:20
templates/config-wb-mir_v2_buttons.json.jinja Outdated Show resolved Hide resolved
{% set FIRST_INPUT = 1 -%}
{
"title": "WB-MIR-v.3_template_title",
"device_type": "WB-MIR v.3",
Copy link
Contributor

Choose a reason for hiding this comment

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

wb_mir_v3?
@KraPete подскажи, есть ли критерии/пожелания, как должен выглядеть device_type?

Copy link

coderabbitai bot commented Dec 10, 2024

Walkthrough

The pull request updates the wb-mqtt-serial package to version 2.153.0, marking the deprecation of the WB-MIR v.2 template and introducing new templates for WB-MIR v.2 with button support and WB-MIR v.3. The JSON configuration for the deprecated WB-MIR v.2 device has been modified to reflect its status, while new configuration templates for WB-MIR v.2 and v.3 have been added, incorporating dynamic parameters and localization support.

Changes

File Change Summary
debian/changelog Updated to version 2.153.0; deprecated WB-MIR v.2 template; added WB-MIR v.2 with buttons and WB-MIR v.3 templates.
templates/config-wb-mir_v2.json Added property "deprecated": true to indicate the deprecation of WB-MIR v.2.
templates/config-wb-mir_v2_buttons.json.jinja Introduced new JSON configuration template for WB-MIR v.2 with button support, including dynamic parameters and localization.
templates/config-wb-mir_v3.json.jinja Introduced new JSON configuration template for WB-MIR v.3, defining parameters, channels, and localization.

Possibly related PRs

Suggested reviewers

  • KraPete

🐰 In the meadow, changes bloom,
New templates rise to chase the gloom.
With buttons bright and v.3 in sight,
The old gives way, making room for light.
Hops of joy, we celebrate,
A future bright, we can’t await! 🌼


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 601b48f and 1fa854b.

⛔ Files ignored due to path filters (1)
  • test/TDeviceTemplatesTest.Validate.dat is excluded by !**/*.dat
📒 Files selected for processing (1)
  • templates/config-wb-mir_v2_buttons.json.jinja (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • templates/config-wb-mir_v2_buttons.json.jinja

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 8d09c25 and 9b66436.

⛔ Files ignored due to path filters (1)
  • test/TDeviceTemplatesTest.Validate.dat is excluded by !**/*.dat
📒 Files selected for processing (4)
  • debian/changelog (1 hunks)
  • templates/config-wb-mir_v2.json (1 hunks)
  • templates/config-wb-mir_v2_buttons.json.jinja (1 hunks)
  • templates/config-wb-mir_v3.json.jinja (1 hunks)
🔇 Additional comments (4)
templates/config-wb-mir_v2_buttons.json.jinja (2)

21-21: 🛠️ Refactor suggestion

Remove unnecessary "min_request_interval" parameter

The "min_request_interval" parameter is no longer required and should be removed to keep the template clean and up-to-date.

Apply this diff to remove the parameter:

- "min_request_interval": 100,

229-252: 🛠️ Refactor suggestion

Ensure consistent naming: use "ROM" instead of "BANK"

To maintain consistency across the template and avoid confusion, consider renaming "BANK" commands to "ROM", as suggested previously.

Apply this diff to rename the commands:

- "name": "Play from BANK",
+ "name": "Play from ROM",
...

- "name": "BANK -> RAM",
+ "name": "ROM -> RAM",
...

- "name": "Learn to BANK",
+ "name": "Learn to ROM",
templates/config-wb-mir_v2.json (1)

5-5: Deprecation flag added correctly

The "deprecated": true property is correctly added to indicate that the WB-MIR v2 device is deprecated.

debian/changelog (1)

1-7: Changelog updates are properly formatted

The changelog entries accurately reflect the changes made, and the formatting follows the standard conventions.

Comment on lines +341 to +347
"condition": "
{%- for in_num in range(FIRST_INPUT, INPUTS_NUMBER + 1) -%}
in{{in_num}}_mode==1
{%- if not loop.last -%} || {%- endif -%}
{%- endfor -%}
"
},
Copy link

@coderabbitai coderabbitai bot Dec 10, 2024

Choose a reason for hiding this comment

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

⚠️ Potential issue

Refactor multiline "condition" field to avoid JSON syntax errors

The multiline string in the "condition" field may cause JSON syntax errors, as JSON strings cannot contain unescaped newlines. Refactor the Jinja template to generate a single-line condition.

Apply this diff to fix the issue:

- "condition": "
-     {%- for in_num in range(FIRST_INPUT, INPUTS_NUMBER + 1) -%}
-         in{{in_num}}_mode==1
-         {%- if not loop.last -%} || {%- endif -%}
-     {%- endfor -%}
- "
+ "condition": "{% for in_num in range(FIRST_INPUT, INPUTS_NUMBER + 1) -%}in{{in_num}}_mode==1{% if not loop.last %} || {% endif %}{% endfor %}"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"condition": "
{%- for in_num in range(FIRST_INPUT, INPUTS_NUMBER + 1) -%}
in{{in_num}}_mode==1
{%- if not loop.last -%} || {%- endif -%}
{%- endfor -%}
"
},
"condition": "{% for in_num in range(FIRST_INPUT, INPUTS_NUMBER + 1) -%}in{{in_num}}_mode==1{% if not loop.last %} || {% endif %}{% endfor %}"
},

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Тоже ложная тревога, нормально разваорачивается

Copy link

Choose a reason for hiding this comment

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

@ad7718, спасибо за разъяснение. Я отметил, что многострочные условия в поле "condition" Jinja-шаблона разворачиваются корректно и не вызывают ошибок JSON.


✏️ Learnings added
Learnt from: ad7718
PR: wirenboard/wb-mqtt-serial#825
File: templates/config-wb-mir_v3.json.jinja:341-347
Timestamp: 2024-12-17T16:22:40.235Z
Learning: В данном проекте многострочные условия в поле `"condition"` Jinja-шаблона разворачиваются корректно и не вызывают ошибок синтаксиса JSON.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

Comment on lines 187 to 217
"reg_type": "coil",
"address": {{ 5300 + rom - 1 }},
"type": "switch",
"group": "ir_commands",
"enabled": false
},
{
"name": "ROM{{ rom }} size",
"reg_type": "input",
"address": {{ 5400 + rom - 1 }},
"group": "ir_commands",
"enabled": false
},
{% set enabled = "true" if rom < 11 else "false" -%}
{
"name": "Play from ROM{{ rom }}",
"reg_type": "coil",
"address": {{ 5100 + rom - 1 }},
"type": "pushbutton",
"group": "ir_commands",
"enabled": {{ enabled }}
},
{
"name": "ROM{{ rom }} -> RAM",
"reg_type": "coil",
"address": {{ 5200 + rom - 1 }},
"type": "switch",
"group": "ir_commands",
"enabled": {{ enabled }}
},
{% endfor -%}
Copy link

@coderabbitai coderabbitai bot Dec 10, 2024

Choose a reason for hiding this comment

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

⚠️ Potential issue

Replace string literals with boolean values for the "enabled" field

The "enabled" field is currently set using strings "true" or "false". In JSON, boolean values should be unquoted. Modify the Jinja template to assign actual boolean values to ensure correct JSON output.

Apply this diff to fix the issue:

- {% set enabled = "true" if rom < 11 else "false" -%}
+ {% set enabled = true if rom < 11 else false -%}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"reg_type": "coil",
"address": {{ 5300 + rom - 1 }},
"type": "switch",
"group": "ir_commands",
"enabled": false
},
{
"name": "ROM{{ rom }} size",
"reg_type": "input",
"address": {{ 5400 + rom - 1 }},
"group": "ir_commands",
"enabled": false
},
{% set enabled = "true" if rom < 11 else "false" -%}
{
"name": "Play from ROM{{ rom }}",
"reg_type": "coil",
"address": {{ 5100 + rom - 1 }},
"type": "pushbutton",
"group": "ir_commands",
"enabled": {{ enabled }}
},
{
"name": "ROM{{ rom }} -> RAM",
"reg_type": "coil",
"address": {{ 5200 + rom - 1 }},
"type": "switch",
"group": "ir_commands",
"enabled": {{ enabled }}
},
{% endfor -%}
"reg_type": "coil",
"address": {{ 5300 + rom - 1 }},
"type": "switch",
"group": "ir_commands",
"enabled": false
},
{
"name": "ROM{{ rom }} size",
"reg_type": "input",
"address": {{ 5400 + rom - 1 }},
"group": "ir_commands",
"enabled": false
},
{% set enabled = true if rom < 11 else false -%}
{
"name": "Play from ROM{{ rom }}",
"reg_type": "coil",
"address": {{ 5100 + rom - 1 }},
"type": "pushbutton",
"group": "ir_commands",
"enabled": {{ enabled }}
},
{
"name": "ROM{{ rom }} -> RAM",
"reg_type": "coil",
"address": {{ 5200 + rom - 1 }},
"type": "switch",
"group": "ir_commands",
"enabled": {{ enabled }}
},
{% endfor -%}

Copy link
Contributor Author

@ad7718 ad7718 Dec 17, 2024

Choose a reason for hiding this comment

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

Тут ложная тревога, кавычек в итоговом json нет, и если их убрать, то подставляются питоновские True/False, с заглавной буквы

Copy link

Choose a reason for hiding this comment

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

@ad7718, спасибо за разъяснение. Если кавычки необходимы для правильного формирования JSON, то мой комментарий можно игнорировать. Учту это в будущих проверках.

(_/)
(•_•)
(< )


✏️ Learnings added
Learnt from: ad7718
PR: wirenboard/wb-mqtt-serial#825
File: templates/config-wb-mir_v3.json.jinja:187-217
Timestamp: 2024-12-17T16:15:42.530Z
Learning: В шаблонах Jinja при генерации JSON, использование строковых литералов "true" или "false" в кавычках позволяет избежать вставки Python True/False с заглавной буквы, что не соответствует формату JSON. Поэтому использование кавычек в таких случаях допустимо.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

@ad7718
Copy link
Contributor Author

ad7718 commented Dec 17, 2024

Включил для первых 10 ROM кнопки "Learn to ROMx" для повышения удобства UI. Также теперь в шаблоне v.3 доступны все 80 ROM'ов, в v.2 оставил как было, т.к. были версии пошивок с 40 ROM'ами.

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.

4 participants