Skip to content

Commit d5fe7ba

Browse files
authored
Add NodeAlive event to the ZWaveNode class, and add lastSeen property to the NodeStatistics class. (#67)
* Add NodeAlive event to the ZWaveNode class, and add lastSeen property to the NodeStatistics class. * Add lastSeen to the ZWaveNode and Statistics classes as DateTime?
1 parent fd41e0a commit d5fe7ba

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

Visual Studio Projects/ZWaveJS.NET/ZWaveJS.NET/Driver.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,17 @@ private void MapNodeEvents()
194194
});
195195
});
196196

197+
NodeEventMap.Add("alive", (JO) =>
198+
{
199+
int NID = JO.SelectToken("event.nodeId").ToObject<int>();
200+
ZWaveNode N = this.Controller.Nodes.Get(NID);
201+
202+
Task.Run(() =>
203+
{
204+
N.Trigger_NodeAlive();
205+
});
206+
});
207+
197208
NodeEventMap.Add("dead", (JO) =>
198209
{
199210
int NID = JO.SelectToken("event.nodeId").ToObject<int>();

Visual Studio Projects/ZWaveJS.NET/ZWaveJS.NET/Statistics.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
namespace ZWaveJS.NET
1+
using System;
2+
3+
namespace ZWaveJS.NET
24
{
35
public class NodeStatisticsUpdatedArgs : NodeStatistics
46
{
@@ -27,6 +29,8 @@ internal NodeStatistics() { }
2729
public RouteStatisctics lwr { get; internal set; }
2830
[Newtonsoft.Json.JsonProperty]
2931
public RouteStatisctics nlwr { get; internal set; }
32+
[Newtonsoft.Json.JsonProperty]
33+
public DateTime? lastSeen { get; internal set; }
3034
}
3135

3236
public class ControllerStatisticsUpdatedArgs : ControllerStatistics

Visual Studio Projects/ZWaveJS.NET/ZWaveJS.NET/ZWaveNode.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,14 @@ internal void Trigger_Notification(int CCID, JObject Args)
8080
Notification?.Invoke(this, CCID, Args);
8181
}
8282

83+
public delegate void NodeAliveEvent(ZWaveNode Node);
84+
public event NodeAliveEvent NodeAlive;
85+
internal void Trigger_NodeAlive()
86+
{
87+
this.status = Enums.NodeStatus.Alive;
88+
NodeAlive?.Invoke(this);
89+
}
90+
8391
public delegate void NodeDeadEvent(ZWaveNode Node);
8492
public event NodeDeadEvent NodeDead;
8593
internal void Trigger_NodeDead()
@@ -834,6 +842,8 @@ public Task<CMDResult> WaitForWakeup()
834842
[Newtonsoft.Json.JsonProperty]
835843
public NodeStatistics statistics { get; internal set; }
836844
[Newtonsoft.Json.JsonProperty]
845+
public DateTime? lastSeen { get; internal set; }
846+
[Newtonsoft.Json.JsonProperty]
837847
public Protocols protocol { get; internal set; }
838848

839849
[Newtonsoft.Json.JsonProperty(PropertyName = "nodeId")]

0 commit comments

Comments
 (0)