Giter VIP home page Giter VIP logo

zwavejs.net's People

Contributors

alcalzone avatar dependabot[bot] avatar marcus-j-davies avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

zwavejs.net's Issues

Access to homeID

When a client connects to the ZWave JS server, the first message it receives includes the homeID that identify the ZWave network.
https://github.com/zwave-js/zwave-js-server#api

Could we add access to this value in version 4?
Or is there any other way to get this value using the ZWaveJS.NET lib?

Thanks

Driver.Destroy() throws an exception if Driver.Controller is not initialized

If Driver.Destroy() is called for a Driver instance that has not been successfully initialized for example, it throws an exception at

Controller.Nodes = null;

because Controller is null.
it is easily fixable by checking if Controller is null

if (Controller != null)
{
    Controller.Nodes = null;
    Controller = null;
}

but I wonder what is the benefit of setting Controller.Nodes to null at all, since Controller itself is set to null on the next line?

Method calls for asleep nodes never return

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?

VirtualNode.GetDefinedValueIDs() throws a null reference exception (4.0.0 branch)

Looks like there might be a small mistake in the path for the JO.SelectToken call in the following code:

Driver.Instance.Callbacks.Add(ID, (JO) =>
 {
     CMDResult Res = new CMDResult(JO);
     if (Res.Success)
     {
         Res.SetPayload(JO.SelectToken("result.valueIds").ToObject<ValueID[]>());
     }

     Result.SetResult(Res);
 });

The JSON in the response has "valueIDs" versus the "valueIds" being used in the path.

Can't create a second Driver after destroying the first one

After calling driver.Destroy() I would expect to be able to create and start a new driver instance.

Instead the DriverReady event is never fired, and I can see this is because the Controller property is never set.

Not sure if something needs to be updated, so that the driver and be re-created and started again.

Controller Node is filtered out of the Nodes collection

Why does the library filters out the controller node from the Controller.Nodes collection?

Nodes = Nodes.Where((N) => !N.isControllerNode).ToArray();

The ZWaveNode class includes some useful information like ZWaveNode.deviceConfig.label, ZWaveNode.deviceConfig.manufacturer, that we may want to have access to for the controller node.

ZWaveJS.NET does not support multiple drivers

I'm trying to control multiple instances of ZWave JS from the same C# program. For this, I initialize multiple instances of the ZWaveJS.NET.Driver class but as soon as I initialize a second instance, the Driver.Instance of the first instance is overwritten because Driver.Instance is static:

internal static volatile Driver Instance;

So I think we should refactor the library so that it does not use a singleton pattern for the Driver class. Do you agree ?

RefreshValues does not return any error when node is dead.

If the following code is called for a dead node
CMDResult result = await node.RefreshValues();
the result.Success value is always true

other methods like SetValue() correctly return false for result.Success with a message saying "The message cannot be sent because node 53 is dead (ZW0202)"

Looks like the problem is probably more in ZWave JS Server or node-zwave-js, but I wanted to check here first to know what you think.

Event handlers block processing of new events

When the library calls an event handler, it blocks the processing of new events received from Z-Wave JS Server until the event handler returns.
So if what is implemented in the event handler is time consuming it can cause big delays in the whole application.
Moreover if the event handler itself synchronously calls another ZWave JS .NET method which expects a response from the Z-Wave JS server it creates a deadlock.

To workaround this issue all my event handlers look like this:

private void ExclusionStartedEventHandler()
  {
      //need a Task.Run here because event processing in ZWaveJS.NET is delayed by any event handler
      Task.Run(() =>
      {
....
      });
  }

I don't mind to keep doing this, but I wonder if there is any case where we actually want this blocking behavior?

No error or exception when websocket client fails to connect in client mode

I'm using the ZWaveJS.NET library in client mode, i.e I use some code similar to the example below to connect to an already running ZWave JS server.
If the ZWaveJS Server is not running, I would expect the StartUpError event to be raised but it isn't, and no exception is thrown either. Is there a way to detect that connection has failed?

I'm testing with the 4.0.0 branch, but I think there is the same problem with the main branch.

internal class Program
 {
     static Driver _driver;
     static int schemaVersion = 17;
     static string zWaveJSServerUrl = "ws://localhost:3000";

     static void Main(string[] args)
     {
         try
         {
             _driver = new Driver(new Uri(zWaveJSServerUrl), schemaVersion);
             _driver.DriverReady += Driver_DriverReady;
             _driver.StartUpError += Driver_StartupErrorEvent;
             _driver.Start();

             Console.WriteLine("press enter to stop");
             Console.ReadKey();
         }
         catch(Exception ex)
         {
             Console.WriteLine(ex.ToString());
         }
     }

     static private void Driver_StartupErrorEvent(string message)
     {
         Console.WriteLine(message);
     }

     static private void Driver_DriverReady()
     {
         Console.WriteLine("Driver ready");
     }
}

Logging config not settable

Implemented V3 and it looks great!!!! I needed to rework my app to handle mapping of CMDResults to models my app required, but otherwise, working great! Thank-you and well-done!!!!!!

I did notice that the Options.logConfig property is readonly (with a private setter only), so it's not possible to adjust the logging behavior. Not sure if you intended that to be for your own use or generally available. Either way, I thought I would point it out.

Thanks again for your great work!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.