Search documentation of grizzly

# View Source Grizzly.VirtualDevices (grizzly v7.4.2)

Virtual devices

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

# Summary

## Types

add_opt()

Options for adding a virtual devices

id()

Id for a virtual device

remove_opt()

Options for removing virtual devices

## Functions

add_device(device_impl, opts \\ [])

Add a new virtual device to the virtual device network

broadcast_command(device_id, command)

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

list_nodes()

List the nodes in the virtual devices network

remove_device(device_id, opts \\ [])

Remove a device from the virtual device network

send_command(device_id, node_info_get)

Send a Z-Wave command to the virtual device

whereis(device_id)

Get the pid for the device id

# Types

Link to this type

# add_opt()

View Source

    @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.

Link to this type

# id()

View Source

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

Id for a virtual device

Link to this type

# remove_opt()

View Source

    @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`.

# 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

Link to this function

# list_nodes()

View Source

    @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()} | {:error, :device_not_found | Grizzly.Report.t()}

Send a Z-Wave command to the virtual device

Link to this function

# whereis(device_id)

View Source

    @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.