Update CustomCommand.cs

pull/122/head
TerminalMan 3 years ago committed by GitHub
parent da64302a6c
commit e1dc2d5c7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -30,6 +30,11 @@ namespace hass_workstation_service.Domain.Commands
startInfo.FileName = "cmd.exe"; startInfo.FileName = "cmd.exe";
startInfo.Arguments = $"/C {this.Command}"; startInfo.Arguments = $"/C {this.Command}";
this.Process.StartInfo = startInfo; 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 try
{ {
this.Process.Start(); this.Process.Start();
@ -39,12 +44,6 @@ namespace hass_workstation_service.Domain.Commands
Log.Logger.Error($"Sensor {this.Name} failed", e); Log.Logger.Error($"Sensor {this.Name} failed", e);
this.State = "FAILED"; this.State = "FAILED";
} }
while (!this.Process.HasExited)
{
await Task.Delay(1000);
}
this.State = "OFF";
} }

Loading…
Cancel
Save