Search documentation of grizzly

# View Source Grizzly.ZWave.Command behaviour (grizzly v7.4.2)

Data struct and behaviour for working with Z-Wave commands

# Summary

## Types

delay_seconds()
params()
t()

Command struct

## Callbacks

decode_params(binary)

Decode the binary string of command params

encode_params(t)

Encode the command parameters

encode_params(t, opts)

Encode the command parameters with encoding options

new(params)

Make a new `Command.t()` from the params provided

## Functions

encode_params(command)
has_param?(command, param)
param(command, param, default \\ nil)

Get the command param value out the params list

param!(command, param)

Just like `param/3` but will raise if the the param is not in the param list

put_param(command, param, new_value)

Put the param value into the params list, updating pervious value if there is one

to_binary(command)

Encode the `Command.t()` into it's binary representation

# Types

Link to this type

# delay_seconds()

View Source

    @type delay_seconds() :: non_neg_integer()

Link to this type

# params()

View Source

    @type params() :: Keyword.t()

Link to this type

# t()

View Source

    @type t() :: %Grizzly.ZWave.Command{
      command_byte: byte() | nil,
      command_class: Grizzly.ZWave.CommandClass.t(),
      impl: module(),
      name: atom(),
      params: params()
    }

Command struct

- `:name` - the name of the command
- `:command_class` - the command class module for the command
- `:command_byte` - the byte representation of the command
- `:params` - the parameters for the command as outlined by the Z-Wave specification
- `:impl` - the module that implements the Command behaviour

# Callbacks

Link to this callback

# decode_params(binary)

View Source

    @callback decode_params(binary()) ::
      {:ok, keyword()} | {:error, Grizzly.ZWave.DecodeError.t()}

Decode the binary string of command params

Link to this callback

# encode_params(t)

View Source

    @callback encode_params(t()) :: binary()

Encode the command parameters

Link to this callback

# encode_params(t, opts)

View Source (optional)

    @callback encode_params(t(), opts :: keyword()) :: binary()

Encode the command parameters with encoding options

The encoding options help pass extra context to how the parameters for the command should be encoded.

This is an optional callback.

Link to this callback

# new(params)

View Source

    @callback new(params :: keyword()) :: {:ok, t()} | {:error, reason :: any()}

Make a new `Command.t()` from the params provided

Param validation should take place here.

# Functions

Link to this function

# encode_params(command)

View Source

    @spec encode_params(t()) :: binary()

Link to this function

# has_param?(command, param)

View Source

    @spec has_param?(t(), atom()) :: boolean()

Link to this function

# param(command, param, default \\ nil)

View Source

    @spec param(t(), atom(), term()) :: term() | nil

Get the command param value out the params list

Link to this function

# param!(command, param)

View Source

    @spec param!(t(), atom()) :: term() | no_return()

Just like `param/3` but will raise if the the param is not in the param list

Link to this function

# put_param(command, param, new_value)

View Source

    @spec put_param(t(), atom(), any()) :: t()

Put the param value into the params list, updating pervious value if there is one

Link to this function

# to_binary(command)

View Source

    @spec to_binary(t()) :: binary()

Encode the `Command.t()` into it's binary representation