Merge branch 'release/AddProxyShelly_01'

This commit is contained in:
Samuele Locatelli
2025-02-12 10:54:44 +01:00
41 changed files with 1609 additions and 83 deletions
+163 -83
View File
@@ -178,6 +178,19 @@ EgwProxy.Ftp:build:
script:
- '& "$env:MSBUILD_PATH" "$env:APP_NAME\$env:APP_NAME.csproj" -target:Build /p:Configuration=Release /p:Platform="x86" /p:OutputPath=bin/ /nodeReuse:false /verbosity:minimal /m'
EgwProxy.Gomba:build:
stage: build
tags:
- win
variables:
APP_NAME: EgwProxy.Gomba
before_script:
- *nuget-fix
- '& "$env:NUGET_PATH" restore "$env:APP_NAME.sln" -verbosity quiet'
- *version-fix
script:
- '& "$env:MSBUILD_PATH" "$env:APP_NAME\$env:APP_NAME.csproj" -target:Build /p:Configuration=Release /p:Platform="x86" /p:OutputPath=bin/ /nodeReuse:false /verbosity:minimal /m'
EgwProxy.Icoel:build:
stage: build
tags:
@@ -217,12 +230,12 @@ EgwProxy.OsaiCncLib:build:
script:
- '& "$env:MSBUILD_PATH" "$env:APP_NAME\$env:APP_NAME.vbproj" -target:Build /p:Configuration=Release /p:Platform="x86" /p:OutputPath=bin/ /nodeReuse:false /verbosity:minimal /m'
EgwProxy.SqlDb:build:
EgwProxy.Shelly:build:
stage: build
tags:
- win
variables:
APP_NAME: EgwProxy.SqlDb
APP_NAME: EgwProxy.Shelly
before_script:
- *nuget-fix
- '& "$env:NUGET_PATH" restore "$env:APP_NAME.sln" -verbosity quiet'
@@ -230,12 +243,12 @@ EgwProxy.SqlDb:build:
script:
- '& "$env:MSBUILD_PATH" "$env:APP_NAME\$env:APP_NAME.csproj" -target:Build /p:Configuration=Release /p:Platform="x86" /p:OutputPath=bin/ /nodeReuse:false /verbosity:minimal /m'
EgwProxy.Gomba:build:
EgwProxy.SqlDb:build:
stage: build
tags:
- win
variables:
APP_NAME: EgwProxy.Gomba
APP_NAME: EgwProxy.SqlDb
before_script:
- *nuget-fix
- '& "$env:NUGET_PATH" restore "$env:APP_NAME.sln" -verbosity quiet'
@@ -275,6 +288,34 @@ EgwProxy.Ftp:staging:
- '& "$env:NUGET_PATH" setapikey $NUGET_API_KEY -source http://nexus.steamware.net/repository/nuget-hosted'
- '& "$env:NUGET_PATH" push *$env:NUM_DEB.nupkg -Source http://nexus.steamware.net/repository/nuget-hosted'
EgwProxy.Gomba:staging:
stage: staging
needs: ["EgwProxy.Gomba:build"]
tags:
- win
variables:
CONFIG: Debug
APP_NAME: EgwProxy.Gomba
rules:
- if: $CI_COMMIT_BRANCH == 'develop'
changes:
- EgwProxy.Gomba/*
when: always
- if: $CI_COMMIT_BRANCH == 'SDK/Gomba'
changes:
- EgwProxy.Gomba/*
before_script:
- *nuget-fix
- '& "$env:NUGET_PATH" restore "$env:APP_NAME.sln" -verbosity quiet'
- *version-fix
- *nuspec-fix
script:
- '& "$env:MSBUILD_PATH" "$env:APP_NAME\$env:APP_NAME.csproj" -target:Build /p:Configuration=$env:CONFIG /p:Platform="Any CPU" /p:OutputPath=bin/$env:CONFIG /verbosity:minimal /m'
- '& Remove-Item *.nupkg'
- '& $env:NUGET_PATH pack "$env:APP_NAME.Debug.nuspec"'
- '& "$env:NUGET_PATH" setapikey $NUGET_API_KEY -source http://nexus.steamware.net/repository/nuget-hosted'
- '& "$env:NUGET_PATH" push *$env:NUM_DEB.nupkg -Source http://nexus.steamware.net/repository/nuget-hosted'
EgwProxy.Icoel:staging:
stage: staging
needs: ["EgwProxy.Icoel:build"]
@@ -328,7 +369,6 @@ EgwProxy.MultiCncLib:staging:
- '& "$env:MSBUILD_PATH" "$env:APP_NAME\$env:APP_NAME.vbproj" -target:Build /p:Configuration=$env:CONFIG /p:Platform="Any CPU" /p:OutputPath=bin/$env:CONFIG /verbosity:minimal /m'
- '& Remove-Item *.nupkg'
- '& $env:NUGET_PATH pack "$env:APP_NAME.Debug.nuspec"'
# - '& "$env:NUGET_PATH" pack "$env:APP_NAME\$env:APP_NAME.vbproj" -properties Configuration=$env:CONFIG -Version $env:NUM_DEB'
- '& "$env:NUGET_PATH" setapikey $NUGET_API_KEY -source http://nexus.steamware.net/repository/nuget-hosted'
- '& "$env:NUGET_PATH" push *$env:NUM_DEB.nupkg -Source http://nexus.steamware.net/repository/nuget-hosted'
@@ -357,7 +397,34 @@ EgwProxy.OsaiCncLib:staging:
- '& "$env:MSBUILD_PATH" "$env:APP_NAME\$env:APP_NAME.vbproj" -target:Build /p:Configuration=$env:CONFIG /p:Platform="Any CPU" /p:OutputPath=bin/$env:CONFIG /verbosity:minimal /m'
- '& Remove-Item *.nupkg'
- '& $env:NUGET_PATH pack "$env:APP_NAME.Debug.nuspec"'
# - '& "$env:NUGET_PATH" pack "$env:APP_NAME\$env:APP_NAME.vbproj" -properties Configuration=$env:CONFIG -Version $env:NUM_DEB'
- '& "$env:NUGET_PATH" setapikey $NUGET_API_KEY -source http://nexus.steamware.net/repository/nuget-hosted'
- '& "$env:NUGET_PATH" push *$env:NUM_DEB.nupkg -Source http://nexus.steamware.net/repository/nuget-hosted'
EgwProxy.Shelly:staging:
stage: staging
needs: ["EgwProxy.Shelly:build"]
tags:
- win
variables:
CONFIG: Debug
APP_NAME: EgwProxy.Shelly
rules:
- if: $CI_COMMIT_BRANCH == 'develop'
changes:
- EgwProxy.Shelly/*
when: always
- if: $CI_COMMIT_BRANCH == 'SDK/Shelly'
changes:
- EgwProxy.Shelly/*
before_script:
- *nuget-fix
- '& "$env:NUGET_PATH" restore "$env:APP_NAME.sln" -verbosity quiet'
- *version-fix
- *nuspec-fix
script:
- '& "$env:MSBUILD_PATH" "$env:APP_NAME\$env:APP_NAME.csproj" -target:Build /p:Configuration=$env:CONFIG /p:Platform="Any CPU" /p:OutputPath=bin/$env:CONFIG /verbosity:minimal /m'
- '& Remove-Item *.nupkg'
- '& $env:NUGET_PATH pack "$env:APP_NAME.Debug.nuspec"'
- '& "$env:NUGET_PATH" setapikey $NUGET_API_KEY -source http://nexus.steamware.net/repository/nuget-hosted'
- '& "$env:NUGET_PATH" push *$env:NUM_DEB.nupkg -Source http://nexus.steamware.net/repository/nuget-hosted'
@@ -389,35 +456,6 @@ EgwProxy.SqlDb:staging:
- '& "$env:NUGET_PATH" setapikey $NUGET_API_KEY -source http://nexus.steamware.net/repository/nuget-hosted'
- '& "$env:NUGET_PATH" push *$env:NUM_DEB.nupkg -Source http://nexus.steamware.net/repository/nuget-hosted'
EgwProxy.Gomba:staging:
stage: staging
needs: ["EgwProxy.Gomba:build"]
tags:
- win
variables:
CONFIG: Debug
APP_NAME: EgwProxy.Gomba
rules:
- if: $CI_COMMIT_BRANCH == 'develop'
changes:
- EgwProxy.Gomba/*
when: always
- if: $CI_COMMIT_BRANCH == 'SDK/Gomba'
changes:
- EgwProxy.Gomba/*
before_script:
- *nuget-fix
- '& "$env:NUGET_PATH" restore "$env:APP_NAME.sln" -verbosity quiet'
- *version-fix
- *nuspec-fix
script:
- '& "$env:MSBUILD_PATH" "$env:APP_NAME\$env:APP_NAME.csproj" -target:Build /p:Configuration=$env:CONFIG /p:Platform="Any CPU" /p:OutputPath=bin/$env:CONFIG /verbosity:minimal /m'
- '& Remove-Item *.nupkg'
- '& $env:NUGET_PATH pack "$env:APP_NAME.Debug.nuspec"'
- '& "$env:NUGET_PATH" setapikey $NUGET_API_KEY -source http://nexus.steamware.net/repository/nuget-hosted'
- '& "$env:NUGET_PATH" push *$env:NUM_DEB.nupkg -Source http://nexus.steamware.net/repository/nuget-hosted'
# --------------------------------
# RELEASE
# --------------------------------
@@ -443,7 +481,31 @@ EgwProxy.Ftp:build:release:
- '& "$env:MSBUILD_PATH" "$env:APP_NAME\$env:APP_NAME.csproj" -target:Build /p:Configuration=$env:CONFIG /p:Platform="Any CPU" /p:OutputPath=bin/$env:CONFIG /verbosity:minimal /m'
- '& Remove-Item *.nupkg'
- '& $env:NUGET_PATH pack "$env:APP_NAME.Release.nuspec"'
# - '& "$env:NUGET_PATH" pack "$env:APP_NAME\$env:APP_NAME.csproj" -properties Configuration=$env:CONFIG -Version $env:NUM_REL'
- '& "$env:NUGET_PATH" setapikey $NUGET_API_KEY -source http://nexus.steamware.net/repository/nuget-hosted'
- '& "$env:NUGET_PATH" push *$env:NUM_REL.nupkg -Source http://nexus.steamware.net/repository/nuget-hosted'
EgwProxy.Gomba:build:release:
stage: release
needs: ["EgwProxy.Gomba:build"]
tags:
- win
variables:
CONFIG: Release
APP_NAME: EgwProxy.Gomba
rules:
- if: $CI_COMMIT_BRANCH == 'master'
changes:
- EgwProxy.Gomba/*
when: always
before_script:
- *nuget-fix
- '& "$env:NUGET_PATH" restore "$env:APP_NAME.sln" -verbosity quiet'
- *version-fix
- *nuspec-fix
script:
- '& "$env:MSBUILD_PATH" "$env:APP_NAME\$env:APP_NAME.csproj" -target:Build /p:Configuration=$env:CONFIG /p:Platform="Any CPU" /p:OutputPath=bin/$env:CONFIG /verbosity:minimal /m'
- '& Remove-Item *.nupkg'
- '& $env:NUGET_PATH pack "$env:APP_NAME.Release.nuspec"'
- '& "$env:NUGET_PATH" setapikey $NUGET_API_KEY -source http://nexus.steamware.net/repository/nuget-hosted'
- '& "$env:NUGET_PATH" push *$env:NUM_REL.nupkg -Source http://nexus.steamware.net/repository/nuget-hosted'
@@ -493,7 +555,6 @@ EgwProxy.MultiCncLib:build:release:
- '& "$env:MSBUILD_PATH" "$env:APP_NAME\$env:APP_NAME.vbproj" -target:Build /p:Configuration=$env:CONFIG /p:Platform="Any CPU" /p:OutputPath=bin/$env:CONFIG /verbosity:minimal /m'
- '& Remove-Item *.nupkg'
- '& $env:NUGET_PATH pack "$env:APP_NAME.Release.nuspec"'
# - '& "$env:NUGET_PATH" pack "$env:APP_NAME\$env:APP_NAME.vbproj" -properties Configuration=$env:CONFIG -Version $env:NUM_REL'
- '& "$env:NUGET_PATH" setapikey $NUGET_API_KEY -source http://nexus.steamware.net/repository/nuget-hosted'
- '& "$env:NUGET_PATH" push *$env:NUM_REL.nupkg -Source http://nexus.steamware.net/repository/nuget-hosted'
@@ -521,6 +582,30 @@ EgwProxy.OsaiCncLib:build:release:
- '& "$env:NUGET_PATH" setapikey $NUGET_API_KEY -source http://nexus.steamware.net/repository/nuget-hosted'
- '& "$env:NUGET_PATH" push *$env:NUM_REL.nupkg -Source http://nexus.steamware.net/repository/nuget-hosted'
EgwProxy.Shelly:build:release:
stage: release
needs: ["EgwProxy.Shelly:build"]
tags:
- win
variables:
CONFIG: Release
APP_NAME: EgwProxy.Shelly
rules:
- if: $CI_COMMIT_BRANCH == 'master'
changes:
- EgwProxy.Shelly/*
before_script:
- *nuget-fix
- '& "$env:NUGET_PATH" restore "$env:APP_NAME.sln" -verbosity quiet'
- *version-fix
- *nuspec-fix
script:
- '& "$env:MSBUILD_PATH" "$env:APP_NAME\$env:APP_NAME.csproj" -target:Build /p:Configuration=$env:CONFIG /p:Platform="Any CPU" /p:OutputPath=bin/$env:CONFIG /verbosity:minimal /m'
- '& Remove-Item *.nupkg'
- '& $env:NUGET_PATH pack "$env:APP_NAME.Release.nuspec"'
- '& "$env:NUGET_PATH" setapikey $NUGET_API_KEY -source http://nexus.steamware.net/repository/nuget-hosted'
- '& "$env:NUGET_PATH" push *$env:NUM_REL.nupkg -Source http://nexus.steamware.net/repository/nuget-hosted'
EgwProxy.SqlDb:build:release:
stage: release
needs: ["EgwProxy.SqlDb:build"]
@@ -547,31 +632,6 @@ EgwProxy.SqlDb:build:release:
- '& "$env:NUGET_PATH" setapikey $NUGET_API_KEY -source http://nexus.steamware.net/repository/nuget-hosted'
- '& "$env:NUGET_PATH" push *$env:NUM_REL.nupkg -Source http://nexus.steamware.net/repository/nuget-hosted'
EgwProxy.Gomba:build:release:
stage: release
needs: ["EgwProxy.Gomba:build"]
tags:
- win
variables:
CONFIG: Release
APP_NAME: EgwProxy.Gomba
rules:
- if: $CI_COMMIT_BRANCH == 'master'
changes:
- EgwProxy.Gomba/*
when: always
before_script:
- *nuget-fix
- '& "$env:NUGET_PATH" restore "$env:APP_NAME.sln" -verbosity quiet'
- *version-fix
- *nuspec-fix
script:
- '& "$env:MSBUILD_PATH" "$env:APP_NAME\$env:APP_NAME.csproj" -target:Build /p:Configuration=$env:CONFIG /p:Platform="Any CPU" /p:OutputPath=bin/$env:CONFIG /verbosity:minimal /m'
- '& Remove-Item *.nupkg'
- '& $env:NUGET_PATH pack "$env:APP_NAME.Release.nuspec"'
- '& "$env:NUGET_PATH" setapikey $NUGET_API_KEY -source http://nexus.steamware.net/repository/nuget-hosted'
- '& "$env:NUGET_PATH" push *$env:NUM_REL.nupkg -Source http://nexus.steamware.net/repository/nuget-hosted'
# --------------------------------
# DocFx
# --------------------------------
@@ -594,6 +654,26 @@ EgwProxy.Ftp:docfx:
- docfx $env:APP_NAME/docfx.json
- mv $env:APP_NAME/_site "docfx"
- *DocReplica
EgwProxy.Gomba:docfx:
stage: docfx
needs: ["EgwProxy.Gomba:build"]
tags:
- win
variables:
APP_NAME: EgwProxy.Gomba
rules:
- if: $CI_COMMIT_BRANCH == 'master'
changes:
- EgwProxy.Gomba/*
when: always
before_script:
- *nuget-fix
- '& "$env:NUGET_PATH" restore "$env:APP_NAME.sln" -verbosity quiet'
script:
- docfx $env:APP_NAME/docfx.json
- mv $env:APP_NAME/_site "docfx"
- *DocReplica
EgwProxy.Icoel:docfx:
stage: docfx
@@ -654,7 +734,27 @@ EgwProxy.OsaiCncLib:docfx:
- docfx $env:APP_NAME/docfx.json
- mv $env:APP_NAME/_site "docfx"
- *DocReplica
EgwProxy.Shelly:docfx:
stage: docfx
needs: ["EgwProxy.Shelly:build"]
tags:
- win
variables:
APP_NAME: EgwProxy.Shelly
rules:
- if: $CI_COMMIT_BRANCH == 'master'
changes:
- EgwProxy.Shelly/*
when: always
before_script:
- *nuget-fix
- '& "$env:NUGET_PATH" restore "$env:APP_NAME.sln" -verbosity quiet'
script:
- docfx $env:APP_NAME/docfx.json
- mv $env:APP_NAME/_site "docfx"
- *DocReplica
EgwProxy.SqlDb:docfx:
stage: docfx
needs: ["EgwProxy.SqlDb:build"]
@@ -674,23 +774,3 @@ EgwProxy.SqlDb:docfx:
- docfx $env:APP_NAME/docfx.json
- mv $env:APP_NAME/_site "docfx"
- *DocReplica
EgwProxy.Gomba:docfx:
stage: docfx
needs: ["EgwProxy.Gomba:build"]
tags:
- win
variables:
APP_NAME: EgwProxy.Gomba
rules:
- if: $CI_COMMIT_BRANCH == 'master'
changes:
- EgwProxy.Gomba/*
when: always
before_script:
- *nuget-fix
- '& "$env:NUGET_PATH" restore "$env:APP_NAME.sln" -verbosity quiet'
script:
- docfx $env:APP_NAME/docfx.json
- mv $env:APP_NAME/_site "docfx"
- *DocReplica
+26
View File
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<package >
<metadata>
<id>EgwProxy.Shelly</id>
<version>#version#</version>
<title>EgwProxy.Shelly</title>
<authors>Samuele E. Locatelli, EgalWare</authors>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<license type="expression">MIT</license>
<description>Libreria per comunicazione con dispositivi Shelly x lettura dati stato/potenza (IOB-WIN-NEXT) - beta/unstable</description>
<releaseNotes>#releaseNotes#</releaseNotes>
<copyright>#copyright#</copyright>
<tags>EgwProxy.Shelly EgwProxy Shelly</tags>
<dependencies>
<dependency id="Flurl" version="4.0.0" />
<dependency id="Flurl.Http" version="4.0.2" />
<dependency id="Newtonsoft.Json" version="13.0.3" />
<dependency id="NLog" version="5.1.3" />
</dependencies>
</metadata>
<files>
<file src="EgwProxy.Shelly\bin\Debug\EgwProxy*.dll" target="lib" />
<file src="EgwProxy.Shelly\bin\Debug\EgwProxy*.config" target="lib" />
<file src="EgwProxy.Shelly\bin\Debug\EgwProxy*.pdb" target="lib" />
</files>
</package>
+25
View File
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<package >
<metadata>
<id>EgwProxy.Shelly</id>
<version>#version#</version>
<title>EgwProxy.Shelly</title>
<authors>Samuele E. Locatelli, EgalWare</authors>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<license type="expression">MIT</license>
<description>Libreria per comunicazione con dispositivi Shelly x lettura dati stato/potenza (IOB-WIN-NEXT)</description>
<releaseNotes>#releaseNotes#</releaseNotes>
<copyright>#copyright#</copyright>
<tags>EgwProxy.Shelly EgwProxy Shelly</tags>
<dependencies>
<dependency id="Flurl" version="4.0.0" />
<dependency id="Flurl.Http" version="4.0.2" />
<dependency id="Newtonsoft.Json" version="13.0.3" />
<dependency id="NLog" version="5.1.3" />
</dependencies>
</metadata>
<files>
<file src="EgwProxy.Shelly\bin\Release\EgwProxy*.dll" target="lib" />
<file src="EgwProxy.Shelly\bin\Release\EgwProxy*.config" target="lib" />
</files>
</package>
+17
View File
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" />
</startup>
<appSettings>
<add key="testFile" value="testSetup.json" />
</appSettings>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{081AB7E7-4C36-49D7-9343-2C567F324B74}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>EgwProxy.Shelly.Test</RootNamespace>
<AssemblyName>EgwProxy.Shelly.Test</AssemblyName>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TestSetup.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="conf\.placeholder" />
<None Include="conf\testSetup.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\EgwProxy.Shelly\EgwProxy.Shelly.csproj">
<Project>{69b1068b-e53f-4e54-9a3d-1031f84889ba}</Project>
<Name>EgwProxy.Shelly</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
+172
View File
@@ -0,0 +1,172 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using EgwProxy.Shelly.Clients;
using System.Net.Http;
using EgwProxy.Shelly.Options;
using System.Threading;
namespace EgwProxy.Shelly.Test
{
internal class Program
{
/// <summary>
/// Helper separatore dash
/// </summary>
private const string separator = "------------------------";
private static Stopwatch sw = new Stopwatch();
/// <summary>
/// legge conf in formato stringa
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
protected static string ReadSetting(string key)
{
string answ = "";
try
{
answ = $"{ConfigurationManager.AppSettings[key]}" ?? "";
}
catch (Exception exc)
{
Console.Write("Eccezione in ReadSettings");
Console.Write(exc.Message);
}
return answ;
}
//// caffè
//private string shellyAddr = "10.74.81.72";
//APC
private string shellyAddr = "10.74.81.71";
/// <summary>
/// Programma principale
/// </summary>
/// <param name="args"></param>
private static void Main(string[] args)
{
Console.WriteLine(separator);
Console.WriteLine("Test Shelly Client");
Console.WriteLine(separator);
Console.WriteLine();
string exePath = System.Reflection.Assembly.GetExecutingAssembly().Location;
string BaseDirectory = System.IO.Path.GetDirectoryName(exePath);
string testFile = Path.Combine(BaseDirectory, "conf", ReadSetting("testFile"));
if (!string.IsNullOrEmpty(testFile))
{
Console.WriteLine(separator);
Console.WriteLine($"Mode json ({testFile})");
Console.WriteLine(separator);
Console.WriteLine();
if (File.Exists(testFile))
{
var rawData = File.ReadAllText(testFile);
if (!string.IsNullOrEmpty(rawData))
{
TestSetup testConf = new TestSetup();
try
{
testConf = JsonConvert.DeserializeObject<TestSetup>(rawData);
}
catch
{ }
// setup devAddr
Shelly1PmOptions options = new Shelly1PmOptions()
{
DefaultTimeout = TimeSpan.FromSeconds(testConf.tOutSec),
ServerUri = new Uri($"http://{testConf.devAddr}/rpc")
};
Shelly1PmClient shelly = new Shelly1PmClient(new HttpClient(), options);
// test chiamata completa
serverTest(shelly);
bool doRepeat = true;
while (doRepeat)
{
// eseguo per ogni step
foreach (var item in testConf.steps)
{
// ripeto per il num di volte richieste...
for (int i = 0; i < item.numRep; i++)
{
Console.WriteLine(separator);
Console.WriteLine($"Rep: {i + 1}");
Console.WriteLine(separator);
string esitoStep = "";
sw.Restart();
switch (item.action)
{
case stepType.getFullStatus:
var respFull = Task.Run(() => shelly.GetStatus(CancellationToken.None)).Result;
if (respFull.IsSuccess)
{
esitoStep = JsonConvert.SerializeObject(respFull.Value, Formatting.Indented);
}
else
{
esitoStep = "Errore in GetStatus";
}
break;
case stepType.getSwitchStatus:
var respSwitch = Task.Run(() => shelly.GetSwitchStatus(CancellationToken.None, 0)).Result;
if (respSwitch.IsSuccess)
{
esitoStep = JsonConvert.SerializeObject(respSwitch.Value, Formatting.Indented);
}
else
{
esitoStep = "Errore in GetSwitchStatus";
}
break;
default:
esitoStep = "Action not managed: skipping";
break;
}
sw.Stop();
Console.WriteLine(esitoStep);
Console.WriteLine(separator);
Console.WriteLine($"Elapsed: {sw.Elapsed.TotalMilliseconds:N3}ms");
Console.WriteLine(separator);
Console.WriteLine();
Thread.Sleep(item.waitTime);
}
Console.WriteLine($"------ Done Step {item.id} ------");
}
Console.WriteLine("Do you want to repeat from the beginnning? esc to close");
ConsoleKeyInfo answ = Console.ReadKey();
doRepeat = answ.Key != ConsoleKey.Escape;
}
}
}
}
}
private static void serverTest(Shelly1PmClient shellyClient)
{
Console.WriteLine(separator);
// registro ed eseguo chiamata in modalità sincrona
sw.Restart();
var response = Task.Run(() => shellyClient.GetStatus(CancellationToken.None)).Result;
sw.Stop();
Console.WriteLine($"CallSuccess: {response.IsSuccess}");
if (response.Value != null)
{
Console.WriteLine(separator);
Console.WriteLine(JsonConvert.SerializeObject(response.Value, Formatting.Indented));
Console.WriteLine(separator);
Console.WriteLine($"Elapsed: {sw.Elapsed.TotalMilliseconds:N3}ms");
Console.WriteLine(separator);
Console.WriteLine();
}
}
}
}
@@ -0,0 +1,33 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("EgwProxy.Shelly.Test")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("EgwProxy.Shelly.Test")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("081ab7e7-4c36-49d7-9343-2c567f324b74")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
+36
View File
@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EgwProxy.Shelly.Test
{
public class TestSetup
{
public string devAddr { get; set; } = "";
public int tOutSec{ get; set; } = 5;
public List<singleStep> steps { get; set; }
}
public class singleStep
{
public string id { get; set; } = "00";
public string description { get; set; } = "00";
public stepType action { get; set; } = stepType.none;
public int numRep { get; set; } = 1;
public int waitTime { get; set; } = 1000;
public List<string> paramList { get; set; } = new List<string>();
}
public enum stepType
{
none,
getFullStatus,
getSwitchStatus
}
}
+1
View File
@@ -0,0 +1 @@

+13
View File
@@ -0,0 +1,13 @@
{
"devAddr": "10.74.81.71",
"steps": [
{
"id": "01",
"description": "Test SwitchStatus",
"action": "getSwitchStatus",
"numRep": 5,
"waitTime": 500,
"paramList": []
}
]
}
+4
View File
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net462" />
</packages>
+31
View File
@@ -0,0 +1,31 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.12.35527.113
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EgwProxy.Shelly", "EgwProxy.Shelly\EgwProxy.Shelly.csproj", "{69B1068B-E53F-4E54-9A3D-1031F84889BA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EgwProxy.Shelly.Test", "EgwProxy.Shelly.Test\EgwProxy.Shelly.Test.csproj", "{081AB7E7-4C36-49D7-9343-2C567F324B74}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{69B1068B-E53F-4E54-9A3D-1031F84889BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{69B1068B-E53F-4E54-9A3D-1031F84889BA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{69B1068B-E53F-4E54-9A3D-1031F84889BA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{69B1068B-E53F-4E54-9A3D-1031F84889BA}.Release|Any CPU.Build.0 = Release|Any CPU
{081AB7E7-4C36-49D7-9343-2C567F324B74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{081AB7E7-4C36-49D7-9343-2C567F324B74}.Debug|Any CPU.Build.0 = Debug|Any CPU
{081AB7E7-4C36-49D7-9343-2C567F324B74}.Release|Any CPU.ActiveCfg = Release|Any CPU
{081AB7E7-4C36-49D7-9343-2C567F324B74}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E2472E21-58D3-4EAD-BC4A-BC3915B18BEF}
EndGlobalSection
EndGlobal
+12
View File
@@ -0,0 +1,12 @@
using EgwProxy.Shelly.DTO;
using System;
using System.Threading;
using System.Threading.Tasks;
namespace EgwProxy.Shelly.Clients
{
public interface IShelly1
{
Task<ShellyResult<ShellyGen2StatusDto>> GetStatus(CancellationToken cancellationToken, TimeSpan? timeout = null);
}
}
+12
View File
@@ -0,0 +1,12 @@
using EgwProxy.Shelly.DTO;
using System;
using System.Threading;
using System.Threading.Tasks;
namespace EgwProxy.Shelly.Clients
{
public interface IShelly1Pm
{
Task<ShellyResult<Shelly1PmStatusDto>> GetStatus(CancellationToken cancellationToken, TimeSpan? timeout = null);
}
}
+24
View File
@@ -0,0 +1,24 @@
using EgwProxy.Shelly.DTO;
using EgwProxy.Shelly.Options;
using Flurl;
using System;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
namespace EgwProxy.Shelly.Clients
{
public class Shelly1Client : ShellyClientBase, IShelly1
{
public Shelly1Client(HttpClient httpClient, Shelly1Options shelly1Options) : base(httpClient, shelly1Options)
{
}
public async Task<ShellyResult<ShellyGen2StatusDto>> GetStatus(CancellationToken cancellationToken, TimeSpan? timeout = null)
{
var endpoint = ServerUri.AppendPathSegment("status");
var requestMessage = new HttpRequestMessage(HttpMethod.Get, endpoint);
return await ExecuteRequestAsync<ShellyGen2StatusDto>(requestMessage, cancellationToken, timeout);
}
}
}
@@ -0,0 +1,31 @@
using EgwProxy.Shelly.DTO;
using EgwProxy.Shelly.Options;
using Flurl;
using System;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
namespace EgwProxy.Shelly.Clients
{
public class Shelly1PmClient : ShellyClientBase, IShelly1Pm
{
public Shelly1PmClient(HttpClient httpClient, Shelly1PmOptions shellyOptions) : base(httpClient, shellyOptions)
{
}
public async Task<ShellyResult<Shelly1PmStatusDto>> GetStatus(CancellationToken cancellationToken, TimeSpan? timeout = null)
{
var endpoint = ServerUri.AppendPathSegment("Shelly.GetStatus");
var requestMessage = new HttpRequestMessage(HttpMethod.Get, endpoint);
return await ExecuteRequestAsync<Shelly1PmStatusDto>(requestMessage, cancellationToken, timeout);
}
public async Task<ShellyResult<DTO.Shelly1PM.SwitchDto>> GetSwitchStatus(CancellationToken cancellationToken, int id, TimeSpan? timeout = null)
{
var endpoint = ServerUri.AppendPathSegment("Switch.GetStatus").AppendQueryParam("id",id);
var requestMessage = new HttpRequestMessage(HttpMethod.Get, endpoint);
return await ExecuteRequestAsync<DTO.Shelly1PM.SwitchDto>(requestMessage, cancellationToken, timeout);
}
}
}
@@ -0,0 +1,84 @@
using EgwProxy.Shelly.Options;
using Newtonsoft.Json;
using System;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace EgwProxy.Shelly.Clients
{
public abstract class ShellyClientBase
{
protected readonly HttpClient ShellyHttpClient;
private readonly IShellyCommonOptions _shellyCommonOptions;
protected readonly Uri ServerUri;
protected TimeSpan DefaultTimeout = TimeSpan.FromSeconds(5);
public ShellyClientBase(HttpClient httpClient, IShellyCommonOptions shellyCommonOptions)
{
if (httpClient == null) throw new ArgumentNullException(nameof(httpClient));
if (shellyCommonOptions == null) throw new ArgumentNullException(nameof(shellyCommonOptions));
ShellyHttpClient = httpClient;
_shellyCommonOptions = shellyCommonOptions;
ServerUri = shellyCommonOptions.ServerUri;
if (shellyCommonOptions.DefaultTimeout.HasValue)
{
DefaultTimeout = shellyCommonOptions.DefaultTimeout.Value;
}
}
protected async Task<ShellyResult<T>> ExecuteRequestAsync<T>(HttpRequestMessage httpRequestMessage,
CancellationToken cancellationToken, TimeSpan? timeout = null)
{
timeout = timeout ?? DefaultTimeout;
using (var timeoutTokenSource = new CancellationTokenSource(timeout.Value))
{
var authenticationString = $"{_shellyCommonOptions.UserName}:{_shellyCommonOptions.Password}";
var base64EncodedAuthenticationString = Convert.ToBase64String(Encoding.ASCII.GetBytes(authenticationString));
httpRequestMessage.Headers.Authorization = new AuthenticationHeaderValue("Basic", base64EncodedAuthenticationString);
var linkedTokenSource = CancellationTokenSource.CreateLinkedTokenSource(timeoutTokenSource.Token, cancellationToken);
var response = await ShellyHttpClient.SendAsync(httpRequestMessage, linkedTokenSource.Token);
if (response.StatusCode == 0)
{
// Status code of 0 means timeout reached
return ShellyResult<T>.TransientFailure("Device did not respond within timeout period");
}
if (response.StatusCode == HttpStatusCode.ServiceUnavailable)
{
return ShellyResult<T>.TransientFailure("Device responded with ServiceUnavailable");
}
if (response.StatusCode == HttpStatusCode.NotFound)
{
return ShellyResult<T>.Success(default, "Device responded with NotFound");
}
if (response.StatusCode != HttpStatusCode.OK)
{
return ShellyResult<T>.Failure($"Device responded with http status code {response.StatusCode}");
}
return await HandleOkResponse<T>(response);
}
}
protected virtual async Task<ShellyResult<T>> HandleOkResponse<T>(HttpResponseMessage response)
{
var readAsStringAsync = await response.Content.ReadAsStringAsync();
var shelly1Status = JsonConvert.DeserializeObject<T>(readAsStringAsync);
return ShellyResult<T>.Success(shelly1Status);
}
}
}
+13
View File
@@ -0,0 +1,13 @@
using Newtonsoft.Json;
namespace EgwProxy.Shelly.DTO.Shelly1PM
{
public class BaseServiceDto
{
/// <summary>
/// Connection State
/// </summary>
[JsonProperty("connected")]
public bool Connected { get; set; }
}
}
+14
View File
@@ -0,0 +1,14 @@
using EgwProxy.Shelly.DTO.Shelly1PM;
using Newtonsoft.Json;
namespace EgwProxy.Shelly.DTO
{
public class CloudDto :BaseServiceDto
{
/// <summary>
/// Define if service is enabled
/// </summary>
[JsonProperty("enabled")]
public bool Enabled { get; set; } = true;
}
}
@@ -0,0 +1,28 @@
using Newtonsoft.Json;
namespace EgwProxy.Shelly.DTO.Shelly1PM
{
/// <summary>
/// Energy Info
/// </summary>
public class EnergyDto
{
/// <summary>
/// Total returned energy consumed in Watt-hours
/// </summary>
[JsonProperty("total")]
public double Total { get; set; }
/// <summary>
/// Returned energy in Milliwatt-hours for the last three complete minutes. The 0-th element indicates the counts accumulated during the minute preceding minute_ts. Present only if the device clock is synced.
/// </summary>
[JsonProperty("by_minute")]
public double[] LastByMinute { get; set; }
/// <summary>
/// Unix timestamp marking the start of the current minute (in UTC).
/// </summary>
[JsonProperty("minute_ts")]
public long TimeStamp { get; set; }
}
}
+22
View File
@@ -0,0 +1,22 @@
using Newtonsoft.Json;
namespace EgwProxy.Shelly.DTO.Shelly1PM
{
/// <summary>
/// Input info
/// </summary>
public class InputDto
{
/// <summary>
/// Id of the Input component instance
/// </summary>
[JsonProperty("id")]
public int Id { get; set; }
/// <summary>
/// Current State(only for type switch, button) State of the input (null if the input instance is stateless, i.e. for type button)
/// </summary>
[JsonProperty("state")]
public bool State { get; set; }
}
}
@@ -0,0 +1,67 @@
using Newtonsoft.Json;
namespace EgwProxy.Shelly.DTO.Shelly1PM
{
public class SwitchDto
{
/// <summary>
/// Id of the Switch component instance
/// </summary>
[JsonProperty("id")]
public int Id { get; set; } = 0;
/// <summary>
/// Source of the last command, for example: init, WS_in, http, ...
/// </summary>
[JsonProperty("source")]
public string Source { get; set; } = "";
/// <summary>
/// Output status: rue if the output channel is currently on, false otherwise
/// </summary>
[JsonProperty("output")]
public bool Output { get; set; }
/// <summary>
/// Last measured instantaneous active power(in Watts) delivered to the attached load(shown if applicable)
/// </summary>
[JsonProperty("apower")]
public double Power { get; set; }
/// <summary>
/// Last measured voltage in Volts (shown if applicable)
/// </summary>
[JsonProperty("voltage")]
public double Voltage { get; set; }
/// <summary>
/// Last measured current in Amperes (shown if applicable)
/// </summary>
[JsonProperty("current")]
public double Current { get; set; }
/// <summary>
/// Information about the active energy counter (shown if applicable)
/// </summary>
[JsonProperty("aenergy")]
public EnergyDto ActEnergy { get; set; }
/// <summary>
/// Information about the returned active energy counter * (shown if applicable)
/// </summary>
[JsonProperty("ret_aenergy")]
public EnergyDto RetEnergy { get; set; }
/// <summary>
/// Information about the temperature (shown if applicable)
/// </summary>
[JsonProperty("temperature")]
public TemperatureDto Temperature { get; set; }
/// <summary>
/// Error conditions occurred. May contain overtemp, overpower, overvoltage, undervoltage, (shown if at least one error is present)
/// </summary>
[JsonProperty("errors")]
public string[] Errors { get; set; }
}
}
+25
View File
@@ -0,0 +1,25 @@
using EgwProxy.Shelly.DTO.Shelly1PM;
using Newtonsoft.Json;
namespace EgwProxy.Shelly.DTO
{
/// <summary>
/// Extended information for the Shelly1PM
/// https://shelly-api-docs.shelly.cloud/gen2/Devices/Gen3/Shelly1PMG3
/// </summary>
public class Shelly1PmStatusDto : ShellyGen2StatusDto
{
/// <summary>
/// Input channel
/// </summary>
[JsonProperty("input:0")]
public InputDto Input { get; set; }
/// <summary>
/// Switch 0 data
/// </summary>
[JsonProperty("switch:0")]
public SwitchDto Switch { get; set; }
}
}
@@ -0,0 +1,44 @@
using EgwProxy.Shelly.DTO.Shelly1PM;
using Newtonsoft.Json;
namespace EgwProxy.Shelly.DTO
{
/// <summary>
/// Shelly Gen2 device status data
/// https://shelly-api-docs.shelly.cloud/gen2/#status
/// </summary>
public class ShellyGen2StatusDto
{
/// <summary>
/// WiFi data
/// </summary>
[JsonProperty("wifi")]
public WifiDto WiFiStatus { get; set; }
/// <summary>
/// Shelly Cloud state
/// </summary>
[JsonProperty("cloud")]
public CloudDto ShellyCloud { get; set; }
/// <summary>
/// MQTT queue state
/// </summary>
[JsonProperty("mqtt")]
public BaseServiceDto MQTT { get; set; }
/// <summary>
/// Sys Info data
/// </summary>
[JsonProperty("sys")]
public SysDto SysInfo { get; set; }
/// <summary>
/// WS state
/// </summary>
[JsonProperty("ws")]
public BaseServiceDto WebSocket { get; set; }
}
}
+101
View File
@@ -0,0 +1,101 @@
using Newtonsoft.Json;
namespace EgwProxy.Shelly.DTO
{
/// <summary>
/// System Info
/// </summary>
public class SysDto
{
/// <summary>
/// Mac address of the device
/// </summary>
[JsonProperty("mac")]
public string Mac { get; set; } = "";
/// <summary>
/// True if restart is required, false otherwise
/// </summary>
[JsonProperty("restart_required")]
public bool RestartRequired { get; set; } = false;
/// <summary>
/// Current time in the format HH:MM (24-hour time format in the current timezone with leading zero). null when time is not synced from NTP server.
/// </summary>
[JsonProperty("time")]
public string Time { get; set; } = "";
/// <summary>
/// Unix timestamp (in UTC), null when time is not synced from NTP server.
/// </summary>
[JsonProperty("unixtime")]
public int UnixTime { get; set; } = 0;
/// <summary>
/// Time in seconds since last reboot
/// </summary>
[JsonProperty("uptime")]
public int Uptime { get; set; } = 0;
/// <summary>
/// Total size of the RAM in the system in Bytes
/// </summary>
[JsonProperty("ram_size")]
public int RamSize { get; set; } = 0;
/// <summary>
/// Size of the free RAM in the system in Bytes
/// </summary>
[JsonProperty("ram_free")]
public int RamFree { get; set; } = 0;
/// <summary>
/// Total size of the file system in Bytes
/// </summary>
[JsonProperty("fs_size")]
public int FSSize { get; set; } = 0;
/// <summary>
/// Size of the free file system in Bytes
/// </summary>
[JsonProperty("fs_free")]
public int FSFree { get; set; } = 0;
/// <summary>
/// Configuration revision number
/// </summary>
[JsonProperty("cfg_rev")]
public int CfgRev { get; set; } = 0;
/// <summary>
/// KVS (Key-Value Store) revision number
/// </summary>
[JsonProperty("kvs_rev")]
public int KvsRev { get; set; } = 0;
/// <summary>
/// Schedules revision number, present if schedules are enabled
/// </summary>
[JsonProperty("schedule_rev")]
public int ScheduleRev { get; set; } = 0;
/// <summary>
/// Webhooks revision number, present if webhooks are enabled
/// </summary>
[JsonProperty("webhook_rev")]
public int WebhookRev { get; set; } = 0;
/// <summary>
/// Webhooks revision number, present if webhooks are enabled
/// </summary>
[JsonProperty("available_updates")]
public UpdateDto AvailUpdates { get; set; }
/// <summary>
/// Information about reset type and cause
/// </summary>
[JsonProperty("reset_reason")]
public int ResetReason { get; set; } = 0;
}
}
+19
View File
@@ -0,0 +1,19 @@
using Newtonsoft.Json;
namespace EgwProxy.Shelly.DTO
{
public class TemperatureDto
{
/// <summary>
/// Temperature in Celsius (null if the temperature is out of the measurement range)
/// </summary>
[JsonProperty("tC")]
public double? Celsius { get; set; }
/// <summary>
/// Temperature in Fahrenheit (null if the temperature is out of the measurement range)
/// </summary>
[JsonProperty("tF")]
public double? Fahrenheit { get; set; }
}
}
+22
View File
@@ -0,0 +1,22 @@
using Newtonsoft.Json;
namespace EgwProxy.Shelly.DTO
{
/// <summary>
/// Info about sw update
/// </summary>
public class UpdateDto
{
/// <summary>
/// Shown only if beta update is available
/// </summary>
[JsonProperty("beta")]
public VersDto Beta { get; set; }
/// <summary>
/// Shown only if beta update is available
/// </summary>
[JsonProperty("stable")]
public VersDto Stable { get; set; }
}
}
+13
View File
@@ -0,0 +1,13 @@
using Newtonsoft.Json;
namespace EgwProxy.Shelly.DTO
{
public class VersDto
{
/// <summary>
/// Version of the new firmware
/// </summary>
[JsonProperty("version")]
public string Version { get; set; } = "";
}
}
+40
View File
@@ -0,0 +1,40 @@
using Newtonsoft.Json;
namespace EgwProxy.Shelly.DTO
{
/// <summary>
/// WiFi status info
/// </summary>
public class WifiDto
{
/// <summary>
/// Ip of the device in the network (null if disconnected)
/// </summary>
[JsonProperty("sta_ip")]
public string StaIp { get; set; } = "";
/// <summary>
/// Status of the connection. Range of values: disconnected, connecting, connected, got ip
/// </summary>
[JsonProperty("status")]
public string Status { get; set; } = "";
/// <summary>
/// SSID of the network (null in case of hidden network)
/// </summary>
[JsonProperty("ssid")]
public string SSID { get; set; } = "";
/// <summary>
/// Strength of the signal in dBms
/// </summary>
[JsonProperty("rssi")]
public int RSSI { get; set; } = 0;
/// <summary>
/// Number of clients connected to the access point. Present only when AP is enabled and range extender functionality is present and enabled.
/// </summary>
[JsonProperty("ap_client_count")]
public int NumClients { get; set; } = 0;
}
}
+119
View File
@@ -0,0 +1,119 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{69B1068B-E53F-4E54-9A3D-1031F84889BA}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>EgwProxy.Shelly</RootNamespace>
<AssemblyName>EgwProxy.Shelly</AssemblyName>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Flurl, Version=4.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Flurl.4.0.0\lib\net461\Flurl.dll</HintPath>
</Reference>
<Reference Include="Flurl.Http, Version=4.0.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Flurl.Http.4.0.2\lib\net461\Flurl.Http.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.6.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.Core" />
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Text.Encodings.Web, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Encodings.Web.6.0.0\lib\net461\System.Text.Encodings.Web.dll</HintPath>
</Reference>
<Reference Include="System.Text.Json, Version=6.0.0.4, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Json.6.0.4\lib\net461\System.Text.Json.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net461\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Clients\IShelly1.cs" />
<Compile Include="Clients\IShelly1Pm.cs" />
<Compile Include="Clients\Shelly1Client.cs" />
<Compile Include="Clients\Shelly1PmClient.cs" />
<Compile Include="Clients\ShellyClientBase.cs" />
<Compile Include="DTO\BaseServiceDto.cs" />
<Compile Include="DTO\CloudDto.cs" />
<Compile Include="DTO\Shelly1PmStatusDto.cs" />
<Compile Include="DTO\Shelly1PM\EnergyDto.cs" />
<Compile Include="DTO\Shelly1PM\InputDto.cs" />
<Compile Include="DTO\Shelly1PM\SwitchDto.cs" />
<Compile Include="DTO\ShellyGen2StatusDto.cs" />
<Compile Include="DTO\SysDto.cs" />
<Compile Include="DTO\TemperatureDto.cs" />
<Compile Include="DTO\UpdateDto.cs" />
<Compile Include="DTO\VersDto.cs" />
<Compile Include="DTO\WifiDto.cs" />
<Compile Include="Options\IShellyAuthOptions.cs" />
<Compile Include="Options\IShellyCommonOptions.cs" />
<Compile Include="Options\Shelly1Options.cs" />
<Compile Include="Options\Shelly1PmOptions.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ShellyResult.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\System.Text.Json.6.0.4\build\System.Text.Json.targets" Condition="Exists('..\packages\System.Text.Json.6.0.4\build\System.Text.Json.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\System.Text.Json.6.0.4\build\System.Text.Json.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\System.Text.Json.6.0.4\build\System.Text.Json.targets'))" />
</Target>
</Project>
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EgwProxy.Shelly.Options
{
/// <summary>
/// Common authentication options across all shelly devices
/// </summary>
public interface IShellyAuthOptions
{
string UserName { get; }
string Password { get; }
}
}
@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EgwProxy.Shelly.Options
{
/// <summary>
/// Common options across all shelly devices
/// </summary>
public interface IShellyCommonOptions : IShellyAuthOptions
{
/// <summary>
/// URI for the Shelly device
/// </summary>
Uri ServerUri { get; }
/// <summary>
/// Default timeout for HTTP requests if a specific timeout is not supplied
/// </summary>
TimeSpan? DefaultTimeout { get; }
}
}
+21
View File
@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EgwProxy.Shelly.Options
{
public class Shelly1Options : IShellyCommonOptions
{
public Uri ServerUri { get; set; }
public TimeSpan? DefaultTimeout { get; set; }
public string UserName { get; set; }
public string Password { get; set; }
public Shelly1Options()
{
DefaultTimeout = null;
}
}
}
@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EgwProxy.Shelly.Options
{
public class Shelly1PmOptions : IShellyCommonOptions
{
public Uri ServerUri { get; set; }
public TimeSpan? DefaultTimeout { get; set; }
public string UserName { get; set; }
public string Password { get; set; }
public Shelly1PmOptions()
{
DefaultTimeout = null;
}
}
}
@@ -0,0 +1,33 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("EgwProxy.Shelly")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("EgwProxy.Shelly")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("69b1068b-e53f-4e54-9a3d-1031f84889ba")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
+94
View File
@@ -0,0 +1,94 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EgwProxy.Shelly
{
public class ShellyResult<T>
{
#region Public Properties
/// <summary>
/// Indicates the client request has failed
/// </summary>
public bool IsFailure => !IsSuccess;
/// <summary>
/// Indicates the client request has completed successfully
/// </summary>
public bool IsSuccess
{
get
{
_successChecked = true;
return _success;
}
}
/// <summary>
/// Indicates if the reason for failure is transient
/// </summary>
public bool IsTransient { get; private set; }
/// <summary>
/// Any message that accompanies this result
/// </summary>
public string Message { get; }
public T Value
{
get
{
if (!_successChecked)
{
throw new InvalidOperationException("Cannot access value of result without checking success first");
}
return _value;
}
}
#endregion Public Properties
#region Public Methods
public static ShellyResult<T> Failure(string message = null)
{
return new ShellyResult<T>(default, success: false, isTransient: false, message);
}
public static ShellyResult<T> Success(T value, string message = null)
{
return new ShellyResult<T>(value, true, false, message);
}
public static ShellyResult<T> TransientFailure(string message = null)
{
return new ShellyResult<T>(default, success: false, isTransient: true, message);
}
#endregion Public Methods
#region Private Fields
private bool _success = false;
private bool _successChecked = false;
private T _value;
#endregion Private Fields
#region Private Constructors
private ShellyResult(T value, bool success, bool isTransient, string message = null)
{
_value = value;
_success = success;
IsTransient = isTransient;
Message = message;
}
#endregion Private Constructors
}
}
+11
View File
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
+69
View File
@@ -0,0 +1,69 @@
{
"metadata": [
{
"src": [
{
"files": [
"*.csproj",
"*.vbproj"
],
"cwd": ".",
"exclude": [
"**/obj/**",
"**/bin/**",
"_site/**"
]
}
],
"dest": "obj/api"
}
],
"build": {
"content": [
{
"files": [
"api/**.yml"
],
"cwd": "obj"
},
{
"files": [
"api/*.md",
"articles/**.md",
"toc.yml",
"*.md"
],
"exclude": [
"obj/**",
"_site/**"
]
}
],
"resource": [
{
"files": [
"images/**"
],
"exclude": [
"obj/**",
"_site/**"
]
}
],
"overwrite": [
{
"files": [
"apidoc/**.md"
],
"exclude": [
"obj/**",
"_site/**"
]
}
],
"dest": "_site",
"template": [
"default"
]
}
}
+19
View File
@@ -0,0 +1,19 @@
# EgwProxy.Shelly Library
Documentazione relativa alla libreria di interfaccia con sistemi Shelly x controllo domotico e del consumo energetico.
Disponibile in forma di pacchetto nuget sul repo aziendale nexus.steamware.net: i pacchetti sono disponibili all'indirizzo
https://nexus.steamware.net/#browse/browse:nuget-hosted
Vedere la sezione Articles per maggiori informazioni sulle definizioni, l'impiego ed esempi.
L'oggetot id base è **EgwProxy.Shelly.Clients.* **
## Articles
Per maggiori dettagli, definizioni e demo funzionamento si rimanda alla sezione Articles
## Api
Per ogni dettaglio e riferimento alla libreria si rimanda alla sezione Api Documentation
+15
View File
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Flurl" version="4.0.0" targetFramework="net462" />
<package id="Flurl.Http" version="4.0.2" targetFramework="net462" />
<package id="Microsoft.Bcl.AsyncInterfaces" version="6.0.0" targetFramework="net462" />
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net462" />
<package id="System.Buffers" version="4.5.1" targetFramework="net462" />
<package id="System.Memory" version="4.5.4" targetFramework="net462" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net462" />
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net462" />
<package id="System.Text.Encodings.Web" version="6.0.0" targetFramework="net462" />
<package id="System.Text.Json" version="6.0.4" targetFramework="net462" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net462" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net462" />
</packages>
+6
View File
@@ -0,0 +1,6 @@
- name: Articles
href: articles/
- name: API Documentation
href: obj/api/
homepage: api/index.md