This repository has been archived by the owner on Dec 27, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
47 additions
and
6 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
HomeAssistantPlugin/src/HomeAssistantPlugin/Actions/HomeAssistantTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
namespace Loupedeck.HomeAssistantPlugin | ||
{ | ||
using System; | ||
using System.Net.Http.Headers; | ||
using System.Net.Http; | ||
|
||
public class HomeAssistantState : PluginDynamicCommand | ||
{ | ||
public HomeAssistantState() : base() | ||
{ | ||
this.MakeProfileAction("text;Select entity;"); | ||
} | ||
|
||
protected override void RunCommand(String actionParameter) | ||
{ | ||
var _client = new HttpClient(); | ||
var url = HomeAssistantPlugin.Config.Url + "states/" + actionParameter; | ||
_client.DefaultRequestHeaders.Authorization = | ||
new AuthenticationHeaderValue("Bearer", HomeAssistantPlugin.Config.Token); | ||
var resp = _client.GetStringAsync(url); | ||
} | ||
|
||
protected override String GetCommandDisplayName(String actionParameter, PluginImageSize imageSize) | ||
{ | ||
return actionParameter; | ||
} | ||
|
||
protected override BitmapImage GetCommandImage(String actionParameter, PluginImageSize imageSize) | ||
{ | ||
using (var bitmapBuilder = new BitmapBuilder(imageSize)) | ||
{ | ||
var fn = EmbeddedResources.FindFile("ButtonBaseHomeAssistant.png"); | ||
bitmapBuilder.SetBackgroundImage(EmbeddedResources.ReadImage(fn)); | ||
bitmapBuilder.DrawText(actionParameter); | ||
|
||
return bitmapBuilder.ToImage(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+774 Bytes
HomeAssistantPlugin/src/HomeAssistantPlugin/Resources/ButtonBaseHomeAssistant.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.