WeatherLinkLiveLibrary 1.0.3
dotnet add package WeatherLinkLiveLibrary --version 1.0.3
NuGet\Install-Package WeatherLinkLiveLibrary -Version 1.0.3
<PackageReference Include="WeatherLinkLiveLibrary" Version="1.0.3" />
<PackageVersion Include="WeatherLinkLiveLibrary" Version="1.0.3" />
<PackageReference Include="WeatherLinkLiveLibrary" />
paket add WeatherLinkLiveLibrary --version 1.0.3
#r "nuget: WeatherLinkLiveLibrary, 1.0.3"
#:package WeatherLinkLiveLibrary@1.0.3
#addin nuget:?package=WeatherLinkLiveLibrary&version=1.0.3
#tool nuget:?package=WeatherLinkLiveLibrary&version=1.0.3
WeatherLink Live™ Library
WeatherLink Live™ Library queries the current conditions from a local WeatherLink Live device. It supports .NET Framework 4.7.2 and .NET 10, with compatibility support isolated to the .NET Framework build.
- Usage
- Automated tests
- Live device tests
- Console test harness
- Build and release
- Documentation and license
Usage
Construct WeatherLinkLive.WeatherLinkLiveAPI.WeatherLinkLive with the device's IPv4 address, then await InitializeAsync() before reading any properties. No cloud account or API key is required. The client requests the local /v1/current_conditions endpoint.
Call RefreshAsync() periodically. The minimum refresh interval defaults to 30 seconds and must be at least 10 seconds. Calls within that interval reuse the last successful response. The maximum permitted cache age defaults to 60 seconds; reading older data throws InvalidOperationException. Choose a maximum age at least as long as the minimum refresh interval.
Concurrent refreshes are serialized. Only a successful response updates the cached readings and their age; failures propagate to the caller and leave the previous snapshot intact. Cancellation is supported. Dispose the client when finished; further reading, initialization and refresh operations throw ObjectDisposedException.
Readings cover temperature and calculated temperature indices, humidity, wind speed and direction, rainfall, and sea-level pressure and trend. The first ISS record (data_structure_type: 1) supplies outdoor readings, and the barometer record (data_structure_type: 3) supplies pressure, regardless of their positions in the response. The API does not currently select between multiple ISS transmitters.
Temperatures default to Fahrenheit; CelciusTemperature selects Celsius (the existing property spelling is retained). Wind defaults to mph, with MetricWind selecting km/h. Rain defaults to inches, with MetricRain selecting millimetres. MetricBarometer selects millimetres of mercury, not hPa. These preferences convert cached readings without requesting the device again.
The existing non-nullable numeric API returns zero for unavailable readings, so zero alone cannot distinguish missing sensor data from a measured zero. Missing pressure trend returns Unknown.
Automated tests
Open WeatherLink Live Library.sln in Visual Studio and use Test Explorer. WeatherLinkLive.Tests uses NUnit and its Visual Studio adapter, targeting net472 and net10.0. The test project is not a NuGet package.
The 127 offline cases cover every reading property, unit conversions, rain collector sizes, compass bearings, pressure trends, missing data, culture independence, HTTP and JSON failures, initialization, polling and stale-data timing, cancellation, concurrent requests, disposal, sensor ordering and live-setting validation. The HTTP handler and clock are controlled by the tests; offline cases never contact a weather station.
Run both frameworks on Windows:
dotnet test .\WeatherLinkLive.Tests\WeatherLinkLive.Tests.csproj --settings .\WeatherLinkLive.Tests\offline.runsettings --filter "TestCategory!=Live"
Use -f net472 or -f net10.0 to run one target. CI runs the offline suite for both targets, and the release workflow requires it to pass before publishing.
Live device tests
Three read-only tests check current readings, cached metric conversions and a fresh response after a ten-second polling interval. They do not modify the station or assume the weather will change. The test computer must be able to reach the device's local HTTP endpoint.
- Copy
WeatherLinkLive.Tests/LiveTestSettings.example.jsontoWeatherLinkLive.Tests/LiveTestSettings.json. - Replace the documentation-only example address with your device's IPv4 address. No credentials are needed.
- Add
/WeatherLinkLive.Tests/LiveTestSettings.jsonto your checkout's.git/info/excludebefore saving personal settings. Keep that file local.
The private JSON contains enabled (default false) and ipAddress. Live tests are skipped unless enabled by that file or the NUnit EnableLiveTests=true parameter. EnableLiveTests=false always disables them. The fixtures are categorized Live; they do not use NUnit's Explicit attribute.
For Visual Studio, select WeatherLinkLive.Tests/live.runsettings through Test > Configure Run Settings > Select Solution Wide runsettings File, then select the LiveDeviceTests fixture in Test Explorer. Switch to offline.runsettings to force live tests off.
From a terminal, run one framework at a time:
dotnet test .\WeatherLinkLive.Tests\WeatherLinkLive.Tests.csproj -f net472 --settings .\WeatherLinkLive.Tests\live.runsettings --filter "TestCategory=Live"
dotnet test .\WeatherLinkLive.Tests\WeatherLinkLive.Tests.csproj -f net10.0 --settings .\WeatherLinkLive.Tests\live.runsettings --filter "TestCategory=Live"
Settings are found by walking from the test output directory back towards the solution, which finds the private file beside the test project. A fallback is %LOCALAPPDATA%/WeatherLinkLive/LiveTestSettings.json. For an external runner, NUnit's TestDataDirectory parameter identifies the folder containing LiveTestSettings.json; when provided, that location is authoritative. An explicitly enabled run with missing or invalid settings fails clearly.
The private file is never copied to build or publish output and is never packed. Only the example is included in source control. The console's saved IP may be copied into this private JSON when setting up the tests; the fixtures do not depend on the console project.
Console test harness
The existing WeattherLinkLive Test project is a console program for manual smoke testing. Its spelling is retained in the solution.
Provide the device IP using WEATHERLINK_LIVE_IP, or .local/weatherlink-live-ip.txt in the solution root. Exclude .local/ through your checkout's .git/info/exclude file. These inputs are separate from the NUnit JSON settings.
Build and release
dotnet build ".\WeatherLink Live Library.sln" -c Release
Release builds can generate DocFX documentation. Pass -p:GenerateApiDocumentation=false when only building or testing binaries. The GitHub release-nuget.yml workflow builds and tests both frameworks, publishes the library package and creates a GitHub release from version tags. Live tests are disabled in CI.
See CHANGELOG.md for changes and GitHub releases for released versions.
Documentation and license
The automated test project uses NUnit, licensed under the MIT license. NUnit is a test dependency and is not required by users of the library.
This independent client library is not affiliated with or endorsed by Davis Instruments. WeatherLink Live is a trademark of Davis Instruments.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Framework | net472 is compatible. net48 was computed. net481 was computed. |
-
.NETFramework 4.7.2
- Hafner.Compatibility.MetaPackage (>= 1.9.0)
- log4net (>= 3.4.0)
- Newtonsoft.Json (>= 13.0.5-beta1)
- System.Net.Http (>= 4.3.4)
-
net10.0
- log4net (>= 3.4.0)
- Newtonsoft.Json (>= 13.0.5-beta1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Fix sensor ordering, refresh timing, cache recovery, disposal and metric wind conversion. Add 127 offline and three opt-in live NUnit tests. See CHANGELOG.md for details.