# Node-red-contrib-zwave-js values

**URL:** <https://discourse.nodered.org/t/node-red-contrib-zwave-js-values/48706>\
**Category:** General\
**Created:** [21 July 2021 10:56 UTC](https://discourse.nodered.org/t/node-red-contrib-zwave-js-values/48706 "2021-07-21T10:56:45Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![tjarcoboerkoel](https://avatars.discourse-cdn.com/v4/letter/t/67e7ee/32.png) [@tjarcoboerkoel](https://discourse.nodered.org/u/tjarcoboerkoel)\
**Post date:** [21 July 2021 10:56 UTC](https://discourse.nodered.org/t/node-red-contrib-zwave-js-values/48706/1 "2021-07-21T10:56:45Z")

</div>

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 🔗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?

---

<div class="post-metadata">

**Author:** ![tjarcoboerkoel](https://avatars.discourse-cdn.com/v4/letter/t/67e7ee/32.png) [@tjarcoboerkoel](https://discourse.nodered.org/u/tjarcoboerkoel)\
**Post date:** [21 July 2021 17:08 UTC](https://discourse.nodered.org/t/node-red-contrib-zwave-js-values/48706/2 "2021-07-21T17:08:33Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [22 July 2021 03:28 UTC](https://discourse.nodered.org/t/node-red-contrib-zwave-js-values/48706/3 "2021-07-22T03:28:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![tjarcoboerkoel](https://avatars.discourse-cdn.com/v4/letter/t/67e7ee/32.png) [@tjarcoboerkoel](https://discourse.nodered.org/u/tjarcoboerkoel)\
**Post date:** [22 July 2021 04:39 UTC](https://discourse.nodered.org/t/node-red-contrib-zwave-js-values/48706/4 "2021-07-22T04:39:57Z")

</div>

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 🙂

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.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [22 July 2021 06:40 UTC](https://discourse.nodered.org/t/node-red-contrib-zwave-js-values/48706/5 "2021-07-22T06:40:48Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [22 July 2021 07:55 UTC](https://discourse.nodered.org/t/node-red-contrib-zwave-js-values/48706/6 "2021-07-22T07:55:40Z")

</div>

@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"]]}]`

---

<div class="post-metadata">

**Author:** ![tjarcoboerkoel](https://avatars.discourse-cdn.com/v4/letter/t/67e7ee/32.png) [@tjarcoboerkoel](https://discourse.nodered.org/u/tjarcoboerkoel)\
**Post date:** [22 July 2021 07:57 UTC](https://discourse.nodered.org/t/node-red-contrib-zwave-js-values/48706/7 "2021-07-22T07:57:12Z")

</div>

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,

---

<div class="post-metadata">

**Author:** ![tjarcoboerkoel](https://avatars.discourse-cdn.com/v4/letter/t/67e7ee/32.png) [@tjarcoboerkoel](https://discourse.nodered.org/u/tjarcoboerkoel)\
**Post date:** [22 July 2021 07:59 UTC](https://discourse.nodered.org/t/node-red-contrib-zwave-js-values/48706/8 "2021-07-22T07:59:10Z")

</div>

Hi Marcus,

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

Best regards,

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [22 July 2021 07:59 UTC](https://discourse.nodered.org/t/node-red-contrib-zwave-js-values/48706/9 "2021-07-22T07:59:26Z")

</div>

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

CCAPI Wiki

> **[CC API · zwave-js/node-red-contrib-zwave-js Wiki](https://github.com/zwave-js/node-red-contrib-zwave-js/wiki/CC-API)**
>
> An extremely easy to use, zero dependency and feature rich Z-Wave node for Node Red, based on Z-Wave JS - CC API · zwave-js/node-red-contrib-zwave-js Wiki

ValueAPI Wiki

> **[Value API · zwave-js/node-red-contrib-zwave-js Wiki](https://github.com/zwave-js/node-red-contrib-zwave-js/wiki/Value-API)**
>
> An extremely easy to use, zero dependency and feature rich Z-Wave node for Node Red, based on Z-Wave JS - Value API · zwave-js/node-red-contrib-zwave-js Wiki

---

<div class="post-metadata">

**Author:** ![tjarcoboerkoel](https://avatars.discourse-cdn.com/v4/letter/t/67e7ee/32.png) [@tjarcoboerkoel](https://discourse.nodered.org/u/tjarcoboerkoel)\
**Post date:** [22 July 2021 08:28 UTC](https://discourse.nodered.org/t/node-red-contrib-zwave-js-values/48706/10 "2021-07-22T08:28:40Z")

</div>

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,

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [22 July 2021 08:32 UTC](https://discourse.nodered.org/t/node-red-contrib-zwave-js-values/48706/11 "2021-07-22T08:32:52Z")

</div>

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

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/0/5049e7aaf73b1a4dfebd8456e0689179dac51647.png)

---

<div class="post-metadata">

**Author:** ![tjarcoboerkoel](https://avatars.discourse-cdn.com/v4/letter/t/67e7ee/32.png) [@tjarcoboerkoel](https://discourse.nodered.org/u/tjarcoboerkoel)\
**Post date:** [22 July 2021 10:38 UTC](https://discourse.nodered.org/t/node-red-contrib-zwave-js-values/48706/12 "2021-07-22T10:38:22Z")

</div>

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,

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [22 July 2021 10:46 UTC](https://discourse.nodered.org/t/node-red-contrib-zwave-js-values/48706/13 "2021-07-22T10:46:28Z")

</div>

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 )

---

<div class="post-metadata">

**Author:** ![tjarcoboerkoel](https://avatars.discourse-cdn.com/v4/letter/t/67e7ee/32.png) [@tjarcoboerkoel](https://discourse.nodered.org/u/tjarcoboerkoel)\
**Post date:** [22 July 2021 10:55 UTC](https://discourse.nodered.org/t/node-red-contrib-zwave-js-values/48706/14 "2021-07-22T10:55:53Z")

</div>

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.

```auto
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,

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [22 July 2021 11:02 UTC](https://discourse.nodered.org/t/node-red-contrib-zwave-js-values/48706/15 "2021-07-22T11:02:39Z")

</div>

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`

```auto
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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [20 September 2021 11:03 UTC](https://discourse.nodered.org/t/node-red-contrib-zwave-js-values/48706/16 "2021-09-20T11:03:28Z")

</div>

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