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

Bayesian config flow #35703

Closed
wants to merge 12 commits into from
Closed

Conversation

HarvsG
Copy link
Contributor

@HarvsG HarvsG commented Nov 11, 2024

Proposed change

  1. Adds configuration instructions for Config Flow support
  2. Adds clarity to the descriptions

Type of change

  • Spelling, grammar or other readability improvements (current branch).
  • Adjusted missing or incorrect information in the current documentation (current branch).
  • Added documentation for a new integration I'm adding to Home Assistant (next branch).
  • Added documentation for a new feature I'm adding to Home Assistant (next branch).
  • Removed stale or deprecated documentation.

Additional information

  • Link to parent pull request in the codebase: Baysesian Config Flow core#122552
  • Link to parent pull request in the Brands repository:
  • This PR fixes or closes issue: fixes #

Checklist

  • This PR uses the correct branch, based on one of the following:
    • I made a change to the existing documentation and used the current branch.
    • I made a change that is related to an upcoming version of Home Assistant and used the next branch.
  • The documentation follows the Home Assistant documentation standards.

Summary by CodeRabbit

  • Documentation
    • Revised documentation for the bayesian binary sensor platform to improve clarity and detail.
    • Enhanced explanations of the sensor's functionality, including event detection and probability thresholds.
    • Updated configuration instructions with structured guidance and additional examples for various observation platforms.
    • Minor terminology adjustments and corrections for consistency and accuracy.

@home-assistant home-assistant bot added has-parent This PR has a parent PR in a other repo next This PR goes into the next branch labels Nov 11, 2024
@HarvsG HarvsG changed the title Bayes configflow Bayesian config flow Nov 11, 2024
Copy link

netlify bot commented Nov 11, 2024

Deploy Preview for home-assistant-docs ready!

Name Link
🔨 Latest commit 9e4a69a
🔍 Latest deploy log https://app.netlify.com/sites/home-assistant-docs/deploys/67320bea2e2a8a00081c46a4
😎 Deploy Preview https://deploy-preview-35703--home-assistant-docs.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 Nov 11, 2024

📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough

Walkthrough

The documentation for the bayesian binary sensor platform has undergone significant revisions to improve clarity and detail. Key updates include a refined explanation of the sensor's functionality, enhanced descriptions of posterior probability in relation to the probability_threshold, and a clearer presentation of event detection capabilities. The documentation now supports both UI and YAML configurations, with an expanded theoretical explanation of Bayes' Rule and structured guidance on estimating probabilities based on historical data. Minor terminology adjustments and corrections have also been made for consistency.

Changes

File Path Change Summary
source/_integrations/bayesian.markdown Revised documentation to clarify the bayesian sensor's functionality, refined explanations of posterior probability, updated event detection descriptions, added support for UI and YAML setups, expanded theoretical background on Bayes' Rule, and improved configuration guidance with examples. Minor terminology and consistency corrections made throughout.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UI
    participant YAML
    participant BayesianSensor

    User->>UI: Configure Bayesian Sensor
    User->>YAML: Define probabilities
    UI->>BayesianSensor: Set up sensor with parameters
    YAML->>BayesianSensor: Load configuration
    BayesianSensor->>BayesianSensor: Calculate posterior probability
    BayesianSensor->>User: Notify event detection
Loading

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 or @coderabbitai title 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 (4)
source/_integrations/bayesian.markdown (4)

21-25: LGTM! Clear and informative introduction.

The introduction effectively explains the Bayesian sensor's purpose and operation. The distinction between UI (percentages) and YAML (0-1) probability formats is particularly helpful for users.

Consider adding an example to illustrate the UI vs YAML probability difference:

-Both UI and YAML setup is supported, importantly YAML uses probabilities of `0` to `1` whereas UI uses percentages.
+Both UI and YAML setup is supported, importantly YAML uses probabilities of `0` to `1` (e.g., 0.5) whereas UI uses percentages (e.g., 50%).

109-113: Clarify probability descriptions

The descriptions for prob_given_true and prob_given_false could be more precise to help users understand these crucial parameters.

Consider this clarification:

-      description: >
-        Assuming the bayesian binary_sensor is `on`, the probability the entity state is occurring.
+      description: >
+        The probability that this observation would be true when the event (that the Bayesian sensor detects) is occurring.
-      description: Assuming the bayesian binary_sensor is `off` the probability the entity state is occurring.
+      description: The probability that this observation would be true when the event (that the Bayesian sensor detects) is not occurring.
🧰 Tools
🪛 LanguageTool

[uncategorized] ~109-~109: Possible missing preposition found.
Context: ... binary_sensor is on, the probability the entity state is occurring. requir...

(AI_HYDRA_LEO_MISSING_OF)


120-127: Fix grammar and enhance clarity

The probability estimation guidance contains helpful information but needs minor improvements.

  1. Fix grammar in line 127:
-increasing `probability_threshold:` and vice-versa.
+increasing `probability_threshold:` and vice versa.
  1. Consider adding a brief explanation about why extreme values (0 and 1) should be avoided:
-1. Avoid `0` and `1`, these will mess with the odds and are rarely true - sensors fail.
+1. Avoid `0` and `1`, as these extreme values can skew the calculations significantly. In real-world scenarios, no sensor is 100% reliable, so using values like `0.001` or `0.999` is more realistic.
🧰 Tools
🪛 LanguageTool

[grammar] ~127-~127: The expression “vice versa” is spelled without hyphens.
Context: ...increasing probability_threshold: and vice-versa. ## Full examples These are a number ...

(VICE_VERSA)


223-277: Improve formatting and clarity of the bins example

The bins example is comprehensive but could benefit from improved readability.

  1. Consider grouping related observations with comments:
 binary_sensor:
   name: "Bins need bringing in"
   platform: "bayesian"
   prior: 0.14 # bins are left out for usually about one day a week
   probability_threshold: 0.5
   observations:
+    # Signal strength observations
     - platform: "numeric_state"
     entity_id: "sensor.signal_strength"
     ...
+    # Bin collection status observations
     - platform: "state"
     entity_id: "sensor.bin_collection"
     ...
  1. Add a summary comment at the start explaining the probability distributions:
# This example combines:
# 1. Signal strength observations (5 ranges with probabilities summing to 1.0)
# 2. Bin collection status (3 states with probabilities summing to 1.0)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 8ceb866 and cd5e387.

📒 Files selected for processing (1)
  • source/_integrations/bayesian.markdown (6 hunks)
🧰 Additional context used
🪛 LanguageTool
source/_integrations/bayesian.markdown

[style] ~58-~58: This phrase is redundant. Consider writing “point” or “time”.
Context: ...obability of the event (0 to 1). At any point in time (ignoring all external influences) ...

(MOMENT_IN_TIME)


[typographical] ~66-~66: Consider adding a comma.
Context: ...the threshold is higher than the prior then the default state will be off requi...

(IF_THEN_COMMA)


[uncategorized] ~109-~109: Possible missing preposition found.
Context: ... binary_sensor is on, the probability the entity state is occurring. requir...

(AI_HYDRA_LEO_MISSING_OF)


[grammar] ~127-~127: The expression “vice versa” is spelled without hyphens.
Context: ...increasing probability_threshold: and vice-versa. ## Full examples These are a number ...

(VICE_VERSA)


[style] ~219-~219: The words ‘observed’ and ‘observation’ are quite similar. Consider replacing ‘observed’ with a different word.
Context: ... a value that has not been specified is observed, then the observation will be ignored a...

(VERB_NOUN_SENT_LEVEL_REP)

@HarvsG
Copy link
Contributor Author

HarvsG commented Nov 11, 2024

git history issues, deleting and re-opening

@HarvsG HarvsG closed this Nov 11, 2024
@HarvsG HarvsG deleted the bayes-configflow branch November 11, 2024 13:56
@github-actions github-actions bot locked and limited conversation to collaborators Nov 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
has-parent This PR has a parent PR in a other repo next This PR goes into the next branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants