HADotNet.Core 0.1.0-beta

This is a prerelease version of HADotNet.Core.
There is a newer version of this package available.
See the version list below for details.
dotnet add package HADotNet.Core --version 0.1.0-beta                
NuGet\Install-Package HADotNet.Core -Version 0.1.0-beta                
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="HADotNet.Core" Version="0.1.0-beta" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add HADotNet.Core --version 0.1.0-beta                
#r "nuget: HADotNet.Core, 0.1.0-beta"                
#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 HADotNet.Core as a Cake Addin
#addin nuget:?package=HADotNet.Core&version=0.1.0-beta&prerelease

// Install HADotNet.Core as a Cake Tool
#tool nuget:?package=HADotNet.Core&version=0.1.0-beta&prerelease                

HADotNet

A simple, straighforward .NET Standard library for the Home Assistant API.

Features

  • .NET Standard 2.0 cross-platform library
  • DI-friendly client initialization (suitable for ASP.NET Core)
  • Home Assistant data is represented by strongly-typed, commented model classes

Getting Started

Install HADotNet.Core from NuGet:

Install-Package HADotNet.Core

From Source

Clone this repo and either include the HADotNet.Core library in your project, or build the project and include the DLL as a reference.

Examples

Initializing The Client Factory

The ClientFactory class is reponsible for initializing all other clients in a reusable way, so you only have to define your instance URL and API key once.

To initialize the ClientFactory, pass in your base Home Assistant URL and a long-lived access token that you created on your profile page.

ClientFactory.Initialize("https://my-home-assistant-url/", "AbCdEf0123456789...");

Getting Home Assistant's Current Configuration

Get a ConfigClient and then call GetConfiguration():

var configClient = ClientFactory.GetClient<ConfigClient>();
var config = await configClient.GetConfiguration();
// config.LocationName: "Home"
// config.Version: 0.96.1

Retrieving All Entity States

Get a StatesClient and then call GetStates():

var statesClient = ClientFactory.GetClient<StatesClient>();
var allMyStates = await statesClient.GetStates();

Retrieving State By Entity

Get a StatesClient and then call GetState(entity):

var statesClient = ClientFactory.GetClient<StatesClient>();
var state = await statesClient.GetState("sun.sun");
// state.EntityId: "sun.sun"
// state.State: "below_horizon"

Retrieving All Service Definitions

Get a ServiceClient and then call GetServices():

var serviceClient = ClientFactory.GetClient<ServiceClient>();
var services = await serviceClient.GetServices();

Calling a Service

Get a ServiceClient and then call CallService():

var serviceClient = ClientFactory.GetClient<ServiceClient>();

var resultingState = await serviceClient.CallService("homeassistant", "restart");
// Or
var resultingState = await serviceClient.CallService("light", "turn_on", new { entity_id = "light.my_light" });
// Or
var resultingState = await serviceClient.CallService("light.turn_on", new { entity_id = "light.my_light" });
// Or
var resultingState = await serviceClient.CallService("light.turn_on", @"{""entity_id"":""light.my_light""}");
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 netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  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 (1)

Showing the top 1 NuGet packages that depend on HADotNet.Core:

Package Downloads
HADotNet.Entities

A Home Assistant library for .NET Standard to make use of strongly typed Home Assistant entities.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.6.0 1,645 8/14/2021
1.5.1 1,422 2/1/2021
1.5.0 312 1/31/2021
1.4.1 375 1/25/2021
1.4.0 436 1/23/2021 1.4.0 is deprecated because it has critical bugs.
1.3.2 668 8/9/2020
1.3.1 509 8/9/2020
1.3.0 568 5/9/2020
1.2.2 502 4/12/2020
1.2.1 809 1/9/2020
1.2.0 531 10/5/2019
1.1.0 592 9/4/2019
1.0.0 579 8/17/2019
0.2.0 519 8/7/2019
0.1.1-beta 383 8/7/2019
0.1.0-beta 366 7/24/2019