From e1dc2d5c7febd6d4a54530b3c44597ce965a1f08 Mon Sep 17 00:00:00 2001 From: TerminalMan <84923604+SecretiveShell@users.noreply.github.com> Date: Fri, 5 Nov 2021 13:14:29 +0000 Subject: [PATCH] Update CustomCommand.cs --- .../Domain/Commands/CustomCommand.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/hass-workstation-service/Domain/Commands/CustomCommand.cs b/hass-workstation-service/Domain/Commands/CustomCommand.cs index f4dced8..02d265a 100644 --- a/hass-workstation-service/Domain/Commands/CustomCommand.cs +++ b/hass-workstation-service/Domain/Commands/CustomCommand.cs @@ -30,6 +30,11 @@ namespace hass_workstation_service.Domain.Commands startInfo.FileName = "cmd.exe"; startInfo.Arguments = $"/C {this.Command}"; this.Process.StartInfo = startInfo; + + // turn off the sensor to guarantee disable the switch + // useful if command changes power state of device + this.State = "OFF"; + try { this.Process.Start(); @@ -39,12 +44,6 @@ namespace hass_workstation_service.Domain.Commands Log.Logger.Error($"Sensor {this.Name} failed", e); this.State = "FAILED"; } - - while (!this.Process.HasExited) - { - await Task.Delay(1000); - } - this.State = "OFF"; }