@mangar2/zwave
v1.1.0
Published
Integrates open zwave to yaha home automation
Downloads
1
Readme
Abstract
Provides an object to connect openzwave to the yaha mqtt-like broker
--------------------------------------------------------------------------------------------------- This software is licensed under the GNU LESSER GENERAL PUBLIC LICENSE Version 3 . It is furnished "as is" , without any support , and with no warranty , express or implied , as to its usefulness for any purpose . File : zwave . js Author : Volker Böhm Copyright : Volker Böhm ---------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------- This software is licensed under the GNU LESSER GENERAL PUBLIC LICENSE Version 3 . It is furnished "as is" , without any support , and with no warranty , express or implied , as to its usefulness for any purpose . File : zwavecontroller . js Author : Volker Böhm Copyright : Volker Böhm ---------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------- This software is licensed under the GNU LESSER GENERAL PUBLIC LICENSE Version 3 . It is furnished "as is" , without any support , and with no warranty , express or implied , as to its usefulness for any purpose . File : zwave . js Author : Volker Böhm Copyright : Volker Böhm ---------------------------------------------------------------------------------------------------
Contents
Meta
| | | | --- | --- | | File | index.js | | Abstract | Provides an object to connect openzwave to the yaha mqtt-like broker | | Author | Volker Böhm | | Copyright | Copyright ( c ) 2020 Volker Böhm | | License | This software is licensed under the GNU LESSER GENERAL PUBLIC LICENSE Version 3 . It is furnished "as is" , without any support , and with no warranty , express or implied , as to its usefulness for any purpose . |
Type definitions
ZwaveValue {Object}
| Name | Type | Description |
| ---- | ---- | ------- |
| node_id
| number
| | | id of the zwave node | |
| class_id
| number
| | | id of the zwave parameter class | |
| label
| string
| | | label of the value changed | |
| instance
| number
| optional | 1 | index of device instance for a multi instance zwave device | |
| index
| number
| optional | 0 | index of the feature for a multi-feature device class | |
Global functions
_addNode
_addNode (nodeId)
Adds a new zwave device node
_addNode Parameters
| Name | Type | Description |
| ---------- | ------------ | ----------------- |
| nodeId
| string
| id of the zwave device node | |
_notification
_notification (node_id, notif)
_notification Parameters
| Name | Type | Description |
| ---------- | ------------ | ----------------- |
| node_id
| string, number
| id of the node | |
| notif
| number
| notification number | |
_onValueAdded
_onValueAdded (nodeId, comClass, value)
Adds a value to the node tree
_onValueAdded Parameters
| Name | Type | Description |
| ---------- | ------------ | ----------------- |
| nodeId
| string
| id of the zwave device | |
| comClass
| string
| parameter class | |
| value
| string
| new value of the device class | |
_onValueRemoved
_onValueRemoved (nodeId, comClass, index)
Handles a value removed event by removing the value from the node tree
_onValueRemoved Parameters
| Name | Type | Description |
| ---------- | ------------ | ----------------- |
| nodeId
| string
| id of the zwave device | |
| comClass
| string
| parameter class | |
| index
| string
| value index | |
_requestAllConfigParameter
_requestAllConfigParameter (node_id)
Requests all configuration parameter for a dedicated node
_requestAllConfigParameter Parameters
| Name | Type |
| ---------- | ------------ |
| node_id
| value
| |
_setConfigParam
_setConfigParam (nodeId, paramId, value)
Sets a parameter of a zwave node
_setConfigParam Parameters
| Name | Type | Description |
| ---------- | ------------ | ----------------- |
| nodeId
| number
| id of the node | |
| paramId
| number
| id of the parameter to set | |
| value
| number
| parameter value | |
_setValue
_setValue (zwaveObject, value)
Sets a value of a zwave object
_setValue Parameters
| Name | Type | Description |
| ---------- | ------------ | ----------------- |
| zwaveObject
| object
| zwave object to set the value to | |
| value
| string, number, boolean
| value to set | |
addDevice
addDevice ()
Enable adding devices
close
async close ()
Disconnects from usb device
constructor
constructor (config)
Constructs a new zwave controller and binds it to an input device
constructor Parameters
| Name | Type | Description |
| ---------- | ------------ | ----------------- |
| config
| object
| zwave controller configuration | |
config properties
| Name | Type | Description |
| ---------- | ------------ | ----------------- |
| device
| string
| zwave controller device ( COM port ) | |
| topic
| string
| zwave controller topic to send messages | |
logNode
logNode (nodeId)
Logs the infos of a zwave device node to console
logNode Parameters
| Name | Type | Description |
| ---------- | ------------ | ----------------- |
| nodeId
| string
| id of the zwave device node | |
on
on (event, callback)
Sets a callback .
on Parameters
| Name | Type | Description |
| ---------- | ------------ | ----------------- |
| event
| string
| event name ( not case sensitive ) for the callback | |
| callback
| function
| ( parameter ) | |
on throws
| Type | Description |
| ---- | ----------- |
| Error
| if the event is not supported |
| Error
| if the callback is not 'function' |
prepare
prepare (config, zwave) => {Zwave}
Instantiates exactly one zwave object
prepare Parameters
| Name | Type | Attribute | Default | Description |
| ---------- | ------------ | ------------ | ------------ | ----------------- |
| config
| Object
| | | automation configuration | |
| zwave
| Zwave
| optional | null | existing zwave class | |
prepare returns
| Type | Description |
| ---- | ----------- |
| Zwave
| the prepared zwave object |
publishValue
publishValue (nodeId, zwaveValue, reasonString)
Publishes a value
publishValue Parameters
| Name | Type | Description |
| ---------- | ------------ | ----------------- |
| nodeId
| string
| id of the zwave device | |
| zwaveValue
| object
| new value information structure of the device class | |
| reasonString
| string
| the reason string | |
publishValueChange
publishValueChange (nodeId, comClass, value)
Publishes a value change
publishValueChange Parameters
| Name | Type | Description |
| ---------- | ------------ | ----------------- |
| nodeId
| string
| id of the zwave device | |
| comClass
| string
| parameter class | |
| value
| object
| new value information structure of the device class | |
registerZwaveCallbacks
registerZwaveCallbacks ()
Register callbacks for zwave
removeFailedNode
removeFailedNode ()
Remove/delete a failed node or device
requestConfigParametersForAllNodes
requestConfigParametersForAllNodes ()
Iterates through all configurated nodes and requests their configuration parameters
setDeviceConfiguration
setDeviceConfiguration (devices)
Sets the zwave device configuration
setDeviceConfiguration Parameters
| Name | Type | Description |
| ---------- | ------------ | ----------------- |
| devices
| Devices
| tree of device configuration information | |
setNodeInfo
setNodeInfo (nodeId, nodeInfo)
Sets the node info
setNodeInfo Parameters
| Name | Type | Description |
| ---------- | ------------ | ----------------- |
| nodeId
| string
| id of the zwave device node | |
| nodeInfo
| object
| additional information for the node | |
setValue
setValue (topic, value)
Sets a value
setValue Parameters
| Name | Type | Description |
| ---------- | ------------ | ----------------- |
| topic
| string
| name of the topic | |
| value
| string, number, boolean
| to set | |
Class ZwaveDevices
new ZwaveDevices()
ZwaveDevices Methods
_calcMatch
_calcMatch (deviceConfig, zwaveValue) => {number}
Calculates the matching of a device and a value
_calcMatch Parameters
| Name | Type | Description |
| ---------- | ------------ | ----------------- |
| deviceConfig
| DeviceConfig
| new value information structure of the device class | |
| zwaveValue
| ZwaveValue
| new value information structure of the device class | |
_calcMatch returns
| Type | Description |
| ---- | ----------- |
| number
| number of matching sub-items |
_completeDeviceConfig
_completeDeviceConfig (nodes, label, device) => {DeviceConfig}
Gets a full set of zwave identifiers based on the zwave device configuration , default values for instance , index and type - if they are undefined in the configuration and the class_id based on the label - if it is undefined in the configuration
_completeDeviceConfig Parameters
| Name | Type | Description |
| ---------- | ------------ | ----------------- |
| nodes
| Array.<object>
| zwave nodes structure | |
| label
| string
| label of the setting | |
| device
| DeviceConfig
| device configuration | |
_completeDeviceConfig returns
| Type | Description |
| ---- | ----------- |
| DeviceConfig
| device configuration filled with default values and label |
_getObjectByLabel
_getObjectByLabel (nodes, label, nodeId, instanceId)
Gets a zwave controllable element by label
_getObjectByLabel Parameters
| Name | Type | Attribute | Default | Description |
| ---------- | ------------ | ------------ | ------------ | ----------------- |
| nodes
| Array.<object>
| | | zwave nodes structure | |
| label
| string
| | | label of the setting | |
| nodeId
| number
| | | id of the node | |
| instanceId
| number
| optional | 1 | id of the instance | |
_getObjectByLabelRec
_getObjectByLabelRec (object, label, instance)
Recursively searches for an object in the zwave node tree
_getObjectByLabelRec Parameters
| Name | Type | Description |
| ---------- | ------------ | ----------------- |
| object
| object
| object to search for the right zwave object | |
| label
| string
| label of the zwave object to search for | |
| instance
| number
| instance number of the zwave object to search for | |
constructor
constructor (config)
Constructs a new zwave controller and binds it to an input device
constructor Parameters
| Name | Type | Description |
| ---------- | ------------ | ----------------- |
| config
| object
| zwave controller configuration | |
config properties
| Name | Type | Description |
| ---------- | ------------ | ----------------- |
| devices
| object, array
| device definition structure | |
topicToZwaveId
topicToZwaveId (nodes, topic, label) => {DeviceConfig}
Gets a full set of zwave identifiers based on the zwave device configuration , default values for instance , index and type - if they are undefined in the configuration and the class_id based on the label - if it is undefined in the configuration
topicToZwaveId Parameters
| Name | Type | Description |
| ---------- | ------------ | ----------------- |
| nodes
| Array.<object>
| zwave nodes structure | |
| topic
| topic
| topic to look for | |
| label
| string
| label of the setting | |
topicToZwaveId returns
| Type | Description |
| ---- | ----------- |
| DeviceConfig
| zwaveId ( node_id , class_id , instance , index , type ) |
valueToTopicAndType
valueToTopicAndType (zwaveValue) => {Object.<topic:string, type:string>}
Gets the right topic for a value object
valueToTopicAndType Parameters
| Name | Type | Description |
| ---------- | ------------ | ----------------- |
| zwaveValue
| ZwaveValue
| new value information structure of the device class | |
valueToTopicAndType returns
| Type | Description |
| ---- | ----------- |
| Object.<topic:string, type:string>
| topic , if found and device type . Both can be undefined |
Class ZwaveService
new ZwaveService(options)
Creates a remote service
ZwaveService Parameters
| Name | Type | Description |
| ---------- | ------------ | ----------------- |
| options
| Object
| configuration settings for zwave | |
options properties
| Name | Type | Description |
| ---------- | ------------ | ----------------- |
| usb
| string
| zwave usb device name | |
| services
| Array.<Service>
| list of supported services | |
ZwaveService Methods
_setValueIdToDevices
_setValueIdToDevices ()
Iterates through the zwave devices adding value ids
close
async close ()
Closes the broker , stops listening
getSubscriptions
getSubscriptions () => {topic:qos}
Gets the list of required subscriptions for this service
getSubscriptions returns
| Type | Description |
| ---- | ----------- |
| topic:qos
| list of subscription strings |
handleMessage
handleMessage (message)
Processes an incoming mqtt message
handleMessage Parameters
| Name | Type | Description |
| ---------- | ------------ | ----------------- |
| message
| Message
| mqtt message | |
on
on (event, callback)
Sets a callback .
on Parameters
| Name | Type | Description |
| ---------- | ------------ | ----------------- |
| event
| string
| event name ( not case sensitive ) for the callback | |
| callback
| function
| function ( . . . parameter ) | |
on throws
| Type | Description |
| ---- | ----------- |
| Error
| if the event is not supported |
| Error
| if the callback is not 'function' |
run
run ()
Called once after registration to handle additional tasks
setDeviceConfiguration
setDeviceConfiguration (config)
setDeviceConfiguration Parameters
| Name | Type | Description |
| ---------- | ------------ | ----------------- |
| config
| Object
| configuration settings for zwave | |