Skip to content

Commit

Permalink
Cope with deviceInstance changes, update dbus-native
Browse files Browse the repository at this point in the history
Make sure that the cache copes with deviceInstance changes (which
happen with virtual nodes).
And also start depending on dbus-native-victron instead of
dbus-native.
  • Loading branch information
dirkjanfaber committed Oct 30, 2024
1 parent 0c73f46 commit 3ef2ec4
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 40 deletions.
68 changes: 31 additions & 37 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Custom Node-RED Nodes for Victron Energy",
"version": "1.5.23",
"dependencies": {
"dbus-native": "^0.4.0",
"dbus-native-victron": "^0.4.2",
"debug": "^4.3.7",
"lodash": "^4.17.21",
"promise-retry": "^2.0.1",
Expand Down
9 changes: 7 additions & 2 deletions src/services/dbus-listener.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* https://github.com/sbender9/signalk-venus-plugin/blob/master/dbus-listener.js
*/

const dbus = require('dbus-native')
const dbus = require('dbus-native-victron')
const debug = require('debug')('node-red-contrib-victron:dbus')
const _ = require('lodash')

Expand Down Expand Up @@ -167,12 +167,14 @@ class VictronDbusListener {
service.fluidType = data.FluidType
}

const deviceInstance = data['/DeviceInstance'] != null ? data['/DeviceInstance'] : service.deviceInstance;

const messages = _.keys(data).map(path => {
return {
path: '/' + path.replace(/^\/+/, ''),
senderName: service.name.split('.').splice(0, 3).join('.'),
value: data[path],
deviceInstance: (service.deviceInstance != null ? service.deviceInstance : ''),
deviceInstance,
fluidType: service.fluidType
}
})
Expand Down Expand Up @@ -228,6 +230,9 @@ class VictronDbusListener {
if (!service || !service.name) {
return
}
if (m.path === '/DeviceInstance') {
service.deviceInstance = m.value
}
m.senderName = service.name.split('.').splice(0, 3).join('.')
if (service.deviceInstance === null) {
service.deviceInstance = searchDeviceInstanceByName(this.services, m.senderName, '')
Expand Down

0 comments on commit 3ef2ec4

Please sign in to comment.