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 publish Action for Nextion components #4360

Closed
wants to merge 7 commits into from

Conversation

pkejval
Copy link
Contributor

@pkejval pkejval commented Oct 21, 2024

Description:

Related issue (if applicable): fixes

Pull request in esphome with YAML changes (if applicable): esphome/esphome#7646

Checklist:

  • I am merging into next because this is new documentation that has a matching pull-request in esphome as linked above.
    or

  • I am merging into current because this is a fix, change and/or adjustment in the current documentation and is not for a new component or feature.

  • Link added in /index.rst when creating new documents for new components or cookbook.

Copy link

netlify bot commented Oct 21, 2024

Deploy Preview for esphome ready!

Name Link
🔨 Latest commit 29af6f1
🔍 Latest deploy log https://app.netlify.com/sites/esphome/deploys/671772bbfe97a500088323a1
😎 Deploy Preview https://deploy-preview-4360--esphome.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

coderabbitai bot commented Oct 21, 2024

Walkthrough

The changes introduce new documentation sections for the Nextion components, specifically for binary sensors, sensors, switches, and text sensors. Each section details a new action, publish, which allows users to publish states from their YAML configurations. The documentation includes required and optional parameters, example configurations, and notes on using lambda functions for dynamic state management. These updates enhance the functionality of the respective components by providing more flexible state management options.

Changes

File Path Change Summary
components/binary_sensor/nextion.rst Added section for binary_sensor.nextion.publish action, detailing parameters and example YAML configurations.
components/sensor/nextion.rst Added section for sensor.nextion.publish action, specifying parameters and including example configurations.
components/switch/nextion.rst Added section for switch.nextion.publish action, detailing parameters and providing example configurations.
components/text_sensor/nextion.rst Added section for text_sensor.nextion.publish action, including parameters and example configurations.

Suggested labels

next

Suggested reviewers

  • jesserockz
  • nagyrobi

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 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
Contributor

@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: 0

🧹 Outside diff range and nitpick comments (6)
components/text_sensor/nextion.rst (2)

66-89: LGTM: Comprehensive example configuration

The example configuration is well-structured and demonstrates both basic and templated usage of the text_sensor.nextion.publish action. It covers all parameters and provides context for when the action might be used.

Consider adding a brief comment above the templated example to explain when a user might choose this approach over the basic example. This could help users understand the benefits of using templates in this context.


98-106: LGTM: Helpful lambda calls example

The lambda calls example is well-presented and provides clear guidance for users who need to use this action in C++ code. The different variations of the set_state method are particularly useful.

Consider adding a brief explanation of the parameters in the set_state method calls. For example:

// Set state with default publish and send_to_nextion (both true)
id(nextion_text).set_state("Hello World");
// Set state with custom publish value, default send_to_nextion
id(nextion_text).set_state("Hello World", true);
// Set state with custom publish and send_to_nextion values
id(nextion_text).set_state("Hello World", true, true);

This would help users understand the purpose of each parameter more clearly.

components/switch/nextion.rst (1)

62-111: LGTM! Consider adding a brief introductory sentence.

The new section on the switch.nextion.publish action is well-structured, accurate, and provides valuable information for users. The example configuration, explanation of parameters, and notes on lambda usage are clear and comprehensive.

Consider adding a brief introductory sentence at the beginning of the section to provide context. For example:

 ``switch.nextion.publish`` Action
 ---------------------------------------

+The `switch.nextion.publish` action allows you to update the state of a Nextion switch programmatically from your ESPHome configuration.
+
 You can also publish a state to a Nextion switch from elsewhere in your YAML file
 with the ``switch.nextion.publish`` action.

This addition would help users quickly understand the purpose of the action before diving into the details.

components/sensor/nextion.rst (2)

106-129: LGTM: Comprehensive examples provided

The examples effectively demonstrate both standard and templated usage of the sensor.nextion.publish action, including optional parameters.

Consider adding a brief comment above the templated example to explain when a user might prefer this approach over the standard one.


138-146: LGTM: Helpful lambda usage examples

The inclusion of lambda examples is valuable for advanced users, demonstrating different ways to use the set_state method.

Consider adding a brief explanation of the differences between the three set_state examples to clarify the purpose of each parameter.

components/binary_sensor/nextion.rst (1)

90-139: LGTM! New section on binary_sensor.nextion.publish action is well-documented.

The new section is clear, well-structured, and consistent with the existing documentation style. It provides comprehensive information about the new action, including YAML examples, configuration options, and lambda usage.

Consider adding a brief introductory sentence explaining the purpose of this action, such as:
"This action allows you to programmatically update the state of a Nextion binary sensor from within your ESPHome configuration."

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 4d329c6 and e4fe9de.

📒 Files selected for processing (4)
  • components/binary_sensor/nextion.rst (1 hunks)
  • components/sensor/nextion.rst (1 hunks)
  • components/switch/nextion.rst (1 hunks)
  • components/text_sensor/nextion.rst (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
components/binary_sensor/nextion.rst (1)

Pattern **: - Do not generate or add any sequence diagrams

components/sensor/nextion.rst (1)

Pattern **: - Do not generate or add any sequence diagrams

components/switch/nextion.rst (1)

Pattern **: - Do not generate or add any sequence diagrams

components/text_sensor/nextion.rst (1)

Pattern **: - Do not generate or add any sequence diagrams

🔇 Additional comments (6)
components/text_sensor/nextion.rst (3)

58-64: LGTM: Clear introduction of the new action

The introduction for the text_sensor.nextion.publish action is well-written and informative. It clearly states the purpose of the action and its context within the Nextion text sensor component.


91-96: LGTM: Well-documented configuration options

The configuration options for the text_sensor.nextion.publish action are clearly presented. Each parameter is properly described with its requirements, type, and default values where applicable. The formatting is consistent with ESPHome documentation standards.


58-106: Summary: Excellent addition of the text_sensor.nextion.publish action documentation

The new section introducing the text_sensor.nextion.publish action is a valuable addition to the Nextion text sensor component documentation. It provides clear instructions, well-structured examples, and comprehensive configuration options. The content is consistent with ESPHome documentation standards and aligns well with the PR objectives.

This addition will greatly benefit users by enabling them to publish states to Nextion text sensors from other parts of their YAML configuration, enhancing the flexibility and functionality of Nextion components in ESPHome projects.

components/sensor/nextion.rst (3)

98-104: LGTM: Clear introduction of the new action

The introduction effectively explains the purpose of the new sensor.nextion.publish action, aligning with the PR objectives.


131-136: LGTM: Well-documented configuration options

The configuration options are clearly explained, with required and optional parameters properly identified. The inclusion of default values and templatable options is particularly helpful for users.


98-146: LGTM: Excellent addition to the Nextion sensor documentation

The new section on the sensor.nextion.publish action is a valuable addition to the documentation. It provides clear explanations, comprehensive examples, and detailed configuration options. The inclusion of both YAML and lambda usage examples caters to users with different levels of expertise.

The changes align well with the PR objectives and enhance the functionality of the Nextion sensor component by allowing for more dynamic state management.

@pkejval pkejval changed the base branch from current to next October 21, 2024 09:11
@probot-esphome probot-esphome bot added next and removed current labels Oct 21, 2024

- **id** (**Required**, :ref:`config-id`): The ID of the Nextion switch.
- **state** (**Required**, string, :ref:`templatable <config-templatable>`): The boolean state to publish.
- **publish_state** (**Optional**, bool, :ref:`templatable <config-templatable>`): Publish new state to HASS. Default is true.
Copy link
Contributor

Choose a reason for hiding this comment

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

I wouldn't use "HASS". I think "Publish new state to Home Assistant." makes it more clear.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed. I copied this line from existing documentation - lambda call section.

Copy link
Contributor

Choose a reason for hiding this comment

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

What if one uses publish_state: false and send_to_nextion: false? Will this function do anything?
Is there really a need for an optional send_to_nextion? Why not make it mandatory (always publish to Nextion) if this component is all about the Nextion?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right, that call will be nonsense. But I tried to keep same functionality as lambda calls offers. You can check API: https://esphome.io/api/classesphome_1_1nextion_1_1_nextion_component_base

I can image someone needs to publish value into sensor (that triggers filters and on_value actions) and not yet update Nextion...
Yeah, it sounds overcomplicated but as I said I just tried to keep all options possible in lambdas in YAML actions.

pkejval and others added 6 commits October 22, 2024 11:27
* Tabs label CSS night mode fix

* Update _static/custom.css

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* removed border attribute

* Update custom.css

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@pkejval pkejval closed this Oct 22, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Oct 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants