Skip to content
This repository has been archived by the owner on Dec 27, 2023. It is now read-only.

Commit

Permalink
prep
Browse files Browse the repository at this point in the history
  • Loading branch information
lubeda committed Nov 9, 2022
1 parent 09d1ec6 commit 5e743e8
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 6 deletions.
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();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class HAAPIConfig
public String Token;

public HAServiceEntry[] Entries;
public String[] States;
}

internal static HAAPIConfig Config;
Expand All @@ -45,9 +46,7 @@ public override void Unload()
{
}



private void Init()
private void Init()
{
if (!Directory.Exists(Path.Combine(UserProfilePath, DEFAULT_PATH)))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Actions\HomeAssistantTest.cs" />
<Compile Include="Actions\HomeAssistantComand.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="HomeAssistantApplication.cs" />
Expand All @@ -74,15 +75,16 @@
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Folder Include="Resources\" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<None Include="metadata\Icon16x16.png" />
<None Include="metadata\Icon256x256.png" />
<None Include="metadata\Icon32x32.png" />
<None Include="metadata\Icon48x48.png" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\ButtonBaseHomeAssistant.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent Condition="$(OS) == 'Windows_NT'">call "$(ProjectDir)BuildEvents\postbuild.cmd" "$(ProjectDir)" "$(TargetDir)"</PostBuildEvent>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5e743e8

Please sign in to comment.