An Elixir library for Z-Wave
def deps do
[
{:grizzly, "~> 0.6"}
]
end
See instructions for compiling the zipgateway
binary.
When adding Z-Wave devices you will have to know what security group the device is using. There are 3 groups: none, S0, and S2. For none and S0 you don't have to do anything special during the inclusion process:
iex> Grizzly.add_node()
iex> flush
{:node_added, %Grizzly.Node{...}}
After calling Grizzly.add_node/0
you will then trigger the pairing process
on the device, the instructions for that process can be found in the device's
user manual.
However, if your device is using S2 security you will need to use Grizzly.add_node/1
.
If you are using s2_unauthenticated
this is call you will want to make:
iex> Grizzly.add_node(s2_keys: [:s2_unauthenticated])
iex> flush
If you are using s2_authenticated
you will need to provide a pin that
is located on the device:
iex> Grizzly.add_node(s2_keys: [:s2_authenticated], pin: 1111)
iex> flush
You will see some additional messages when flushing when using S2 security
but you will not need to do anything with them. When using a GenServer
to
manage inclusion you can handle messages via handle_info/2
See Grizzly.Inclusion
module for more information about adding Z-Wave devices
to the network.
Removing a Z-Wave device looks like:
iex> Grizzly.remove_node()
iex> flush
{:node_removed, 12}
Where 12
is the id of the node you removed.
When you use a GenServer
to manage exclusion you can handle messages via
handle_info/2
See Grizzly.Inclusion
module for more information about removing Z-Wave devices
from the network.
Additional Z-Wave docs can be found at Silicon Labs.
Say you have added a door lock to your Z-Wave controller that has the id of 12
, now
you want to unlock it. There are three steps to this process: get the node from the
Z-Wave network, connect to the node, and then send Z-Wave commands to it.
iex> {:ok, lock} = Grizzly.get_node(12)
iex> {:ok, lock} = Grizzly.Node.connect(lock)
iex> Grizzly.send_command(lock, Grizzly.CommandClass.DoorLock.OperationSet, mode: :unsecured)
:ok
If you are just trying things out in an iex session can you use send_command
with the node id:
iex> Grizzly.send_command(12, Grizzly.CommandClass.DoorLock.OperationSet, mode: :unsecured)
However, this is slower in general and is only recommended for quick one off command sending. If you're building a long running application the first example is recommend along with storing the connected device to keep the connection alive for faster response times.
see the Grizzly
module docs for more details about Grizzly.send_command
Different systems will use different serial ports to talk to the Z-Wave controller.
In order to configure this, there is a serial_port
option. Below is an example
for the Raspberry PI 3:
config :grizzly,
serial_port: "/dev/ttyACM0"
If you are using a base nerves system please see the documentation for your particular system at the Nerves Project github page.
If you want to run tests without running the zipgateway
binary provided by Silicon Labs you
can configure run_zipgateway_bin
to be false
:
config :grizzly,
run_zipgateway_bin: false
First download the Z/IP GW SDK from Silicon Labs.
For this you will need to make a free account with Silicon Labs. The default binaries that come
with the download will not work by default in Nerves system, so you will need to compile the source
for your target. The source code can be found in the Source
directory.
This can be tricky and the instructions are a work in progress, so for now please contact us if you any troubles.