View Source Grizzly.VirtualDevices (grizzly v5.3.0)

Virtual devices

Virtual devices are in-memory devices that act like a Z-Wave device

Link to this section Summary

Types

Options for adding a virtual devices

Id for a virtual device

Options for removing virtual devices

Functions

Add a new virtual device to the virtual device network

Broadcast a command to the rest of the Z-Wave network

List the nodes in the virtual devices network

Remove a device from the virtual device network

Send a Z-Wave command to the virtual device

Get the pid for the device id

Link to this section Types

@type add_opt() ::
  {:inclusion_handler, Grizzly.handler()}
  | Grizzly.VirtualDevices.Device.device_opt()

Options for adding a virtual devices

  • :inclusion_handler - if an inclusion handler is provider via the add options it will override the initial inclusion handle argument to the network server if one was provided only for that one call to add_device/2.

You may also include other device options that will passed to your callback functions for implementation specific support.

@type id() :: {:virtual, integer()}

Id for a virtual device

@type remove_opt() :: {:inclusion_handler, Grizzly.handler()}

Options for removing virtual devices

  • :inclusion_handler - if an inclusion handler is provider via the add options it will override the initial inclusion handle argument to the network server if one was provided only for that one call to remove_device/2.

Link to this section Functions

Link to this function

add_device(device_impl, opts \\ [])

View Source
@spec add_device(Grizzly.VirtualDevices.Device.t(), [add_opt()]) :: id()

Add a new virtual device to the virtual device network

To add a virtual device you must supply a module that implements the Grizzly.VirtualDevices.Device behaviour.

If the device takes any options you can pass a tuple of {device, opts}.

Link to this function

broadcast_command(device_id, command)

View Source
@spec broadcast_command(id(), Grizzly.ZWave.Command.t()) :: :ok

Broadcast a command to the rest of the Z-Wave network

@spec list_nodes() :: [id()]

List the nodes in the virtual devices network

Link to this function

remove_device(device_id, opts \\ [])

View Source
@spec remove_device(id(), [remove_opt()]) :: :ok

Remove a device from the virtual device network

Link to this function

send_command(device_id, node_info_get)

View Source
@spec send_command(id(), Grizzly.ZWave.Command.t()) :: {:ok, Grizzly.Report.t()}

Send a Z-Wave command to the virtual device

@spec whereis(id()) :: pid() | nil

Get the pid for the device id

This is useful for when you device is processed-based and you need to send messages to it.