Skip to content

Commit

Permalink
Merge pull request #206 from mcrossley/main
Browse files Browse the repository at this point in the history
4.1.4 - b4029
  • Loading branch information
mcrossley authored Aug 22, 2024
2 parents e521632 + ad07684 commit e94d9c8
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 14 deletions.
4 changes: 2 additions & 2 deletions CumulusMX/CumulusMX.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
</PropertyGroup>

<PropertyGroup>
<Version>4.1.3.4028</Version>
<Version>4.1.4.4029</Version>
<Copyright>Copyright © 2015-$([System.DateTime]::Now.ToString('yyyy')) Cumulus MX</Copyright>
</PropertyGroup>

Expand Down Expand Up @@ -90,7 +90,7 @@
<PackageReference Include="Microsoft.Win32.SystemEvents" Version="8.0.0" />
<PackageReference Include="NReco.Logging.File" Version="1.2.1" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.5" />
<PackageReference Include="SQLitePCLRaw.bundle_green" Version="2.1.9" />
<PackageReference Include="SQLitePCLRaw.bundle_green" Version="2.1.8" />
<PackageReference Include="System.CodeDom" Version="8.0.0" />
<PackageReference Include="System.Diagnostics.PerformanceCounter" Version="8.0.0" />
<PackageReference Include="EmbedIO" Version="3.5.2" />
Expand Down
18 changes: 11 additions & 7 deletions CumulusMX/DavisCloudStation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ internal partial class DavisCloudStation : WeatherStation
private bool startingUp = true;
private DateTime lastRecordTime = DateTime.MinValue;
private DateTime lastHistoricData;
private string subscriptionLevel = string.Empty;

public DavisCloudStation(Cumulus cumulus) : base(cumulus)
{
Expand Down Expand Up @@ -139,7 +140,7 @@ public DavisCloudStation(Cumulus cumulus) : base(cumulus)

DateTime tooOld = new DateTime(0, DateTimeKind.Local);

if ((cumulus.LastUpdateTime <= tooOld) || !cumulus.UseDataLogger)
if ((cumulus.LastUpdateTime <= tooOld) || subscriptionLevel == "basic" || !cumulus.UseDataLogger)
{
// there's nothing in the database, so we haven't got a rain counter
// we can't load the history data, so we'll just have to go live
Expand Down Expand Up @@ -494,6 +495,7 @@ private void GetHistoricData(BackgroundWorker worker)
cumulus.LogErrorMessage($"GetHistoricData: WeatherLink API Historic Error: {historyError.code}, {historyError.message}");
Cumulus.LogConsoleMessage($" - Error {historyError.code}: {historyError.message}", ConsoleColor.Red);
//cumulus.LastUpdateTime = Utils.FromUnixTime(endTime)
maxArchiveRuns = 0;
return;
}

Expand All @@ -502,6 +504,7 @@ private void GetHistoricData(BackgroundWorker worker)
cumulus.LogWarningMessage("GetHistoricData: WeatherLink API Historic: No data was returned. Check your Device Id.");
Cumulus.LogConsoleMessage(" - No historic data available");
lastHistoricData = Utils.FromUnixTime(endTime);
maxArchiveRuns = 0;
return;
}
else if (responseBody.StartsWith("{\"")) // basic sanity check
Expand Down Expand Up @@ -542,6 +545,7 @@ private void GetHistoricData(BackgroundWorker worker)
cumulus.LogErrorMessage("GetHistoricData: Invalid historic message received");
cumulus.LogMessage("GetHistoricData: Received: " + responseBody);
lastHistoricData = Utils.FromUnixTime(endTime);
maxArchiveRuns = 0;
return;
}
}
Expand All @@ -555,6 +559,7 @@ private void GetHistoricData(BackgroundWorker worker)
}

lastHistoricData = Utils.FromUnixTime(endTime);
maxArchiveRuns = 0;
return;
}

Expand Down Expand Up @@ -3688,10 +3693,10 @@ private void GetAvailableStationIds(bool logToConsole = false)

foreach (var station in stationsObj.stations)
{
cumulus.LogMessage($"GetStations: Found WeatherLink station id = {station.station_id}, name = {station.station_name}");
cumulus.LogMessage($"GetStations: WeatherLink station id = {station.station_id}, name = {station.station_name}, subscription = {station.subscription_type}");
if (stationsObj.stations.Count > 1 && logToConsole)
{
Cumulus.LogConsoleMessage($" - Found WeatherLink station id = {station.station_id}, name = {station.station_name}, active = {station.active}");
Cumulus.LogConsoleMessage($" - Found WeatherLink station id = {station.station_id}, name = {station.station_name}, active = {station.active}, subscription = {station.subscription_type}");
}
if (station.station_id == cumulus.WllStationId || station.station_id_uuid == cumulus.WllStationUuid)
{
Expand All @@ -3706,7 +3711,6 @@ private void GetAvailableStationIds(bool logToConsole = false)
wlStationArchiveInterval = station.recording_interval;
SetDataTimeout(station.subscription_type);


if (cumulus.WllStationId < 10)
{
cumulus.WllStationId = station.station_id;
Expand Down Expand Up @@ -3749,17 +3753,17 @@ private void GetAvailableStationIds(bool logToConsole = false)

private void SetDataTimeout(string subscription)
{
subscription = (subscription ?? "basic").ToLower();
subscriptionLevel = (subscription ?? "basic").ToLower();

DataTimeoutMins = subscription switch
DataTimeoutMins = subscriptionLevel switch
{
"basic" => 15 + 3,
"pro" => 5 + 3,
"pro+" => 1 + 3,
_ => 15 + 3,
};

cumulus.LogMessage($"GetStations: Subscription type = {subscription}, update rate = {DataTimeoutMins} minutes");
cumulus.LogMessage($"GetStations: Subscription type = {subscription}, data timeout = {DataTimeoutMins} minutes");
}

private void GetAvailableSensors()
Expand Down
2 changes: 1 addition & 1 deletion CumulusMX/DavisStation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ private void bw_DoWork(object sender, DoWorkEventArgs e)

GetArchiveData();

// The VP" seems to need a nudge after a DMPAFT command
// The VP2 seems to need a nudge after a DMPAFT command
if (isSerial)
{
WakeVP(comport, true);
Expand Down
9 changes: 7 additions & 2 deletions CumulusMX/DavisWllStation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ internal partial class DavisWllStation : WeatherStation
private readonly bool useWeatherLinkDotCom = true;
private readonly bool[] sensorContactLost = new bool[9];
private DateTime lastHistoricData;
private string subscriptionType = string.Empty;

public DavisWllStation(Cumulus cumulus) : base(cumulus)
{
Expand Down Expand Up @@ -3039,10 +3040,10 @@ private void GetAvailableStationIds(bool logToConsole = false)

foreach (var station in stationsObj.stations)
{
cumulus.LogMessage($"WLLStations: Found WeatherLink station id = {station.station_id}, name = {station.station_name}");
cumulus.LogMessage($"WLLStations: WeatherLink station id = {station.station_id}, name = {station.station_name}, active = {station.active}, subscription = {station.subscription_type}");
if (stationsObj.stations.Count > 1 && logToConsole)
{
Cumulus.LogConsoleMessage($" - Found WeatherLink station id = {station.station_id}, name = {station.station_name}, active = {station.active}");
Cumulus.LogConsoleMessage($" - Found WeatherLink station id = {station.station_id}, name = {station.station_name}, active = {station.active}, subscription = {station.subscription_type}");
}
if (station.station_id == cumulus.WllStationId || cumulus.WllStationUuid == station.station_id_uuid)
{
Expand All @@ -3063,6 +3064,8 @@ private void GetAvailableStationIds(bool logToConsole = false)
cumulus.WllStationUuid = station.station_id_uuid;
}

subscriptionType = station.subscription_type.ToLower();

cumulus.WriteIniFile();
}
}
Expand All @@ -3078,6 +3081,8 @@ private void GetAvailableStationIds(bool logToConsole = false)
cumulus.LogMessage($"WLLStations: Only found 1 WeatherLink station, using id = {usedId}");
cumulus.WllStationId = stationsObj.stations[0].station_id;
cumulus.WllStationUuid = stationsObj.stations[0].station_id_uuid;
subscriptionType = stationsObj.stations[0].subscription_type.ToLower();

// And save it to the config file
cumulus.WriteIniFile();

Expand Down
17 changes: 15 additions & 2 deletions Updates.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
4.1.4 - b4029
—————————————
Fixed
- Davis Cloud stations in endless loop at startup if there is no historic data to process or access is denied

Changed
- Davis WLL/DAvis Cloud stations now use the WL.com subscription level to determine if they use WL.com as a logger


Package Updates
- SQLite: Reverted to v2.1.8 pending fix from author



4.1.3 - b4028
—————————————
New
- New web tag <#stationId> which returns the internal station number used by CMX to determine the station type
- For Davis WLL and WeatherLink Cloud stations you can now specify the station identifier using the stations UUID instead of the numeric Id. The UUID is simplier to find
- For Davis WLL and WeatherLink Cloud stations you can now specify the station identifier using the stations UUID instead of the numeric Id. The UUID is simpler to find
as it forms part of the URL of every web page related to your station on weatherlink.com

Changed

Fixed
- The Cumulus MX version comparison with latest online at startup and daily
- Fix CMX version check when no betas are available on Github repo
- Fix CMX version check when no betas are available on GitHub repo
- Davis Cloud Station can now accurately determine the current conditions update rate
- Fix Davis WLL (and others) creating erroneous wind speed spike warnings
- Alternative Interface 2 - Davis reception stats display incorrectly
Expand Down

0 comments on commit e94d9c8

Please sign in to comment.