In a previous post, I showed you an Arduino based controller to manage the lighting system in the house. Such a device is useful for handling the basic 'electrical' stuff such as lights, doorbells, gates, knobs and buttons.
For other home automation/control desires, you often need to put special purpose devices in difficult locations, such as roller-shutters near the windows, RGB-controllers in the ceiling.
To accomplish the latter, for this project, I've opted not to build all these devices myself, but instead go for a ready made solution, based on the Z-Wave protocol. This project will only cover the basics: setting up the gateway and adding/removing Z-Wave devices.
Note: The gateway is required cause Z-Wave devices can't directly connect to the internet.
IngredientsWe are going to use:
- 1 Raspberry Pi for running the applications
- 1 sigma USB controller
- 1 or more Z-Wave devices like a door-sensor, eye, roller-shutter.
The software running on the RPi is called pygate. It's a framework that turns your RPi in a gateway to the AllThingsTalk cloud. The application works with plugins so that it's functionality can be selected, depending on the project: do you want Z-Wave, virtual devices (web-resources), xBee, associations, scenes, groups, or something else, just pick the plugins that you like and put them together.
For this project, we are going to use the Z-Wave plugin. This module uses the open-zwave libraries for communicating with our devices.
The gateway is hooked up to the AllThingsTalk cloud for long distance access and for talking to other devices, like the Controllino as discussed in this post. The AllThingsTalk cloud also provides a 'developer view
' user interface on the gateway which allows you to configure and control the gateway and devices.
- Follow this procedure to install the Pygate framework on the RPI
- Connect the USB dongle to the RPI.
- Next, you need to install the Z-Wave plugin for Pygate. You can follow this procedure.
- Don't forget to configure the plugin
- Activate it (Note: use the manual process, since the gateway has not yet been added to the cloud)
You are now ready to start up your gateway, so reboot the RPI.
ClaimOnce your RPI is running, it's time to add it to your account on AllThingsTalk. You do this by 'claiming
' your gateway.
Note: The claim code for your gateway, is the MAC address of the RPi, formatted like so: A44A16BF1665. You can find it with the command 'ifconfig
' or in the log file of Pygate.
- Make certain that Pygate is running on the RPI (and connected to the internet)
- Go to the gateways page (the connector icon in the left upper corner) and click on: '
connect a gateway
'
- Enter your claim code (the mac address)
- Wait until the process is done
Once your gateway is available on AllThingsTalk, you can start adding Z-Wave devices to the controller. In Z-Wave, adding a device requires both an action on the Z-Wave controller (the RPI) and on the device. The general approach is always:
- The controller needs to be put in a special '
include
' mode
- Next you probably have to do some action on the device, usually this is clicking on a button 3 times, but it is manufacturer dependent, so check the docs. For instance, some devices will perform the include immediately after power up for the first time.
- Wait until the operation is done (or canceled).
With Pygate, the procedure becomes:
- Go to the overview page of the gateway, this looks like so (Note: the UI gets frequent updates, so changes might have happened):
- Select the first asset: '
zwave discovery state'
, who's value should be 'off
'. See the screenshot in 'remove a device
'.
- If the input is not a drop-down box, click on the upper right gear and select the correct control. When done, close the details popup.
- Click on the drop-down and select '
include
'.
- As a confirmation, the '
state
' at the top of the window should have been changed to 'include
'.
- Perform the action on the device.
- Wait a couple of seconds for the sync to start.
- When the initial handshake is done and the sync operation is running, the '
zwave discovery state
' will change back to 'off
'.
- You can now go to the devices page and view the newly added device. Note, for battery powered devices, it might take a while before all the assets have been added. This can take up to hours in some cases.
The procedure for removing a device is almost identical to the include process:
- Go to the '
zwave discovery state
' again
- Click on the drop-down and select '
exclude
'
- As a confirmation, the '
state
' at the top of the window should have been changed to 'exclude
'
- Perform the action on the device.
- Wait a couple of seconds for the removal process to finish.
- When the operation is done, '
zwave discovery state
' will change back to 'off
'.
Reset
You can reset the Z-Wave controller using 1 of the 2 gateway actuators:
- soft reset: Resets a controller without erasing its network configuration settings
- hard reset: Resets a controller and erases its network configuration settings. The controller becomes a primary controller ready to add devices to a new network
State
You can monitor the state of the Z-Wave plugin with these 3 gateway sensors:
- Controller state: the last reported state of the USB controller: normal, starting, cancel, error, waiting, sleeping, in-progress, completed, failed, nodeok, nodefailed.
- Network state: the state of network: starting, failed, ready, awake.
- Devices state: The query state of the devices (None queried, essentials queried, awake queried, all queried, all queried-some dead).
Devices
Each device receives some standard assets for maintenance and monitoring, which are always present for all Z-Wave devices:
- Refresh: ask the device to refresh it's definition and the values for all the assets.
- Query state: reports the state of the sync process: what functionality has already been reported and what is not yet done.
- Failed: in case of battery powered devices, this asset reports if the Z-Wave controller considered the device as '
failed
', meaning it can be removed from the network without intervention on the device itself.
Up until now, we have only used the default device and gateway views on the AllThingsTalk platform in order to control and monitor things.
This can become a little tedious for your devices as they tend to have a lot of assets. This is primarily because of the many configuration features. Which often makes it hard to find the correct asset in the list when you want to do something with the device (like open/close the roller-shutters).
There are several options that you an take to add some 'remote-control' views to your setup:
- Create pinboards: The AllThingsTalk platform allows you to create your custom pin-boards, that allows you to select which assets and where on the pinboard they need to be placed. This is a screenshot:
- If you want something different, you can always try out the att-dash mobile application (as shown in last section of the previous post):
Comments
Please log in or sign up to comment.