Jerome Brette's Blog

Jerome Brette's Blog

ZWave/ZigBee

Goal

In order to transforme a PI into a home automation controller, it is necessary to add Zwave and ZigBee capabilities to the the Wifi and Bluetooth capabilities of the PI.

Key

  • Transform Raspberry-PI + Dongle into a SUC ZWave controller
  • Try to use with OpenHAB or HomeAssistant

Testing on the OpenHAB Container

The OpenHAB architecture is Java based.

Testing on the HomeAssistant Container

HomeAssistant is Python based and relies on OpenZWave. Some of the data is also saved in SQLite. In both cases developping small Python scripts to investigate the setup seems to be the easiest way.

Commands

HomeAssistant seems to intialize ZWave support through the following code

/usr/lib/python3.6/site-packages/homeassistant/components/zwave/__init__.py

In the docker container itself.

pyozw_check -d /dev/ttyUSB0

-------------------------------------------------------------------------------
Import libs
Try to import libopenzwave
Try to import libopenzwave.PyLogLevels
Try to get options
Try to get manager
Try to get python_openzwave version
0.4.3
Try to get python_openzwave full version
python_openzwave version 0.4.3 (embed-cython / Jul  4 2018 - 18:58:22)
Try to get openzwave version
1.4.2926
Try to get default config path
/usr/lib/python3.6/site-packages/python_openzwave/ozw_config
Try to destroy manager
Try to destroy options
Try to import openzwave (API)

Logs

OpenZWave.txt

2018-07-07 05:11:04.866 Always, OpenZwave Version 1.4.2926 Starting Up
2018-07-07 05:11:20.242 Info, Setting Up Provided Network Key for Secure Communications
2018-07-07 05:11:20.242 Warning, Failed - Network Key Not Set
2018-07-07 05:11:20.243 Info, mgr,     Added driver for controller /dev/ttyUSB0
2018-07-07 05:11:20.243 Info,   Opening controller /dev/ttyUSB0
2018-07-07 05:11:20.243 Info, Trying to open serial port /dev/ttyUSB0 (attempt 1)
2018-07-07 05:11:20.245 Info, Serial port /dev/ttyUSB0 opened (attempt 1)
2018-07-07 05:11:20.245 Detail, contrlr, Queuing (Command) FUNC_ID_ZW_GET_VERSION: 0x01, 0x03, 0x00, 0x15, 0xe9
2018-07-07 05:11:20.245 Detail, contrlr, Queuing (Command) FUNC_ID_ZW_MEMORY_GET_ID: 0x01, 0x03, 0x00, 0x20, 0xdc
2018-07-07 05:11:20.246 Detail, contrlr, Queuing (Command) FUNC_ID_ZW_GET_CONTROLLER_CAPABILITIES: 0x01, 0x03, 0x00, 0x05, 0xf9
2018-07-07 05:11:20.246 Detail, contrlr, Queuing (Command) FUNC_ID_SERIAL_API_GET_CAPABILITIES: 0x01, 0x03, 0x00, 0x07, 0xfb
2018-07-07 05:11:20.246 Detail, contrlr, Queuing (Command) FUNC_ID_ZW_GET_SUC_NODE_ID: 0x01, 0x03, 0x00, 0x56, 0xaa
2018-07-07 05:11:20.246 Detail,
2018-07-07 05:11:20.246 Info, contrlr, Sending (Command) message (Callback ID=0x00, Expected Reply=0x15) - FUNC_ID_ZW_GET_VERSION: 0x01, 0x03, 0x00, 0x15, 0xe9
2018-07-07 05:11:20.250 Detail, contrlr,   Received: 0x01, 0x10, 0x01, 0x15, 0x5a, 0x2d, 0x57, 0x61, 0x76, 0x65, 0x20, 0x34, 0x2e, 0x30, 0x35, 0x00, 0x01, 0x97
2018-07-07 05:11:20.250 Detail,
2018-07-07 05:11:20.250 Info, contrlr, Received reply to FUNC_ID_ZW_GET_VERSION:
2018-07-07 05:11:20.250 Info, contrlr,     Static Controller library, version Z-Wave 4.05
2018-07-07 05:11:20.250 Detail, Node045,   Expected reply was received
2018-07-07 05:11:20.250 Detail, Node045,   Message transaction complete
2018-07-07 05:11:20.250 Detail,
2018-07-07 05:11:20.250 Detail, contrlr, Removing current message
2018-07-07 05:11:20.251 Detail,
2018-07-07 05:11:20.251 Info, contrlr, Sending (Command) message (Callback ID=0x00, Expected Reply=0x20) - FUNC_ID_ZW_MEMORY_GET_ID: 0x01, 0x03, 0x00, 0x20, 0xdc
2018-07-07 05:11:20.254 Detail, contrlr,   Received: 0x01, 0x08, 0x01, 0x20, 0xec, 0x5a, 0x75, 0x19, 0x01, 0x0d
2018-07-07 05:11:20.254 Detail,
2018-07-07 05:11:20.254 Info, contrlr, Received reply to FUNC_ID_ZW_MEMORY_GET_ID. Home ID = 0xec5a7519.  Our node ID = 1
2018-07-07 05:11:20.254 Detail, Node090,   Expected reply was received
2018-07-07 05:11:20.254 Detail, Node090,   Message transaction complete
2018-07-07 05:11:20.254 Detail,
2018-07-07 05:11:20.254 Detail, contrlr, Removing current message
2018-07-07 05:11:20.254 Detail,
2018-07-07 05:11:20.254 Info, contrlr, Sending (Command) message (Callback ID=0x00, Expected Reply=0x05) - FUNC_ID_ZW_GET_CONTROLLER_CAPABILITIES: 0x01, 0x03, 0x00, 0x05, 0xf9
2018-07-07 05:11:20.257 Detail, contrlr,   Received: 0x01, 0x04, 0x01, 0x05, 0x28, 0xd7
2018-07-07 05:11:20.257 Detail,
2018-07-07 05:11:20.257 Info, contrlr, Received reply to FUNC_ID_ZW_GET_CONTROLLER_CAPABILITIES:
2018-07-07 05:11:20.257 Info, contrlr,     There is no SUC ID Server (SIS) in this network.
2018-07-07 05:11:20.257 Info, contrlr,     The PC controller is a primary controller.
2018-07-07 05:11:20.257 Detail, Node215,   Expected reply was received
2018-07-07 05:11:20.257 Detail, Node215,   Message transaction complete
2018-07-07 05:11:20.257 Detail,
2018-07-07 05:11:20.257 Detail, contrlr, Removing current message
2018-07-07 05:11:20.257 Detail,
2018-07-07 05:11:20.257 Info, contrlr, Sending (Command) message (Callback ID=0x00, Expected Reply=0x07) - FUNC_ID_SERIAL_API_GET_CAPABILITIES: 0x01, 0x03, 0x00, 0x07, 0xfb
2018-07-07 05:11:20.263 Detail, contrlr,   Received: 0x01, 0x2b, 0x01, 0x07, 0x04, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0xfe, 0x81, 0xff, 0x88, 0xcf, 0x1f, 0x00, 0x00, 0xfb, 0x9f, 0x7d,
2018-07-07 05:11:20.263 Detail,
2018-07-07 05:11:20.263 Info, contrlr,  Received reply to FUNC_ID_SERIAL_API_GET_CAPABILITIES
2018-07-07 05:11:20.264 Info, contrlr,     Serial API Version:   4.32
2018-07-07 05:11:20.264 Info, contrlr,     Manufacturer ID:      0x0000
2018-07-07 05:11:20.264 Info, contrlr,     Product Type:         0x0001
2018-07-07 05:11:20.264 Info, contrlr,     Product ID:           0x0001
2018-07-07 05:11:20.264 Detail, contrlr, Queuing (Command) FUNC_ID_ZW_GET_RANDOM: 0x01, 0x04, 0x00, 0x1c, 0x20, 0xc7
2018-07-07 05:11:20.264 Detail, contrlr, Queuing (Command) FUNC_ID_SERIAL_API_GET_INIT_DATA: 0x01, 0x03, 0x00, 0x02, 0xfe
2018-07-07 05:11:20.264 Detail, contrlr, Queuing (Command) FUNC_ID_SERIAL_API_SET_TIMEOUTS: 0x01, 0x05, 0x00, 0x06, 0x64, 0x0f, 0x97
2018-07-07 05:11:20.264 Detail, contrlr, Queuing (Command) FUNC_ID_SERIAL_API_APPL_NODE_INFORMATION: 0x01, 0x07, 0x00, 0x03, 0x01, 0x02, 0x01, 0x00, 0xf9
2018-07-07 05:11:20.264 Detail, Node032,   Expected reply was received
2018-07-07 05:11:20.264 Detail, Node032,   Message transaction complete
2018-07-07 05:11:20.264 Detail,
2018-07-07 05:11:20.264 Detail, contrlr, Removing current message
2018-07-07 05:11:20.264 Detail,
2018-07-07 05:11:20.264 Info, contrlr, Sending (Command) message (Callback ID=0x00, Expected Reply=0x56) - FUNC_ID_ZW_GET_SUC_NODE_ID: 0x01, 0x03, 0x00, 0x56, 0xaa
2018-07-07 05:11:20.267 Detail, contrlr,   Received: 0x01, 0x04, 0x01, 0x56, 0x00, 0xac
2018-07-07 05:11:20.280 Detail,
2018-07-07 05:11:20.280 Info, contrlr, Received reply to GET_SUC_NODE_ID.  Node ID = 0
2018-07-07 05:11:20.280 Info, Controller Does not Support SUC - Cannot Setup Controller as SUC Node
2018-07-07 05:11:20.280 Detail, Node172,   Expected reply was received
2018-07-07 05:11:20.281 Detail, Node172,   Message transaction complete
2018-07-07 05:11:20.281 Detail,
2018-07-07 05:11:20.281 Detail, contrlr, Removing current message
2018-07-07 05:11:20.281 Detail,
2018-07-07 05:11:20.281 Info, contrlr, Sending (Command) message (Callback ID=0x00, Expected Reply=0x1c) - FUNC_ID_ZW_GET_RANDOM: 0x01, 0x04, 0x00, 0x1c, 0x20, 0xc7
2018-07-07 05:11:20.335 Detail, contrlr,   Received: 0x01, 0x25, 0x01, 0x1c, 0x01, 0x20, 0x05, 0xee, 0x89, 0xf8, 0xcc, 0xfc, 0x39, 0xec, 0xc6, 0xe2, 0xe8, 0x96, 0x54, 0xe1, 0x49, 0x4f, 0x2b,
2018-07-07 05:11:20.335 Detail,
2018-07-07 05:11:20.335 Info, contrlr, Received reply to FUNC_ID_ZW_GET_RANDOM: true
2018-07-07 05:11:20.335 Detail, Node032,   Expected reply was received
2018-07-07 05:11:20.335 Detail, Node032,   Message transaction complete
2018-07-07 05:11:20.335 Detail,
2018-07-07 05:11:20.335 Detail, contrlr, Removing current message
2018-07-07 05:11:20.335 Detail,
2018-07-07 05:11:20.335 Info, contrlr, Sending (Command) message (Callback ID=0x00, Expected Reply=0x02) - FUNC_ID_SERIAL_API_GET_INIT_DATA: 0x01, 0x03, 0x00, 0x02, 0xfe
2018-07-07 05:11:20.393 Detail, contrlr,   Received: 0x01, 0x25, 0x01, 0x02, 0x05, 0x00, 0x1d, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2018-07-07 05:11:20.393 Detail,
2018-07-07 05:11:20.393 Info, mgr,     Driver with Home ID of 0xec5a7519 is now ready.
2018-07-07 05:11:20.393 Info,
2018-07-07 05:11:20.394 Info, contrlr, Received reply to FUNC_ID_SERIAL_API_GET_INIT_DATA:
2018-07-07 05:11:20.394 Info, contrlr,     Node 001 - Known
2018-07-07 05:11:20.394 Detail, Node001, AdvanceQueries queryPending=0 queryRetries=0 queryStage=CacheLoad live=1
2018-07-07 05:11:20.394 Detail, Node001, QueryStage_CacheLoad
2018-07-07 05:11:20.394 Info, Node001, Node Identity Codes: 0000:0001:0001
2018-07-07 05:11:20.394 Detail, Node001, QueryStage_Associations
2018-07-07 05:11:20.394 Detail, Node001, QueryStage_Neighbors
2018-07-07 05:11:20.394 Detail, contrlr, Requesting routing info (neighbor list) for Node 1
2018-07-07 05:11:20.394 Detail, Node001, Queuing (Command) Get Routing Info (Node=1): 0x01, 0x07, 0x00, 0x80, 0x01, 0x00, 0x00, 0x03, 0x7a
2018-07-07 05:11:20.394 Detail, Node001, Queuing (Query) Query Stage Complete (Neighbors)
2018-07-07 05:11:20.394 Detail,   Expected reply was received
2018-07-07 05:11:20.394 Detail,   Message transaction complete
2018-07-07 05:11:20.394 Detail,
2018-07-07 05:11:20.394 Detail, contrlr, Removing current message
2018-07-07 05:11:20.395 Detail, Node001, Notification: DriverReady
2018-07-07 05:11:20.402 Detail, Node001, Notification: NodeAdded
2018-07-07 05:11:20.430 Detail, Node001, Notification: NodeProtocolInfo
2018-07-07 05:11:20.432 Detail, Node001, Notification: EssentialNodeQueriesComplete
2018-07-07 05:11:20.432 Detail, Node001, Notification: ValueAdded
2018-07-07 05:11:20.433 Detail,
2018-07-07 05:11:20.434 Info, contrlr, Sending (Command) message (Callback ID=0x00, Expected Reply=0x06) - FUNC_ID_SERIAL_API_SET_TIMEOUTS: 0x01, 0x05, 0x00, 0x06, 0x64, 0x0f, 0x97
2018-07-07 05:11:20.436 Detail, contrlr,   Received: 0x01, 0x05, 0x01, 0x06, 0x64, 0x0f, 0x96
2018-07-07 05:11:20.437 Detail,
2018-07-07 05:11:20.437 Info, contrlr, Received reply to FUNC_ID_SERIAL_API_SET_TIMEOUTS
2018-07-07 05:11:20.437 Detail, Node015,   Expected reply was received
2018-07-07 05:11:20.437 Detail, Node015,   Message transaction complete
2018-07-07 05:11:20.437 Detail,
2018-07-07 05:11:20.437 Detail, contrlr, Removing current message
2018-07-07 05:11:20.437 Detail,
2018-07-07 05:11:20.437 Info, contrlr, Sending (Command) message (Callback ID=0x00, Expected Reply=0x00) - FUNC_ID_SERIAL_API_APPL_NODE_INFORMATION: 0x01, 0x07, 0x00, 0x03, 0x01, 0x02, 0x01,
2018-07-07 05:11:20.439 Detail, contrlr, Removing current message
2018-07-07 05:11:20.439 Detail,
2018-07-07 05:11:20.439 Info, Node001, Sending (Command) message (Callback ID=0x00, Expected Reply=0x80) - Get Routing Info (Node=1): 0x01, 0x07, 0x00, 0x80, 0x01, 0x00, 0x00, 0x03, 0x7a
2018-07-07 05:11:20.446 Detail, Node001,   Received: 0x01, 0x20, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2018-07-07 05:11:20.466 Detail,
2018-07-07 05:11:20.466 Info, Node001, Received reply to FUNC_ID_ZW_GET_ROUTING_INFO
2018-07-07 05:11:20.466 Info, Node001,     Neighbors of this node are:
2018-07-07 05:11:20.466 Info, Node001,  (none reported)
2018-07-07 05:11:20.466 Detail,   Expected reply was received
2018-07-07 05:11:20.466 Detail,   Message transaction complete
2018-07-07 05:11:20.466 Detail,
2018-07-07 05:11:20.466 Detail, Node001, Removing current message
2018-07-07 05:11:20.466 Detail, Node001, Query Stage Complete (Neighbors)
2018-07-07 05:11:20.466 Detail, Node001, AdvanceQueries queryPending=0 queryRetries=0 queryStage=Session live=1
2018-07-07 05:11:20.467 Detail, Node001, QueryStage_Session
2018-07-07 05:11:20.467 Detail, Node001, QueryStage_Dynamic
2018-07-07 05:11:20.467 Detail, Node001, QueryStage_Configuration
2018-07-07 05:11:20.467 Detail, Node001, QueryStage_Complete
2018-07-07 05:11:20.467 Warning, CheckCompletedNodeQueries m_allNodesQueried=0 m_awakeNodesQueried=0
2018-07-07 05:11:20.467 Warning, CheckCompletedNodeQueries all=1, deadFound=0 sleepingOnly=1
2018-07-07 05:11:20.467 Info,          Node query processing complete.
2018-07-07 05:11:20.467 Detail, Node001, Notification: NodeQueriesComplete
2018-07-07 05:11:20.469 Detail, contrlr, Notification: AllNodesQueried
~~~

### Reference Links

- [Link2](https://github.com/OpenZWave/python-openzwave)

Last updated on 6 Jul 2018
Published on 6 Jul 2018
 Edit on GitHub