Class WeatherLinkLiveAPI.WeatherLinkLive
- Namespace
- WeatherLinkLive
- Assembly
- WeatherLink Live Library.dll
Client for a local WeatherLink Live device. Construct, call InitializeAsync(CancellationToken), then use the exposed properties to read the latest values.
public class WeatherLinkLive : IDisposable
- Inheritance
-
ObjectWeatherLinkLiveAPI.WeatherLinkLive
- Implements
-
IDisposable
- Inherited Members
-
Object.ToString()Object.Equals(Object)Object.Equals(Object, Object)Object.ReferenceEquals(Object, Object)Object.GetHashCode()Object.GetType()Object.MemberwiseClone()
Constructors
WeatherLinkLive(IPAddress, Int32, Int32, Boolean, Boolean, Boolean, Boolean)
Initializes a new instance of the WeatherLinkLiveAPI.WeatherLinkLive class. Initializes a new instance from an System.Net.IPAddress.
public WeatherLinkLive(IPAddress weatherLinkLiveIP, int refreshIntervalSeconds = 30, int forceRefreshIntervalSeconds = 60, bool celciusTemperature = false, bool metricRain = false, bool metricWind = false, bool metricBarometer = false)
Parameters
weatherLinkLiveIPIPAddressThe WeatherLink Live device IPv4 address.
refreshIntervalSecondsInt32Minimum seconds between refreshes. Must be greater than or equal to10.
forceRefreshIntervalSecondsInt32Maximum allowed age of cached data before access throws.
celciusTemperatureBooleanTrue to return temperatures in Celsius instead of Fahrenheit.
metricRainBooleanTrue to return rainfall in metric units.
metricWindBooleanTrue to return wind speed in metric units.
metricBarometerBooleanTrue to return barometer in metric units.
Exceptions
- System.ArgumentException
Thrown when
refreshIntervalSecondsis less than10.
WeatherLinkLive(String, Int32, Int32, Boolean, Boolean, Boolean, Boolean)
Initializes a new instance of the WeatherLinkLiveAPI.WeatherLinkLive class. Initializes a new instance from an IP address string.
public WeatherLinkLive(string iPAddress, int refreshIntervalSeconds = 30, int forceRefreshIntervalSeconds = 60, bool celciusTemperature = false, bool metricRain = false, bool metricWind = false, bool metricBarometer = false)
Parameters
iPAddressStringThe WeatherLink Live device IPv4 address.
refreshIntervalSecondsInt32Minimum seconds between refreshes. Must be greater than or equal to10.
forceRefreshIntervalSecondsInt32Maximum allowed age of cached data before access throws.
celciusTemperatureBooleanTrue to return temperatures in Celsius instead of Fahrenheit.
metricRainBooleanTrue to return rainfall in metric units.
metricWindBooleanTrue to return wind speed in metric units.
metricBarometerBooleanTrue to return barometer in metric units.
Exceptions
- System.ArgumentException
Thrown when
refreshIntervalSecondsis less than10.
Properties
BarometerAtSeaLevel
Gets the sea-level corrected barometric pressure.
public float BarometerAtSeaLevel { get; }
Property Value
- Single
Pressure in inches of mercury, or millimeters when MetricBarometer is true.
BarometerTrend
Gets the textual barometer trend.
public string BarometerTrend { get; }
Property Value
- String
A string such as "Rising", "Falling", or "Steady".
CelciusTemperature
Gets or sets a value indicating whether temperatures are returned in Celsius (true) or Fahrenheit (false).
public bool CelciusTemperature { get; set; }
Property Value
- Boolean
True for Celsius; otherwise false for Fahrenheit.
DewPoint
Gets the dew point.
public float DewPoint { get; }
Property Value
- Single
Dew point in Fahrenheit, or Celsius when CelciusTemperature is true.
HeatIndex
Gets the heat index.
public float HeatIndex { get; }
Property Value
- Single
Heat index in Fahrenheit, or Celsius when CelciusTemperature is true.
Humidity
Gets the current relative humidity.
public float Humidity { get; }
Property Value
- Single
Relative humidity as a percentage in the range0–100.
MetricBarometer
Gets or sets a value indicating whether barometric pressure values are returned in metric units.
public bool MetricBarometer { get; set; }
Property Value
- Boolean
True for metric pressure; otherwise false.
MetricRain
Gets or sets a value indicating whether rainfall values are returned in metric units.
public bool MetricRain { get; set; }
Property Value
- Boolean
True for metric rainfall; otherwise false.
MetricWind
Gets or sets a value indicating whether wind speed values are returned in metric units.
public bool MetricWind { get; set; }
Property Value
- Boolean
True for metric wind speeds; otherwise false.
RainfallLast24Hours
Gets the rainfall measured in the last24 hours.
public float RainfallLast24Hours { get; }
Property Value
- Single
Rainfall in device units; output is metric when MetricRain is true.
RainRate
Gets the current rain rate.
public float RainRate { get; }
Property Value
- Single
Rain rate in device units; output is metric when MetricRain is true.
Temperature
Gets the current temperature.
public float Temperature { get; }
Property Value
- Single
Temperature in Fahrenheit, or Celsius when CelciusTemperature is true.
ThswIndex
Gets the THSW index (Temperature-Humidity-Sun-Wind).
public float ThswIndex { get; }
Property Value
- Single
THSW index in Fahrenheit, or Celsius when CelciusTemperature is true.
ThwIndex
Gets the THW index (Temperature-Humidity-Wind).
public float ThwIndex { get; }
Property Value
- Single
THW index in Fahrenheit, or Celsius when CelciusTemperature is true.
WetBulb
Gets the wet bulb temperature.
public float WetBulb { get; }
Property Value
- Single
Wet bulb temperature in Fahrenheit, or Celsius when CelciusTemperature is true.
WindChill
Gets the wind chill.
public float WindChill { get; }
Property Value
- Single
Wind chill in Fahrenheit, or Celsius when CelciusTemperature is true.
WindDirectionAverage1Minute
Gets the1 minute scalar average wind direction.
public float WindDirectionAverage1Minute { get; }
Property Value
- Single
Average wind direction in degrees (0–360).
WindDirectionAverage1MinuteCompass
Gets the compass direction string for the1 minute average wind direction.
public string WindDirectionAverage1MinuteCompass { get; }
Property Value
- String
One of N, NNE, NE, …, N.
WindDirectionLast
Gets the last wind direction.
public float WindDirectionLast { get; }
Property Value
- Single
Wind direction in degrees (0–360).
WindDirectionLastCompass
Gets the compass direction string for the last wind direction.
public string WindDirectionLastCompass { get; }
Property Value
- String
One of N, NNE, NE, …, N.
WindSpeedHighLast10Minutes
Gets the highest wind speed over the last10 minutes.
public float WindSpeedHighLast10Minutes { get; }
Property Value
- Single
Wind speed in MPH, or KPH when MetricWind is true.
WindSpeedLast
Gets the most recent wind speed.
public float WindSpeedLast { get; }
Property Value
- Single
Wind speed in MPH, or KPH when MetricWind is true.
Methods
Dispose()
Releases HTTP and managed resources used by this instance.
public void Dispose()
InitializeAsync(CancellationToken)
Performs asynchronous initialization by fetching the initial dataset. Must be called before accessing any data properties.
public Task InitializeAsync(CancellationToken cancellationToken = default(CancellationToken))
Parameters
cancellationTokenCancellationTokenOptional token to cancel the operation.
Returns
- Task
A task that represents the asynchronous initialization operation.
Exceptions
- System.Net.Http.HttpRequestException
Thrown on network errors while contacting the device.
- Newtonsoft.Json.JsonException
Thrown when the received JSON cannot be parsed.
RefreshAsync(CancellationToken)
Refreshes the cached data asynchronously. Call periodically, or when accessing data becomes stale.
public Task RefreshAsync(CancellationToken cancellationToken = default(CancellationToken))
Parameters
cancellationTokenCancellationTokenOptional token to cancel the operation.
Returns
- Task
A task that represents the asynchronous refresh operation.
Exceptions
- System.Net.Http.HttpRequestException
Thrown on network errors while contacting the device.
- Newtonsoft.Json.JsonException
Thrown when the received JSON cannot be parsed.