Skip to content

Commit

Permalink
Documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
jdomnitz committed Nov 13, 2024
1 parent 623b939 commit 8ae0f44
Show file tree
Hide file tree
Showing 19 changed files with 242 additions and 23 deletions.
3 changes: 3 additions & 0 deletions ZWaveDotNet/CommandClasses/ApplicationCapability.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@

namespace ZWaveDotNet.CommandClasses
{
/// <summary>
/// The Application Capability Command Class comprises commands for handling issues related to dynamic support for command classes.
/// </summary>
[CCVersion(CommandClass.ApplicationCapability)]
public class ApplicationCapability : CommandClassBase
{
Expand Down
4 changes: 4 additions & 0 deletions ZWaveDotNet/CommandClasses/ApplicationStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@

namespace ZWaveDotNet.CommandClasses
{
/// <summary>
/// This command class contains commands that are not directly related to a specific functionality in the application,
/// but are useful for maintaining an optimal Z-Wave system.
/// </summary>
[CCVersion(CommandClass.ApplicationStatus)]
public class ApplicationStatus : CommandClassBase
{
Expand Down
34 changes: 34 additions & 0 deletions ZWaveDotNet/CommandClasses/Association.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@

namespace ZWaveDotNet.CommandClasses
{
/// <summary>
/// The Association Command Class is used to manage associations to NodeID destinations.
/// A NodeID destination may be a simple device or the Root Device of a Multi Channel device.
/// </summary>
[CCVersion(CommandClass.Association, 1, 3)]
public class Association : CommandClassBase
{
Expand All @@ -36,28 +40,58 @@ enum AssociationCommand
}
public Association(Node node, byte endpoint) : base(node, endpoint, CommandClass.Association) { }

/// <summary>
/// <b>Version 1</b>: Request the current destinations of a given association group
/// </summary>
/// <param name="groupID"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public async Task<AssociationReport> Get(byte groupID, CancellationToken cancellationToken = default)
{
ReportMessage response = await SendReceive(AssociationCommand.Get, AssociationCommand.Report, cancellationToken, groupID);
return new AssociationReport(response.Payload.Span);
}

/// <summary>
/// <b>Version 2</b>: This command allows a portable controller to interactively create associations from a multi-button device to a destination that is out of direct range.
/// </summary>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public async Task<byte> GetSpecific(CancellationToken cancellationToken = default)
{
var response = await SendReceive(AssociationCommand.SpecificGroupGet, AssociationCommand.SpecificGroupReport, cancellationToken);
return response.Payload.Span[0];
}

/// <summary>
/// <b>Version 1</b>: Add destinations to a given association group
/// </summary>
/// <param name="groupID"></param>
/// <param name="cancellationToken"></param>
/// <param name="nodeIDs"></param>
/// <returns></returns>
public async Task Add(byte groupID, CancellationToken cancellationToken, params byte[] nodeIDs)
{
await SendCommand(AssociationCommand.Set, cancellationToken, nodeIDs.Prepend(groupID).ToArray());
}

/// <summary>
/// <b>Version 1</b>: Remove destinations from a given association group
/// </summary>
/// <param name="groupID"></param>
/// <param name="cancellationToken"></param>
/// <param name="nodeIDs"></param>
/// <returns></returns>
public async Task Remove(byte groupID, CancellationToken cancellationToken, params byte[] nodeIDs)
{
await SendCommand(AssociationCommand.Remove, cancellationToken, nodeIDs.Prepend(groupID).ToArray());
}

/// <summary>
/// <b>Version 1</b>: Request the number of association groups that this node supports
/// </summary>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public async Task<AssociationGroupsReport> GetGroups(CancellationToken cancellationToken = default)
{
ReportMessage response = await SendReceive(AssociationCommand.GroupingsGet, AssociationCommand.GroupingsReport, cancellationToken);
Expand Down
35 changes: 35 additions & 0 deletions ZWaveDotNet/CommandClasses/BarrierOperator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@

namespace ZWaveDotNet.CommandClasses
{
/// <summary>
/// The Barrier Operator Command Class is used to control and query the status of motorized barriers.
/// </summary>
[CCVersion(CommandClass.BarrierOperator, 1)]
public class BarrierOperator : CommandClassBase
{
Expand All @@ -41,6 +44,12 @@ enum BarrierOperatorCommand : byte

public BarrierOperator(Node node, byte endpoint) : base(node, endpoint, CommandClass.BarrierOperator) { }

/// <summary>
/// Request the current state of a barrier operator device
/// </summary>
/// <param name="cancellationToken"></param>
/// <returns></returns>
/// <exception cref="MethodAccessException"></exception>
public async Task<BarrierReport> Get(CancellationToken cancellationToken = default)
{
if (node.ID == Node.BROADCAST_ID)
Expand All @@ -49,11 +58,22 @@ public async Task<BarrierReport> Get(CancellationToken cancellationToken = defau
return new BarrierReport(response.Payload.Span);
}

/// <summary>
/// Initiate an unattended change in state of the barrier
/// </summary>
/// <param name="open"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public async Task Set(bool open, CancellationToken cancellationToken = default)
{
await SendCommand(BarrierOperatorCommand.Set, cancellationToken, open ? (byte)0xFF : (byte)0x00);
}

/// <summary>
/// Query a device for available subsystems which may be controlled via Z-Wave
/// </summary>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public async Task<BarrierSignal[]> GetSupportedSignals(CancellationToken cancellationToken = default)
{
ReportMessage response = await SendReceive(BarrierOperatorCommand.SupportedGet, BarrierOperatorCommand.SupportedReport, cancellationToken);
Expand All @@ -67,11 +87,26 @@ public async Task<BarrierSignal[]> GetSupportedSignals(CancellationToken cancell
return supportedTypes.ToArray();
}

/// <summary>
/// Turn on or off an event signaling subsystem that is supported by the device
/// </summary>
/// <param name="signal"></param>
/// <param name="active"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public async Task SignalSet(BarrierSignal signal, bool active, CancellationToken cancellationToken = default)
{
await SendCommand(BarrierOperatorCommand.Set, cancellationToken, (byte)signal, active ? (byte)0xFF : (byte)0x00);
}

/// <summary>
/// Request the state of a signaling subsystem to a supporting node
/// </summary>
/// <param name="signal"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
/// <exception cref="MethodAccessException"></exception>
/// <exception cref="DataException"></exception>
public async Task<KeyValuePair<BarrierSignal, bool>> SignalGet(BarrierSignal signal, CancellationToken cancellationToken = default)
{
if (node.ID == Node.BROADCAST_ID)
Expand Down
15 changes: 15 additions & 0 deletions ZWaveDotNet/CommandClasses/Basic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@

namespace ZWaveDotNet.CommandClasses
{
/// <summary>
/// The Basic Command Class allows a controlling device to operate the primary functionality of a supporting device without any further knowledge.
/// </summary>
[CCVersion(CommandClass.Basic, 2)]
public class Basic : CommandClassBase
{
Expand All @@ -33,6 +36,12 @@ enum BasicCommand : byte

public Basic(Node node, byte endpoint) : base(node, endpoint, CommandClass.Basic) { }

/// <summary>
/// <b>Version 1</b>: Request the status of a supporting device
/// </summary>
/// <param name="cancellationToken"></param>
/// <returns></returns>
/// <exception cref="MethodAccessException"></exception>
public async Task<BasicReport> Get(CancellationToken cancellationToken = default)
{
if (node.ID == Node.BROADCAST_ID)
Expand All @@ -41,6 +50,12 @@ public async Task<BasicReport> Get(CancellationToken cancellationToken = default
return new BasicReport(response.Payload.Span);
}

/// <summary>
/// <b>Version 1</b>: Set a value in a supporting device
/// </summary>
/// <param name="value"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public async Task Set(byte value, CancellationToken cancellationToken = default)
{
await SendCommand(BasicCommand.Set, cancellationToken, value);
Expand Down
4 changes: 2 additions & 2 deletions ZWaveDotNet/CommandClasses/CRC16.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ public enum CRC16Command

public CRC16(Node node, byte endpoint) : base(node, endpoint, CommandClass.CRC16) { }

public static bool IsEncapsulated(ReportMessage msg)
internal static bool IsEncapsulated(ReportMessage msg)
{
return msg.CommandClass == CommandClass.CRC16 && msg.Command == (byte)CRC16Command.Encap;
}

public static void Encapsulate (List<byte> payload)
internal static void Encapsulate (List<byte> payload)
{
byte[] header = new byte[]
{
Expand Down
9 changes: 6 additions & 3 deletions ZWaveDotNet/CommandClasses/DeviceResetLocally.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

using ZWaveDotNet.Entities;
using ZWaveDotNet.SerialAPI;
using ZWaveDotNet.Enums;
using Serilog;
using ZWaveDotNet.CommandClassReports.Enums;
using ZWaveDotNet.Entities;
using ZWaveDotNet.Enums;
using ZWaveDotNet.SerialAPI;

namespace ZWaveDotNet.CommandClasses
{
/// <summary>
/// This Command Class is used to notify central controllers that a Z-Wave device is resetting its network specific parameters.
/// </summary>
[CCVersion(CommandClass.DeviceResetLocally)]
public class DeviceResetLocally : CommandClassBase
{
Expand Down
4 changes: 2 additions & 2 deletions ZWaveDotNet/CommandClasses/MultiChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ public async Task<List<byte>> GetAggregatedMembers(byte endpointId, Cancellation
return ret;
}

public static bool IsEncapsulated(ReportMessage msg)
internal static bool IsEncapsulated(ReportMessage msg)
{
return msg.CommandClass == CommandClass.MultiChannel && msg.Command == (byte)MultiChannelCommand.Encap;
}

public static void Encapsulate (List<byte> payload, byte destinationEndpoint)
internal static void Encapsulate (List<byte> payload, byte destinationEndpoint)
{
byte[] header = new byte[]
{
Expand Down
4 changes: 2 additions & 2 deletions ZWaveDotNet/CommandClasses/MultiCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ public enum MultiCommandCommand
}
public MultiCommand(Node node, byte endpoint) : base(node, endpoint, CommandClass.MultiCommand) { }

public static bool IsEncapsulated(ReportMessage msg)
internal static bool IsEncapsulated(ReportMessage msg)
{
return msg.CommandClass == CommandClass.MultiCommand && msg.Command == (byte)MultiCommandCommand.Encap;
}

public static void Encapsulate (List<byte> payload, List<CommandMessage> commands)
internal static void Encapsulate (List<byte> payload, List<CommandMessage> commands)
{
payload.Clear();
payload.Add((byte)CommandClass.MultiCommand);
Expand Down
11 changes: 10 additions & 1 deletion ZWaveDotNet/CommandClasses/SceneActivation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@

namespace ZWaveDotNet.CommandClasses
{
/// <summary>
/// This Command Class is used for launching scenes in a number of actuator nodes e.g. another scene-controlling unit, a multilevel switch, a binary switch etc.
/// </summary>
[CCVersion(CommandClass.SceneActivation)]
public class SceneActivation : CommandClassBase
{
Expand All @@ -28,9 +31,15 @@ enum SceneActivationCommand : byte

public SceneActivation(Node node, byte endpoint) : base(node, endpoint, CommandClass.SceneActivation) { }

/// <summary>
/// Activate the scene associated to the scene ID
/// </summary>
/// <param name="sceneId"></param>
/// <param name="duration"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public async Task Set(byte sceneId, TimeSpan duration, CancellationToken cancellationToken = default)
{

await SendCommand(SceneActivationCommand.Set, cancellationToken, sceneId, PayloadConverter.GetByte(duration));
}

Expand Down
20 changes: 20 additions & 0 deletions ZWaveDotNet/CommandClasses/SceneActuatorConf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@

namespace ZWaveDotNet.CommandClasses
{
/// <summary>
/// This Command Class is used to configure scenes settings for a node supporting an actuator Command Class, e.g.a multilevel switch, binary switch etc.
/// </summary>
[CCVersion(CommandClass.SceneActuatorConf)]
public class SceneActuatorConf : CommandClassBase
{
Expand All @@ -31,6 +34,14 @@ enum SceneActuatorConfCommand : byte

public SceneActuatorConf(Node node, byte endpoint) : base(node, endpoint, CommandClass.SceneActuatorConf) { }

/// <summary>
/// Request the settings for a given scene identifier or for the scene currently active
/// </summary>
/// <param name="sceneId"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
/// <exception cref="MethodAccessException"></exception>
/// <exception cref="ArgumentException"></exception>
public async Task<SceneActuatorConfigurationReport> Get(byte sceneId, CancellationToken cancellationToken = default)
{
if (node.ID == Node.BROADCAST_ID)
Expand All @@ -42,6 +53,15 @@ public async Task<SceneActuatorConfigurationReport> Get(byte sceneId, Cancellati
return new SceneActuatorConfigurationReport(response.Payload.Span);
}

/// <summary>
/// Associate the specified scene ID to the defined actuator settings
/// </summary>
/// <param name="sceneId"></param>
/// <param name="duration"></param>
/// <param name="level"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
/// <exception cref="ArgumentException"></exception>
public async Task Set(byte sceneId, TimeSpan duration, byte? level = null, CancellationToken cancellationToken = default)
{
if (sceneId == 0)
Expand Down
20 changes: 20 additions & 0 deletions ZWaveDotNet/CommandClasses/SceneControllerConf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@

namespace ZWaveDotNet.CommandClasses
{
/// <summary>
/// This Command Class is used to configure nodes launching scenes using their association groups
/// </summary>
[CCVersion(CommandClass.SceneControllerConf)]
public class SceneControllerConf : CommandClassBase
{
Expand All @@ -31,6 +34,14 @@ enum SceneActuatorConfCommand : byte

public SceneControllerConf(Node node, byte endpoint) : base(node, endpoint, CommandClass.SceneControllerConf) { }

/// <summary>
/// Request the settings for a given association grouping identifier or the active settings
/// </summary>
/// <param name="groupId"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
/// <exception cref="MethodAccessException"></exception>
/// <exception cref="ArgumentException"></exception>
public async Task<SceneControllerConfigurationReport> Get(byte groupId, CancellationToken cancellationToken = default)
{
if (node.ID == Node.BROADCAST_ID)
Expand All @@ -42,6 +53,15 @@ public async Task<SceneControllerConfigurationReport> Get(byte groupId, Cancella
return new SceneControllerConfigurationReport(response.Payload.Span);
}

/// <summary>
/// Configure settings for a given physical item on the device
/// </summary>
/// <param name="groupId"></param>
/// <param name="sceneId"></param>
/// <param name="duration"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
/// <exception cref="ArgumentException"></exception>
public async Task Set(byte groupId, byte sceneId, TimeSpan duration, CancellationToken cancellationToken = default)
{
if (groupId == 0)
Expand Down
Loading

0 comments on commit 8ae0f44

Please sign in to comment.