All Projects → rille111 → HomeAssistant.AppStarter

rille111 / HomeAssistant.AppStarter

Licence: Apache-2.0 license
Home Assistant 'Hass' is a home automation system running on Unix-systems. This package aims to enable .NET developers to create their own 'app-like' programs that integrate with Home Assistant through it's Websocket and Web API's.

Programming Languages

C#
18002 projects

Projects that are alternatives of or similar to HomeAssistant.AppStarter

home-assistant-opentherm-thermostat
Home Assistant OpenTherm Thermostat
Stars: ✭ 26 (+100%)
Mutual labels:  home-automation, home-assistant
home-assistant-config
My home-assistant configuration
Stars: ✭ 48 (+269.23%)
Mutual labels:  home-automation, home-assistant
addon-home-panel
Home Panel - Home Assistant Community Add-ons
Stars: ✭ 164 (+1161.54%)
Mutual labels:  home-automation, home-assistant
ha-illuminance
Home Assistant Illuminance Sensor
Stars: ✭ 53 (+307.69%)
Mutual labels:  home-automation, home-assistant
homeassistant
Home Assistant Config
Stars: ✭ 50 (+284.62%)
Mutual labels:  home-automation, home-assistant
ocpp
Home Assistant integration for electric vehicle chargers that support the Open Charge Point Protocol (OCPP).
Stars: ✭ 82 (+530.77%)
Mutual labels:  home-automation, home-assistant
double-take
Unified UI and API for processing and training images for facial recognition.
Stars: ✭ 585 (+4400%)
Mutual labels:  home-automation, home-assistant
Netdisco
🔎 Python library to scan local network for services and devices.
Stars: ✭ 240 (+1746.15%)
Mutual labels:  home-automation, home-assistant
google fit hass
A Home assistant custom component to get your fitness information using Google Fitness API.
Stars: ✭ 23 (+76.92%)
Mutual labels:  home-automation, home-assistant
hifiberry
This is a custom component to allow control of HifiberryOS devices in Home Assistant using the audiocontrol2 REST API.
Stars: ✭ 26 (+100%)
Mutual labels:  home-automation, home-assistant
node-homeassistant
Node.js wrapper for the home-assistant websocket api
Stars: ✭ 27 (+107.69%)
Mutual labels:  home-automation, home-assistant
HomeAssistant-Tapo-Control
Control for Tapo cameras as a Home Assistant component
Stars: ✭ 327 (+2415.38%)
Mutual labels:  home-automation, home-assistant
home-assistant-config
🏠 Home Assistant Configuration & Documentation for my smart home using Node-RED for automations. Press ⭐ for notification of updates.
Stars: ✭ 34 (+161.54%)
Mutual labels:  home-automation, home-assistant
Home-AssistantConfig---OLD
AtomicPapa's Amazing Home Assistant Config
Stars: ✭ 15 (+15.38%)
Mutual labels:  home-automation, home-assistant
Home Assistant Cli
💻 Command-line tool for Home Assistant
Stars: ✭ 243 (+1769.23%)
Mutual labels:  home-automation, home-assistant
hass-amplifi
A home assistant integration for Ubiquiti Amplifi
Stars: ✭ 17 (+30.77%)
Mutual labels:  home-automation, home-assistant
Smart Home
⭐ (Almost) everything needed to run my smart home with Home Assistant and more!
Stars: ✭ 221 (+1600%)
Mutual labels:  home-automation, home-assistant
Node Red Contrib Home Assistant Websocket
Node-RED integration with Home Assistant Core
Stars: ✭ 222 (+1607.69%)
Mutual labels:  home-automation, home-assistant
docker-iot-stack
💻 My personal Docker IoT Stack
Stars: ✭ 24 (+84.62%)
Mutual labels:  home-automation, home-assistant
Home-Assistant-Config
🏠 My huizebruin Home Assistant configuration, Be sure to 🌟 this repository for updates! huizebruin
Stars: ✭ 29 (+123.08%)
Mutual labels:  home-automation, home-assistant

Hass AppStarter

Purpose

Home Assistant 'Hass' is a home automation system running on Unix-systems and AppDaemon is used along with it to further empower developers to write Python-based automations and apps, working with Hass.

I don't excel at either Unix or Python but I still enjoy Home Assistant and want to use .NET to accomplish things I couldn't with Hass-AppDaemon. Hence the birth of this project, and being inspired by AppDaemon I want to enable myself and others to use their existing .NET knowledge to write app-like implementations based on Hass.

It is easy, just nuget-install Rille.Hass.AppStarter and follow the steps and you'll be going in no time!

Installation

Usage - Create apps

  • Create a class that implements IHassApp
  • Filling out the various properties (see code for examples)
  • Implement ExecuteAsync() with your code

Usage - Configure & Run

Super easy! Better show with code:

        public async Task RunAppStarter()
        {
            await Task.Delay(0);

            var appRunner = new HassAppsRunner("ws://192.168.0.201:8123/api/websocket");

            appRunner.TraceOutput += (sender, args) => _logger.Trace(args.Exception, args.Text);
            appRunner.DebugOutput += (sender, args) => _logger.Debug(args.Exception, args.Text);
            appRunner.WarnOutput += (sender, args) => _logger.Warn(args.Exception, args.Text);
            appRunner.InfoOutput += (sender, args) => _logger.Info(args.Exception, args.Text);
            appRunner.ErrorOutput += (sender, args) => _logger.Error(args.Exception, args.Text);

            appRunner.Start();

            System.Console.WriteLine($"\n-- Connected. Press any key to exit --");
            System.Console.ReadKey();
            appRunner.Stop();
        }

And an app to help you wake up! (It will be found by the AppStarter since it scans for everything that implements IHassApp)

    public class WakeUpApp : IHassApp
    {
        public string TriggeredByEntities { get; set; } = "automation.wakeup_*"; // <-- yes, wildcards are supported!

        // Dependencies (IoC or Factories not supported right now)
        private readonly Logger _logger = LogManager.GetCurrentClassLogger();
        private readonly HassWebApiServiceProxy _hassApiProxy = new HassWebApiServiceProxy("http://192.168.0.201:8123/api");

        public async Task ExecuteAsync(EventData e, string rawData)
        {
            if (e.StateChangeData.OldState != "on" || e.StateChangeData.NewState != "on")
                return; // A trigger for an automation has both these states set to "on" by some reason.

            _logger.Info($"Executing {nameof(WakeUpApp)} for [{e.EntityId}]");

            // Turn on all lamps
            await TurnOnLightFor("light.dimmer_vardagsrum_level", 155);
            await TurnOnLightFor("light.dimmer_minihall_level", 155);
            await TurnOnLightFor("light.dimmer_hall_level", 155);
            await TurnOnLightFor("light.led_sovrum_tak_level", 255);
        }

        public bool IsExecuting { get; set; }

        private async Task TurnOnLightFor(string entity_id, int brightness)
        {
            await _hassApiProxy.CallHassService("light", "turn_on", new {entity_id, brightness});
        }
    }

Engine

Since Hass exposes a Websocket API, this lib will subscribe to all state_changed events via this Websocket, and connect your written apps with those events.

TODO

  • Since it's in alpha development it will crash! Feel free to contribute. :)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].