diff --git a/src/PepperDash.Essentials.Core/CrestronIO/GenericDigitalInputDevice.cs b/src/PepperDash.Essentials.Core/CrestronIO/GenericDigitalInputDevice.cs index 20ed56d6..3692d58d 100644 --- a/src/PepperDash.Essentials.Core/CrestronIO/GenericDigitalInputDevice.cs +++ b/src/PepperDash.Essentials.Core/CrestronIO/GenericDigitalInputDevice.cs @@ -21,7 +21,7 @@ namespace PepperDash.Essentials.Core.CrestronIO public class GenericDigitalInputDevice : EssentialsBridgeableDevice, IDigitalInput, IHasFeedback { private DigitalInput inputPort; - private bool invertState; + private readonly bool invertState; /// /// Gets or sets the InputStateFeedback @@ -42,9 +42,8 @@ namespace PepperDash.Essentials.Core.CrestronIO IOPortConfig config) : base(key, name) { - invertState = !string.IsNullOrEmpty(config.CircuitType) && - config.CircuitType.Equals("NC", StringComparison.OrdinalIgnoreCase); - + invertState = string.Equals(config.CircuitType, "NC", StringComparison.OrdinalIgnoreCase); + InputStateFeedback = new BoolFeedback("inputState", () => invertState ? !inputPort.State : inputPort.State); AddPostActivationAction(() => diff --git a/src/PepperDash.Essentials.Core/CrestronIO/GenericVersiportInputDevice.cs b/src/PepperDash.Essentials.Core/CrestronIO/GenericVersiportInputDevice.cs index 43d97e9c..47e8aef6 100644 --- a/src/PepperDash.Essentials.Core/CrestronIO/GenericVersiportInputDevice.cs +++ b/src/PepperDash.Essentials.Core/CrestronIO/GenericVersiportInputDevice.cs @@ -18,7 +18,7 @@ namespace PepperDash.Essentials.Core.CrestronIO public class GenericVersiportDigitalInputDevice : EssentialsBridgeableDevice, IDigitalInput, IPartitionStateProvider, IHasFeedback { private Versiport inputPort; - private bool invertState; + private readonly bool invertState; /// /// Gets or sets the InputStateFeedback @@ -48,9 +48,9 @@ namespace PepperDash.Essentials.Core.CrestronIO public GenericVersiportDigitalInputDevice(string key, string name, Func postActivationFunc, IOPortConfig config) : base(key, name) { - invertState = !string.IsNullOrEmpty(config.CircuitType) && - config.CircuitType.Equals("NC", StringComparison.OrdinalIgnoreCase); - + var circuitType = string.IsNullOrEmpty(config.CircuitType) ? "NO" : config.CircuitType; + invertState = circuitType.Equals("NC", StringComparison.OrdinalIgnoreCase); + InputStateFeedback = new BoolFeedback("inputState", () => invertState ? !inputPort.DigitalIn : inputPort.DigitalIn); PartitionPresentFeedback = new BoolFeedback("partitionPresent", () => !inputPort.DigitalIn);