Skip to content

Commit

Permalink
Separated permanent and transient parts of the configuration (#311)
Browse files Browse the repository at this point in the history
  • Loading branch information
climategadgets committed Apr 6, 2024
1 parent bb5caaa commit a05d259
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@
public interface EconomizerConfig {
@JsonProperty("ambient-sensor")
String ambientSensor();
@JsonProperty("changeover-delta")
double changeoverDelta();
@JsonProperty("target-temperature")
double targetTemperature();
@JsonProperty("keep-hvac-on")
Boolean keepHvacOn();
@JsonProperty("controller")
PidControllerConfig controller();
@JsonProperty("mode")
Expand All @@ -23,4 +17,15 @@ public interface EconomizerConfig {
String hvacDevice();
@JsonProperty("timeout")
Optional<Duration> timeout();
@JsonProperty("settings")
Optional<Settings> settings();

interface Settings {
@JsonProperty("changeover-delta")
double changeoverDelta();
@JsonProperty("target-temperature")
double targetTemperature();
@JsonProperty("keep-hvac-on")
Boolean keepHvacOn();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,18 @@ public interface InterfaceRecordMapper {
net.sf.dz3r.runtime.config.model.ZoneSettingsConfig settings(ZoneSettingsConfig source);

@Mapping(expression = "java(source.ambientSensor())", target = "ambientSensor")
@Mapping(expression = "java(source.changeoverDelta())", target = "changeoverDelta")
@Mapping(expression = "java(source.targetTemperature())", target = "targetTemperature")
@Mapping(expression = "java(source.keepHvacOn())", target = "keepHvacOn")
@Mapping(expression = "java(InterfaceRecordMapper.INSTANCE.controller(source.controller()))", target = "controller")
@Mapping(expression = "java(source.mode())", target = "mode")
@Mapping(expression = "java(source.hvacDevice())", target = "hvacDevice")
@Mapping(expression = "java(source.timeout().orElse(null))", target = "timeout")
@Mapping(expression = "java(InterfaceRecordMapper.INSTANCE.settings(source.settings().orElse(null)))", target = "settings")
net.sf.dz3r.runtime.config.model.EconomizerConfig economizer(EconomizerConfig source);

@Mapping(expression = "java(source.changeoverDelta())", target = "changeoverDelta")
@Mapping(expression = "java(source.targetTemperature())", target = "targetTemperature")
@Mapping(expression = "java(source.keepHvacOn())", target = "keepHvacOn")
net.sf.dz3r.runtime.config.model.EconomizerConfig.Settings settings(EconomizerConfig.Settings source);

@Mapping(expression = "java(source.min())", target = "min")
@Mapping(expression = "java(source.max())", target = "max")
net.sf.dz3r.runtime.config.model.RangeConfig range(RangeConfig source);
Expand Down
39 changes: 39 additions & 0 deletions docs/release-notes/v4.3.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
Home Climate Control: v4.3.0. Release Notes - DRAFT
==

Release focus: [Economizer and Scheduler integration](https://github.com/home-climate-control/dz/milestone/18).

### Breaking Changes
#### Economizer Configuration
The [economizer](../configuration/zones.md#economizer) section of the configuration looks a bit different now.

Old syntax:
```yaml
economizer:
ambient-sensor: *ambient-patio-temperature
changeover-delta: 1
target-temperature: 22
keep-hvac-on: true
controller:
p: 1
i: 0.0000008
limit: 0.7
mode: cooling
hvac-device: *hvac-a6
```
New syntax (note the user changeable settings moving into their own `settings` section):
```yaml
economizer:
ambient-sensor: *ambient-patio-temperature
controller:
p: 1
i: 0.0000008
limit: 0.7
mode: cooling
hvac-device: *hvac-a6
settings:
changeover-delta: 1
target-temperature: 22
keep-hvac-on: true
```
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,24 @@ private EconomizerContext createEconomizer(String zoneName, EconomizerConfig cf)
return t;
});

if (cf.settings() == null) {

// This is likely a result of a breaking change in the configuration, let's complain loudly but not explode
// PS: It might be a good idea to remove this check a bit later when the users do update the configuration
// PPS: Or just pretend it doesn't exist and configure the economizer inactive without them, see https://github.com/home-climate-control/dz/issues/267

logger.error("null settings, have you updated the configuration? Here's what it looks like: {}", cf);
logger.error("Ignoring economizer configuration for now");

return null;
}

return new EconomizerContext(
new EconomizerSettings(
cf.mode(),
cf.changeoverDelta(),
cf.targetTemperature(),
cf.keepHvacOn(),
cf.settings().changeoverDelta(),
cf.settings().targetTemperature(),
cf.settings().keepHvacOn(),
cf.controller().p(),
cf.controller().i(),
cf.controller().limit()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@
@JsonNaming(PropertyNamingStrategies.KebabCaseStrategy.class)
public record EconomizerConfig(
String ambientSensor,
double changeoverDelta,
double targetTemperature,
Boolean keepHvacOn,
PidControllerConfig controller,
HvacMode mode,
String hvacDevice,
Duration timeout
Duration timeout,
Settings settings
) {
public record Settings(
double changeoverDelta,
double targetTemperature,
Boolean keepHvacOn
) {

}
}

0 comments on commit a05d259

Please sign in to comment.