implement updating sensors/commands if they have more properties

merge-updating
Sleevezipper 4 years ago
parent f0c27fbbac
commit 36d78f11af

@ -11,6 +11,8 @@ namespace UserInterface.ViewModels
private bool _showCommandInput; private bool _showCommandInput;
private bool _showKeyInput; private bool _showKeyInput;
private string _moreInfoLink; private string _moreInfoLink;
private string _command;
private string _key;
public AvailableCommands SelectedType { get => _selectedType; set => this.RaiseAndSetIfChanged(ref _selectedType, value); } public AvailableCommands SelectedType { get => _selectedType; set => this.RaiseAndSetIfChanged(ref _selectedType, value); }
public string Name { get => _name; set => this.RaiseAndSetIfChanged(ref _name, value); } public string Name { get => _name; set => this.RaiseAndSetIfChanged(ref _name, value); }
@ -18,7 +20,7 @@ namespace UserInterface.ViewModels
public bool ShowCommandInput { get => _showCommandInput; set => this.RaiseAndSetIfChanged(ref _showCommandInput, value); } public bool ShowCommandInput { get => _showCommandInput; set => this.RaiseAndSetIfChanged(ref _showCommandInput, value); }
public bool ShowKeyInput { get => _showKeyInput; set => this.RaiseAndSetIfChanged(ref _showKeyInput, value); } public bool ShowKeyInput { get => _showKeyInput; set => this.RaiseAndSetIfChanged(ref _showKeyInput, value); }
public string MoreInfoLink { get => _moreInfoLink; set => this.RaiseAndSetIfChanged(ref _moreInfoLink, value); } public string MoreInfoLink { get => _moreInfoLink; set => this.RaiseAndSetIfChanged(ref _moreInfoLink, value); }
public string Command { get; set; } public string Command { get => _command; set => this.RaiseAndSetIfChanged(ref _command, value); }
public string Key { get; set; } public string Key { get => _key; set => this.RaiseAndSetIfChanged(ref _key, value); }
} }
} }

@ -11,8 +11,9 @@ namespace UserInterface.ViewModels
private string _description; private string _description;
private bool _showQueryInput; private bool _showQueryInput;
private bool _showWindowNameInput; private bool _showWindowNameInput;
private bool _showDetectionModeOptions;
private string _moreInfoLink; private string _moreInfoLink;
private string _query;
private string _windowName;
public AvailableSensors SelectedType { get => _selectedType; set => this.RaiseAndSetIfChanged(ref _selectedType, value); } public AvailableSensors SelectedType { get => _selectedType; set => this.RaiseAndSetIfChanged(ref _selectedType, value); }
public string Name { get => _name; set => this.RaiseAndSetIfChanged(ref _name, value); } public string Name { get => _name; set => this.RaiseAndSetIfChanged(ref _name, value); }
@ -20,9 +21,8 @@ namespace UserInterface.ViewModels
public string Description { get => _description; set => this.RaiseAndSetIfChanged(ref _description, value); } public string Description { get => _description; set => this.RaiseAndSetIfChanged(ref _description, value); }
public bool ShowQueryInput { get => _showQueryInput; set => this.RaiseAndSetIfChanged(ref _showQueryInput, value); } public bool ShowQueryInput { get => _showQueryInput; set => this.RaiseAndSetIfChanged(ref _showQueryInput, value); }
public bool ShowWindowNameInput { get => _showWindowNameInput; set => this.RaiseAndSetIfChanged(ref _showWindowNameInput, value); } public bool ShowWindowNameInput { get => _showWindowNameInput; set => this.RaiseAndSetIfChanged(ref _showWindowNameInput, value); }
public bool ShowDetectionModeOptions { get => _showDetectionModeOptions; set => this.RaiseAndSetIfChanged(ref _showDetectionModeOptions, value); }
public string MoreInfoLink { get => _moreInfoLink; set => this.RaiseAndSetIfChanged(ref _moreInfoLink, value); } public string MoreInfoLink { get => _moreInfoLink; set => this.RaiseAndSetIfChanged(ref _moreInfoLink, value); }
public string Query { get; set; } public string Query { get => _query; set => this.RaiseAndSetIfChanged(ref _query, value); }
public string WindowName { get; set; } public string WindowName { get => _windowName; set => this.RaiseAndSetIfChanged(ref _windowName, value); }
} }
} }

@ -1,193 +1,193 @@
using Avalonia; using Avalonia;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Interactivity; using Avalonia.Interactivity;
using Avalonia.Markup.Xaml; using Avalonia.Markup.Xaml;
using hass_workstation_service.Communication.InterProcesCommunication.Models; using hass_workstation_service.Communication.InterProcesCommunication.Models;
using hass_workstation_service.Communication.NamedPipe; using hass_workstation_service.Communication.NamedPipe;
using JKang.IpcServiceFramework.Client; using JKang.IpcServiceFramework.Client;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using System; using System;
using System.Linq; using System.Linq;
using System.Text.Json; using System.Text.Json;
using UserInterface.Util; using UserInterface.Util;
using UserInterface.ViewModels; using UserInterface.ViewModels;
namespace UserInterface.Views namespace UserInterface.Views
{ {
public class AddCommandDialog : Window public class AddCommandDialog : Window
{ {
private readonly IIpcClient<IServiceContractInterfaces> _client; private readonly IIpcClient<IServiceContractInterfaces> _client;
public ComboBox ComboBox { get; set; } public ComboBox ComboBox { get; set; }
public ComboBox DetectionModecomboBox { get; set; } public ComboBox DetectionModecomboBox { get; set; }
public Guid CommandId { get; } public Guid CommandId { get; }
public AddCommandDialog(Guid commandId) : this() public AddCommandDialog(Guid commandId) : this()
{ {
CommandId = commandId; CommandId = commandId;
GetCommandInfo(CommandId); GetCommandInfo(CommandId);
Title = "Edit command"; Title = "Edit command";
}
public AddCommandDialog()
{
InitializeComponent();
DataContext = new AddCommandViewModel();
ComboBox = this.FindControl<ComboBox>("ComboBox");
ComboBox.Items = Enum.GetValues(typeof(AvailableCommands)).Cast<AvailableCommands>().OrderBy(v => v.ToString());
ComboBox.SelectedIndex = 0;
// register IPC clients
ServiceProvider serviceProvider = new ServiceCollection()
.AddNamedPipeIpcClient<IServiceContractInterfaces>("addCommand", pipeName: "pipeinternal")
.BuildServiceProvider();
// resolve IPC client factory
IIpcClientFactory<IServiceContractInterfaces> clientFactory = serviceProvider
.GetRequiredService<IIpcClientFactory<IServiceContractInterfaces>>();
// create client
_client = clientFactory.CreateClient("addCommand");
Title = "Add command";
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
private async void GetCommandInfo(Guid commandId)
{
var command = await _client.InvokeAsync(x => x.GetConfiguredCommand(commandId));
ComboBox.SelectedItem = command.Type;
FillDefaultValues();
ComboBox.IsEnabled = false;
var item = (AddCommandViewModel)DataContext;
item.SelectedType = command.Type;
item.Name = command.Name;
item.Command = command.Command;
item.Key = command.Key;
} }
public AddCommandDialog() public async void Save(object sender, RoutedEventArgs args)
{ {
InitializeComponent(); var item = (AddCommandViewModel)DataContext;
DataContext = new AddCommandViewModel(); dynamic model = new { item.Name, item.Command, item.Key };
ComboBox = this.FindControl<ComboBox>("ComboBox"); string json = JsonSerializer.Serialize(model);
ComboBox.Items = Enum.GetValues(typeof(AvailableCommands)).Cast<AvailableCommands>().OrderBy(v => v.ToString()); if (CommandId == Guid.Empty)
ComboBox.SelectedIndex = 0; await _client.InvokeAsync(x => x.AddCommand(item.SelectedType, json));
else
// register IPC clients
ServiceProvider serviceProvider = new ServiceCollection()
.AddNamedPipeIpcClient<IServiceContractInterfaces>("addCommand", pipeName: "pipeinternal")
.BuildServiceProvider();
// resolve IPC client factory
IIpcClientFactory<IServiceContractInterfaces> clientFactory = serviceProvider
.GetRequiredService<IIpcClientFactory<IServiceContractInterfaces>>();
// create client
_client = clientFactory.CreateClient("addCommand");
Title = "Add sensor";
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
private async void GetCommandInfo(Guid commandId)
{
var command = await _client.InvokeAsync(x => x.GetConfiguredCommand(commandId));
ComboBox.SelectedItem = command.Type;
FillDefaultValues();
ComboBox.IsEnabled = false;
var item = (AddCommandViewModel)DataContext;
item.SelectedType = command.Type;
item.Name = command.Name;
//item.UpdateInterval = command.UpdateInterval;
//item.WindowName =
//item.Query =
}
public async void Save(object sender, RoutedEventArgs args)
{
var item = (AddCommandViewModel)DataContext;
dynamic model = new { item.Name, item.Command, item.Key };
string json = JsonSerializer.Serialize(model);
if (CommandId == Guid.Empty)
await _client.InvokeAsync(x => x.AddCommand(item.SelectedType, json));
else
await _client.InvokeAsync(x => x.UpdateCommandById(CommandId, json)); await _client.InvokeAsync(x => x.UpdateCommandById(CommandId, json));
Close(); Close();
} }
public void ComboBoxClosed(object sender, SelectionChangedEventArgs args) public void ComboBoxClosed(object sender, SelectionChangedEventArgs args)
{ {
FillDefaultValues(); FillDefaultValues();
} }
private void FillDefaultValues() private void FillDefaultValues()
{ {
var item = (AddCommandViewModel)DataContext; var item = (AddCommandViewModel)DataContext;
switch (ComboBox.SelectedItem) switch (ComboBox.SelectedItem)
{ {
case AvailableCommands.CustomCommand: case AvailableCommands.CustomCommand:
item.Description = "This command lets you execute any command you want. It will run in a Windows Command Prompt silently. "; item.Description = "This command lets you execute any command you want. It will run in a Windows Command Prompt silently. ";
item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#customcommand"; item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#customcommand";
item.ShowCommandInput = true; item.ShowCommandInput = true;
item.ShowKeyInput = false; item.ShowKeyInput = false;
break; break;
case AvailableCommands.ShutdownCommand: case AvailableCommands.ShutdownCommand:
item.Description = "This command shuts down the PC immediately. "; item.Description = "This command shuts down the PC immediately. ";
item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#shutdowncommand"; item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#shutdowncommand";
item.ShowCommandInput = false; item.ShowCommandInput = false;
item.ShowKeyInput = false; item.ShowKeyInput = false;
break; break;
case AvailableCommands.RestartCommand: case AvailableCommands.RestartCommand:
item.Description = "This command restarts the PC immediately. "; item.Description = "This command restarts the PC immediately. ";
item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#restartcommand"; item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#restartcommand";
item.ShowCommandInput = false; item.ShowCommandInput = false;
item.ShowKeyInput = false; item.ShowKeyInput = false;
break; break;
case AvailableCommands.LogOffCommand: case AvailableCommands.LogOffCommand:
item.Description = "This command logs the current user off immediately. "; item.Description = "This command logs the current user off immediately. ";
item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#logoffcommand"; item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#logoffcommand";
item.ShowCommandInput = false; item.ShowCommandInput = false;
item.ShowKeyInput = false; item.ShowKeyInput = false;
break; break;
case AvailableCommands.KeyCommand: case AvailableCommands.KeyCommand:
item.Description = "This command can be used to emulate a keystroke. It requires a key code which you can find by clicking the info button below."; item.Description = "This command can be used to emulate a keystroke. It requires a key code which you can find by clicking the info button below.";
item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#keycommand"; item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#keycommand";
item.ShowCommandInput = false; item.ShowCommandInput = false;
item.ShowKeyInput = true; item.ShowKeyInput = true;
break; break;
case AvailableCommands.PlayPauseCommand: case AvailableCommands.PlayPauseCommand:
item.Description = "This command plays or pauses currently playing media."; item.Description = "This command plays or pauses currently playing media.";
item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#media-commands"; item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#media-commands";
item.ShowCommandInput = false; item.ShowCommandInput = false;
item.ShowKeyInput = false; item.ShowKeyInput = false;
break; break;
case AvailableCommands.NextCommand: case AvailableCommands.NextCommand:
item.Description = "This command skips to the next media."; item.Description = "This command skips to the next media.";
item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#media-commands"; item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#media-commands";
item.ShowCommandInput = false; item.ShowCommandInput = false;
item.ShowKeyInput = false; item.ShowKeyInput = false;
break; break;
case AvailableCommands.PreviousCommand: case AvailableCommands.PreviousCommand:
item.Description = "This command plays previous media."; item.Description = "This command plays previous media.";
item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#media-commands"; item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#media-commands";
item.ShowCommandInput = false; item.ShowCommandInput = false;
item.ShowKeyInput = false; item.ShowKeyInput = false;
break; break;
case AvailableCommands.VolumeDownCommand: case AvailableCommands.VolumeDownCommand:
item.Description = "Lowers the system volume."; item.Description = "Lowers the system volume.";
item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#media-commands"; item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#media-commands";
item.ShowCommandInput = false; item.ShowCommandInput = false;
item.ShowKeyInput = false; item.ShowKeyInput = false;
break; break;
case AvailableCommands.VolumeUpCommand: case AvailableCommands.VolumeUpCommand:
item.Description = "Raises the system volume."; item.Description = "Raises the system volume.";
item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#media-commands"; item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#media-commands";
item.ShowCommandInput = false; item.ShowCommandInput = false;
item.ShowKeyInput = false; item.ShowKeyInput = false;
break; break;
case AvailableCommands.MuteCommand: case AvailableCommands.MuteCommand:
item.Description = "Toggles muting the system volume."; item.Description = "Toggles muting the system volume.";
item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#media-commands"; item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#media-commands";
item.ShowCommandInput = false; item.ShowCommandInput = false;
item.ShowKeyInput = false; item.ShowKeyInput = false;
break; break;
default: default:
item.Description = null; item.Description = null;
item.MoreInfoLink = null; item.MoreInfoLink = null;
item.ShowCommandInput = false; item.ShowCommandInput = false;
item.ShowKeyInput = false; item.ShowKeyInput = false;
break; break;
} }
} }
public void OpenInfo(object sender, RoutedEventArgs args) public void OpenInfo(object sender, RoutedEventArgs args)
{ {
var item = (AddCommandViewModel)DataContext; var item = (AddCommandViewModel)DataContext;
BrowserUtil.OpenBrowser(item.MoreInfoLink); BrowserUtil.OpenBrowser(item.MoreInfoLink);
} }
public void Test(object sender, RoutedEventArgs args) public void Test(object sender, RoutedEventArgs args)
{ {
var item = (AddCommandViewModel)DataContext; var item = (AddCommandViewModel)DataContext;
var process = new System.Diagnostics.Process(); var process = new System.Diagnostics.Process();
var startInfo = new System.Diagnostics.ProcessStartInfo var startInfo = new System.Diagnostics.ProcessStartInfo
{ {
WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal, WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal,
FileName = "cmd.exe", FileName = "cmd.exe",
Arguments = $"/k {"echo You won't see this window normally. &&" + item.Command}" Arguments = $"/k {"echo You won't see this window normally. &&" + item.Command}"
}; };
process.StartInfo = startInfo; process.StartInfo = startInfo;
process.Start(); process.Start();
} }
} }
} }

@ -1,229 +1,222 @@
using Avalonia; using Avalonia;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Interactivity; using Avalonia.Interactivity;
using Avalonia.Markup.Xaml; using Avalonia.Markup.Xaml;
using hass_workstation_service.Communication.InterProcesCommunication.Models; using hass_workstation_service.Communication.InterProcesCommunication.Models;
using hass_workstation_service.Communication.NamedPipe; using hass_workstation_service.Communication.NamedPipe;
using JKang.IpcServiceFramework.Client; using JKang.IpcServiceFramework.Client;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using System; using System;
using System.Linq; using System.Linq;
using System.Text.Json; using System.Text.Json;
using UserInterface.Util; using UserInterface.Util;
using UserInterface.ViewModels; using UserInterface.ViewModels;
namespace UserInterface.Views namespace UserInterface.Views
{ {
public class AddSensorDialog : Window public class AddSensorDialog : Window
{ {
private readonly IIpcClient<IServiceContractInterfaces> _client; private readonly IIpcClient<IServiceContractInterfaces> _client;
public ComboBox ComboBox { get; set; } public ComboBox ComboBox { get; set; }
public ComboBox DetectionModecomboBox { get; set; } public ComboBox DetectionModecomboBox { get; set; }
public Guid SensorId { get; } public Guid SensorId { get; }
public AddSensorDialog(Guid sensorId) : this() public AddSensorDialog(Guid sensorId) : this()
{ {
SensorId = sensorId; SensorId = sensorId;
GetSensorInfo(SensorId); GetSensorInfo(SensorId);
Title = "Edit sensor"; Title = "Edit sensor";
} }
public AddSensorDialog() public AddSensorDialog()
{ {
InitializeComponent(); InitializeComponent();
DataContext = new AddSensorViewModel(); DataContext = new AddSensorViewModel();
ComboBox = this.FindControl<ComboBox>("ComboBox"); ComboBox = this.FindControl<ComboBox>("ComboBox");
ComboBox.Items = Enum.GetValues(typeof(AvailableSensors)).Cast<AvailableSensors>().OrderBy(v => v.ToString()); ComboBox.Items = Enum.GetValues(typeof(AvailableSensors)).Cast<AvailableSensors>().OrderBy(v => v.ToString());
ComboBox.SelectedIndex = 0; ComboBox.SelectedIndex = 0;
// register IPC clients // register IPC clients
ServiceProvider serviceProvider = new ServiceCollection() ServiceProvider serviceProvider = new ServiceCollection()
.AddNamedPipeIpcClient<IServiceContractInterfaces>("addsensor", pipeName: "pipeinternal") .AddNamedPipeIpcClient<IServiceContractInterfaces>("addsensor", pipeName: "pipeinternal")
.BuildServiceProvider(); .BuildServiceProvider();
// resolve IPC client factory // resolve IPC client factory
IIpcClientFactory<IServiceContractInterfaces> clientFactory = serviceProvider IIpcClientFactory<IServiceContractInterfaces> clientFactory = serviceProvider
.GetRequiredService<IIpcClientFactory<IServiceContractInterfaces>>(); .GetRequiredService<IIpcClientFactory<IServiceContractInterfaces>>();
// create client // create client
_client = clientFactory.CreateClient("addsensor"); _client = clientFactory.CreateClient("addsensor");
Title = "Add sensor"; Title = "Add sensor";
} }
private void InitializeComponent() private void InitializeComponent()
{ {
AvaloniaXamlLoader.Load(this); AvaloniaXamlLoader.Load(this);
} }
private async void GetSensorInfo(Guid sensorId) private async void GetSensorInfo(Guid sensorId)
{ {
var sensor = await _client.InvokeAsync(x => x.GetConfiguredSensor(sensorId)); ConfiguredSensorModel sensor = await _client.InvokeAsync(x => x.GetConfiguredSensor(sensorId));
ComboBox.SelectedItem = sensor.Type; ComboBox.SelectedItem = sensor.Type;
FillDefaultValues(); FillDefaultValues();
ComboBox.IsEnabled = false; ComboBox.IsEnabled = false;
var item = (AddSensorViewModel)DataContext; var item = (AddSensorViewModel)DataContext;
item.SelectedType = sensor.Type; item.SelectedType = sensor.Type;
item.Name = sensor.Name; item.Name = sensor.Name;
item.UpdateInterval = sensor.UpdateInterval; item.UpdateInterval = sensor.UpdateInterval;
//item.WindowName = item.Query = sensor.Query;
//item.Query = item.WindowName = sensor.WindowName;
}
Title = $"Edit {sensor.Name}";
public async void Save(object sender, RoutedEventArgs args) }
{
var item = (AddSensorViewModel)DataContext; public async void Save(object sender, RoutedEventArgs args)
dynamic model = new { item.Name, item.Query, item.UpdateInterval, item.WindowName }; {
string json = JsonSerializer.Serialize(model); var item = (AddSensorViewModel)DataContext;
if (SensorId == Guid.Empty) dynamic model = new { item.Name, item.Query, item.UpdateInterval, item.WindowName };
await _client.InvokeAsync(x => x.AddSensor(item.SelectedType, json)); string json = JsonSerializer.Serialize(model);
else if (SensorId == Guid.Empty)
await _client.InvokeAsync(x => x.UpdateSensorById(SensorId, json)); await _client.InvokeAsync(x => x.AddSensor(item.SelectedType, json));
else
Close(); await _client.InvokeAsync(x => x.UpdateSensorById(SensorId, json));
}
Close();
public void ComboBoxClosed(object sender, SelectionChangedEventArgs args) }
{
FillDefaultValues(); public void ComboBoxClosed(object sender, SelectionChangedEventArgs args)
} {
FillDefaultValues();
private void FillDefaultValues() }
{
var item = (AddSensorViewModel)DataContext; private void FillDefaultValues()
switch (ComboBox.SelectedItem) {
{ var item = (AddSensorViewModel)DataContext;
case AvailableSensors.UserNotificationStateSensor: switch (ComboBox.SelectedItem)
item.Description = "This sensor watches the UserNotificationState. This is normally used in applications to determine if it is appropriate to send a notification but we can use it to expose this state. \n "; {
item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#usernotificationstate"; case AvailableSensors.UserNotificationStateSensor:
item.ShowDetectionModeOptions = false; item.Description = "This sensor watches the UserNotificationState. This is normally used in applications to determine if it is appropriate to send a notification but we can use it to expose this state. \n ";
item.ShowQueryInput = false; item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#usernotificationstate";
item.ShowWindowNameInput = false; item.ShowQueryInput = false;
item.UpdateInterval = 5; item.ShowWindowNameInput = false;
break; item.UpdateInterval = 5;
case AvailableSensors.DummySensor: break;
item.Description = "This sensor spits out a random number every second. Useful for testing, maybe you'll find some other use for it."; case AvailableSensors.DummySensor:
item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#dummy"; item.Description = "This sensor spits out a random number every second. Useful for testing, maybe you'll find some other use for it.";
item.ShowDetectionModeOptions = false; item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#dummy";
item.ShowQueryInput = false; item.ShowQueryInput = false;
item.ShowWindowNameInput = false; item.ShowWindowNameInput = false;
item.UpdateInterval = 1; item.UpdateInterval = 1;
break; break;
case AvailableSensors.CPULoadSensor: case AvailableSensors.CPULoadSensor:
item.Description = "This sensor checks the current CPU load. It averages the load on all logical cores every second and rounds the output to two decimals."; item.Description = "This sensor checks the current CPU load. It averages the load on all logical cores every second and rounds the output to two decimals.";
item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#cpuload"; item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#cpuload";
item.ShowDetectionModeOptions = false; item.ShowQueryInput = false;
item.ShowQueryInput = false; item.ShowWindowNameInput = false;
item.ShowWindowNameInput = false; item.UpdateInterval = 5;
item.UpdateInterval = 5; break;
break; case AvailableSensors.CurrentClockSpeedSensor:
case AvailableSensors.CurrentClockSpeedSensor: item.Description = "This sensor returns the BIOS configured baseclock for the processor.";
item.Description = "This sensor returns the BIOS configured baseclock for the processor."; item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#currentclockspeed";
item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#currentclockspeed"; item.ShowQueryInput = false;
item.ShowDetectionModeOptions = false; item.ShowWindowNameInput = false;
item.ShowQueryInput = false; item.UpdateInterval = 3600;
item.ShowWindowNameInput = false; break;
item.UpdateInterval = 3600; case AvailableSensors.WMIQuerySensor:
break; item.Description = "This advanced sensor executes a user defined WMI query and exposes the result. The query should return a single value.";
case AvailableSensors.WMIQuerySensor: item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#wmiquerysensor";
item.Description = "This advanced sensor executes a user defined WMI query and exposes the result. The query should return a single value."; item.ShowQueryInput = true;
item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#wmiquerysensor"; item.ShowWindowNameInput = false;
item.ShowDetectionModeOptions = false; item.UpdateInterval = 10;
item.ShowQueryInput = true; break;
item.ShowWindowNameInput = false; case AvailableSensors.MemoryUsageSensor:
item.UpdateInterval = 10; item.Description = "This sensor calculates the percentage of used memory.";
break; item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#usedmemory";
case AvailableSensors.MemoryUsageSensor: item.ShowQueryInput = false;
item.Description = "This sensor calculates the percentage of used memory."; item.ShowWindowNameInput = false;
item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#usedmemory"; item.UpdateInterval = 10;
item.ShowDetectionModeOptions = false; break;
item.ShowQueryInput = false; case AvailableSensors.ActiveWindowSensor:
item.ShowWindowNameInput = false; item.Description = "This sensor exposes the name of the currently active window.";
item.UpdateInterval = 10; item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#activewindow";
break; item.ShowQueryInput = false;
case AvailableSensors.ActiveWindowSensor: item.ShowWindowNameInput = false;
item.Description = "This sensor exposes the name of the currently active window."; item.UpdateInterval = 5;
item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#activewindow"; break;
item.ShowDetectionModeOptions = false; case AvailableSensors.WebcamActiveSensor:
item.ShowQueryInput = false; item.Description = "This sensor shows if the webcam is currently being used.";
item.ShowWindowNameInput = false; item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#webcamactive";
item.UpdateInterval = 5; item.ShowQueryInput = false;
break; item.UpdateInterval = 10;
case AvailableSensors.WebcamActiveSensor: break;
item.Description = "This sensor shows if the webcam is currently being used."; case AvailableSensors.MicrophoneActiveSensor:
item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#webcamactive"; item.Description = "This sensor shows if the microphone is currently in use.";
item.ShowDetectionModeOptions = true; item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#microphoneactive";
item.ShowQueryInput = false; item.ShowQueryInput = false;
item.UpdateInterval = 10; item.UpdateInterval = 10;
break; break;
case AvailableSensors.MicrophoneActiveSensor: case AvailableSensors.NamedWindowSensor:
item.Description = "This sensor shows if the microphone is currently in use."; item.Description = "This sensor returns true if a window was found with the name you search for. ";
item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#microphoneactive"; item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#namedwindow";
item.ShowDetectionModeOptions = false; item.ShowQueryInput = false;
item.ShowQueryInput = false; item.ShowWindowNameInput = true;
item.UpdateInterval = 10; item.UpdateInterval = 5;
break; break;
case AvailableSensors.NamedWindowSensor: case AvailableSensors.LastActiveSensor:
item.Description = "This sensor returns true if a window was found with the name you search for. "; item.Description = "This sensor returns the date/time that the workstation was last active.";
item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#namedwindow"; item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#lastactive";
item.ShowQueryInput = false; item.ShowQueryInput = false;
item.ShowWindowNameInput = true; item.ShowWindowNameInput = false;
item.UpdateInterval = 5; item.UpdateInterval = 5;
break; break;
case AvailableSensors.LastActiveSensor: case AvailableSensors.LastBootSensor:
item.Description = "This sensor returns the date/time that the workstation was last active."; item.Description = "This sensor returns the date/time that Windows was last booted";
item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#lastactive"; item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#lastboot";
item.ShowQueryInput = false; item.ShowQueryInput = false;
item.ShowWindowNameInput = false; item.ShowWindowNameInput = false;
item.UpdateInterval = 5; item.UpdateInterval = 5;
break; break;
case AvailableSensors.LastBootSensor: case AvailableSensors.SessionStateSensor:
item.Description = "This sensor returns the date/time that Windows was last booted"; item.Description = "This sensor returns the state of the Windows session.";
item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#lastboot"; item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#sessionstate";
item.ShowQueryInput = false; item.ShowQueryInput = false;
item.ShowWindowNameInput = false; item.ShowWindowNameInput = false;
item.UpdateInterval = 5; item.UpdateInterval = 5;
break; break;
case AvailableSensors.SessionStateSensor: case AvailableSensors.CurrentVolumeSensor:
item.Description = "This sensor returns the state of the Windows session."; item.Description = "This sensor returns the volume of currently playing audio.";
item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#sessionstate"; item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#currentvolume";
item.ShowQueryInput = false; item.ShowQueryInput = false;
item.ShowWindowNameInput = false; item.ShowWindowNameInput = false;
item.UpdateInterval = 5; item.UpdateInterval = 5;
break; break;
case AvailableSensors.CurrentVolumeSensor: case AvailableSensors.GPUTemperatureSensor:
item.Description = "This sensor returns the volume of currently playing audio."; item.Description = "This sensor returns the current temperature of the GPU in °C.";
item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#currentvolume"; item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#gputemperature";
item.ShowQueryInput = false; item.ShowQueryInput = false;
item.ShowWindowNameInput = false; item.ShowWindowNameInput = false;
item.UpdateInterval = 5; item.UpdateInterval = 5;
break; break;
case AvailableSensors.GPUTemperatureSensor: case AvailableSensors.GPULoadSensor:
item.Description = "This sensor returns the current temperature of the GPU in °C."; item.Description = "This sensor returns the current GPU load.";
item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#gputemperature"; item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#gpuload";
item.ShowQueryInput = false; item.ShowQueryInput = false;
item.ShowWindowNameInput = false; item.ShowWindowNameInput = false;
item.UpdateInterval = 5; item.UpdateInterval = 5;
break; break;
case AvailableSensors.GPULoadSensor: default:
item.Description = "This sensor returns the current GPU load."; item.Description = null;
item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#gpuload"; item.MoreInfoLink = null;
item.ShowQueryInput = false; item.ShowQueryInput = false;
item.ShowWindowNameInput = false; break;
item.UpdateInterval = 5; }
break; }
default:
item.Description = null; public void OpenInfo(object sender, RoutedEventArgs args)
item.MoreInfoLink = null; {
item.ShowQueryInput = false; var item = (AddSensorViewModel)DataContext;
break; BrowserUtil.OpenBrowser(item.MoreInfoLink);
} }
} }
public void OpenInfo(object sender, RoutedEventArgs args)
{
var item = (AddSensorViewModel)DataContext;
BrowserUtil.OpenBrowser(item.MoreInfoLink);
}
}
} }

@ -1,65 +1,65 @@
using Avalonia; using Avalonia;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Markup.Xaml; using Avalonia.Markup.Xaml;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using hass_workstation_service.Communication.NamedPipe; using hass_workstation_service.Communication.NamedPipe;
using JKang.IpcServiceFramework.Client; using JKang.IpcServiceFramework.Client;
using Avalonia.Interactivity; using Avalonia.Interactivity;
using System.Reactive.Linq; using System.Reactive.Linq;
using UserInterface.ViewModels; using UserInterface.ViewModels;
using hass_workstation_service.Communication.InterProcesCommunication.Models; using hass_workstation_service.Communication.InterProcesCommunication.Models;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Avalonia.Controls.ApplicationLifetimes; using Avalonia.Controls.ApplicationLifetimes;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace UserInterface.Views namespace UserInterface.Views
{ {
public class CommandSettings : UserControl public class CommandSettings : UserControl
{ {
private readonly IIpcClient<IServiceContractInterfaces> _client; private readonly IIpcClient<IServiceContractInterfaces> _client;
private readonly DataGrid _dataGrid; private readonly DataGrid _dataGrid;
private bool _commandsNeedToRefresh; private bool _commandsNeedToRefresh;
public CommandSettings() public CommandSettings()
{ {
InitializeComponent(); InitializeComponent();
// register IPC clients // register IPC clients
ServiceProvider serviceProvider = new ServiceCollection() ServiceProvider serviceProvider = new ServiceCollection()
.AddNamedPipeIpcClient<IServiceContractInterfaces>("commands", pipeName: "pipeinternal") .AddNamedPipeIpcClient<IServiceContractInterfaces>("commands", pipeName: "pipeinternal")
.BuildServiceProvider(); .BuildServiceProvider();
// resolve IPC client factory // resolve IPC client factory
IIpcClientFactory<IServiceContractInterfaces> clientFactory = serviceProvider IIpcClientFactory<IServiceContractInterfaces> clientFactory = serviceProvider
.GetRequiredService<IIpcClientFactory<IServiceContractInterfaces>>(); .GetRequiredService<IIpcClientFactory<IServiceContractInterfaces>>();
// create client // create client
_client = clientFactory.CreateClient("commands"); _client = clientFactory.CreateClient("commands");
_dataGrid = this.FindControl<DataGrid>("Grid"); _dataGrid = this.FindControl<DataGrid>("Grid");
DataContext = new CommandSettingsViewModel(); DataContext = new CommandSettingsViewModel();
GetConfiguredCommands(); GetConfiguredCommands();
} }
private void InitializeComponent() private void InitializeComponent()
{ {
AvaloniaXamlLoader.Load(this); AvaloniaXamlLoader.Load(this);
} }
public async void GetConfiguredCommands() public async void GetConfiguredCommands()
{ {
List<ConfiguredCommandModel> status = await _client.InvokeAsync(x => x.GetConfiguredCommands()); List<ConfiguredCommandModel> status = await _client.InvokeAsync(x => x.GetConfiguredCommands());
((CommandSettingsViewModel)DataContext).ConfiguredCommands = status.Select(s => ((CommandSettingsViewModel)DataContext).ConfiguredCommands = status.Select(s =>
new CommandViewModel() new CommandViewModel()
{ {
Name = s.Name, Name = s.Name,
Type = s.Type, Type = s.Type,
Id = s.Id Id = s.Id
}).ToList(); }).ToList();
if (_commandsNeedToRefresh) if (_commandsNeedToRefresh)
{ {
await Task.Delay(1000); await Task.Delay(1000);
GetConfiguredCommands(); GetConfiguredCommands();
_commandsNeedToRefresh = false; _commandsNeedToRefresh = false;
@ -104,5 +104,5 @@ namespace UserInterface.Views
_dataGrid.SelectedIndex = -1; _dataGrid.SelectedIndex = -1;
viewModel.TriggerUpdate(); viewModel.TriggerUpdate();
} }
} }
} }

@ -59,15 +59,7 @@ namespace hass_workstation_service.Communication.InterProcesCommunication
if (!Enum.TryParse(s.GetType().Name, out AvailableSensors type)) if (!Enum.TryParse(s.GetType().Name, out AvailableSensors type))
Log.Logger.Error("Unknown sensor"); Log.Logger.Error("Unknown sensor");
return new ConfiguredSensorModel() return new ConfiguredSensorModel(s);
{
Name = s.Name,
Type = type,
Value = s.PreviousPublishedState,
Id = s.Id,
UpdateInterval = s.UpdateInterval,
UnitOfMeasurement = ((SensorDiscoveryConfigModel)s.GetAutoDiscoveryConfig()).Unit_of_measurement
};
}).ToList(); }).ToList();
} }
@ -82,31 +74,18 @@ namespace hass_workstation_service.Communication.InterProcesCommunication
if (!Enum.TryParse(s.GetType().Name, out AvailableSensors type)) if (!Enum.TryParse(s.GetType().Name, out AvailableSensors type))
Log.Logger.Error("Unknown sensor"); Log.Logger.Error("Unknown sensor");
return new ConfiguredSensorModel() return new ConfiguredSensorModel(s);
{
Name = s.Name,
Type = type,
Value = s.PreviousPublishedState,
Id = s.Id,
UpdateInterval = s.UpdateInterval,
UnitOfMeasurement = ((SensorDiscoveryConfigModel)s.GetAutoDiscoveryConfig()).Unit_of_measurement
};
} }
} }
public List<ConfiguredCommandModel> GetConfiguredCommands() public List<ConfiguredCommandModel> GetConfiguredCommands()
{ {
return _configurationService.ConfiguredCommands.Select(s => return _configurationService.ConfiguredCommands.Select(c =>
{ {
if (!Enum.TryParse(s.GetType().Name, out AvailableCommands type)) if (!Enum.TryParse(c.GetType().Name, out AvailableCommands type))
Log.Logger.Error("Unknown command"); Log.Logger.Error("Unknown command");
return new ConfiguredCommandModel() return new ConfiguredCommandModel(c);
{
Name = s.Name,
Type = type,
Id = s.Id
};
}).ToList(); }).ToList();
} }
@ -120,12 +99,7 @@ namespace hass_workstation_service.Communication.InterProcesCommunication
if (!Enum.TryParse(c.GetType().Name, out AvailableCommands type)) if (!Enum.TryParse(c.GetType().Name, out AvailableCommands type))
Log.Logger.Error("Unknown command"); Log.Logger.Error("Unknown command");
return new ConfiguredCommandModel() return new ConfiguredCommandModel(c);
{
Name = c.Name,
Type = type,
Id = c.Id
};
} }
} }
@ -229,12 +203,12 @@ namespace hass_workstation_service.Communication.InterProcesCommunication
AvailableCommands.RestartCommand => new RestartCommand(_publisher, model.Name), AvailableCommands.RestartCommand => new RestartCommand(_publisher, model.Name),
AvailableCommands.LogOffCommand => new LogOffCommand(_publisher, model.Name), AvailableCommands.LogOffCommand => new LogOffCommand(_publisher, model.Name),
AvailableCommands.CustomCommand => new CustomCommand(_publisher, model.Command, model.Name), AvailableCommands.CustomCommand => new CustomCommand(_publisher, model.Command, model.Name),
AvailableCommands.PlayPauseCommand => new MediaPlayPauseCommand(_publisher, model.Name), AvailableCommands.PlayPauseCommand => new PlayPauseCommand(_publisher, model.Name),
AvailableCommands.NextCommand => new MediaNextCommand(_publisher, model.Name), AvailableCommands.NextCommand => new NextCommand(_publisher, model.Name),
AvailableCommands.PreviousCommand => new MediaPreviousCommand(_publisher, model.Name), AvailableCommands.PreviousCommand => new PreviousCommand(_publisher, model.Name),
AvailableCommands.VolumeUpCommand => new MediaVolumeUpCommand(_publisher, model.Name), AvailableCommands.VolumeUpCommand => new VolumeUpCommand(_publisher, model.Name),
AvailableCommands.VolumeDownCommand => new MediaVolumeDownCommand(_publisher, model.Name), AvailableCommands.VolumeDownCommand => new VolumeDownCommand(_publisher, model.Name),
AvailableCommands.MuteCommand => new MediaMuteCommand(_publisher, model.Name), AvailableCommands.MuteCommand => new MuteCommand(_publisher, model.Name),
AvailableCommands.KeyCommand => new KeyCommand(_publisher, Convert.ToByte(model.Key, 16), model.Name), AvailableCommands.KeyCommand => new KeyCommand(_publisher, Convert.ToByte(model.Key, 16), model.Name),
_ => null _ => null
}; };

@ -1,3 +1,5 @@
using hass_workstation_service.Domain.Commands;
using hass_workstation_service.Domain.Sensors;
using System; using System;
namespace hass_workstation_service.Communication.InterProcesCommunication.Models namespace hass_workstation_service.Communication.InterProcesCommunication.Models
@ -23,8 +25,33 @@ namespace hass_workstation_service.Communication.InterProcesCommunication.Models
public AvailableSensors Type { get; set; } public AvailableSensors Type { get; set; }
public string Name { get; set; } public string Name { get; set; }
public string Value { get; set; } public string Value { get; set; }
public string Query { get; set; }
public string WindowName { get; set; }
public int UpdateInterval { get; set; } public int UpdateInterval { get; set; }
public string UnitOfMeasurement { get; set; } public string UnitOfMeasurement { get; set; }
public ConfiguredSensorModel(AbstractSensor sensor)
{
this.Id = sensor.Id;
this.Name = sensor.Name;
Enum.TryParse(sensor.GetType().Name, out AvailableSensors type);
this.Type = type;
this.Value = sensor.PreviousPublishedState;
if (sensor is WMIQuerySensor wMIQuerySensor)
{
this.Query = wMIQuerySensor.Query;
}
if (sensor is NamedWindowSensor namedWindowSensor)
{
this.WindowName = namedWindowSensor.WindowName;
}
this.UpdateInterval = sensor.UpdateInterval;
this.UnitOfMeasurement = ((SensorDiscoveryConfigModel)sensor.GetAutoDiscoveryConfig()).Unit_of_measurement;
}
public ConfiguredSensorModel()
{
}
} }
public class ConfiguredCommandModel public class ConfiguredCommandModel
@ -33,6 +60,28 @@ namespace hass_workstation_service.Communication.InterProcesCommunication.Models
public AvailableCommands Type { get; set; } public AvailableCommands Type { get; set; }
public string Name { get; set; } public string Name { get; set; }
public string Command { get; set; } public string Command { get; set; }
public string Key { get; set; }
public ConfiguredCommandModel(AbstractCommand command)
{
this.Id = command.Id;
Enum.TryParse(command.GetType().Name, out AvailableCommands type);
this.Type = type;
this.Name = command.Name;
if (command is CustomCommand customCommand)
{
this.Command = customCommand.Command;
}
if (command is KeyCommand keyCommand)
{
this.Key = "0x" + Convert.ToString(keyCommand.KeyCode, 16);
}
}
public ConfiguredCommandModel()
{
}
} }
public enum AvailableSensors public enum AvailableSensors

@ -184,22 +184,22 @@ namespace hass_workstation_service.Data
command = new CustomCommand(publisher, configuredCommand.Command, configuredCommand.Name, configuredCommand.Id); command = new CustomCommand(publisher, configuredCommand.Command, configuredCommand.Name, configuredCommand.Id);
break; break;
case "MediaPlayPauseCommand": case "MediaPlayPauseCommand":
command = new MediaPlayPauseCommand(publisher, configuredCommand.Name, configuredCommand.Id); command = new PlayPauseCommand(publisher, configuredCommand.Name, configuredCommand.Id);
break; break;
case "MediaNextCommand": case "MediaNextCommand":
command = new MediaNextCommand(publisher, configuredCommand.Name, configuredCommand.Id); command = new NextCommand(publisher, configuredCommand.Name, configuredCommand.Id);
break; break;
case "MediaPreviousCommand": case "MediaPreviousCommand":
command = new MediaPreviousCommand(publisher, configuredCommand.Name, configuredCommand.Id); command = new PreviousCommand(publisher, configuredCommand.Name, configuredCommand.Id);
break; break;
case "MediaVolumeUpCommand": case "MediaVolumeUpCommand":
command = new MediaVolumeUpCommand(publisher, configuredCommand.Name, configuredCommand.Id); command = new VolumeUpCommand(publisher, configuredCommand.Name, configuredCommand.Id);
break; break;
case "MediaVolumeDownCommand": case "MediaVolumeDownCommand":
command = new MediaVolumeDownCommand(publisher, configuredCommand.Name, configuredCommand.Id); command = new VolumeDownCommand(publisher, configuredCommand.Name, configuredCommand.Id);
break; break;
case "MediaMuteCommand": case "MediaMuteCommand":
command = new MediaMuteCommand(publisher, configuredCommand.Name, configuredCommand.Id); command = new MuteCommand(publisher, configuredCommand.Name, configuredCommand.Id);
break; break;
case "KeyCommand": case "KeyCommand":
command = new KeyCommand(publisher, configuredCommand.KeyCode, configuredCommand.Name, configuredCommand.Id); command = new KeyCommand(publisher, configuredCommand.KeyCode, configuredCommand.Name, configuredCommand.Id);
@ -385,6 +385,7 @@ namespace hass_workstation_service.Data
public async void UpdateConfiguredCommand(Guid id, AbstractCommand command) public async void UpdateConfiguredCommand(Guid id, AbstractCommand command)
{ {
await DeleteCommand(id); await DeleteCommand(id);
await Task.Delay(500);
AddCommand(command); AddCommand(command);
WriteCommandSettingsAsync(); WriteCommandSettingsAsync();
} }

@ -1,14 +0,0 @@
using hass_workstation_service.Communication;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace hass_workstation_service.Domain.Commands
{
public class MediaPlayPauseCommand : KeyCommand
{
public MediaPlayPauseCommand(MqttPublisher publisher, string name = "PlayPause", Guid id = default(Guid)) : base(publisher, KeyCommand.VK_MEDIA_PLAY_PAUSE, name ?? "PlayPause", id) { }
}
}

@ -1,14 +0,0 @@
using hass_workstation_service.Communication;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace hass_workstation_service.Domain.Commands
{
public class MediaPreviousCommand : KeyCommand
{
public MediaPreviousCommand(MqttPublisher publisher, string name = "Previous", Guid id = default(Guid)) : base(publisher, KeyCommand.VK_MEDIA_PREV_TRACK, name ?? "Previous", id) { }
}
}

@ -1,14 +0,0 @@
using hass_workstation_service.Communication;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace hass_workstation_service.Domain.Commands
{
public class MediaVolumeDownCommand : KeyCommand
{
public MediaVolumeDownCommand(MqttPublisher publisher, string name = "VolumeDown", Guid id = default(Guid)) : base(publisher, KeyCommand.VK_VOLUME_DOWN, name ?? "VolumeDown", id) { }
}
}

@ -1,14 +0,0 @@
using hass_workstation_service.Communication;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace hass_workstation_service.Domain.Commands
{
public class MediaVolumeUpCommand : KeyCommand
{
public MediaVolumeUpCommand(MqttPublisher publisher, string name = "VolumeUp", Guid id = default(Guid)) : base(publisher, KeyCommand.VK_VOLUME_UP, name ?? "VolumeUp", id) { }
}
}

@ -7,8 +7,8 @@ using System.Threading.Tasks;
namespace hass_workstation_service.Domain.Commands namespace hass_workstation_service.Domain.Commands
{ {
public class MediaMuteCommand : KeyCommand public class MuteCommand : KeyCommand
{ {
public MediaMuteCommand(MqttPublisher publisher, string name = "Mute", Guid id = default(Guid)) : base(publisher, KeyCommand.VK_VOLUME_MUTE, name ?? "Mute", id) { } public MuteCommand(MqttPublisher publisher, string name = "Mute", Guid id = default(Guid)) : base(publisher, KeyCommand.VK_VOLUME_MUTE, name ?? "Mute", id) { }
} }
} }

@ -7,8 +7,8 @@ using System.Threading.Tasks;
namespace hass_workstation_service.Domain.Commands namespace hass_workstation_service.Domain.Commands
{ {
public class MediaNextCommand : KeyCommand public class NextCommand : KeyCommand
{ {
public MediaNextCommand(MqttPublisher publisher, string name = "Next", Guid id = default(Guid)) : base(publisher, KeyCommand.VK_MEDIA_NEXT_TRACK, name ?? "Next", id) { } public NextCommand(MqttPublisher publisher, string name = "Next", Guid id = default(Guid)) : base(publisher, KeyCommand.VK_MEDIA_NEXT_TRACK, name ?? "Next", id) { }
} }
} }

@ -0,0 +1,14 @@
using hass_workstation_service.Communication;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace hass_workstation_service.Domain.Commands
{
public class PlayPauseCommand : KeyCommand
{
public PlayPauseCommand(MqttPublisher publisher, string name = "PlayPause", Guid id = default(Guid)) : base(publisher, KeyCommand.VK_MEDIA_PLAY_PAUSE, name ?? "PlayPause", id) { }
}
}

@ -0,0 +1,14 @@
using hass_workstation_service.Communication;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace hass_workstation_service.Domain.Commands
{
public class PreviousCommand : KeyCommand
{
public PreviousCommand(MqttPublisher publisher, string name = "Previous", Guid id = default(Guid)) : base(publisher, KeyCommand.VK_MEDIA_PREV_TRACK, name ?? "Previous", id) { }
}
}

@ -0,0 +1,14 @@
using hass_workstation_service.Communication;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace hass_workstation_service.Domain.Commands
{
public class VolumeDownCommand : KeyCommand
{
public VolumeDownCommand(MqttPublisher publisher, string name = "VolumeDown", Guid id = default(Guid)) : base(publisher, KeyCommand.VK_VOLUME_DOWN, name ?? "VolumeDown", id) { }
}
}

@ -0,0 +1,14 @@
using hass_workstation_service.Communication;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace hass_workstation_service.Domain.Commands
{
public class VolumeUpCommand : KeyCommand
{
public VolumeUpCommand(MqttPublisher publisher, string name = "VolumeUp", Guid id = default(Guid)) : base(publisher, KeyCommand.VK_VOLUME_UP, name ?? "VolumeUp", id) { }
}
}
Loading…
Cancel
Save