Skip to content

Commit

Permalink
Fix if weather condition is 0
Browse files Browse the repository at this point in the history
  • Loading branch information
tukey42 committed May 21, 2024
1 parent e1c45d2 commit 7388c8b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/program.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,13 @@ class Programs {
gadapter.log.info(`Program ${p.name} not started because auf rain`);
return;
}
const wc = await this.weather.condition(gadapter.config.numdays, gadapter.config.condition_override)
gadapter.log.debug(`startProgram: force=${force} weather=${p.weather} condition=${wc}`);
if (!force && p.weather && wc <= 0) {
await gadapter.setStateAsync(`${gadapter.namespace}.${device_name}.${p.name}.running`, false, true);
gadapter.log.info(`Program ${p.name} not started because auf weather condition`);
return;
}
gadapter.log.info(`Queueing program ${p.name}`);
this.runqueue.push(p);
//await gadapter.setStateAsync(`${gadapter.namespace}.${device_name}.${p.name}.running`, true, true);
Expand Down Expand Up @@ -265,7 +272,7 @@ class Program {

async start(factor) {
gadapter.log.info(`Starting Program ${this.name} (${this.isParallel()?'parallel':'serial'}) (factor: ${factor})`);
this.factor = this.weather ? factor : 1;
this.factor = this.weather ? (factor ? factor : 1) : 1;
if (this.isParallel()) {
const az = this.allZones();
for (const z of az) {
Expand Down Expand Up @@ -346,6 +353,10 @@ class Program {
await gadapter.setStateAsync(`${gadapter.namespace}.info.actprogram`, 'none', true);
return false;
} else {
if (this.active == 0) {
gadapter.log.debug("nextZone called, but this.active is 0, ignoring");
return true;
}
let act_zone = zl[this.active-1];
if (act_zone.name != id) {
gadapter.log.debug("nextZone called, but id (" + id + ") and act_zone (" + act_zone.name + ") are different, ignoring");
Expand Down

0 comments on commit 7388c8b

Please sign in to comment.