node-red-contrib-home-assistant-websocket icon indicating copy to clipboard operation
node-red-contrib-home-assistant-websocket copied to clipboard

feat: Set `timeout` flag when `wait-until` timeouted

Open cadavre opened this issue 7 months ago • 1 comments

Very simple, yet helpful addition to wait-until node's timeout output.

Sometimes this node is a beginning to a big flow that may run some portion if state timeout'd. Both outputs may connect to the same next node, but it may be a switch that performs slightly different actions on state reached or timeout.

I'm not sure if I made the addition in a correct place and, true – I haven't tested this locally – but that effort would be much bigger than just creating this PR. Therefore I ask for your understanding. :)

Summary by CodeRabbit

  • New Features
    • Output context now explicitly indicates when a wait-until node times out, providing clearer feedback for timeout events.
  • Documentation
    • Updated the "Wait Until" node documentation to include the new timeout output property and improved descriptions.

cadavre avatar May 06 '25 15:05 cadavre

## Walkthrough

A new property, `timeout: true`, is added to the context object passed to the `setCustomOutputs` method within the timeout callback of the wait-until node. This change explicitly signals that the output was triggered by a timeout event, without altering any other logic or control flow.

## Changes

| File(s)                                   | Change Summary                                                                                 |
|-------------------------------------------|-----------------------------------------------------------------------------------------------|
| src/nodes/wait-until/WaitUntilController.ts | Adds `timeout: true` to the context object in the timeout callback for `setCustomOutputs`.     |
| docs/node/wait-until.md                    | Updates documentation to describe the new `timeout` output property and modifies `config` description. |

## Sequence Diagram(s)

```mermaid
sequenceDiagram
    participant WaitUntilNode
    participant Entity
    participant Controller

    WaitUntilNode->>Entity: Wait for state change
    alt State changes before timeout
        Entity-->>WaitUntilNode: State changed
        WaitUntilNode->>Controller: setCustomOutputs(context)
    else Timeout occurs
        WaitUntilNode->>Controller: setCustomOutputs({..., timeout: true})
    end

<!-- walkthrough_end -->
<!-- internal state start -->


<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEYDEZyAAUASpETZWaCrKNwSPbABsvkCiQBHbGlcSHFcLzpIACIAMxJqLgBlElCAA3E2fDw0yFivNCJIAH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JKIumwkgAA9FMVkYH1SXGxgIZgAHl5zwRBcjYeFFDOQlYwPZVtz0gRu2pPISNk9LUCpUd4tolrkY6iEut6m4aLapKCMwT5wUo+w2157SSHSgXaGLWTPm1x5OXUJq2epeSPFVF50RoXWZVhYshJDBTZTL0JUFoYIZVFF3Pikep9gAOUBGcJhdIhOX4PgK4ucqXTdC0vBoCcjHMSxabntawP3EYlAYZNWLkhCc+4bzez4NUBC8UfAPEbmDH78gNUp6Ipsh2gqURtckdBUOvA0ZhaHJh/qbL0ZqQZ6CZ6Cs2cPIDmqdEA80gC/UcMld55BSiMaIGN1CQGxg0Doa4epN0gHqLwbdKKskDJrbA3BpgDDtEKW45BRYXHFonJQiAGC4W4D7A4HgdZEkCmkdEHIiC5DFpQFh0h2HwE4daDs9hz6bgiPIJi7J4BRCGJaWytwcLaHPpo8WBpaD7FpsLN0BDRESzFChHIsiKIXFbtcWg/JWGSNWPQTWqxArjD1mKOWJBcjslXNCOcuAFyyJwvAIgqYiwkMBB3KxoQSDd00JAfu/Amxex+LJbkY9BgkBUkNbJfNSCBmDNmKYMIWoIMcOwXeGEl501Xi9dedoDxbx3rJJcK4daHzIsfTwZ8L4J1UbAm+ho04UypgYaaBgrrxwWiuB6y0QHM3oBtd6fg0BfUcGzeQR1oSAzUMDC6YMZmzQUKwdQAB9AqiBLn+HyiLOglyEpkVBuDWZAB2BgABmb5AgACsOwABs/zPL/K2GgHY2w0BbA2LQWI/yvloDQGsNAAAmWgGxrhAsLCQAAnECt5pyICDFiFMNYAh4X/IYBsZFQKNj/IJaiglQLXForRbEDYAgGCcrRQwNFQKdjfKJcSqAayrk3LuYk1RZJaCXPmm8oAA== -->

<!-- internal state end -->
<!-- tips_start -->

---

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

<details>
<summary>❤️ Share</summary>

- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)
- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)
- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)
- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)

</details>

<details>
<summary>🪧 Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=zachowj/node-red-contrib-home-assistant-websocket&utm_content=1804):

- 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.`

### Support

Need help? Create a ticket on our [support page](https://www.coderabbit.ai/contact-us/support) for assistance with any issues or questions.

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](https://docs.coderabbit.ai/finishing-touches/docstrings) for this PR.
- `@coderabbitai generate sequence diagram` to generate a sequence diagram of the changes in this 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.

### Documentation and Community

- Visit our [Documentation](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->

coderabbitai[bot] avatar May 06 '25 15:05 coderabbitai[bot]