View Source Grizzly.VirtualDevices (grizzly v8.6.6)
Virtual devices
Virtual devices are in-memory devices that act like a Z-Wave device
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
Same as add_device/3
but raises an ArgumentError if a device with the requested
id is already registered.
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
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 toadd_device/2
.
You may also include other device options that will passed to your callback functions for implementation specific support.
@type device_entry() :: %{ device_impl: Grizzly.VirtualDevices.Device.t(), device_class: Grizzly.ZWave.DeviceClass.t(), device_opts: [Grizzly.VirtualDevices.Device.device_opt()], id: id(), pid: pid() }
@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 toremove_device/2
.
Functions
@spec add_device(id(), Grizzly.VirtualDevices.Device.t(), [add_opt()]) :: {:ok, id()} | {:error, {:already_registered, device_entry()}}
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}
.
@spec add_device!(id(), Grizzly.VirtualDevices.Device.t(), [add_opt()]) :: id()
Same as add_device/3
but raises an ArgumentError if a device with the requested
id is already registered.
@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
@spec remove_device(id(), [remove_opt()]) :: :ok
Remove a device from the virtual device network
@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
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.