-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
zeekoe
committed
Jan 29, 2024
1 parent
24ded4b
commit 959579a
Showing
11 changed files
with
128 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/main/java/com/github/zeekoe/bluebird/influx/DummyInfluxConnection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.github.zeekoe.bluebird.influx; | ||
|
||
import org.influxdb.dto.Point; | ||
|
||
public class DummyInfluxConnection implements InfluxConnection{ | ||
@Override | ||
public void writePoint(Point point) { | ||
System.out.println(point); | ||
} | ||
} |
44 changes: 0 additions & 44 deletions
44
src/main/java/com/github/zeekoe/bluebird/influx/Influx.java
This file was deleted.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
src/main/java/com/github/zeekoe/bluebird/influx/InfluxConnection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.github.zeekoe.bluebird.influx; | ||
|
||
import org.influxdb.dto.Point; | ||
|
||
public interface InfluxConnection { | ||
void writePoint(Point point); | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/com/github/zeekoe/bluebird/influx/RealInfluxConnection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.github.zeekoe.bluebird.influx; | ||
|
||
import org.influxdb.InfluxDB; | ||
import org.influxdb.InfluxDBFactory; | ||
import org.influxdb.dto.Point; | ||
|
||
import static com.github.zeekoe.bluebird.infrastructure.BluebirdProperties.property; | ||
import static com.github.zeekoe.bluebird.infrastructure.BluebirdProperty.INFLUXDB_DATABASE; | ||
import static com.github.zeekoe.bluebird.infrastructure.BluebirdProperty.INFLUXDB_PASSWORD; | ||
import static com.github.zeekoe.bluebird.infrastructure.BluebirdProperty.INFLUXDB_URL; | ||
import static com.github.zeekoe.bluebird.infrastructure.BluebirdProperty.INFLUXDB_USERNAME; | ||
|
||
public class RealInfluxConnection implements InfluxConnection { | ||
private final InfluxDB influxDB; | ||
|
||
public RealInfluxConnection() { | ||
influxDB = InfluxDBFactory.connect( | ||
property(INFLUXDB_URL), | ||
property(INFLUXDB_USERNAME), | ||
property(INFLUXDB_PASSWORD)); | ||
} | ||
|
||
public void writePoint(Point point) { | ||
influxDB.setDatabase(property(INFLUXDB_DATABASE)); | ||
influxDB.write(point); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/com/github/zeekoe/bluebird/infrastructure/BluebirdProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.github.zeekoe.bluebird.infrastructure; | ||
|
||
import java.io.FileInputStream; | ||
import java.io.IOException; | ||
import java.util.Properties; | ||
|
||
public class BluebirdProperties { | ||
private static final Properties properties; | ||
|
||
static { | ||
final String configFile = "/etc/bluebird.config"; | ||
properties = new Properties(); | ||
try { | ||
properties.load(new FileInputStream(configFile)); | ||
} catch (IOException e) { | ||
throw new RuntimeException("Error in loading properties file: " + configFile, e); | ||
} | ||
} | ||
|
||
public static String property(BluebirdProperty property) { | ||
return properties.getProperty(property.getKey()); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/com/github/zeekoe/bluebird/infrastructure/BluebirdProperty.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.github.zeekoe.bluebird.infrastructure; | ||
|
||
|
||
public enum BluebirdProperty { | ||
WEHEAT_USERNAME("bluebird.username"), | ||
WEHEAT_PASSWORD("bluebird.password"), | ||
WEHEAT_LOG_URL("bluebird.logurl"), | ||
|
||
INFLUXDB_URL("influxdb.url"), | ||
INFLUXDB_DATABASE("influxdb.database"), | ||
INFLUXDB_USERNAME("influxdb.username"), | ||
INFLUXDB_PASSWORD("influxdb.password"), | ||
INFLUXDB_MEASUREMENT("influxdb.bluebird.measurement"); | ||
|
||
private final String key; | ||
|
||
BluebirdProperty(String key) { | ||
this.key = key; | ||
} | ||
|
||
public String getKey() { | ||
return key; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/test/java/com/github/zeekoe/bluebird/HeatpumpTestRunner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.github.zeekoe.bluebird; | ||
|
||
import com.github.zeekoe.bluebird.heatpump.Heatpump; | ||
import com.github.zeekoe.bluebird.influx.DummyInfluxConnection; | ||
|
||
public class HeatpumpTestRunner { | ||
public static void main(String[] args) { | ||
final Heatpump heatpump = new Heatpump(new DummyInfluxConnection()); | ||
heatpump.run(); | ||
// final LocalDateTime localDate = Instant.ofEpochSecond(1706523458).atOffset(ZoneOffset.ofHours(1)).toLocalDateTime(); | ||
// System.out.println(localDate); | ||
} | ||
} |