Skip to content

Commit

Permalink
Merge pull request #95 from foxthefox/0.0.31
Browse files Browse the repository at this point in the history
0.0.31
  • Loading branch information
foxthefox committed Jun 1, 2024
2 parents 19d3dd9 + aba413c commit 175cac3
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ Wave is not available, could be implemented, if data is available.
* (foxthefox) initial update slave battery to HA
* (foxthefox) online status from latestQuotas
* (foxthefox) adapter config merge all device tabs into one (to overcome the problem that on tablets the last tab is not reachable), size adjustment
* (foxthefox) correction for deltapro at xt60ChgType

### 0.0.30 (npm)
* (foxthefox) correction for River2Pro/Max cmd dcChgCurrent
Expand Down
5 changes: 5 additions & 0 deletions lib/ecoflow_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -15506,6 +15506,11 @@ const pstationRanges = {
mpptTemp: { max: 90 },
outAmp: { max: 30 },
inAmp: { max: 15 }
},
diagnostic: {
xt60ChgType: {
xt60ChgType: { 0: 'not detected', 1: 'adapter', 2: 'MPPT' }
}
}
}
},
Expand Down
6 changes: 5 additions & 1 deletion test/emu/ef_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ quota['DAEBZ5ZE4112345'] = require('../lastQuotas/deltamax.json');
quota['R521ZEB4XEC12345'] = require('../lastQuotas/river2max.json');
quota['R621ZEB4XEC12345'] = require('../lastQuotas/river2pro.json');
quota['R421ZEB4XEC12345'] = require('../lastQuotas/riverpro.json');
quota['R351ZFB4HF6SL12345'] = require('../lastQuotas/delt2max2slave.json');
quota['DAEBZ5ZE41SL12345'] = require('../lastQuotas/deltamax1slave.json');
quota['DPU0ZFB5EF412345'] = require('../lastQuotas/dpu.js').message.get_reply;

const panelparams = require('../websource/shp/vm2.js').params;
Expand All @@ -52,7 +54,9 @@ const pdevices = {
DAEBZ5ZE4112345: { devName: 'My deltamax', devType: 'deltamax', haEnable: false },
R521ZEB4XEC12345: { devName: 'My river2max', devType: 'river2max', haEnable: false },
R621ZEB4XEC12345: { devName: 'My river2pro', devType: 'river2pro', haEnable: false },
R421ZEB4XEC12345: { devName: 'My riverpro', devType: 'riverpro', haEnable: false }
R421ZEB4XEC12345: { devName: 'My riverpro', devType: 'riverpro', haEnable: false },
R351ZFB4HF6SL12345: { devName: 'My delta2max Slave', devType: 'delta2max', haEnable: false },
DAEBZ5ZE41SL12345: { devName: 'My deltamax Slave', devType: 'deltamax', haEnable: false }
};

let lastQuotInterval = null;
Expand Down
67 changes: 67 additions & 0 deletions test/emu/habroker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
const aedes = require('aedes')();
const server = require('net').createServer(aedes.handle);
const port = 1884;

server.listen(port, function() {
console.log(`HA MQTT Broker running on port: ${port}`);
});
/*
// authenticate the connecting client
aedes.authenticate = (client, username, password, callback) => {
password = Buffer.from(password, 'base64').toString();
if (username === 'username' && password === 'password') {
return callback(null, true);
}
const error = new Error('Authentication Failed!! Invalid user credentials.');
console.log('Error ! Authentication failed.');
return callback(error, false);
};
// authorizing client to publish on a message topic
aedes.authorizePublish = (client, packet, callback) => {
if (packet.topic === 'home/bedroom/fan') {
return callback(null);
}
console.log('Error ! Unauthorized publish to a topic.');
return callback(new Error('You are not authorized to publish on this message topic.'));
};
*/
// emitted when a client connects to the broker
aedes.on('client', function(client) {
console.log(`[CLIENT_CONNECTED] Client ${client ? client.id : client} connected to broker ${aedes.id}`);
});

// emitted when a client disconnects from the broker
aedes.on('clientDisconnect', function(client) {
console.log(`[CLIENT_DISCONNECTED] Client ${client ? client.id : client} disconnected from the broker ${aedes.id}`);
});

// emitted when a client subscribes to a message topic
aedes.on('subscribe', function(subscriptions, client) {
console.log(
`[TOPIC_SUBSCRIBED] Client ${client ? client.id : client} subscribed to topics: ${subscriptions
.map((s) => s.topic)
.join(',')} on broker ${aedes.id}`
);
});

// emitted when a client unsubscribes from a message topic
aedes.on('unsubscribe', function(subscriptions, client) {
console.log(
`[TOPIC_UNSUBSCRIBED] Client ${client ? client.id : client} unsubscribed to topics: ${subscriptions.join(
','
)} from broker ${aedes.id}`
);
});

// emitted when a client publishes a message packet on the topic
aedes.on('publish', async function(packet, client) {
if (client) {
console.log(
`[MESSAGE_PUBLISHED] Client ${client
? client.id
: 'BROKER_' + aedes.id} has published message on ${packet.topic} to broker ${aedes.id}`
);
console.log(packet.topic + ' ' + String(packet.payload));
}
});

0 comments on commit 175cac3

Please sign in to comment.