Grizzly.ZWave.Commands (grizzly v9.1.0)

Copy Markdown View Source

Lookup table for sendable Z-Wave commands.

Summary

Functions

Get the handler spec for the command

Look up the command module and handler options for a given command, either by name or from its binary representation.

Look up the command module and handler options for a given command class byte and command byte.

Get the command spec for a given command name.

Get the command spec for a given command class byte and command byte.

Whether the command can be supervised (only commands that use the AckResponse handler can be supervised).

Functions

builtin_commands()

create(command_name, params \\ [])

@spec create(
  atom(),
  keyword()
) :: {:error, :unknown_command} | {:ok, Grizzly.ZWave.Command.t()}

create!(command_name, params \\ [])

@spec create!(
  atom(),
  keyword()
) :: Grizzly.ZWave.Command.t()

decode(binary)

format_handler_spec(spec)

@spec format_handler_spec(module() | Grizzly.handler_spec()) :: Grizzly.handler_spec()

handler(command_name)

@spec handler(Grizzly.command()) :: Grizzly.handler_spec()

Get the handler spec for the command

lookup(command_name)

@spec lookup(Grizzly.command() | binary()) :: {module(), [Grizzly.command_opt()]}

Look up the command module and handler options for a given command, either by name or from its binary representation.

lookup(cc_byte, command_byte)

@spec lookup(byte(), byte()) :: {module(), [Grizzly.command_opt()]}

Look up the command module and handler options for a given command class byte and command byte.

spec_for(command_name)

@spec spec_for(Grizzly.command()) ::
  {:ok, Grizzly.ZWave.CommandSpec.t()} | {:error, :unknown_command}

Get the command spec for a given command name.

Examples

iex> Grizzly.ZWave.Commands.spec_for(:user_set)
{:ok, %Grizzly.ZWave.CommandSpec{
  name: :user_set,
  command_byte: 0x05,
  command_class: :user_credential,
  default_params: [],
  module: Grizzly.ZWave.Commands.UserSet,
  encode_fun: {Grizzly.ZWave.Commands.UserSet, :encode_params},
  decode_fun: {Grizzly.ZWave.Commands.UserSet, :decode_params},
  handler: {Grizzly.Requests.Handlers.AckResponse, []},
  supports_supervision?: true
}}

spec_for(cc_byte, command_byte)

@spec spec_for(byte(), byte()) ::
  {:ok, Grizzly.ZWave.CommandSpec.t()} | {:error, :unknown_command}

Get the command spec for a given command class byte and command byte.

spec_for!(command_name)

See spec_for/1.

spec_for!(cc_byte, command_byte)

@spec spec_for!(byte(), byte()) :: Grizzly.ZWave.CommandSpec.t()

See spec_for/2.

supports_supervision?(command_name)

@spec supports_supervision?(Grizzly.command()) :: boolean()

Whether the command can be supervised (only commands that use the AckResponse handler can be supervised).