Skip to content

Method calls for asleep nodes never return #51

Closed

Description

@spudwebb

If, for example, the RefreshValues() or SetValue() methods are called for a node that is asleep, the method never return (unless the node wakes up)
Shouldn't there be some sort of timeout in order to guarantee that the method will return within a certain time?

Activity

  1. marcus-j-davies commented on Nov 14, 2023

    @marcus-j-davies
    Member

    Hi @spudwebb

    All calls to a node will wait until the node responds, as that is how the driver behaves. the reason there is no timeout here or driver side, is due to the fact the set could fail once awake, if a value is outside the range for the device for example

    There is the method of ZWaveNode.WaitForWakeup() but in reality there is no difference into just allowing the calls to complete once a node is awake.

  2. spudwebb commented on Nov 15, 2023

    @spudwebb
    ContributorAuthor

    Hi @marcus-j-davies

    I understand the rationale behind this, but from a practical standpoint I don't see how any application could use such command methods without implementing some kind of timeout themselves: any application that has user interaction or needs to run a command within a certain timeframe can't wait indefinitely for the method to return.

    That's why I wish most of command methods in ZWaveNode would have an optional timeout parameter (or an optional CancellationToken parameter) and would return an error saying something like "No response received from the driver after X seconds. The command may or may not succeed"

    For now I will implement something like this on my side.

  3. marcus-j-davies commented on Nov 17, 2023

    @marcus-j-davies
    Member

    Sorry @spudwebb
    Have been down with a winter virus since Tuesday, still recovering.

    I do get it, and will keep it in mind for the future, I think its my stubbornness with wanting to keep the lib to near native API as possible with the JS counterpart, I don't have to write masses amount of documentation that way, as users can follow the Native Driver docs 😄

    Example, most Driver methods are a javascript promise, so it feels right to follow that Trend with Tasks.

    With that said,
    You can check ZWaveNode.status before deciding if you should wait for an action to "resolve"

    public enum NodeStatus
    {
         Unknown,
         Asleep,
         Awake,
         Dead,
         Alive
    }

    Alive, Awake is only different in that, the node can also sleep (Asleep) if Awake

  4. locked and limited conversation to collaborators on Nov 17, 2023
  5. converted this issue into a discussion #53 on Nov 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions