Skip to content

Commit

Permalink
Updates (#110)
Browse files Browse the repository at this point in the history
* Update Nuget packages
* Check json valid from post response
  • Loading branch information
dk307 authored Nov 24, 2023
1 parent 4a684a5 commit 6bc5821
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 23 deletions.
12 changes: 8 additions & 4 deletions plugin/HSPI_ZWaveParameters.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@
<DependentUpon>HtmlSnippets.resx</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Shared\Hspi\CompilerHelper.cs" />
<Compile Include="Shared\Hspi\HSPIBase.cs" />
<Compile Include="Shared\Hspi\Logger2.cs" />
<Compile Include="Shared\Hspi\Utils\ExceptionHelper.cs" />
Expand Down Expand Up @@ -162,7 +161,7 @@
<Version>8.0.746</Version>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers">
<Version>7.0.4</Version>
<Version>8.0.0</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand All @@ -174,6 +173,11 @@
<PackageReference Include="Nito.AsyncEx.Coordination">
<Version>5.1.2</Version>
</PackageReference>
<PackageReference Include="PolySharp">
<Version>1.13.2</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Serilog">
<Version>3.1.1</Version>
</PackageReference>
Expand All @@ -189,7 +193,7 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="System.Collections.Immutable">
<Version>7.0.0</Version>
<Version>8.0.0</Version>
</PackageReference>
<PackageReference Include="System.Drawing.Primitives">
<Version>4.3.0</Version>
Expand All @@ -198,7 +202,7 @@
<Version>4.3.4</Version>
</PackageReference>
<PackageReference Include="System.Text.Json">
<Version>7.0.3</Version>
<Version>8.0.0</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion plugin/Hspi/DeviceConfigPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ private static long GetValueFromView(AbstractView view, ZWaveDeviceParameter par
private static int ZWaveParameterFromId(string idParameter)
{
if (idParameter.StartsWith(ZWaveParameterPrefix, StringComparison.OrdinalIgnoreCase) &&
int.TryParse(idParameter.Substring(ZWaveParameterPrefix.Length), out int id))
int.TryParse(idParameter[ZWaveParameterPrefix.Length..], out int id))
{
return id;
}
Expand Down
8 changes: 2 additions & 6 deletions plugin/Hspi/ZWaveConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,8 @@ public ZWaveData GetDeviceZWaveData(int deviceRef)
throw new NotAZWaveDeviceException("Device is not a Z-Wave device");
}

var plugInData = (PlugExtraData)HomeSeerSystem.GetPropertyByRef(deviceRef, EProperty.PlugExtraData);
if (plugInData == null)
{
throw new ZWavePlugInDataInvalidException("Device Plugin extra data is not valid");
}

var plugInData = (PlugExtraData)HomeSeerSystem.GetPropertyByRef(deviceRef, EProperty.PlugExtraData)
?? throw new ZWavePlugInDataInvalidException("Device Plugin extra data is not valid");
var manufacturerId = GetValueFromExtraDataWithTrim<Int32>(plugInData, "manufacturer_id");
var productId = GetValueFromExtraDataWithTrim<UInt16>(plugInData, "manufacturer_prod_id");
var productType = GetValueFromExtraDataWithTrim<UInt16>(plugInData, "manufacturer_prod_type");
Expand Down
4 changes: 2 additions & 2 deletions plugin/HtmlSnippets.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 12 additions & 4 deletions plugin/HtmlSnippets.resx
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ function decimalToHexString(number, size)
}

function refreshZWaveParameter(homeId, nodeId, parameter, idMessage, idValueWrapper, idValue) {
var formObject = {
const formObject = {
homeId: homeId,
nodeId: nodeId,
parameter: parameter,
Expand All @@ -173,14 +173,22 @@ function refreshZWaveParameter(homeId, nodeId, parameter, idMessage, idValueWrap
})
.done(function(resultJson) {
$('#' + idMessage).removeClass("spinner-border");

var result = JSON.parse(resultJson);

let result;
try {
result = JSON.parse(resultJson);
}
catch(e){
result = {
ErrorMessage : "Failed to get Result with error:" + e.message
};
}

if (result.ErrorMessage == null) {
$('#' + idMessage).hide();
$('#' + idValueWrapper).show();

var parameterValue = result.Value;
const parameterValue = result.Value;

var obj = $('#' + idValue);

Expand Down
17 changes: 11 additions & 6 deletions tests/HSPI_ZWaveParametersTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,16 @@
<Version>5.1.1</Version>
</PackageReference>
<PackageReference Include="HomeSeer-PluginSDK">
<Version>1.4.4</Version>
<Version>1.3.1</Version>
</PackageReference>
<PackageReference Include="HtmlAgilityPack">
<Version>1.11.54</Version>
</PackageReference>
<PackageReference Include="HtmlSanitizer">
<Version>8.0.723</Version>
<Version>8.0.746</Version>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Http">
<Version>7.0.0</Version>
<Version>8.0.0</Version>
</PackageReference>
<PackageReference Include="Moq">
<Version>4.20.69</Version>
Expand All @@ -107,16 +107,21 @@
<PackageReference Include="MSTest.TestFramework">
<Version>3.1.1</Version>
</PackageReference>
<PackageReference Include="PolySharp">
<Version>1.13.2</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Serilog">
<Version>3.0.1</Version>
<Version>3.1.1</Version>
</PackageReference>
<PackageReference Include="SonarAnalyzer.CSharp">
<Version>9.11.0.78383</Version>
<Version>9.12.0.78982</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="System.Text.Json">
<Version>7.0.3</Version>
<Version>8.0.0</Version>
</PackageReference>
<PackageReference Include="System.Xml.XPath">
<Version>4.3.0</Version>
Expand Down

0 comments on commit 6bc5821

Please sign in to comment.