Batterijen en Veiligheid – scripts
In mijn tweede youtube video over Thuisbatterijen en Veiligheid heb ik je een aantal scripts laten zien die je kunt gebruiken om sensoren te koppelen aan de Victron Cerbo waarmee je de installatie zou kunnen beveiligen.
Hieronder tref je de pagina’s en het script die ik heb gemaakt.
context.soc = context.soc || 0.0;
context.chargecurrent = context.chargecurrent || 210;
context.temperatuurboven = context.temperatuurboven || 0;
if (msg.topic === ‘Venus system – Battery State of Charge (%)’) {
context.soc = msg.payload;
}
if (msg.topic === ‘Temp boven – Temperature (°C)’) {
context.temperatuurboven = msg.payload;
}
// node.warn (context.soc);
// node.warn (context.chargecurrent);
// node.warn (context.temperatuurboven);
if (context.soc < 95) {
if (context.temperatuurboven < 50) {
context.chargecurrent = { payload: 200};
}
}
if (context.soc < 95) {
if (context.temperatuurboven > 50) {
context.chargecurrent = { payload: 100};
}
}
if (context.soc >= 95) {
context.chargecurrent = { payload: 100};
}
if (context.soc >= 97) {
context.chargecurrent = { payload: 50};
}
if (context.soc >= 98) {
context.chargecurrent = { payload: 25};
}
if (context.soc >= 99) {
context.chargecurrent = { payload: 15};
}
// node.warn (context.chargecurrent);
return [context.chargecurrent];
Hieronder het script dat de Digital Input poorten uitleest
context.shutdownalarm = context.shutdownalarm || 0;
context.smokefirecoalarm = context.smokefirecoalarm || 0;
context.emergencyswitch = context.emergencyswitch || 0;
context.switchinverter = context.switchinverter || 3;
if (msg.topic === ‘Shutdown Alarm MK’) {
context.shutdownalarm = msg.payload;
}
if (msg.topic === ‘Smoke, Fire & CO Alarm’) {
context.smokefirealarm = msg.payload;
}
if (msg.topic === ‘Shutdown button ESS’) {
context.emergencyswitch = msg.payload;
}
// node.warn (context.shutdownalarm);
// node.warn (context.smokefirealarm);
// node.warn (context.switchinverter);
if (context.shutdownalarm == 0) {
context.switchinverter = { payload: 3};
}
if (context.smokefirealarm == 0) {
context.switchinverter = { payload: 3};
}
if (context.emergencyswitch == 0) {
context.switchinverter = { payload: 3};
}
if (context.shutdownalarm == 2) {
context.switchinverter = { payload: 4};
}
if (context.smokefirealarm == 2) {
context.switchinverter = { payload: 4};
}
if (context.emergencyswitch == 2) {
context.switchinverter = { payload: 4};
}
//node.warn (context.switchinverter);
return [context.switchinverter];