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

Tidy up of Paths related to Battery and Alternator #111

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 53 additions & 17 deletions venusToDeltas.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,19 @@ module.exports = function (app, options, handleMessage) {
}
}
],
'/Link/NetworkStatus': [
{
path: m => {
return makePath(m, `${m.instanceName}.mode`)
},
conversion: convertNetworkStatus
},
{
path: m => {
return makePath(m, `${m.instanceName}.modeNumber`)
}
}
],
'/ErrorCode': {
path: m => {
return 'notifications.' + makePath(m, `${m.instanceName}.error`)
Expand Down Expand Up @@ -821,12 +834,10 @@ const stateMaps = {

'com.victronenergy.alternator': {
0: 'off',
1: 'bulk',
2: 'absorbtion',
3: 'bulk',
4: 'absorbtion',
5: 'float',
7: 'Ext Control',
8: 'disabled',
9: 'float'
252: 'Ext. Control'
},

'com.victronenergy.dcdc': {
Expand All @@ -837,7 +848,27 @@ const stateMaps = {
7: 'Ext Control',
8: 'disabled',
9: 'float'
}
},

'com.victronenergy.battery': {
0: 'initializing',
1: 'initializing',
2: 'initializing',
3: 'initializing',
4: 'initializing',
5: 'initializing',
6: 'initializing',
7: 'initializing',
8: 'initializing',
9: 'running',
10: 'error',
12: 'shutdown',
13: 'updating',
14: 'standby',
15: 'going to run',
16: 'pre-charging',
17: 'contactor check'
}
}

function senderNamePrefix (senderName) {
Expand Down Expand Up @@ -880,15 +911,9 @@ const modeMaps = {
5: 'eco'
},
'com.victronenergy.battery': {
0: 'sleep',
1: 'hibernation',
2: 'standby',
3: 'on'
},
'com.victronenergy.alternator': {
0: 'standalone',
1: 'master',
2: 'slave'
3: 'on',
4: 'off',
252: 'Standby'
},
'com.victronenergy.dcdc': {
0: 'standalone',
Expand All @@ -897,13 +922,19 @@ const modeMaps = {
}
}

const networkStatusMaps = {
'com.victronenergy.alternator': {
0: 'standalone',
1: 'master',
4: 'slave'
},
}

const statePropName = {
'com.victronenergy.vebus': 'chargingMode',
'com.victronenergy.charger': 'chargingMode',
'com.victronenergy.solarcharger': 'controllerMode',
'com.victronenergy.inverter': 'inverterMode',
'com.victronenergy.battery': 'mode',
'com.victronenergy.alternator': 'chargingMode',
'com.victronenergy.dcdc': 'chargingMode'
}

Expand All @@ -916,6 +947,11 @@ function convertMode (msg) {
return (modeMap && modeMap[Number(msg.value)]) || 'unknown'
}

function convertNetworkStatus (msg) {
var networkStatusMap = networkStatusMaps[senderNamePrefix(msg.senderName)]
return (networkStatusMap && networkStatusMap[Number(msg.value)]) || 'unknown'
}

const acinSourceMap = {
1: 'grid',
2: 'genset',
Expand Down