# Interrogating z wave thermostat using node-red-contrib-zwave-js

**URL:** <https://discourse.nodered.org/t/interrogating-z-wave-thermostat-using-node-red-contrib-zwave-js/56332>\
**Category:** General\
**Created:** [8 January 2022 23:24 UTC](https://discourse.nodered.org/t/interrogating-z-wave-thermostat-using-node-red-contrib-zwave-js/56332 "2022-01-08T23:24:41Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![magicman](https://avatars.discourse-cdn.com/v4/letter/m/73ab20/32.png) [@magicman](https://discourse.nodered.org/u/magicman)\
**Post date:** [8 January 2022 23:24 UTC](https://discourse.nodered.org/t/interrogating-z-wave-thermostat-using-node-red-contrib-zwave-js/56332/1 "2022-01-08T23:24:41Z")

</div>

Hi i am using the Zwave JS node.  
I am trying to get the "Air temperature" from the configuration file for the Secure SRT321 thermostat,  
just not sure how to interrogate the Zwave data to obtain it? i want to move it into msg.payload . I can view it in the configuration file in the Zwave JS UI. i can see it is CommandClass Multilever Sensor.

Thanks for any help 🙂

---

<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:** [9 January 2022 10:19 UTC](https://discourse.nodered.org/t/interrogating-z-wave-thermostat-using-node-red-contrib-zwave-js/56332/2 "2022-01-09T10:19:57Z")

</div>

Hi @magicman,

In the UI, double click the title for **Air temperature** - this will give you a ValueID (copy it)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/e/3e98104bd198334202bcd5b36d0b292d442ed6d9.jpeg)

Then,  
Send the below to the controller node or a device-node - depending on your setup.  
You will get a response on the other end - for which you can do as you please.

The event type will be **GET\_VALUE\_RESPONSE**  
The value can be found at **msg.payload.object.response**

The device does not have to be awake, its taken from the last known values, which is updated when your device sends any updates.

A **Value ID** represents, what command class, endpoint and a property a value is located.  
Example: swapping **Air temperature** for **Illuminance** will give you the lux value from the sensor  
(if its supported)

You can also use the **cmd factory** to do the same thing, below is assuming the use of a function node.

```javascript
const MyValueID = {
      "commandClassName": "Multilevel Sensor",
      "commandClass": 49,
      "endpoint": 0,
      "property": "Air temperature",
      "propertyName": "Air temperature"
}

const Message = {
    "payload": {
        "mode": "ValueAPI",
        "node": 6,
        "method": "getValue",
        "params": [MyValueID]
    }
}
return Message

```

Value API Wiki (as well as the others)

> **[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 powerful, easy to use, 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:** ![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:** [9 January 2022 11:17 UTC](https://discourse.nodered.org/t/interrogating-z-wave-thermostat-using-node-red-contrib-zwave-js/56332/3 "2022-01-09T11:17:03Z")

</div>

I have taken the liberty if demoing the **CMD Factory** and **Event Filter** nodes.  
see the exported flow.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/0/c0aaac79a4a3d2100aa323c8ef9ed7a38c8f4511.jpeg)

```json
[{"id":"ce4f8243d5fb07ee","type":"tab","label":"Flow 1","disabled":false,"info":"","env":[]},{"id":"9de7d0266b6a6386","type":"cmd-factory","z":"ce4f8243d5fb07ee","name":"ZWave CMD Factory","node":"node","endpoint":"","cc":"Select Command Class","method":"Select Method","params":"payload","noEvent":false,"forceUpdate":"forceUpdate","api":"ValueAPI","vapiMode":"getValue","vapiValue":"","vapiValueId":"ValueToFetch","vapiOptions":"","x":600,"y":340,"wires":[["a634a8eabf2560b6"]]},{"id":"613527d7c5989bcf","type":"function","z":"ce4f8243d5fb07ee","name":"Set Command Properties","func":"msg.ValueToFetch = {\n \"commandClassName\": \"Multilevel Sensor\",\n \"commandClass\": 49,\n \"endpoint\": 0,\n \"property\": \"Air temperature\",\n \"propertyName\": \"Air temperature\"\n}\nmsg.node = 4\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":470,"y":280,"wires":[["9de7d0266b6a6386"]]},{"id":"801c6ffbfb33931d","type":"inject","z":"ce4f8243d5fb07ee","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":440,"y":220,"wires":[["613527d7c5989bcf"]]},{"id":"a634a8eabf2560b6","type":"debug","z":"ce4f8243d5fb07ee","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":870,"y":340,"wires":[]},{"id":"a782d6cf8313799c","type":"comment","z":"ce4f8243d5fb07ee","name":"Connect here a device node or controller node","info":"","x":380,"y":540,"wires":[]},{"id":"4e510edf71d6dc37","type":"event-filter","z":"ce4f8243d5fb07ee","name":"Split Value Changes","filters":[{"index":0,"name":"Air Temp Changes","valueIds":[{"commandClassName":"Multilevel Sensor","commandClass":49,"endpoint":0,"property":"Air temperature","propertyName":"Air temperature"}],"events":["VALUE_UPDATED","GET_VALUE_RESPONSE"],"strict":false,"id":"186827","_id":0},{"index":1,"name":"Illuminance Chnages","valueIds":[{"commandClassName":"Multilevel Sensor","commandClass":49,"endpoint":0,"property":"Illuminance","propertyName":"Illuminance"}],"events":["VALUE_UPDATED","GET_VALUE_RESPONSE"],"strict":false,"id":"228397","_id":1}],"outputs":2,"changeDate":"2022-01-09T11:08:50.673Z","x":600,"y":500,"wires":[["3291d428ae7db96f"],["f0e455876fd2d507"]]},{"id":"f0e455876fd2d507","type":"debug","z":"ce4f8243d5fb07ee","name":"This wire carries Illuminance changes","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":950,"y":520,"wires":[]},{"id":"3291d428ae7db96f","type":"debug","z":"ce4f8243d5fb07ee","name":"This wire carries Ait Temp changes","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":940,"y":480,"wires":[]},{"id":"ccf534b4444cd3bc","type":"comment","z":"ce4f8243d5fb07ee","name":"Connect here a device node or controller node","info":"","x":980,"y":300,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![magicman](https://avatars.discourse-cdn.com/v4/letter/m/73ab20/32.png) [@magicman](https://discourse.nodered.org/u/magicman)\
**Post date:** [9 January 2022 11:41 UTC](https://discourse.nodered.org/t/interrogating-z-wave-thermostat-using-node-red-contrib-zwave-js/56332/4 "2022-01-09T11:41:41Z")

</div>

Thank you so much @marcus-j-davies i will look at it as soon as i can, thanks for your time again 🙂

---

<div class="post-metadata">

**Author:** ![magicman](https://avatars.discourse-cdn.com/v4/letter/m/73ab20/32.png) [@magicman](https://discourse.nodered.org/u/magicman)\
**Post date:** [10 January 2022 10:19 UTC](https://discourse.nodered.org/t/interrogating-z-wave-thermostat-using-node-red-contrib-zwave-js/56332/5 "2022-01-10T10:19:56Z")

</div>

every day is a school day! thank you so much @marcus-j-davies

---

<div class="post-metadata">

**Author:** ![magicman](https://avatars.discourse-cdn.com/v4/letter/m/73ab20/32.png) [@magicman](https://discourse.nodered.org/u/magicman)\
**Post date:** [13 January 2022 00:08 UTC](https://discourse.nodered.org/t/interrogating-z-wave-thermostat-using-node-red-contrib-zwave-js/56332/6 "2022-01-13T00:08:28Z")

</div>

hi @marcus-j-davies thanks for your help.

I am now interrogating values using the functions etc you pointed me to and it is working but the values are cached values and therefore not "live data". is there any way i can make the unit give live data? i am assuming i need to wake it? or is there an easier way?  
hope you understand what i am trying to say?

thanks again @magicman

---

<div class="post-metadata">

**Author:** ![magicman](https://avatars.discourse-cdn.com/v4/letter/m/73ab20/32.png) [@magicman](https://discourse.nodered.org/u/magicman)\
**Post date:** [13 January 2022 00:11 UTC](https://discourse.nodered.org/t/interrogating-z-wave-thermostat-using-node-red-contrib-zwave-js/56332/7 "2022-01-13T00:11:25Z")

</div>

hi @marcus-j-davies  
i found this shortly after the first message but not sure how to use it 🙂

pollValue  
Poll the device, causing a Cached Value to be updated.  
Note: The ValueID is an object, and not a numerical value.

```auto
let Message = {
    "payload": {
        "mode": "ValueAPI",
        "node": 2,
        "method": "pollValue",
        "params": [<ValueID>]`Preformatted text`
    }
}
return Message

```

> Blockquote

---

<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:** [13 January 2022 05:05 UTC](https://discourse.nodered.org/t/interrogating-z-wave-thermostat-using-node-red-contrib-zwave-js/56332/8 "2022-01-13T05:05:42Z")

</div>

Hi @magicman,

The cache is updated everytime your devices send an update.  
**getValue** will always return the latest information.

**pollValue** just forces it to get updated - 99.9999% of the time it is unnecessary.  
**pollValue** will indeed need the device to be awake (hence the poll will be queued)

I think thermos don't actually sleep - as they need to receive new set points pretty instantly - I could be wrong.

use **getValue** - it will be current, and doesn't need things to be awake.

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/c/4c38e5e4220d6e6e75cb5b5da64110f86da40107.png)

Also note.  
When your devices do send an update, not only is the cache updated - but you will get a message into your flow with an event of **VALUE\_UPDATED**

> **[Payload Messaging Format · zwave-js/node-red-contrib-zwave-js Wiki](https://github.com/zwave-js/node-red-contrib-zwave-js/wiki/Payload-Messaging-Format#incoming-messages-messages-from-z-wave-into-node-red)**
>
> An extremely powerful, easy to use, and feature rich Z-Wave node for Node Red, based on Z-Wave JS. - Payload Messaging Format · zwave-js/node-red-contrib-zwave-js Wiki

😉

---

<div class="post-metadata">

**Author:** ![magicman](https://avatars.discourse-cdn.com/v4/letter/m/73ab20/32.png) [@magicman](https://discourse.nodered.org/u/magicman)\
**Post date:** [14 January 2022 18:35 UTC](https://discourse.nodered.org/t/interrogating-z-wave-thermostat-using-node-red-contrib-zwave-js/56332/9 "2022-01-14T18:35:45Z")

</div>

thanks @marcus-j-davies i am still working with the filter node and it seemed the temperature values were delayed but was my flow not the z wave.node.

Thanks again

---

<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:** [14 January 2022 18:41 UTC](https://discourse.nodered.org/t/interrogating-z-wave-thermostat-using-node-red-contrib-zwave-js/56332/10 "2022-01-14T18:41:39Z")

</div>

Hi @magicman,

The nodes **zwave-device** , **cmd-factory** , and **event-filter** put together can conjure a very potent mix, and help design some really clean and powerful automation.

the module is more of a zwave framework (a toolkit almost) - with great power comes great responsibility 😉

---

<div class="post-metadata">

**Author:** ![magicman](https://avatars.discourse-cdn.com/v4/letter/m/73ab20/32.png) [@magicman](https://discourse.nodered.org/u/magicman)\
**Post date:** [27 January 2022 06:22 UTC](https://discourse.nodered.org/t/interrogating-z-wave-thermostat-using-node-red-contrib-zwave-js/56332/11 "2022-01-27T06:22:32Z")

</div>

hi @marcus-j-davies

Can this function be made to address all thermostats i have 4 controlling my underfloor heating? Nodes 11,12,13,14

```auto
const MyValueID = {
      "commandClassName": "Multilevel Sensor",
      "commandClass": 49,
      "endpoint": 0,
      "property": "Air temperature",
      "propertyName": "Air temperature"
}

const Message = {
    "payload": {
        "mode": "ValueAPI",
        "node": 11,
        "method": "getValue",
        "params": [MyValueID]
    }
}
return Message

```

as it is it addresses node 11 and i have just used this each time for the other 3 stats but wondered if this could be done using the multiple node set up? and get a resulting output per stat?

hope you understand what i am trying to say?  
I am thinking it was an array of some type in the function but cant make it work ☹

Sorry to be a pain but am loving the learning curve!

---

<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:** [27 January 2022 07:31 UTC](https://discourse.nodered.org/t/interrogating-z-wave-thermostat-using-node-red-contrib-zwave-js/56332/12 "2022-01-27T07:31:27Z")

</div>

HI @magicman,

There are 2 ways.

#1 (The Ninja Way)  
be careful here adding to many nodes.  
you could drop in a rate limiting node between this and the network.

EDIT:  
Actualy **getValue** doesn't cause any network traffic - so you should be fine.

```javascript
const TargetNodes = [11, 12, 13, 14];

const MyValueID = {
    "commandClassName": "Multilevel Sensor",
    "commandClass": 49,
    "endpoint": 0,
    "property": "Air temperature",
    "propertyName": "Air temperature"
}

TargetNodes.forEach((ZWNode) => {
    const Message = {
        "payload": {
            "mode": "ValueAPI",
            "node": ZWNode,
            "method": "getValue",
            "params": [MyValueID]
        }
    }
    node.send(Message)
})

```

#2 (The Guided Way)

- Using the **zwave-device** node, set its **Mode** to **Multiple**
- Select the nodes you wish to use with this **zwave-device** node (ctrl-click for windows)
- Then in your message - omit the **node**
- The **device-node** will send a message to each node you have selected. you will see it has throttling - so use what value is best - the default is 4 nodes per second. but again **getValue** doesn't cause traffic.

```auto
const MyValueID = {
      "commandClassName": "Multilevel Sensor",
      "commandClass": 49,
      "endpoint": 0,
      "property": "Air temperature",
      "propertyName": "Air temperature"
}

const Message = {
    "payload": {
        "mode": "ValueAPI",
        "method": "getValue",
        "params": [MyValueID]
    }
}
return Message

```

> Sorry to be a pain but am loving the learning curve!

Don't be sorry, this is why the forums are here.

---

<div class="post-metadata">

**Author:** ![magicman](https://avatars.discourse-cdn.com/v4/letter/m/73ab20/32.png) [@magicman](https://discourse.nodered.org/u/magicman)\
**Post date:** [27 January 2022 13:45 UTC](https://discourse.nodered.org/t/interrogating-z-wave-thermostat-using-node-red-contrib-zwave-js/56332/13 "2022-01-27T13:45:19Z")

</div>

thanks again @marcus-j-davies can i just ask one more thing?

why use ```  
const MyValueID = {

```auto
would var MyValueID = {?

also work?
```

---

<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:** [27 January 2022 15:17 UTC](https://discourse.nodered.org/t/interrogating-z-wave-thermostat-using-node-red-contrib-zwave-js/56332/14 "2022-01-27T15:17:43Z")

</div>

Hi @magicman,

Yes, **var** will work also.

It’s force of habit - if the value doesn’t change during its execution or context, you could say it’s a **const** ant variable 😉

There are prob better resources - but i’m out the house.

> **[var vs let vs const in JavaScript - ui.dev](https://ui.dev/var-let-const/)**
>
> In this post you'll learn the differences between var, let, and const as well as topics like function vs block scope, variable hoisting, and immutability.

---

<div class="post-metadata">

**Author:** ![magicman](https://avatars.discourse-cdn.com/v4/letter/m/73ab20/32.png) [@magicman](https://discourse.nodered.org/u/magicman)\
**Post date:** [27 January 2022 15:19 UTC](https://discourse.nodered.org/t/interrogating-z-wave-thermostat-using-node-red-contrib-zwave-js/56332/15 "2022-01-27T15:19:06Z")

</div>

thanks @marcus-j-davies

i am a 63 year old dinasour lol and learning coding etc from moments like this, sorry if it seemed an easy question 🙂

---

<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:** [27 January 2022 15:19 UTC](https://discourse.nodered.org/t/interrogating-z-wave-thermostat-using-node-red-contrib-zwave-js/56332/16 "2022-01-27T15:19:45Z")

</div>

Again, don’t be sorry

---

<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:** [10 February 2022 15:19 UTC](https://discourse.nodered.org/t/interrogating-z-wave-thermostat-using-node-red-contrib-zwave-js/56332/17 "2022-02-10T15:19:47Z")

</div>

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