Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add node Location and node Name on Value metadata #57

Merged
merged 11 commits into from
Dec 10, 2020
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ Gateway settings:
- **Ignore status updates**: Enable this to prevent gateway to send an MQTT message when a node changes its status (dead/sleep == false, alive == true)
- **Ignore location**: Enable this to remove nodes location from topics
- **Send Zwave Events**: Enable this to send all Zwave client events to MQTT. More info [here](#zwave-events)
- **Include Node Info**: Adds in ValueId json payload two extra values with the Name: `nodeName` and Location `nodeLocation` for better graphing capabilities (usefull in tools like InfluxDb,Grafana)
- **Use nodes name instead of numeric nodeIDs**: When gateway type is `ValueId` use this flag to force to use node names instead of node ids in topic.
- :star:**Hass discovery**:star:: Enable this to automatically create entities on Hass using MQTT autodiscovery (more about this [here](#robot-home-assistant-integration-beta))
- **Discovery Prefix**: The prefix to use to send MQTT discovery messages to HASS
Expand Down
5 changes: 5 additions & 0 deletions lib/Gateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ function onValueChanged (valueId, node, changed) {
case 1: // entire zwave valueId object
data = copy(valueId)
data.value = tmpVal

break
case 2: // just value
data = tmpVal
Expand All @@ -299,6 +300,10 @@ function onValueChanged (valueId, node, changed) {
data = { time: Date.now(), value: tmpVal }
}

if (this.config.includeNodeInfo && typeof data === 'object') {
data.nodeName = node.name
data.nodeLocation = node.loc
}
// valueId is writeable, subscribe for updates
if (valueId.writeable && !this.topicValues[topic]) {
const levels = topic.split('/').length
Expand Down
1 change: 0 additions & 1 deletion lib/ZwaveClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,6 @@ function addValue (zwaveNode, zwaveValue) {

function initValue (zwaveNode, zwaveValue, zwaveValueMeta) {
const node = this.nodes[zwaveNode.id]

const valueId = updateValueMetadata.call(
this,
zwaveNode,
Expand Down
8 changes: 8 additions & 0 deletions src/components/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,14 @@
persistent-hint
></v-switch>
</v-flex>
<v-flex v-if="gateway.type !== 2" xs6>
<v-switch
label="Include Node info"
hint="Include Node's Name and Location on Payload"
v-model="gateway.includeNodeInfo"
persistent-hint
></v-switch>
</v-flex>
<v-flex xs6>
<v-switch
label="Hass Discovery"
Expand Down