Skip to content

Instantly share code, notes, and snippets.

@jiminald
Created April 3, 2019 20:45
Show Gist options
  • Select an option

  • Save jiminald/2e352717e103009f94367f29a80a8c2b to your computer and use it in GitHub Desktop.

Select an option

Save jiminald/2e352717e103009f94367f29a80a8c2b to your computer and use it in GitHub Desktop.
using System.Threading.Tasks;
using HomeAssistant.AppStarter;
using HomeAssistant.AppStarter.Models.Events;
using HomeAssistant.AppStarter.WebServices;
using NLog;
namespace HassLab.Console.HassApps
{
public class WakeUpApp : IHassApp
{
public string TriggeredByEntities { get; set; } = "media_source.*";
// Add your password, if any, for Home Assistant here
private readonly string ApiPassword = "";
// Add the address to your Home Assistant instance here
private readonly string WebApiBaseUrl = "http://ip-address:port/";
// Dependencies (IoC or Factories not supported right now)
private readonly ILogger _logger;
private readonly HassWebApiServiceProxy _hassApiProxy;
// App/Class setup time
public WakeUpApp()
{
_logger = LogManager.GetCurrentClassLogger();
_hassApiProxy = new HassWebApiServiceProxy(WebApiBaseUrl, ApiPassword);
}
// Runs on every successful trigger
public async Task ExecuteAsync(EventData e, string rawData)
{
_logger.Info($"Executing {nameof(WakeUpApp)} for [{e.EntityId}]");
// Update volume slider
// Set amp output name
}
// Internal function
public bool IsExecuting { get; set; }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment