Adds optional enable property to partition sensor config and defaults to enable

This commit is contained in:
Neil Dorin
2023-07-19 09:50:48 -06:00
parent fcd4b5d772
commit f0ae0094dc
2 changed files with 29 additions and 12 deletions

View File

@@ -85,18 +85,32 @@ namespace PepperDash.Essentials.Core
{ {
if (_partitionSensor.IsOnline == false) return; if (_partitionSensor.IsOnline == false) return;
Debug.Console(1, this, "Attempting to apply settings to sensor from config"); // Default to enable
_partitionSensor.Enable.BoolValue = true;
if (PropertiesConfig.Sensitivity != null) Debug.Console(1, this, "Attempting to apply settings to sensor from config");
{
Debug.Console(1, this, "Sensitivity found, attempting to set value '{0}' from config", if (PropertiesConfig.Sensitivity != null)
PropertiesConfig.Sensitivity); {
_partitionSensor.Sensitivity.UShortValue = (ushort) PropertiesConfig.Sensitivity; Debug.Console(1, this, "Sensitivity found, attempting to set value '{0}' from config",
} PropertiesConfig.Sensitivity);
else _partitionSensor.Sensitivity.UShortValue = (ushort)PropertiesConfig.Sensitivity;
{ }
Debug.Console(1, this, "Sensitivity null, no value specified in config"); else
} {
Debug.Console(1, this, "Sensitivity null, no value specified in config");
}
if (PropertiesConfig.Enable != null)
{
Debug.Console(1, this, "Enable found, attempting to set value '{0}' from config",
PropertiesConfig.Enable);
_partitionSensor.Enable.BoolValue = (bool)PropertiesConfig.Enable;
}
else
{
Debug.Console(1, this, "Enable null, no value specified in config");
}
} }

View File

@@ -16,6 +16,9 @@ namespace PepperDash_Essentials_Core.PartitionSensor
/// The sensitivity range shall be between 1(lowest) to 10 (highest). /// The sensitivity range shall be between 1(lowest) to 10 (highest).
/// </remarks> /// </remarks>
[JsonProperty("sensitivity")] [JsonProperty("sensitivity")]
public ushort? Sensitivity { get; set; } public ushort? Sensitivity { get; set; }
[JsonProperty("enable")]
public bool? Enable { get; set; }
} }
} }