add some logging informations and added function that solarumschichtung does not switch on if the woodstove is active
This commit is contained in:
parent
732eb79cb3
commit
a5b0b2b113
@ -1,5 +1,3 @@
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
influxdb:
|
||||
image: influxdb:2.7-alpine
|
||||
|
||||
@ -190,12 +190,21 @@
|
||||
"Notumschichtung": {
|
||||
"Temperaturlabel": "PufferHeizraumTemperatur5",
|
||||
"Ton": 70.0,
|
||||
"Toff": 65.0,
|
||||
"mqtt": {
|
||||
"ctrlTopic": "RelaisUmschichtung/cmnd/POWER1",
|
||||
"msgOn": "ON",
|
||||
"msgOff": "OFF"
|
||||
}
|
||||
"Toff": 65.0
|
||||
},
|
||||
"mqtt": {
|
||||
"ctrlTopic": "RelaisUmschichtung/cmnd/POWER1",
|
||||
"msgOn": "ON",
|
||||
"msgOff": "OFF"
|
||||
},
|
||||
"Differenzregelung": {
|
||||
"QuelltemperaturLabel": "PufferHeizraumTemperatur3",
|
||||
"ZieltemperaturLabel": "PufferHolzraumTemperatur1",
|
||||
"dTon": 2.0,
|
||||
"dToff": 1.0
|
||||
},
|
||||
"FreigabeHolzofen":{
|
||||
"KesselstatusAus": 43
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -29,7 +29,7 @@ let configuredInputs = {};
|
||||
// use socket.on('open', ...) when using serialport
|
||||
socket.on('connect', function () {
|
||||
|
||||
// make some calls
|
||||
console.log("socket connected starting interval timer");
|
||||
setInterval(() => {
|
||||
requestTemps();
|
||||
}, config.interval);
|
||||
@ -44,8 +44,11 @@ fs.readFile('config.json', function (err, data) {
|
||||
configuredInputs.forEach(element => {
|
||||
inputValues[element.label] = { value: null, synced: false, unitConversionDivider: 1 };
|
||||
});
|
||||
console.log("config read");
|
||||
console.log("now connecting to influxdb");
|
||||
influxClient = new InfluxDB({ url: influxUrl, token: config.influxToken });
|
||||
influxWriteClient = influxClient.getWriteApi(influxOrg, influxBucket, 'ms');
|
||||
console.log("connected to influxdb, now trying to connect to modbus tcp and mqtt");
|
||||
socket.connect(options);
|
||||
mqttClient = mqtt.connect(config.mqttBrokerAddress, {
|
||||
username: config.mqttUser,
|
||||
@ -115,17 +118,17 @@ async function writeToInflux() {
|
||||
for (const key in inputValues) {
|
||||
if (Object.hasOwnProperty.call(inputValues, key)) {
|
||||
let point = new Point('CF2').floatField(key, inputValues[key].value);
|
||||
influxWriteClient.writePoint(point);
|
||||
influxWriteClient.flush();
|
||||
influxWriteClient.writePoint(point);
|
||||
}
|
||||
}
|
||||
influxWriteClient.flush();
|
||||
}
|
||||
async function sendMQTT(topic, msg) {
|
||||
let notumschichtung = config.UmschichtungSolar.Notumschichtung
|
||||
let mqttConfig = config.UmschichtungSolar.mqtt;
|
||||
if (typeof mqttClient !== 'undefined' || mqttClient !== null) {
|
||||
if (mqttClient.connected) {
|
||||
mqttClient.publish(topic, msg, { retain: true });
|
||||
console.log(msg);
|
||||
//console.log(msg);
|
||||
} else {
|
||||
console.log("client not connected to the mqtt broker");
|
||||
}
|
||||
@ -135,28 +138,68 @@ async function sendMQTT(topic, msg) {
|
||||
|
||||
//send status over mqtt
|
||||
let val = 0.0;
|
||||
if (msg == notumschichtung.mqtt.msgOn) {
|
||||
if (msg == mqttConfig.msgOn) {
|
||||
val = 100.0;
|
||||
} else if (msg == notumschichtung.mqtt.msgOff) {
|
||||
} else if (msg == mqttConfig.msgOff) {
|
||||
val = 0.0;
|
||||
}
|
||||
let point = new Point('Solarumschichtung').floatField("pumpePercent", val);
|
||||
influxWriteClient.writePoint(point);
|
||||
influxWriteClient.flush();
|
||||
}
|
||||
|
||||
let outputRegler1 = false;
|
||||
let outputRegler2 = false;
|
||||
async function calculateLogic() {
|
||||
let notumschichtung = config.UmschichtungSolar.Notumschichtung
|
||||
let temp = inputValues[notumschichtung.Temperaturlabel];
|
||||
let topic = notumschichtung.mqtt.ctrlTopic;
|
||||
let msgOn = notumschichtung.mqtt.msgOn;
|
||||
let msgOff = notumschichtung.mqtt.msgOff;
|
||||
let Ton = notumschichtung.Ton;
|
||||
let Toff = notumschichtung.Toff;
|
||||
//Notumschichtung regler 1
|
||||
let umschichtungSolar = config.UmschichtungSolar;
|
||||
let notumschichtung = umschichtungSolar.Notumschichtung
|
||||
let temptNotumschichtung = inputValues[notumschichtung.Temperaturlabel].value;
|
||||
let TonNotumschichtung = notumschichtung.Ton;
|
||||
let ToffNotumschichtung = notumschichtung.Toff;
|
||||
|
||||
//mqtt relais
|
||||
//console.log(umschichtungSolar);
|
||||
let topic = umschichtungSolar.mqtt.ctrlTopic;
|
||||
|
||||
let msgOn = umschichtungSolar.mqtt.msgOn;
|
||||
let msgOff = umschichtungSolar.mqtt.msgOff;
|
||||
|
||||
//Differenzregelung
|
||||
let differenzregelung = umschichtungSolar.Differenzregelung
|
||||
let quellTemperatur = inputValues[differenzregelung.QuelltemperaturLabel].value;
|
||||
let zielTemperatur = inputValues[differenzregelung.ZieltemperaturLabel].value;
|
||||
let dTon = differenzregelung.dTon;
|
||||
let dToff = differenzregelung.dToff;
|
||||
|
||||
if (temp.value >= Ton) {
|
||||
//Freigabe Holzofen
|
||||
let kesselstatus = inputValues["Kesselstatus"].value;
|
||||
let freigabeHolzofen = kesselstatus === umschichtungSolar.FreigabeHolzofen.KesselstatusAus ? true : false;
|
||||
|
||||
if (temptNotumschichtung >= TonNotumschichtung) {
|
||||
outputRegler1 = true;
|
||||
|
||||
} else if (temptNotumschichtung <= ToffNotumschichtung) {
|
||||
outputRegler1 = false;
|
||||
}
|
||||
|
||||
let diff = quellTemperatur - zielTemperatur;
|
||||
if(diff >= dTon){
|
||||
outputRegler2 = true;
|
||||
}else if (diff <= dToff) {
|
||||
outputRegler2 = false;
|
||||
}
|
||||
|
||||
let point = new Point('Solarumschichtung').floatField("regler1", outputRegler1 ? 100.0 : 0.0);
|
||||
influxWriteClient.writePoint(point);
|
||||
point = new Point('Solarumschichtung').floatField("regler2", outputRegler2 ? 100.0 : 0.0);
|
||||
influxWriteClient.writePoint(point);
|
||||
point = new Point('Solarumschichtung').floatField("freigabeHolzofen", freigabeHolzofen ? 100.0 : 0.0);
|
||||
influxWriteClient.writePoint(point);
|
||||
influxWriteClient.flush();
|
||||
|
||||
if(freigabeHolzofen && outputRegler1 && outputRegler2){
|
||||
sendMQTT(topic, msgOn);
|
||||
} else if (temp.value <= Toff) {
|
||||
}else{
|
||||
sendMQTT(topic, msgOff);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user