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