Node-red-contrib-zwave-js values

Hi there,

Ive integrated the zwave-js nodes in my flow. They work and a testdevice shows up in te Zwave pane at the right if the gui editor.
One zwave node is configured to listen to the test device (node 2) and there are message caught with a debug node (all msg).

Only thing is, i don't see any real values like temperatures, humidity. I do see the min/max etc but not real measurement values while if I take a look at the zwave pane then they are there.

Q: hoe do i retrieve that info? Google gives me no examples or info.

I expect to setup something with :link:CC API and getValueDB, but not sure how to approach.
Or are these values global accessable through some zwave.node.value thingie?

Could someone point me.in the right direction howto get the values from zwave-js cache?

Update:
I do get updates of values now (battery devices take more time to populate). So i could capture that, but it seems double as there is already a local store (cache).

Hello,

I am the author of node-red-contrib-zwave-js.

Q: hoe do i retrieve that info? Google gives me no examples or info.

A: The values are provided as and when, your devices send the info.
They are provided as an VALUE_UPDATED event. (most the time) - there is an event table on the main GitHub page

Depending on the type of value (CC - Command Class), the event structure may differ, and the value may be under a different property in the event.

Hi Marcus,

Thank you for reaching out. Yes, i've seen the value updated events.
What I would like to achieve is that I can retieve any zwave values from the zwave-node element or the zwave controller element stored in cache, by sending a command like getValueDB(..., Node,..).
Temperature, humidity, battery state, water-detectiom, illumination, etc.
The sensors are all Sensative strips and send only on changes or long interval so I cant really wait for an event to happen.

Please share me your thoughts.

By the way, zwave-je works better then the openzwave :slight_smile:

Addition:
A simple example flow would be perfect, how to insert a command to retrieve a (cached) zwave value.
One controller, one node, a query (insertion + function for example), and a debug out.

Why not store the value in context using a change node ? Then you can retrieve it any time you like.

(The basic concept of nodejs is to be event driven so only to report things when necessary rather than polling)

@tjarcoboerkoel,

As suggested, you can store values in context storage, when your devices send an update,
After all, the values are only sent via VALUE_UPDATED or NOTIFICATION events when they have changed, so fetching them again, will likely yield the same result.

Addition:
A simple example flow would be perfect, how to insert a command to retrieve a (cached) zwave value.
One controller, one node, a query (insertion + function for example), and a debug out.

There are 2 API's to this module: ValueAPI or CCAPI
The ValueAPI - is cache centric, but that cache is updated, as and when your devices send updates.
The CCAPI - is direct communication with the device.

Both API's can set values also - attached is an example flow

[{"id":"26d23f8.a8a2ec","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"44895a54.187244","type":"group","z":"26d23f8.a8a2ec","name":"Using the ValueAPI - Cached","style":{"label":true,"label-position":"ne"},"nodes":["7529e007.f935e8","50ef7165.7170b8","8041d160.de3dc","227591f6.bb3b4e","840f9c41.d9d42","790383f5.f47624"],"x":49,"y":364,"w":512,"h":177},{"id":"4616ded0.650c4","type":"group","z":"26d23f8.a8a2ec","name":"CC API - Not Cached","style":{"label":true,"label-position":"ne"},"nodes":["40cd6458.54a23c","e3179255.bc1b78","85b8a294.74c93","406b2aca.9faa8c"],"x":59,"y":559,"w":492,"h":132},{"id":"2abe451f.18d85a","type":"zwave-js","z":"26d23f8.a8a2ec","serialPort":"Select Port","name":"Z-Wave JS Controller","encryptionKey":"","ackTimeout":"","controllerTimeout":"","sendResponseTimeout":"","logLevel":"none","logFile":"","logNodeFilter":"","sendUsageStatistics":false,"valueCacheDiskThrottle":"normal","customConfigPath":"","x":350,"y":190,"wires":[[]]},{"id":"113592be.af943d","type":"comment","z":"26d23f8.a8a2ec","name":"ZWave Device Node Is optional. (but allows better organisation)","info":"","x":930,"y":445,"wires":[]},{"id":"d040d9a2.e2d5c8","type":"zwave-device","z":"26d23f8.a8a2ec","name":"Some Z-Wave Device","filteredNodeId":"All","multicast":false,"datamode":"Send/Receive","outputs":1,"inputs":1,"x":820,"y":510,"wires":[["c4314390.e19378"]]},{"id":"7529e007.f935e8","type":"inject","z":"26d23f8.a8a2ec","g":"44895a54.187244","name":"Get All Value IDs","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":180,"y":405,"wires":[["227591f6.bb3b4e"]]},{"id":"50ef7165.7170b8","type":"function","z":"26d23f8.a8a2ec","g":"44895a54.187244","name":"","func":"let ValueID = {\n \n \"commandClassName\": \"Notification\",\n \"commandClass\": 113,\n \"endpoint\": 0,\n \"property\": \"Access Control\",\n \"propertyKey\": \"Door state\",\n \"propertyName\": \"Access Control\",\n \"propertyKeyName\": \"Door state\"\n}\n\nlet Message = {\n payload: {\n mode: \"ValueAPI\",\n node: 4,\n method: \"getValue\",\n params: [ValueID]\n }\n}\nreturn Message","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":475,"y":460,"wires":[["d040d9a2.e2d5c8"]]},{"id":"8041d160.de3dc","type":"inject","z":"26d23f8.a8a2ec","g":"44895a54.187244","name":"Get A Value (cache)","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":185,"y":460,"wires":[["50ef7165.7170b8"]]},{"id":"227591f6.bb3b4e","type":"function","z":"26d23f8.a8a2ec","g":"44895a54.187244","name":"","func":"let Message = {\n payload: {\n mode: \"ValueAPI\",\n node: 4,\n method: \"getDefinedValueIDs\",\n }\n}\nreturn Message","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":475,"y":415,"wires":[["d040d9a2.e2d5c8"]]},{"id":"c4314390.e19378","type":"debug","z":"26d23f8.a8a2ec","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":940,"y":580,"wires":[]},{"id":"b59d0196.629eb","type":"comment","z":"26d23f8.a8a2ec","name":"Only 1 Controller can be deployed per Node-red Instance","info":"","x":455,"y":150,"wires":[]},{"id":"840f9c41.d9d42","type":"function","z":"26d23f8.a8a2ec","g":"44895a54.187244","name":"","func":"let ValueID = {\n \n \"commandClassName\": \"Notification\",\n \"commandClass\": 113,\n \"endpoint\": 0,\n \"property\": \"Access Control\",\n \"propertyKey\": \"Door state\",\n \"propertyName\": \"Access Control\",\n \"propertyKeyName\": \"Door state\"\n}\n\nlet Message = {\n payload: {\n mode: \"ValueAPI\",\n node: 4,\n method: \"pollValue\",\n params: [ValueID]\n }\n}\nreturn Message","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":475,"y":500,"wires":[["d040d9a2.e2d5c8"]]},{"id":"790383f5.f47624","type":"inject","z":"26d23f8.a8a2ec","g":"44895a54.187244","name":"Force A Value Update (Poll Device)","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":240,"y":500,"wires":[["840f9c41.d9d42"]]},{"id":"40cd6458.54a23c","type":"inject","z":"26d23f8.a8a2ec","g":"4616ded0.650c4","name":"Get A Value","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":175,"y":600,"wires":[["85b8a294.74c93"]]},{"id":"e3179255.bc1b78","type":"function","z":"26d23f8.a8a2ec","g":"4616ded0.650c4","name":"","func":"let Message = {\n payload: {\n mode: \"CCAPI\",\n node: 9,\n cc: \"Binary Switch\",\n method: \"set\",\n params: [false]\n }\n}\nreturn Message","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":465,"y":650,"wires":[["d040d9a2.e2d5c8"]]},{"id":"85b8a294.74c93","type":"function","z":"26d23f8.a8a2ec","g":"4616ded0.650c4","name":"","func":"let Message = {\n payload: {\n mode: \"CCAPI\",\n node: 9,\n cc: \"Binary Switch\",\n method: \"get\",\n }\n}\nreturn Message","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":465,"y":610,"wires":[["d040d9a2.e2d5c8"]]},{"id":"406b2aca.9faa8c","type":"inject","z":"26d23f8.a8a2ec","g":"4616ded0.650c4","name":"Set A Value","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":180,"y":650,"wires":[["e3179255.bc1b78"]]}]

Could be an option, but it's not logical if there is already al local store with zwave cache.
It is written that all requests getValueDB are not queried at the devicea, but are retrieved from Zwave cache. It's by design. So why should I add another caching mechanism to store all data?

Cache holds values, timestamp, batty levels, etc. If I could just generate a getValueDB(node, valueID[x,y,z] ) resulting in a JSON output (preffered as a single combined JSON output for the device holding all requested values).

Best regards,

Hi Marcus,

Thank you for the flow. I'll take a look.

Best regards,

It's a working Progress, but here is the wiki for each API

CCAPI Wiki

ValueAPI Wiki

Hi Marcus,

Yes, again thanks.
This is exactly what I was looking for. Question, do I need to fill the complete valueID object, or is one enough (for example the property key).

Best regards,

Hey!

I think at the minimum - as long as it identifies the endpoint, CC, and key - it should work.

Here is a hint:
In the UI tab, double click a value. it will show you the ValueID

O wow Marcus,

This works great! Indeed, just copy the device valueID (ait temperature) from the zwave pane and paste it into the Function node's valueID and it works!

What I notice is that if I insert this query into a "some-zwave-device" node, that other device nodes get an "het_value_respondse" event fired.
That could be usefull.

Thank you for the support!

Best regards,

The device node is very dynamic,

if you have multiple device nodes, and they are set to All Nodes or Multiple (with the device selected), those device nodes will receive the same message.

if you have device nodes, in Specific Node mode then it will only receive a messages for that device.

A message being received (as a result of your input) - will be seen by device nodes, providing they have been setup to listen for your target node ( Specific Node, All Nodes, Multiple accordingly )

Hi Marcus,

Last thing, can I add multiple ValudIDs to a query? It seems to be an array but if I add multiple ValueIDs only the first is processed.

let ValueID1 = {
    "commandClassName": "Multilevel Sensor",
    "commandClass": 49,
    "endpoint": 0,
    "property": "Air temperature",
    "propertyName": "Air temperature"
  }
 let ValueID2 = {
    "commandClassName": "Multilevel Sensor",
    "commandClass": 49,
    "endpoint": 0,
    "property": "Illuminance",
    "propertyName": "Illuminance"
  }
 let ValueID3 = {
    "commandClassName": "Multilevel Sensor",
    "commandClass": 49,
    "endpoint": 0,
    "property": "Moisture",
    "propertyName": "Moisture"
  }

let Message = {
 payload: {
 mode: "ValueAPI",
 node: 2,
 method: "getValue",
 params: [ValueID1, ValueID2, ValueID3]
 }
}
return Message

Is this by design?
Best regards,

It is by design.

getValue only supports fetching the value as specified by the ValueID.
The reason the params are an array, is because its used for most commands, that need more then 1 param.

Example, setValue

let Message = {
    payload: {
        mode: "ValueAPI",
        node: 2,
        method: "setValue",
        params: [<ValueID>,<some value>]
    }
}
return Message

params is used to specify any arguments that the method may need, getValue just needs 1 param

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.