Skip to content

Commit

Permalink
Merge pull request #349 from HomeSeer/release/1.4.4
Browse files Browse the repository at this point in the history
Release v1.4.4
  • Loading branch information
jldubz committed Jul 10, 2023
2 parents 3ba5928 + b5c16b8 commit 66945bb
Show file tree
Hide file tree
Showing 9 changed files with 226 additions and 147 deletions.
4 changes: 1 addition & 3 deletions Devices/Controls/EControlType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,10 @@ public enum EControlType {
/// Rendered as a select list.
/// <para>
/// Options are determined by the <see cref="StatusControl.TargetRange"/>'s
/// <see cref="ValueRange.Min"/>, <see cref="ValueRange.Max"/>, and a yet to be implemented property controlling the number of steps to take.
/// This was controlled by the ValueRange.Divisor property in the legacy API and has not been migrated over yet.
/// <see cref="ValueRange.Min"/>, <see cref="ValueRange.Max"/>, and <see cref="ValueRange.Divisor"/>
/// </para>
/// </summary>
/// <seealso href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select">Mozilla Docs - Select Input</seealso>
[Obsolete("Due to a lack of ValueRange.Divisor property this type cannot be properly used at this time.", false)]
ValueRangeDropDown = 6,
/// <summary>
/// Rendered as a slider.
Expand Down
1 change: 0 additions & 1 deletion Devices/FeatureFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,6 @@ public FeatureFactory AddSlider(ValueRange targetRange, ControlLocation location
/// <exception cref="ArgumentNullException">Thrown when <paramref name="targetRange"/> is null.</exception>
/// <exception cref="ArgumentException">Thrown when a control, targeting any of the specified values, already exists.</exception>
/// <seealso cref="EControlType.ValueRangeDropDown"/>
[Obsolete("Due to a lack of ValueRange.Divisor property this control type cannot be properly created at this time.", false)]
public FeatureFactory AddValueDropDown(ValueRange targetRange, ControlLocation location = null, EControlUse controlUse = EControlUse.NotSpecified) {

if (targetRange == null) {
Expand Down
43 changes: 30 additions & 13 deletions Devices/ValueRange.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,13 @@ namespace HomeSeer.PluginSdk.Devices {
[Serializable]
public class ValueRange {

//TODO public int Steps { get; set; } = 10;

private int _decimalPlaces;
private double _min;
private double _max;
private double _offset;
private string _prefix = "";
private string _suffix = "";

//TODO private int _divisor = 1;
private double _divisor = 1;

/// <summary>
/// Initialize a new range of values
Expand Down Expand Up @@ -84,9 +81,13 @@ public double Offset {
get => _offset;
set => _offset = value;
}

/// <summary>
/// The number of decimal places of accuracy displayed by the range
/// <para>
/// The displayed value will be the rounded value to the nearest number of decimals.
/// E.G. If <see cref="DecimalPlaces"/> is 1, a value of 7.1589 will be displayed as 7.2
/// </para>
/// </summary>
/// <exception cref="ArgumentOutOfRangeException">
/// Thrown if you try to set the decimal places to a value less than 0
Expand Down Expand Up @@ -116,6 +117,24 @@ public string Suffix {
set => _suffix = string.IsNullOrWhiteSpace(value) ? "" : value;
}

/// <summary>
/// The amount to divide the value by for display.
/// <para>
/// E.G. A value of 45 will be displayed as 22.5 with a divisor of 2
/// </para>
/// </summary>
/// <exception cref="ArgumentOutOfRangeException">
/// Thrown if you try to set the divisor less than or equal to 0
/// </exception>
public double Divisor {
get => _divisor;
set {
if (value <= 0) throw new ArgumentOutOfRangeException();

_divisor = value;
}
}

/// <summary>
/// Create a deep copy of this <see cref="ValueRange"/>
/// </summary>
Expand All @@ -126,7 +145,8 @@ public ValueRange Clone() {
DecimalPlaces = DecimalPlaces,
Offset = Offset,
Prefix = Prefix,
Suffix = Suffix
Suffix = Suffix,
Divisor = Divisor
};
return clone;
}
Expand All @@ -135,12 +155,12 @@ public ValueRange Clone() {
/// Obtain the string representation of the specified value according to the range's configuration
/// </summary>
/// <remarks>
/// This returns <c>$"{_prefix}{(value - _offset).ToString($"F{_decimalPlaces}")}{_suffix}"</c>
/// This returns <c>$"{_prefix}{((value - _offset) / _divisor).ToString($"F{_decimalPlaces}")}{_suffix}"</c>
/// </remarks>
/// <param name="value">The value to use in the string</param>
/// <returns>The value correctly formatted according to the range</returns>
public string GetStringForValue(double value) {
var stringValue = $"{_prefix}{(value - _offset).ToString($"F{_decimalPlaces}")}{_suffix}";
var stringValue = $"{_prefix}{((value - _offset) / _divisor).ToString($"F{_decimalPlaces}")}{_suffix}";

return stringValue;
}
Expand Down Expand Up @@ -186,12 +206,9 @@ public override bool Equals(object obj) {
if (_decimalPlaces != otherValueRange._decimalPlaces) {
return false;
}
/*if (_divisor != otherValueRange._divisor) {
if (_divisor != otherValueRange._divisor) {
return false;
}*/
/*if (Steps != otherValueRange.Steps) {
return false;
}*/
}

return true;
}
Expand Down
12 changes: 12 additions & 0 deletions Events/EventData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ public struct EventData {
public bool Flag_Include_in_Powerfail;
public bool Flag_Security;
public bool Flag_Priority_Event;
/// <summary>
/// Event can be controlled by voice using the event name or the voice command override, must be set if Amazon or Google is set
/// </summary>
public bool FlagVoiceCommand;
/// <summary>
/// Event can be discovered by Google Home
/// </summary>
public bool FlagGoogleDiscoveryEnabled;
/// <summary>
/// Event can be discovered by Amazon alexa
/// </summary>
public bool FlagAlexaDiscoveryEnabled;
public int Action_Count;
public string[] Actions;
public int Trigger_Count;
Expand Down
6 changes: 3 additions & 3 deletions PluginSdk.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package >
<metadata>
<id>HomeSeer-PluginSDK</id>
<version>1.4.3.0</version>
<version>1.4.4.0</version>
<title>HomeSeer PluginSDK</title>
<authors>HomeSeer</authors>
<owners>HomeSeer</owners>
Expand All @@ -13,7 +13,7 @@
<icon>images\icon-hs-128.png</icon>
<license type="expression">AGPL-3.0-or-later</license>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<releaseNotes>https://homeseer.github.io/Plugin-SDK-Docs/release_notes/pluginsdk_releasenotes_1_4_3_0.html</releaseNotes>
<releaseNotes>https://homeseer.github.io/Plugin-SDK-Docs/release_notes/pluginsdk_releasenotes_1_4_4_0.html</releaseNotes>
<copyright>Copyright 2022</copyright>
<tags>HomeSeer Home Seer Plugin pluginsdk hs4 sdk hs api pluginapi plugins smart auto automation control monitor</tags>
<dependencies>
Expand All @@ -24,4 +24,4 @@
<file src="HSCF.dll" target="lib\net462" />
<file src="icon-hs-128.png" target="images\" />
</files>
</package>
</package>
Loading

0 comments on commit 66945bb

Please sign in to comment.