Skip to content

.NET Standard 1.4 implementation of the AVM SmartHome API

License

Notifications You must be signed in to change notification settings

lazou/AvmSmartHome

 
 

Repository files navigation

AvmSmartHome

Implementation of the AVM Smart Home API

Installation

You can install the package from NuGet: AvmSmartHome.NET

The library implements .NET Standard 1.4 and is supported on (and above):

  • .NET Core 1.0
  • .NET Framework 4.6.1
  • Mono 4.6
  • Xamarin.iOS 10.0
  • Xamarin.Android 7.0
  • Universal Windows Platform 10

Usage

SessionInfo session = new SessionInfo("myiotuser", "myiotpwd", "fritz.box");
await session.AuthenticateAsync();
string[] switches = await session.GetSwitchesAsync();

// Steckdose auswählen
string ain = switches[0];

string name = await session.GetSwitchNameAsync(ain);
double power = await session.GetSwitchPowerAsync(ain);
double energy = await session.GetSwitchEnergyAsync(ain);
double temp = await session.GetSwitchTemperatureAsync(ain);

string message = $"Switch {ain}" +
    $"\r\n name   = {name}" +
    $"\r\n P [mW] = {power}" +
    $"\r\n E [Wh] = {energy}" +
    $"\r\n T [°C] = {temp}";
Debug.WriteLine(message);

// Steckdose anschalten
await session.SetSwitchAsync(ain, true);

// Steckdose umschalten
await session.ToggleSwitchAsync(ain);

Example output:

Switch 087610251891
 name   = FRITZ!DECT 200 #2
 P [mW] = 3070
 E [Wh] = 17236
 T [°C] = 23.5

Testing

For running the unit tests, create a user in your Fritz!Box with the credentials found in TestCredentials.cs, or modify the credentials to match with an existing user. The user needs Smart Home permissions only.

Then you can run the unit tests in Visual Studio 2017 (Community).

About

.NET Standard 1.4 implementation of the AVM SmartHome API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%