diff --git a/src/main/java/homecontrol/impl/hwep1/HWEP1Client.java b/src/main/java/homecontrol/impl/hwep1/HWEP1Client.java index bbeaec8..169ba43 100644 --- a/src/main/java/homecontrol/impl/hwep1/HWEP1Client.java +++ b/src/main/java/homecontrol/impl/hwep1/HWEP1Client.java @@ -27,6 +27,13 @@ public class HWEP1Client { @ConfigProperty(name = "EVCHARGING_HWEP1_IP") String ip; + @ConfigProperty(name = "HAS_GAS", defaultValue = "true") + String hasGas; + + boolean hasGas() { + return Boolean.valueOf(hasGas); + } + @CacheResult(cacheName = "hwep1-data") JsonObject getJsonData() throws IOException { LOGGER.fine("Requesting data from HWEP1"); @@ -93,7 +100,7 @@ Telegram parseTelegram(String body) { if (gas != null && gas.size() > 1) { telegram.setTotal_gas_m3(new BigDecimal(parseValue(gas.get(1)))); } - telegram.setTotal_gas_m3(new BigDecimal(parseValue(map.get("0-1:24.2.3").get(1)))); + if (hasGas()) telegram.setTotal_gas_m3(new BigDecimal(parseValue(map.get("0-1:24.2.3").get(1)))); telegram.setActive_power_average_w(new BigDecimal(parseValue(map.get("1-0:1.4.0").get(0))).multiply(new BigDecimal(1000)).intValue()); telegram.setActive_power_import_w(new BigDecimal(parseValue(map.get("1-0:1.7.0").get(0))).multiply(new BigDecimal(1000)).intValue()); telegram.setActive_power_export_w(new BigDecimal(parseValue(map.get("1-0:2.7.0").get(0))).multiply(new BigDecimal(1000)).intValue()); diff --git a/src/main/java/homecontrol/impl/slack/SlackService.java b/src/main/java/homecontrol/impl/slack/SlackService.java index fb0cb7d..fc9f2bf 100644 --- a/src/main/java/homecontrol/impl/slack/SlackService.java +++ b/src/main/java/homecontrol/impl/slack/SlackService.java @@ -18,9 +18,9 @@ @ApplicationScoped public class SlackService implements NotificationService { - @ConfigProperty(name = "EVCHARGING_SLACK_URL") + @ConfigProperty(name = "EVCHARGING_SLACK_URL", defaultValue="NONE") String slackUrl; - @ConfigProperty(name = "EVCHARGING_SLACK_CHANNEL") + @ConfigProperty(name = "EVCHARGING_SLACK_CHANNEL", defaultValue="NONE") String channel; @Inject diff --git a/src/main/java/homecontrol/impl/sma/SMACharger.java b/src/main/java/homecontrol/impl/sma/SMACharger.java index cfc2583..dd1f6b0 100644 --- a/src/main/java/homecontrol/impl/sma/SMACharger.java +++ b/src/main/java/homecontrol/impl/sma/SMACharger.java @@ -19,7 +19,7 @@ @ApplicationScoped public class SMACharger implements Charger { - @ConfigProperty(name = "EVCHARGING_CHARGER_IP") + @ConfigProperty(name = "EVCHARGING_CHARGER_IP", defaultValue="NONE") String chargerIp; @ConfigProperty(name = "EVCHARGING_CHARGER_USERNAME") String chargerUserName; @@ -53,6 +53,7 @@ public State getCurrentState(StateRefresh stateRefresh) { @Asynchronous @Retry(maxRetries = 3, delay = 2, delayUnit = ChronoUnit.SECONDS) public Uni getActivePower() { + if (isDisabled()) return Uni.createFrom().item(0); int activePower = (int) getLivePowerMeterReading(); return Uni.createFrom().item(activePower); } @@ -64,6 +65,7 @@ public int getChargingMeterReading() { } public State getStateInternal() { + if (isDisabled()) return State.NotConnected; try { if (token == null) { token = authenticate(); @@ -204,4 +206,7 @@ private String authenticate() { } } + boolean isDisabled() { + return "NONE".equals(chargerIp); + } } diff --git a/src/main/java/homecontrol/impl/sma/SMAInverter.java b/src/main/java/homecontrol/impl/sma/SMAInverter.java index 823ad7e..8d52f40 100644 --- a/src/main/java/homecontrol/impl/sma/SMAInverter.java +++ b/src/main/java/homecontrol/impl/sma/SMAInverter.java @@ -27,9 +27,9 @@ @ApplicationScoped public class SMAInverter implements Inverter { public static final Logger LOGGER = Logger.getLogger(SMAInverter.class.getName()); - @ConfigProperty(name = "EVCHARGING_INVERTER_IP") + @ConfigProperty(name = "EVCHARGING_INVERTER_IP", defaultValue="NONE") String inverterIp; - @ConfigProperty(name = "EVCHARGING_INVERTER_PASSWORD") + @ConfigProperty(name = "EVCHARGING_INVERTER_PASSWORD", defaultValue="NONE") String inverterPassword; String sid; @@ -38,6 +38,7 @@ public class SMAInverter implements Inverter { @Retry(maxRetries = 3, delay = 2, delayUnit = ChronoUnit.SECONDS) @Asynchronous public Uni getCurrentYield() { + if (isDisabled()) return Uni.createFrom().item(0); return Uni.createFrom().item(getLiveSMAPowerDataInternal()); } @@ -184,4 +185,8 @@ private void logout() { } } } + + boolean isDisabled() { + return "NONE".equals(inverterIp); + } }