Hi,
Goal:
Let Homey control my underfloor heating to get a comfortable and stable inside temperature based on outside temperature and current inside temperature.
Problem:
The house is built in concrete, so heating and cooling has a lag of about 24 hours. When the temp tomorrow is 5 degrees hotter than current temp, it`s too hot inside and vice versa when the temp suddenly drops.
Devices:
Homey Pro 2023
Heatit Z-Water (3 units)
Heatit Actuator (16 zones)
Aeotec Multisensor 7 (10 units)
Weather app that reports current temp and temp +24 hours.
Current State:
I know almost nothing about JavaScript, but have been playing around with ChatGPT.
The example looks like this:
const devices = await Homey.devices.getDevices();
let currentInsideTemperature = null;
let tempNow = null;
let tempTomorrow = null;
// Iterate over all devices
for (const device of Object.values(devices)) {
if (device.capabilitiesObj) {
// Check if this is the device named "Gang Sensor"
if (device.name === 'Gang Sensor' && device.capabilitiesObj['measure_temperature']) {
// Poll the current inside temperature
currentInsideTemperature = device.capabilitiesObj['measure_temperature'].value;
log(`Current Inside Temperature: ${currentInsideTemperature}`);
}
// Check if this is the device named "Værvarsel"
if (device.name === 'Værvarsel' && device.capabilitiesObj['measure_temperature']) {
// Poll the current temperature
tempNow = device.capabilitiesObj['measure_temperature'].value;
log(`Current Temperature Now: ${tempNow}`);
}
// Check if this is the device named "Værvarsel +24t"
if (device.name === 'Værvarsel +24t' && device.capabilitiesObj['measure_temperature']) {
// Poll the temperature forecast for +24 hours
tempTomorrow = device.capabilitiesObj['measure_temperature'].value;
log(`Temperature Tomorrow: ${tempTomorrow}`);
}
}
}
// Set the variable setTemp.Gang
const setpointVariableName = 'setTemp.Gang';
// If outside temperature in 24 hours is more than 4 degrees hotter or cooler than now
if (tempTomorrow > tempNow + 4 || tempTomorrow < tempNow - 4) {
// Gradually adjust setTemp.Gang to compensate for the lag
adjustSetTempVariable(setpointVariableName, tempNow);
}
// Function to gradually adjust setTemp.Gang
function adjustSetTempVariable(variableName, currentValue) {
const adjustmentStep = 0.5; // You might need to adjust this based on your system's characteristics
const targetValue = currentValue; // You can adjust this based on your requirements
// Gradually adjust setTemp.Gang
while (currentValue < targetValue) {
currentValue += adjustmentStep;
Homey.flow.setVariable(variableName, currentValue);
log(`Setting ${variableName} to ${currentValue}`);
}
while (currentValue > targetValue) {
currentValue -= adjustmentStep;
Homey.flow.setVariable(variableName, currentValue);
log(`Setting ${variableName} to ${currentValue}`);
}
}
Question:
Is this a good base to work from, or is there a better way to script this? Would appreciate any help on this. My thoughts were to take current outside temp, tomorrows outside temp and control the setpoint for the actuators. Hopefully someone has had the same problem and already solved this, would love to hear your thoughts.
Thanks!