Skip to content

Commit

Permalink
Merge branch 'release/1.09'
Browse files Browse the repository at this point in the history
  • Loading branch information
darmbrust committed Jan 13, 2021
2 parents 1c2ffce + d291b5a commit f874298
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 33 deletions.
36 changes: 35 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ java -jar weatherlink<Platform>.jar [ip address]
If you don't have java, grab the latest 11 version for your platform:
https://adoptopenjdk.net/releases.html?variant=openjdk11&jvmVariant=hotspot

You will want to use a x64 installer. It should work with either the JDK or JRE.

For windows, the file name will be something like: OpenJDK11U-jre_x64_windows_hotspot_11.0.9.1_1.msi

# First Run
It should be able to auto-locate your WeatherLinkLive, so long as it is on the local network.

Expand All @@ -34,6 +38,36 @@ data points will be trimmed to 1 per minute (instead of one every 10 seconds).

If you do not wish to maintain the historic data, you can simply delete the archive database (when the application is running)

# Multiple outdoor sensors / wrong sensors displayed

If you have multiple outdoor sensors, and the GUI is trying to display the wrong one - for now, you have to tell it which
sensor id to display with a startup parameter.

First, look in the debug log file

C:\Users\<username>\Weather Link Live GUI Data\weatherLinkDebug.log

for lines like this:

```
2021-01-13 15:13:53,693 DEBUG [gui-init] gui.WeatherLinkLiveGUIController - Using sensor id '279091' for outside info
2021-01-13 15:13:53,693 DEBUG [gui-init] gui.WeatherLinkLiveGUIController - NOT using sensor id '123456' for outside info
2021-01-13 15:13:53,693 DEBUG [gui-init] gui.WeatherLinkLiveGUIController - NOT using sensor id '223456' for outside info
```

Copy the id of the sensor that you wish to be displayed, if there are more than 2, you may have to just guess.

Pass in the id value as the second paramter after the jar file name. The first parameter is for the IP of your weather link live - if you don't wish
to provide a static IP here, just pass in garbage, and it will ignore it and continue to auto-locate the IP address.

Example:

```
java -jar weatherlinkWindows.jar notAnIP 223456
```

Future enhancments will allow for customizing the GUI and sensor selection from within the GUI.

# Issues
Feel free to open open trackers here.

Expand All @@ -51,6 +85,6 @@ There are lots of TODOs.... useful things I may add (pull requests welcome)

Change version in WeatherLinkLiveGUI.java too
```
mvn -B gitflow:release-start gitflow:release-finish -DreleaseVersion=1.08 -DdevelopmentVersion=1.09
mvn -B gitflow:release-start gitflow:release-finish -DreleaseVersion=1.09 -DdevelopmentVersion=1.10
```
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>net.sagebits.weatherlink</groupId>
<artifactId>weatherlink</artifactId>
<version>1.08</version>
<version>1.09</version>
<packaging>jar</packaging>

<name>WeatherLink Logger and GUI</name>
Expand Down
41 changes: 12 additions & 29 deletions src/main/java/net/sagebits/weatherlink/data/StoredDataTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
*/
public enum StoredDataTypes
{
did("device id", "VARCHAR", true, StoredDataTables.ISS, StoredDataTables.SOIL, StoredDataTables.WLL_ENV, StoredDataTables.WLL_BAR),
lsid("logical sensor id", "VARCHAR", true, StoredDataTables.ISS, StoredDataTables.SOIL, StoredDataTables.WLL_ENV, StoredDataTables.WLL_BAR),
ts("timestamp", "BIGINT", true, StoredDataTables.ISS, StoredDataTables.SOIL, StoredDataTables.WLL_ENV, StoredDataTables.WLL_BAR),
did("device id", "VARCHAR", StoredDataTables.ISS, StoredDataTables.SOIL, StoredDataTables.WLL_ENV, StoredDataTables.WLL_BAR),
lsid("logical sensor id", "VARCHAR", StoredDataTables.ISS, StoredDataTables.SOIL, StoredDataTables.WLL_ENV, StoredDataTables.WLL_BAR),
ts("timestamp", "BIGINT", StoredDataTables.ISS, StoredDataTables.SOIL, StoredDataTables.WLL_ENV, StoredDataTables.WLL_BAR),
//TODO TXID is not handled proper in the SQL store nor in the live data - things will break if we receive data with more than 1 unique TXID
txid("transmitter id", "TINYINT", true, StoredDataTables.ISS, StoredDataTables.SOIL),
txid("transmitter id", "TINYINT", StoredDataTables.ISS, StoredDataTables.SOIL),
temp("temp", "REAL", "most recent valid temperature (°F)", StoredDataTables.ISS),
hum("humidity", "REAL", "most recent valid humidity (%RH)", StoredDataTables.ISS),
dew_point("dew point", "REAL", "most recent valid dew point (°F)", StoredDataTables.ISS),
Expand Down Expand Up @@ -51,13 +51,13 @@ public enum StoredDataTypes
solar_rad("solar radiation", "REAL", "most recent solar radiation (W/m²)", StoredDataTables.ISS),
uv_index("uv index", "REAL", "most recent UV index", StoredDataTables.ISS),
rx_state("receiver state", "TINYINT", "configured radio receiver state", StoredDataTables.ISS, StoredDataTables.SOIL),
trans_battery_flag("transmitter battery status flag", "BOOLEAN", "transmitter battery status flag", true, StoredDataTables.ISS, StoredDataTables.SOIL),
trans_battery_flag("transmitter battery status flag", "BOOLEAN", "transmitter battery status flag", StoredDataTables.ISS, StoredDataTables.SOIL),
rainfall_daily("rain since midnight", "REAL", "total rain count since local midnight", LiveDataTypes.rainfall_daily, StoredDataTables.ISS),
rainfall_monthly("rain this month", "REAL", "total rain count since first of month at local midnight", LiveDataTypes.rainfall_monthly, StoredDataTables.ISS),
rainfall_year("rain this year", "REAL", "total rain count since first of user-chosen month at local midnight", LiveDataTypes.rainfall_year, StoredDataTables.ISS),
rain_storm_last("previous rain storm", "REAL", "total rain count since last 24 hour long break in rain", StoredDataTables.ISS), //previous - non-current rain storm
rain_storm_last_start_at("previous storm start time", "BIGINT", "last rainstorm start time", StoredDataTables.ISS),
rain_storm_last_end_at("previous storm end time", "BIGINT", "last rainstorm end time", true, StoredDataTables.ISS),
rain_storm_last_end_at("previous storm end time", "BIGINT", "last rainstorm end time", StoredDataTables.ISS),

temp_1("temp 1", "REAL", "most recent valid soil temp slot 1 (°F)", StoredDataTables.SOIL),
temp_2("temp 2", "REAL", "most recent valid soil temp slot 2 (°F)", StoredDataTables.SOIL),
Expand All @@ -73,11 +73,11 @@ public enum StoredDataTypes
temp_in("temp", "REAL", "most recent valid temperature (°F)", StoredDataTables.WLL_ENV),
hum_in("humidity", "REAL", "most recent valid humidity (%RH)", StoredDataTables.WLL_ENV),
dew_point_in("dew point", "REAL", "most recent valid dew point (°F)", StoredDataTables.WLL_ENV),
heat_index_in("heat index", "REAL", "most recent valid heat index (°F)", true, StoredDataTables.WLL_ENV),
heat_index_in("heat index", "REAL", "most recent valid heat index (°F)", StoredDataTables.WLL_ENV),

bar_sea_level("adjusted pressure", "REAL", "most recent bar sensor reading with elevation adjustment (inches)", StoredDataTables.WLL_BAR),
bar_trend("barometric trend", "REAL", "current 3 hour bar trent (inches)", StoredDataTables.WLL_BAR),
bar_absolute("absolute pressure", "REAL", "raw bar sensor reading (inches)", true, StoredDataTables.WLL_BAR),
bar_absolute("absolute pressure", "REAL", "raw bar sensor reading (inches)", StoredDataTables.WLL_BAR),
;

//private static final Logger log = LogManager.getLogger(StoredDataTypes.class);
Expand All @@ -86,7 +86,6 @@ public enum StoredDataTypes
private String doc;
private StoredDataTables[] tables;
private LiveDataTypes ldt;
private boolean allowNulls;

private static Hashtable<String, StoredDataTypes> lookupHash = new Hashtable<>();

Expand All @@ -97,34 +96,24 @@ public enum StoredDataTypes
}
}

private StoredDataTypes(String displayName, String dataType, boolean allowNulls, StoredDataTables ... tables)
private StoredDataTypes(String displayName, String dataType, StoredDataTables ... tables)
{
this(displayName, dataType, displayName, allowNulls, tables);
this(displayName, dataType, displayName, tables);
}

private StoredDataTypes(String displayName, String dataType, String doc, StoredDataTables ... tables)
{
this(displayName, dataType, doc, null, false, tables);
this(displayName, dataType, doc, null, tables);
}

private StoredDataTypes(String displayName, String dataType, String doc, boolean allowNulls, StoredDataTables ... tables)
{
this(displayName, dataType, doc, null, allowNulls, tables);
}

private StoredDataTypes(String displayName, String dataType, String doc, LiveDataTypes ldt, StoredDataTables ... tables)
{
this(displayName, dataType, doc, ldt, false, tables);
}

private StoredDataTypes(String displayName, String dataType, String doc, LiveDataTypes ldt, boolean allowNulls, StoredDataTables ... tables)
{
this.displayName = displayName;
this.dataType = dataType;
this.doc = doc;
this.ldt = ldt;
this.tables = tables;
this.allowNulls = allowNulls;
for (StoredDataTables sdt : this.tables)
{
sdt.addColumn(this);
Expand All @@ -133,7 +122,7 @@ private StoredDataTypes(String displayName, String dataType, String doc, LiveDat

public String colCreate()
{
return name() + " " + dataType + (allowNulls ? "" : " NOT NULL");
return name() + " " + dataType;
}

public String getDisplayName()
Expand Down Expand Up @@ -249,12 +238,6 @@ public boolean isNumeric()
}
}

public boolean allowNulls()
{
return allowNulls;
}


public static StoredDataTypes match(String name)
{
return lookupHash.get(name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public class PeriodicData
private PeriodicData() throws SQLException
{
File homeFolder = Paths.get(System.getProperty("user.home"), "Weather Link Live GUI Data").toAbsolutePath().toFile();
// File homeFolder = Paths.get("/mnt/SSD/", "Weather Link Live GUI Data").toAbsolutePath().toFile();
homeFolder.mkdirs();
File dbFile = new File(homeFolder, "weatherLinkData");
File dbArchiveFile = new File(homeFolder, "weatherLinkDataArchive");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ public static void main(String[] args)
{
LogManager.getLogger(WeatherLauncher.class).debug("Passed in param '{}' not an ip, ignoring.", args[0]);
}

if (args.length > 1)
{
WeatherLinkLiveGUIController.sensorId = args[1];
LogManager.getLogger(WeatherLauncher.class).debug("Read SensorID '{}' from command line arg", args[1]);
}
}
Application.launch(WeatherLinkLiveGUI.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void finishSetUp()
wllc_ = loader.getController();
wllc_.finishInit(mainStage_);
// mainStage_.getIcons().add(Images.APPLICATION.getImage());
mainStage_.setTitle("Weather Link Live GUI 1.08");
mainStage_.setTitle("Weather Link Live GUI 1.09");
mainStage_.setOnCloseRequest(event ->
{
wllc_.shutdown();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Optional;
import java.util.ResourceBundle;
Expand Down Expand Up @@ -93,6 +94,7 @@ public class WeatherLinkLiveGUIController
private ScheduledExecutorService periodicJobs = Executors.newScheduledThreadPool(2, r -> new Thread(r, "Periodic GUI Jobs"));

protected static String ip = null;
protected static String sensorId = null;

@FXML
void initialize()
Expand Down Expand Up @@ -133,6 +135,7 @@ public void finishInit(Stage mainStage)
{
log.debug("Gui init thread starts");
String wllDeviceId = null;
boolean hadToWait = false;
while (wllDeviceId == null)
{
HashSet<String> wllDeviceIds = DataFetcher.getInstance().getWeatherLinkDeviceIds();
Expand All @@ -141,6 +144,7 @@ public void finishInit(Stage mainStage)
log.debug("Waiting for at least one device ID to be found");
try
{
hadToWait = true;
Thread.sleep(500);
}
catch (InterruptedException e)
Expand All @@ -151,14 +155,39 @@ public void finishInit(Stage mainStage)
else
{
wllDeviceId = wllDeviceIds.iterator().next();
if (hadToWait)
{
try
{
//Sleep another second, to give the initial data time to populate, otherwise, we have issues below building GUI.
Thread.sleep(1000);
}
catch (InterruptedException e)
{
// don't care
}
}
}
}

Set<String> outdoorSensors = DataFetcher.getInstance().getSensorsFor(wllDeviceId, StoredDataTypes.temp);
String sensorOutdoor = null;
if (outdoorSensors.size() > 0)
{
sensorOutdoor = outdoorSensors.iterator().next();
Iterator<String> sensorIterator = outdoorSensors.iterator();
sensorOutdoor = sensorIterator.next();
log.debug("Using sensor id '{}' for outside info", sensorOutdoor);
while (sensorIterator.hasNext())
{
log.debug("NOT using sensor id '{}' for outside info", sensorIterator.next());
}

if (sensorId != null)
{
log.info("Overriding previous sensor id selection with value '{}' passed in on command line for outside info", sensorId);
sensorOutdoor = sensorId;
}

// try
// {
// Gauge wg = buildWindGauge(wllDeviceId, sensorOutdoor);
Expand Down

0 comments on commit f874298

Please sign in to comment.