forked from LAB02-Research/HASS.Agent.Staging
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### Changes - Added "SetAudioInputCommand" (thanks to Chrisdegod for the suggestion) - #41 - Added "ScreenshotSensor", functioning as camera entity (huge thanks for @denisabt for the inital PR with implementation to the original repo)- #42 - Added option to ignore the MQTT/connection grace period when system wakes from hibernation (thanks to @larena1 for the suggestion)- #51 - Added option to use modern (white on transparent) icon for the HASS.Agent's trayicon (big thanks to @MBaliver for the suggestion and the icon) - #55 - Added note to "PowershellSensor" description as a reminder to Home Assistant's 255 character limit for the payload/state (thanks to @EpicLPer for suggestion) - #58 - Last but not least, all dependencies have been bumped to the newest possbile version - #56 ### Fixes - "SetAudioOutputCommand" and "SetApplicationVolume" commands are now properly configurable from the UI (thanks to Chrisdegod for reporting) - #39 - Updated VirtualDesktop management library to stop it crashing on some Windows 11 systems - #40 - Sensor state being evaluated constantly, ignoring the configured update interval (thanks to @shupershuff for reporting) - #45 - "PowershellCommand" arguments not being bound/parsed properly when provided with payload/action (thanks to @shupershuff for reporting) - #47 - "ActiveWindow" sensor not using proper encoding, resulting in some characters being replaced with "?" (thanks to @greghesp for reporting) - #50 - Sensor/command discovery payload messages are now sent on HASS.Agent start and configuration change instead of constantly - should reduce the load on Home Assistant (thanks to @Anto79-ops for reporting) - #5 - "MicrophoneProcessSensor" description has been changed to more accurately describe its function (thanks to @Gvolten for reporting) - #57 #### Note This beta release includes changes from [2.0.2-beta1](https://github.com/hass-agent/HASS.Agent/releases/tag/2.0.2-beta1) and [2.0.2-beta2](https://github.com/hass-agent/HASS.Agent/releases/tag/2.0.2-beta2)
- Loading branch information
1 parent
01463da
commit ee462cd
Showing
57 changed files
with
1,837 additions
and
1,000 deletions.
There are no files selected for viewing
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
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
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
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
67 changes: 67 additions & 0 deletions
67
...S.Agent/HASS.Agent.Shared/HomeAssistant/Commands/InternalCommands/SetAudioInputCommand.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,67 @@ | ||
using CoreAudio; | ||
using HASS.Agent.Shared.Enums; | ||
using Newtonsoft.Json; | ||
using Serilog; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
using System.Text; | ||
|
||
namespace HASS.Agent.Shared.HomeAssistant.Commands.InternalCommands; | ||
|
||
public class SetAudioInputCommand : InternalCommand | ||
{ | ||
private const string DefaultName = "setaudioinput"; | ||
|
||
private string InputDevice { get => CommandConfig; } | ||
|
||
public SetAudioInputCommand(string entityName = DefaultName, string name = DefaultName, string audioDevice = "", CommandEntityType entityType = CommandEntityType.Button, string id = default) : base(entityName ?? DefaultName, name ?? null, audioDevice, entityType, id) | ||
{ | ||
State = "OFF"; | ||
} | ||
|
||
public override void TurnOn() | ||
{ | ||
if (string.IsNullOrWhiteSpace(InputDevice)) | ||
{ | ||
Log.Error("[SETAUDIOIN] Error, input device name cannot be null/blank"); | ||
|
||
return; | ||
} | ||
|
||
TurnOnWithAction(InputDevice); | ||
} | ||
|
||
private MMDevice GetAudioDeviceOrDefault(string playbackDeviceName) | ||
{ | ||
var devices = Variables.AudioDeviceEnumerator.EnumerateAudioEndPoints(DataFlow.Capture, DeviceState.Active); | ||
var playbackDevice = devices.Where(d => d.DeviceFriendlyName == playbackDeviceName).FirstOrDefault(); | ||
|
||
return playbackDevice ?? Variables.AudioDeviceEnumerator.GetDefaultAudioEndpoint(DataFlow.Capture, Role.Communications); | ||
} | ||
|
||
public override void TurnOnWithAction(string action) | ||
{ | ||
State = "ON"; | ||
|
||
try | ||
{ | ||
var outputDevice = GetAudioDeviceOrDefault(action); | ||
if (outputDevice == Variables.AudioDeviceEnumerator.GetDefaultAudioEndpoint(DataFlow.Capture, Role.Communications)) | ||
return; | ||
|
||
outputDevice.Selected = true; | ||
} | ||
catch (Exception ex) | ||
{ | ||
Log.Error("[SETAUDIOIN] Error while processing action '{action}': {err}", action, ex.Message); | ||
} | ||
finally | ||
{ | ||
State = "OFF"; | ||
} | ||
} | ||
} |
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
Oops, something went wrong.