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

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 :slight_smile:

Hi @magicman,

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

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.

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)

1 Like

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

[{"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":[]}]

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

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

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

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

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

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

Blockquote

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

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

:wink:

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

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 :wink:

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

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 :frowning:

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

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.

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

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

why use ```
const MyValueID = {

would var MyValueID = {?

also work?

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 constant variable :wink:

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

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 :slight_smile:

Again, don’t be sorry

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