Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/HASS.Agent.Installer/InstallerScript-Service-x86.iss
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

; Standard installation constants
#define MyAppName "HASS.Agent Satellite Service"
#define MyAppVersion "2.2.0"
#define MyAppVersion "2.2.1"
#define MyAppPublisher "HASS.Agent Team"
#define MyAppURL "https://hass-agent.io"
#define MyAppExeName "HASS.Agent.Satellite.Service.exe"
Expand Down
2 changes: 1 addition & 1 deletion src/HASS.Agent.Installer/InstallerScript-Service.iss
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

; Standard installation constants
#define MyAppName "HASS.Agent Satellite Service"
#define MyAppVersion "2.2.0"
#define MyAppVersion "2.2.1"
#define MyAppPublisher "HASS.Agent Team"
#define MyAppURL "https://hass-agent.io"
#define MyAppExeName "HASS.Agent.Satellite.Service.exe"
Expand Down
2 changes: 1 addition & 1 deletion src/HASS.Agent.Installer/InstallerScript-x86.iss
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

; Standard installation constants
#define MyAppName "HASS.Agent"
#define MyAppVersion "2.2.0"
#define MyAppVersion "2.2.1"
#define MyAppPublisher "HASS.Agent Team"
#define MyAppURL "https://hass-agent.io"
#define MyAppExeName "HASS.Agent.exe"
Expand Down
2 changes: 1 addition & 1 deletion src/HASS.Agent.Installer/InstallerScript.iss
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

; Standard installation constants
#define MyAppName "HASS.Agent"
#define MyAppVersion "2.2.0"
#define MyAppVersion "2.2.1"
#define MyAppPublisher "HASS.Agent Team"
#define MyAppURL "https://hass-agent.io"
#define MyAppExeName "HASS.Agent.exe"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<UserSecretsId>dotnet-HASSAgentSatelliteService-6E4FA50A-3AC9-4E66-8671-9FAB92372154</UserSecretsId>
<PlatformTarget>anycpu</PlatformTarget>
<Platforms>x64;x86;AnyCPU</Platforms>
<Version>2.2.0</Version>
<Version>2.2.1</Version>
<Company>HASS.Agent Team</Company>
<Product>HASS.Agent Satellite Service</Product>
<AssemblyName>HASS.Agent.Satellite.Service</AssemblyName>
Expand All @@ -17,9 +17,9 @@
<PackageProjectUrl>https://github.com/hass-agent/HASS.Agent</PackageProjectUrl>
<RepositoryUrl>https://github.com/hass-agent/HASS.Agent</RepositoryUrl>
<PackageIcon>hass.png</PackageIcon>
<AssemblyVersion>2.2.0</AssemblyVersion>
<AssemblyVersion>2.2.1</AssemblyVersion>
<ApplicationIcon>hass.ico</ApplicationIcon>
<FileVersion>2.2.0</FileVersion>
<FileVersion>2.2.1</FileVersion>
<SupportedOSPlatformVersion>10.0.17763.0</SupportedOSPlatformVersion>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using HASS.Agent.Shared.Enums;
using HASS.Agent.Shared.Enums;
using HASS.Agent.Shared.Models.Config;
using HASS.Agent.Shared.HomeAssistant.Commands;
using HASS.Agent.Shared.HomeAssistant.Commands.CustomCommands;
Expand Down Expand Up @@ -56,7 +56,10 @@ internal static async Task<bool> LoadAsync()
// convert to abstract commands
await Task.Run(delegate
{
foreach (var abstractCommand in configuredCommands.Select(ConvertConfiguredToAbstract)) Variables.Commands.Add(abstractCommand!);
foreach (var abstractCommand in configuredCommands.Select(ConvertConfiguredToAbstract))
{
if (abstractCommand != null) Variables.Commands.Add(abstractCommand);
}
});

// all good
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using HASS.Agent.Shared.Enums;
using HASS.Agent.Shared.Enums;
using HASS.Agent.Shared.Models.Config;
using HASS.Agent.Satellite.Service.Extensions;
using HASS.Agent.Shared.HomeAssistant.Sensors;
Expand Down Expand Up @@ -61,8 +61,16 @@ await Task.Run(delegate
{
foreach (var sensor in configuredSensors)
{
if (sensor.IsSingleValue()) Variables.SingleValueSensors.Add(ConvertConfiguredToAbstractSingleValue(sensor)!);
else Variables.MultiValueSensors.Add(ConvertConfiguredToAbstractMultiValue(sensor)!);
if (sensor.IsSingleValue())
{
var abstractSensor = ConvertConfiguredToAbstractSingleValue(sensor);
if (abstractSensor != null) Variables.SingleValueSensors.Add(abstractSensor);
}
else
{
var abstractSensor = ConvertConfiguredToAbstractMultiValue(sensor);
if (abstractSensor != null) Variables.MultiValueSensors.Add(abstractSensor);
}
}
});

Expand Down
6 changes: 3 additions & 3 deletions src/HASS.Agent/HASS.Agent.Shared/HASS.Agent.Shared.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
<Description>Shared functions and models for the HASS.Agent platform.</Description>
<PackageProjectUrl>https://github.com/hass-agent/HASS.Agent</PackageProjectUrl>
<RepositoryUrl>https://github.com/hass-agent/HASS.Agent</RepositoryUrl>
<AssemblyVersion>2.2.0</AssemblyVersion>
<FileVersion>2.2.0</FileVersion>
<Version>2.2.0</Version>
<AssemblyVersion>2.2.1</AssemblyVersion>
<FileVersion>2.2.1</FileVersion>
<Version>2.2.1</Version>
<PackageIcon>logo_128.png</PackageIcon>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<ApplicationIcon>hassagent.ico</ApplicationIcon>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ private static DateTime GetLastInputTime()
lastInputInfo.cbSize = Marshal.SizeOf(lastInputInfo);
lastInputInfo.dwTime = 0;

var envTicks = Environment.TickCount;
var envTicks = Environment.TickCount64;

if (!GetLastInputInfo(ref lastInputInfo))
return DateTime.Now;

var lastInputTick = Convert.ToDouble(lastInputInfo.dwTime);
var lastInputTick = (long)lastInputInfo.dwTime;

var idleTime = envTicks - lastInputTick;
return idleTime > 0 ? DateTime.Now - TimeSpan.FromMilliseconds(idleTime) : DateTime.Now;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
using HASS.Agent.Functions;
using WK.Libraries.HotkeyListenerNS;
using System.Windows.Forms;

namespace HASS.Agent.Controls.Onboarding
{
public partial class OnboardingHotKey : UserControl
{
private readonly HotkeySelector _hotkeySelector = new();

private Keys _key = Keys.None;
private Keys _modifiers = Keys.None;

Check warning on line 9 in src/HASS.Agent/HASS.Agent/Controls/Onboarding/Onboarding-6-HotKey.cs

View workflow job for this annotation

GitHub Actions / build (Release)

The field 'OnboardingHotKey._modifiers' is assigned but its value is never used

public OnboardingHotKey()
{
InitializeComponent();
}

private void OnboardingHotKey_Load(object sender, EventArgs e)
{
// config quick actions hotkey selector
_hotkeySelector.Enable(TbQuickActionsHotkey);

TbQuickActionsHotkey.ReadOnly = true;
TbQuickActionsHotkey.KeyDown += TbQuickActionsHotkey_KeyDown;

if (string.IsNullOrEmpty(Variables.AppSettings.QuickActionsHotKey))
{
// if nothing set, load default
LoadDefault();
}
else if (Variables.AppSettings.QuickActionsHotKey == _hotkeySelector.EmptyHotkeyText)
else if (Variables.AppSettings.QuickActionsHotKey == string.Empty)
{
// if set to empty, show empty
TbQuickActionsHotkey.Text = _hotkeySelector.EmptyHotkeyText;
TbQuickActionsHotkey.Text = string.Empty;
}
else
{
Expand Down Expand Up @@ -81,13 +81,61 @@
internal bool Store()
{
Variables.AppSettings.QuickActionsHotKey = TbQuickActionsHotkey.Text;
_hotkeySelector.Dispose();
TbQuickActionsHotkey.KeyDown -= TbQuickActionsHotkey_KeyDown;
return true;
}

private void BtnClear_Click(object sender, EventArgs e)
{
TbQuickActionsHotkey.Text = _hotkeySelector.EmptyHotkeyText;
TbQuickActionsHotkey.Text = string.Empty;
}

private void TbQuickActionsHotkey_KeyDown(object sender, KeyEventArgs e)
{
e.SuppressKeyPress = true;

var key = e.KeyCode;

if (key is Keys.LControlKey or Keys.RControlKey
or Keys.LShiftKey or Keys.RShiftKey
or Keys.LWin or Keys.RWin
or Keys.Alt)
{
key = Keys.None;
}

if (key == Keys.Escape)
{
_key = Keys.None;
_modifiers = Keys.None;
TbQuickActionsHotkey.Text = string.Empty;

return;
}

_key = key;
TbQuickActionsHotkey.Text = FormatHotkey(_key, e.Modifiers);
}

private string FormatHotkey(Keys key, Keys modifiers)
{
var parts = new List<string>();
if ((modifiers & Keys.Shift) != 0)
{
parts.Add(nameof(Keys.Shift));
}

if ((modifiers & Keys.Control) != 0)
{
parts.Add(nameof(Keys.Control));
}

if ((modifiers & Keys.Alt) != 0)
{
parts.Add(nameof(Keys.Alt));
}

return parts.Count > 0 ? string.Join(", ", parts) + " + " + key : key.ToString();
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 17 additions & 5 deletions src/HASS.Agent/HASS.Agent/Forms/Commands/CommandsMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ public partial class CommandsMod : MetroForm
private bool _interfaceLockedWrongType;
private bool _loading = true;

private readonly Dictionary<int, string> _commandEntityTypes = new();
private bool _escapeLock = true;

private readonly Dictionary<int, string> _commandEntityTypes = new();
private readonly Dictionary<string, string> _radioDevices = new();

public CommandsMod(ConfiguredCommand command, bool serviceMode = false, string serviceDeviceName = "")
Expand Down Expand Up @@ -977,11 +979,21 @@ private void LblIntegrityInfo_Click(object sender, EventArgs e)

private void CommandsMod_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode != Keys.Escape)
return;
if (e.KeyCode != Keys.Escape)
{
_escapeLock = true;
return;
}

Close();
}
if (_escapeLock)
{
_escapeLock = false;
}
else
{
Close();
}
}

private void CommandsMod_Layout(object sender, LayoutEventArgs e)
{
Expand Down
Loading
Loading