NRuuviTag.Rest.Agent 0.12.1

dotnet add package NRuuviTag.Rest.Agent --version 0.12.1                
NuGet\Install-Package NRuuviTag.Rest.Agent -Version 0.12.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NRuuviTag.Rest.Agent" Version="0.12.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NRuuviTag.Rest.Agent --version 0.12.1                
#r "nuget: NRuuviTag.Rest.Agent, 0.12.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install NRuuviTag.Rest.Agent as a Cake Addin
#addin nuget:?package=NRuuviTag.Rest.Agent&version=0.12.1

// Install NRuuviTag.Rest.Agent as a Cake Tool
#tool nuget:?package=NRuuviTag.Rest.Agent&version=0.12.1                

NRuuviTag.Rest.Agent

An agent to NRuuviTag application created for interacting with RuuviTag IoT sensors from Ruuvi. This agent will collect samples from all sensors for a specified amount of time and then it calculates the average sample value per sensor. The average data is then encapsulated as an array of JSON sample objects and sent to an API endpoint URL using HTTP request POST method.

Publishing Samples to an API REST endpoint URL

The NRuuviTag.Rest.Agent (source) can be used to observe RuuviTag broadcasts and forward the samples to an API REST endpoint URL:

public async Task RestAgent(
  IRuuviTagListener listener,
  ILoggerFactory? loggerFactory = null,
  CancellationToken cancellationToken = default
) {
  var agentOptions = new RestAgentOptions() {
    EndpointUrl = "https://MY_FUNCTIONAPP.azurewbsites.net",
    AverageInterval = 600 // Send average value every 10 minutes
  };
  var agent = new RestAgent(listener, agentOptions, loggerFactory?.CreateLogger<RestAgent>());
  await agent.RunAsync(cancellationToken);
}

Tip of the day: You are not bound to Azure. Create your own API and database where to save data to. Then use Grafana to display you data.

The agent will POST the endpoint a JSON payload containing an array of RuuviTagSampleExtended objects. Example:

[
  {
    "deviceId": "string",
    "displayName": "string",
    "timestamp": "2022-11-28T08:26:08.781Z",
    "signalStrength": 0,
    "dataFormat": 0,
    "temperature": 0,
    "humidity": 0,
    "pressure": 0,
    "accelerationX": 0,
    "accelerationY": 0,
    "accelerationZ": 0,
    "batteryVoltage": 0,
    "txPower": 0,
    "movementCounter": 0,
    "measurementSequence": 0,
    "macAddress": "string"
  }
]

Command-Line Application

nruuvitag is a command-line tool for Windows and Linux that can scan for nearby RuuviTags, and publish device readings to the console, or to an MQTT server or Azure Event Hub.

Add --help to any command to view help.

Examples:

# Scan for nearby devices

nruuvitag devices scan
# Write sensor readings from all nearby devices to the console

nruuvitag publish console
# Add a device to the known devices list

nruuvitag devices add "AB:CD:EF:01:23:45" --id "bedroom-1" --name "Master Bedroom"
# Publish readings from nearby devices to a REST API endpoint URL in a single calculated average of samples per device

nruuvitag publish rest "MY_API_ENDPOINT_URL" --average-interval 600 --known-devices --trust-ssl

Linux Service

The command-line application can be run as a Linux service using systemd. See here for details.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.12.1 200 11/29/2022