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:
|
services:
|
||||||
influxdb:
|
influxdb:
|
||||||
image: influxdb:2.7-alpine
|
image: influxdb:2.7-alpine
|
||||||
|
|||||||
@ -190,12 +190,21 @@
|
|||||||
"Notumschichtung": {
|
"Notumschichtung": {
|
||||||
"Temperaturlabel": "PufferHeizraumTemperatur5",
|
"Temperaturlabel": "PufferHeizraumTemperatur5",
|
||||||
"Ton": 70.0,
|
"Ton": 70.0,
|
||||||
"Toff": 65.0,
|
"Toff": 65.0
|
||||||
|
},
|
||||||
"mqtt": {
|
"mqtt": {
|
||||||
"ctrlTopic": "RelaisUmschichtung/cmnd/POWER1",
|
"ctrlTopic": "RelaisUmschichtung/cmnd/POWER1",
|
||||||
"msgOn": "ON",
|
"msgOn": "ON",
|
||||||
"msgOff": "OFF"
|
"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
|
// use socket.on('open', ...) when using serialport
|
||||||
socket.on('connect', function () {
|
socket.on('connect', function () {
|
||||||
|
|
||||||
// make some calls
|
console.log("socket connected starting interval timer");
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
requestTemps();
|
requestTemps();
|
||||||
}, config.interval);
|
}, config.interval);
|
||||||
@ -44,8 +44,11 @@ fs.readFile('config.json', function (err, data) {
|
|||||||
configuredInputs.forEach(element => {
|
configuredInputs.forEach(element => {
|
||||||
inputValues[element.label] = { value: null, synced: false, unitConversionDivider: 1 };
|
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 });
|
influxClient = new InfluxDB({ url: influxUrl, token: config.influxToken });
|
||||||
influxWriteClient = influxClient.getWriteApi(influxOrg, influxBucket, 'ms');
|
influxWriteClient = influxClient.getWriteApi(influxOrg, influxBucket, 'ms');
|
||||||
|
console.log("connected to influxdb, now trying to connect to modbus tcp and mqtt");
|
||||||
socket.connect(options);
|
socket.connect(options);
|
||||||
mqttClient = mqtt.connect(config.mqttBrokerAddress, {
|
mqttClient = mqtt.connect(config.mqttBrokerAddress, {
|
||||||
username: config.mqttUser,
|
username: config.mqttUser,
|
||||||
@ -116,16 +119,16 @@ async function writeToInflux() {
|
|||||||
if (Object.hasOwnProperty.call(inputValues, key)) {
|
if (Object.hasOwnProperty.call(inputValues, key)) {
|
||||||
let point = new Point('CF2').floatField(key, inputValues[key].value);
|
let point = new Point('CF2').floatField(key, inputValues[key].value);
|
||||||
influxWriteClient.writePoint(point);
|
influxWriteClient.writePoint(point);
|
||||||
|
}
|
||||||
|
}
|
||||||
influxWriteClient.flush();
|
influxWriteClient.flush();
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
async function sendMQTT(topic, msg) {
|
async function sendMQTT(topic, msg) {
|
||||||
let notumschichtung = config.UmschichtungSolar.Notumschichtung
|
let mqttConfig = config.UmschichtungSolar.mqtt;
|
||||||
if (typeof mqttClient !== 'undefined' || mqttClient !== null) {
|
if (typeof mqttClient !== 'undefined' || mqttClient !== null) {
|
||||||
if (mqttClient.connected) {
|
if (mqttClient.connected) {
|
||||||
mqttClient.publish(topic, msg, { retain: true });
|
mqttClient.publish(topic, msg, { retain: true });
|
||||||
console.log(msg);
|
//console.log(msg);
|
||||||
} else {
|
} else {
|
||||||
console.log("client not connected to the mqtt broker");
|
console.log("client not connected to the mqtt broker");
|
||||||
}
|
}
|
||||||
@ -135,28 +138,68 @@ async function sendMQTT(topic, msg) {
|
|||||||
|
|
||||||
//send status over mqtt
|
//send status over mqtt
|
||||||
let val = 0.0;
|
let val = 0.0;
|
||||||
if (msg == notumschichtung.mqtt.msgOn) {
|
if (msg == mqttConfig.msgOn) {
|
||||||
val = 100.0;
|
val = 100.0;
|
||||||
} else if (msg == notumschichtung.mqtt.msgOff) {
|
} else if (msg == mqttConfig.msgOff) {
|
||||||
val = 0.0;
|
val = 0.0;
|
||||||
}
|
}
|
||||||
let point = new Point('Solarumschichtung').floatField("pumpePercent", val);
|
let point = new Point('Solarumschichtung').floatField("pumpePercent", val);
|
||||||
influxWriteClient.writePoint(point);
|
influxWriteClient.writePoint(point);
|
||||||
influxWriteClient.flush();
|
influxWriteClient.flush();
|
||||||
}
|
}
|
||||||
|
let outputRegler1 = false;
|
||||||
|
let outputRegler2 = false;
|
||||||
async function calculateLogic() {
|
async function calculateLogic() {
|
||||||
let notumschichtung = config.UmschichtungSolar.Notumschichtung
|
//Notumschichtung regler 1
|
||||||
let temp = inputValues[notumschichtung.Temperaturlabel];
|
let umschichtungSolar = config.UmschichtungSolar;
|
||||||
let topic = notumschichtung.mqtt.ctrlTopic;
|
let notumschichtung = umschichtungSolar.Notumschichtung
|
||||||
let msgOn = notumschichtung.mqtt.msgOn;
|
let temptNotumschichtung = inputValues[notumschichtung.Temperaturlabel].value;
|
||||||
let msgOff = notumschichtung.mqtt.msgOff;
|
let TonNotumschichtung = notumschichtung.Ton;
|
||||||
let Ton = notumschichtung.Ton;
|
let ToffNotumschichtung = notumschichtung.Toff;
|
||||||
let Toff = notumschichtung.Toff;
|
|
||||||
|
|
||||||
if (temp.value >= Ton) {
|
//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;
|
||||||
|
|
||||||
|
//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);
|
sendMQTT(topic, msgOn);
|
||||||
} else if (temp.value <= Toff) {
|
}else{
|
||||||
sendMQTT(topic, msgOff);
|
sendMQTT(topic, msgOff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user