zwave-js / node-red-contrib-zwave-js

The most powerful, high performing and highly polished Z-Wave node for Node-RED based on Z-Wave JS. If you want a fully featured Z-Wave framework in your Node-RED instance, you have found it.
MIT License
47 stars 6 forks source link

Include node name in payload #44

Closed crxporter closed 3 years ago

crxporter commented 3 years ago

Plugin Version Version 3.2.2.

I've been using zwavejs2mqtt for nothing but to send my zwave things to nodered. I've just discovered this nodered contrib has added the control panel which is awesome and pretty much the only reason I was using the mqtt option instead of just running it inside nodered.

I'm just getting started out and noticed that the payload looks something like this:

{
  "node": 25,
  "event": "VALUE_UPDATED",
  "timestamp": "2021-04-25T03:17:18.640Z",
  "object": {
    "commandClassName": "Binary Switch",
    "commandClass": 37,
    "endpoint": 0,
    "property": "currentValue",
    "newValue": false,
    "prevValue": true,
    "propertyName": "currentValue"
  }
}

My feature request is to add something like nodeName similar to how you have commandClassName. New payload would look something like this and be a lot easier to work with, having names instead of just node numbers:

{
  "nodeName": "DeskLight",
  "node": 25,
  "event": "VALUE_UPDATED",
  "timestamp": "2021-04-25T03:17:18.640Z",
  "object": {
    "commandClassName": "Binary Switch",
    "commandClass": 37,
    "endpoint": 0,
    "property": "currentValue",
    "newValue": false,
    "prevValue": true,
    "propertyName": "currentValue"
  }
}

Thanks for your hard work! I look forward to moving over to this setup!

marcus-j-davies commented 3 years ago

Hey!

Your timing is perfect. The Node Red flows page, has a slight difference in how it renders some markdown compared to others (due to the renderer they use), so have been searching for a reason to push a new version to get it corrected compatible.

Adding the node name should be a breeze - I'll get it done today!

The object component, is the unmodified (in most cases) payload from z-wave js. So this can differ in content, based on what event from z-wave js occurs.

If it also helps your setup - the zwave-device node, allows a single device approach (ensure the main node is deployed first)

Thanks for your hard work! I look forward to moving over to this setup!

Much appreciated 👍

marcus-j-davies commented 3 years ago

And with that - it's done. I have also added the nodeLocation

{
  "node": 22,
  "nodeName": "Security Keypad",
  "nodeLocation": "The Red Room",
  "event": "NOTIFICATION",
  "timestamp": "2021-04-25T09:54:21.320Z",
  "object": {
    "ccId": 111,
    "args": {
      "eventType": 25,
      "dataType": 0
    }
  }
}

I'll keep this open, until you have had a chance to spool it up (v3.2.3) The update should be available in node-red

crxporter commented 3 years ago

This is great! Works like a charm.