zwave-js / zwavejs.net Goto Github PK
View Code? Open in Web Editor NEWA Z-Wave JS wrapper for the .NET Framework. Supporting various targets, and providing a feature rich Z-Wave API.
License: MIT License
A Z-Wave JS wrapper for the .NET Framework. Supporting various targets, and providing a feature rich Z-Wave API.
License: MIT License
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
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?
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?
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.
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.
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.
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:
So I think we should refactor the library so that it does not use a singleton pattern for the Driver class. Do you agree ?
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.
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?
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");
}
}
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!
Diving into this package and I have to say you all are doing wonderful work!!!!
Any timeline on the SmartStart support?
Is there a way to get the ValueMetadata.ccSpecific field?
https://zwave-js.github.io/node-zwave-js/#/api/valueid?id=valuemetadata
If not, could this be added to the ValueMetadata class in 4.0.0 ?
Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.