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 #35705

Open
wants to merge 5 commits into
base: next
Choose a base branch
from
Open

Bayesian Config Flow #35705

wants to merge 5 commits into from

Conversation

HarvsG
Copy link
Contributor

@HarvsG HarvsG commented Nov 11, 2024

Proposed change

  1. Adds config flow to configuration
  2. Improves documentation clarity

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 and enhanced documentation for the Bayesian binary sensor platform for improved clarity and detail.
    • Expanded explanations of Bayes' rule and its application in sensor state determination.
    • Updated configuration instructions and examples, including new terminology and practical tips for effective setup.
    • Improved structure and readability for easier navigation and understanding.

@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
Copy link

netlify bot commented Nov 11, 2024

Deploy Preview for home-assistant-docs ready!

Name Link
🔨 Latest commit eed1b25
🔍 Latest deploy log https://app.netlify.com/sites/home-assistant-docs/deploys/67321c749a8fc60008fe8ddf
😎 Deploy Preview https://deploy-preview-35705--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

Warning

Rate limit exceeded

@HarvsG has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 23 minutes and 30 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 350b39f and eed1b25.

📝 Walkthrough
📝 Walkthrough
📝 Walkthrough

Walkthrough

The documentation for the bayesian binary sensor platform has undergone substantial revisions to improve clarity and detail. Key updates include a modified introduction describing the sensor as a virtual binary sensor, a rephrased explanation of state determination based on probability_threshold, and a restructured section on Bayes' rule. Configuration instructions have been clarified, terminology updated, and additional guidance on estimating probabilities provided. Examples have been reorganized for various observation platforms, and minor adjustments for readability have been made throughout the document.

Changes

File Change Summary
source/_integrations/bayesian.markdown Significant revisions to enhance clarity and detail, including expanded sections on Bayes' rule, updated configuration instructions, and reorganized examples. Minor readability adjustments made throughout.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant BayesianSensor

    User->>BayesianSensor: Configure sensor with parameters
    BayesianSensor-->>User: Acknowledge configuration
    User->>BayesianSensor: Provide observed sensor states
    BayesianSensor->>BayesianSensor: Calculate state using Bayes' rule
    BayesianSensor-->>User: Return current state based on probability threshold
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 (5)
source/_integrations/bayesian.markdown (5)

26-26: Consider enhancing the UI vs YAML format explanation

To prevent potential user confusion, consider expanding this line to be more explicit about the format differences:

-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. Important note on probability formats:
+- YAML configuration: Use decimal values between `0` and `1` (e.g., `0.5` for 50%)
+- UI configuration: Use percentage values between `0` and `100` (e.g., `50` for 50%)

61-62: Minor improvement in prior description

To improve clarity and conciseness:

-     The baseline probability of the event (0 to 1). At any point in time
-     (ignoring all external influences) how likely is this event to be occurring?
+     The baseline probability of the event (0 to 1). At any time
+     (ignoring all external influences) how likely is this event to be occurring?
🧰 Tools
🪛 LanguageTool

[style] ~61-~61: 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)


69-69: Add comma for better readability

Add a comma after the conditional clause:

-    Note: If the threshold is higher than the `prior` then the default state will be `off`
+    Note: If the threshold is higher than the `prior`, then the default state will be `off`
🧰 Tools
🪛 LanguageTool

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

(IF_THEN_COMMA)


130-130: Fix hyphenation and consider adding validation guidance

  1. Fix the hyphenation:
-If your Bayesian sensor ends up triggering `on` too easily, re-check that the probabilities set and estimated make sense, then consider increasing `probability_threshold:` and vice-versa.
+If your Bayesian sensor ends up triggering `on` too easily, re-check that the probabilities set and estimated make sense, then consider increasing `probability_threshold:` and vice versa.
  1. Consider adding a note about validating probabilities:
+7. Validate your probabilities: For each observation, ensure that `prob_given_true` is significantly different from `prob_given_false` to make the observation meaningful. If they're too close, the observation might not contribute meaningfully to the final probability.
🧰 Tools
🪛 LanguageTool

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

(VICE_VERSA)


224-224: Clarify range boundary behavior

The explanation about range boundaries could be clearer:

-When more than one range is specified for the same entity, if a value falls on `below`, it will be included with the range that lists it in `below`. `below` then means "below or equal to". This is not true when only a single range is specified, where both `above` and `below` do not include "equal to".
+Range boundary behavior differs based on configuration:
+- Multiple ranges for same entity:
+  - `below: X` means "less than or equal to X"
+  - A value exactly equal to X belongs to the range that specifies it in `below`
+- Single range:
+  - Both `above` and `below` are exclusive (not including the boundary values)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

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

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

[style] ~61-~61: 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] ~69-~69: Consider adding a comma.
Context: ...the threshold is higher than the prior then the default state will be off requi...

(IF_THEN_COMMA)


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

(VICE_VERSA)

🔇 Additional comments (1)
source/_integrations/bayesian.markdown (1)

Line range hint 1-224: Documentation is comprehensive and well-structured

The documentation effectively explains the Bayesian integration, provides clear configuration guidance, and includes practical examples. The theory section is particularly well-written, making complex concepts accessible to users.

🧰 Tools
🪛 LanguageTool

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

(VICE_VERSA)

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 (3)
source/_integrations/bayesian.markdown (3)

32-36: Fix minor grammatical issues in the theory section

While the content is excellent, there are a few grammatical issues to address:

Apply these corrections:

-However the probability that motion is detected
+However, the probability that motion is detected
-popular with the cats. However the probability
+popular with the cats. However, the probability
-(e.g 95%, p = 0.95)
+(e.g., 95%, p = 0.95)
-(e.g motion detected)
+(e.g., motion detected)
-(e.g human-occupancy of the room)
+(e.g., human-occupancy of the room)
🧰 Tools
🪛 LanguageTool

[uncategorized] ~34-~34: A comma may be missing after the conjunctive/linking adverb ‘However’.
Context: ...) if the room is popular with the cats. However the probability that motion is detected...

(SENT_START_CONJUNCTIVE_LINKING_ADVERB_COMMA)


[uncategorized] ~34-~34: The abbreviation “e.g.” (= for example) requires two periods.
Context: ...that it is occupied by a human is high (e.g 95%, p = 0.95) if our motion sensor is ...

(E_G)


[uncategorized] ~36-~36: The abbreviation “e.g.” (= for example) requires two periods.
Context: ... probability of the sensor observation (e.g motion detected) given the thing you ...

(E_G)


[uncategorized] ~36-~36: The abbreviation “e.g.” (= for example) requires two periods.
Context: ...* the thing you are trying to estimate (e.g human-occupancy of the room). ## Confi...

(E_G)


63-71: Improve clarity of probability descriptions and fix grammar

The descriptions are good but could be more precise:

Apply these improvements:

-At any point in time
+(ignoring all external influences) how likely is this event to be occurring?
-if the threshold is higher than the `prior` then
+if the threshold is higher than the `prior`, then

Also, consider adding a note about the relationship between prior and probability_threshold:
"Setting probability_threshold close to prior will make the sensor more sensitive to changes in observations."

🧰 Tools
🪛 LanguageTool

[style] ~63-~63: 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] ~71-~71: Consider adding a comma.
Context: ...the threshold is higher than the prior then the default state will be off requi...

(IF_THEN_COMMA)


123-133: LGTM! Excellent practical guidance for probability estimation

The guidance is clear and practical, especially the tip about using Home Assistant history to estimate probabilities.

One minor fix needed:

-vice-versa
+vice versa
🧰 Tools
🪛 LanguageTool

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

(VICE_VERSA)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between e3361a3 and 350b39f.

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

[uncategorized] ~34-~34: A comma may be missing after the conjunctive/linking adverb ‘However’.
Context: ...) if the room is popular with the cats. However the probability that motion is detected...

(SENT_START_CONJUNCTIVE_LINKING_ADVERB_COMMA)


[uncategorized] ~34-~34: The abbreviation “e.g.” (= for example) requires two periods.
Context: ...that it is occupied by a human is high (e.g 95%, p = 0.95) if our motion sensor is ...

(E_G)


[uncategorized] ~36-~36: The abbreviation “e.g.” (= for example) requires two periods.
Context: ... probability of the sensor observation (e.g motion detected) given the thing you ...

(E_G)


[uncategorized] ~36-~36: The abbreviation “e.g.” (= for example) requires two periods.
Context: ...* the thing you are trying to estimate (e.g human-occupancy of the room). ## Confi...

(E_G)


[style] ~63-~63: 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] ~71-~71: Consider adding a comma.
Context: ...the threshold is higher than the prior then the default state will be off requi...

(IF_THEN_COMMA)


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

(VICE_VERSA)

🔇 Additional comments (3)
source/_integrations/bayesian.markdown (3)

22-26: LGTM! Clear and practical introduction

The introduction effectively explains what a Bayesian sensor is and provides practical use cases that users can relate to.


226-226: LGTM! Clear explanation of range behavior

The explanation of how ranges work with multiple states is precise and helpful for users.


Line range hint 22-226: Overall excellent documentation improvements

The documentation is now more comprehensive, clearer, and more practical. Key strengths:

  1. Clear explanation of the theory with relatable examples
  2. Practical guidance for estimating probabilities
  3. Well-documented examples with realistic scenarios
  4. Thorough explanation of multiple state handling

The changes align perfectly with the PR objective of improving the documentation for Bayesian features.

🧰 Tools
🪛 LanguageTool

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

(VICE_VERSA)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.

1 participant