Skip to content

Commit

Permalink
All MQTT actuators now have a pace of 1 minute (#292)
Browse files Browse the repository at this point in the history
  • Loading branch information
climategadgets committed Oct 28, 2023
1 parent a83e002 commit 3f03d46
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ private Flux<Map.Entry<String, S>> getSwitches(Map<MqttEndpointSpec, MqttAdapter
var s = createSwitch(
id,
c.switchConfig.heartbeat(),
c.switchConfig.pace(),
getOrDefaultPace(c.switchConfig.pace(), Duration.ofMinutes(1), "switch=" + id),
adapter,
address,
c.switchConfig.availabilityTopic());
Expand All @@ -232,6 +232,16 @@ private Flux<Map.Entry<String, S>> getSwitches(Map<MqttEndpointSpec, MqttAdapter
});
}

private Duration getOrDefaultPace(Duration pace, Duration defaultPace, String target) {

if (pace == null) {
logger.debug("using default pace={} for {}", defaultPace, target);
return defaultPace;
}

return pace;
}

public Flux<Map.Entry<String, F>> getFans() {
return getFans(endpoint2adapter, fanConfigs);
}
Expand All @@ -251,7 +261,7 @@ private Flux<Map.Entry<String, F>> getFans(Map<MqttEndpointSpec, MqttAdapter> en
var s = createFan(
id,
c.fanConfig().heartbeat(),
c.fanConfig().pace(),
getOrDefaultPace(c.fanConfig.pace(), Duration.ofMinutes(1), "fan=" + id),
adapter,
address,
c.fanConfig.availabilityTopic());
Expand Down

0 comments on commit 3f03d46

Please sign in to comment.