Skip to content

Commit

Permalink
Merge pull request #133 from pkuehnel/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
pkuehnel authored Jul 3, 2022
2 parents 5c946ce + dd71095 commit 2500926
Show file tree
Hide file tree
Showing 81 changed files with 2,390 additions and 161 deletions.
31 changes: 30 additions & 1 deletion .github/workflows/alphaRelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
push: true
tags: pkuehnel/smartteslaampsetter:alpha

SmaEnergymeterplugin:
SmaEnergymeterPlugin:
name: Building SMAPlugin Image
runs-on: ubuntu-latest

Expand Down Expand Up @@ -70,3 +70,32 @@ jobs:
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
tags: pkuehnel/smartteslaampsettersmaplugin:alpha

SolarEdgePlugin:
name: Building SolarEdgePlugin Image
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Buildx
id: buildx
uses: docker/setup-buildx-action@v1

- name: DockerHub login
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASS}}

- name: Build and push SolarEdgePlugin
uses: docker/build-push-action@v2
with:
file: ./Plugins.SolarEdge/Dockerfile
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
tags: pkuehnel/smartteslaampsettersolaredgeplugin:alpha
31 changes: 30 additions & 1 deletion .github/workflows/edgeRelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
push: true
tags: pkuehnel/smartteslaampsetter:edge

SmaEnergymeterplugin:
SmaEnergymeterPlugin:
name: Building SMAPlugin Image
runs-on: ubuntu-latest

Expand Down Expand Up @@ -72,3 +72,32 @@ jobs:
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
tags: pkuehnel/smartteslaampsettersmaplugin:edge

SolarEdgePlugin:
name: Building SolarEdgePlugin Image
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Buildx
id: buildx
uses: docker/setup-buildx-action@v1

- name: DockerHub login
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASS}}

- name: Build and push SolarEdgePlugin
uses: docker/build-push-action@v2
with:
file: ./Plugins.SolarEdge/Dockerfile
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
tags: pkuehnel/smartteslaampsettersolaredgeplugin:edge
56 changes: 56 additions & 0 deletions .github/workflows/versionRelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,22 @@ jobs:
# Delete output directory
rm -r "$release_name"
- name: Build Plugins.SolarEdge
shell: bash
run: |
# Define some variables for things we need
tag=$(git describe --tags --abbrev=0)
release_name="Plugins.SolarEdge-$tag-${{ matrix.kind }}"
# Build everything
dotnet publish Plugins.SolarEdge/Plugins.SolarEdge.csproj --runtime "${{ matrix.kind }}" -c Release -o "$release_name"
# Pack files
tar czvf "${release_name}.tar.gz" "$release_name"
# Delete output directory
rm -r "$release_name"
- name: Publish
uses: softprops/action-gh-release@v1
with:
Expand Down Expand Up @@ -157,4 +173,44 @@ jobs:
file: ./Plugins.SmaEnergymeter/Dockerfile
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
tags: ${{ steps.meta.outputs.tags }}

releaseDockerLatestSolarEdgeplugin:
name: Building SolarEdgePlugin Image
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
# list of Docker images to use as base name for tags
images: |
pkuehnel/smartteslaampsettersolaredgeplugin
# generate Docker tags based on the following events/attributes
tags: |
type=semver,pattern={{version}}
- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Buildx
id: buildx
uses: docker/setup-buildx-action@v1

- name: DockerHub login
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASS}}

- name: Build and push SolarEdgePlugin
uses: docker/build-push-action@v2
with:
file: ./Plugins.SolarEdge/Dockerfile
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
tags: ${{ steps.meta.outputs.tags }}
4 changes: 1 addition & 3 deletions Plugins.SmaEnergymeter/SharedValues.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Plugins.SmaEnergymeter.Dtos;

namespace Plugins.SmaEnergymeter;
namespace Plugins.SmaEnergymeter;

public class SharedValues
{
Expand Down
5 changes: 4 additions & 1 deletion Plugins.SmaEnergymeter/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
},
"WriteTo": [
{
"Name": "Console"
"Name": "Console",
"Args": {
"outputTemplate": "[{Timestamp:HH:mm:ss.fff} {Level:u3} {SourceContext}] {Message:lj}{NewLine}{Exception}"
}
}
],
"Enrich": [
Expand Down
7 changes: 7 additions & 0 deletions Plugins.SolarEdge/Contracts/ICurrentValuesService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Plugins.SolarEdge.Contracts;

public interface ICurrentValuesService
{
Task<int> GetCurrentPowerToGrid();
Task<int> GetInverterPower();
}
28 changes: 28 additions & 0 deletions Plugins.SolarEdge/Controllers/CurrentValuesController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Microsoft.AspNetCore.Mvc;
using Plugins.SolarEdge.Contracts;

namespace Plugins.SolarEdge.Controllers;

[Route("api/[controller]/[action]")]
[ApiController]
public class CurrentValuesController : ControllerBase
{
private readonly ICurrentValuesService _currentValuesService;

public CurrentValuesController(ICurrentValuesService currentValuesService)
{
_currentValuesService = currentValuesService;
}

[HttpGet]
public Task<int> GetPowerToGrid()
{
return _currentValuesService.GetCurrentPowerToGrid();
}

[HttpGet]
public Task<int> GetInverterPower()
{
return _currentValuesService.GetInverterPower();
}
}
22 changes: 22 additions & 0 deletions Plugins.SolarEdge/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:6.0-bullseye-slim-amd64 AS build
WORKDIR /src
COPY ["Plugins.SolarEdge/Plugins.SolarEdge.csproj", "Plugins.SolarEdge/"]
RUN dotnet restore "Plugins.SolarEdge/Plugins.SolarEdge.csproj"
COPY . .
WORKDIR "/src/Plugins.SolarEdge"
RUN dotnet build "Plugins.SolarEdge.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "Plugins.SolarEdge.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Plugins.SolarEdge.dll"]
8 changes: 8 additions & 0 deletions Plugins.SolarEdge/Dtos/CloudApi/CloudApiValue.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Plugins.SolarEdge.Dtos.CloudApi;

// CloudApiValue myDeserializedClass = JsonConvert.DeserializeObject<CloudApiValue>(myJsonResponse);

public class CloudApiValue
{
public SiteCurrentPowerFlow SiteCurrentPowerFlow { get; set; }
}
7 changes: 7 additions & 0 deletions Plugins.SolarEdge/Dtos/CloudApi/Connection.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Plugins.SolarEdge.Dtos.CloudApi;

public class Connection
{
public string From { get; set; }
public string To { get; set; }
}
7 changes: 7 additions & 0 deletions Plugins.SolarEdge/Dtos/CloudApi/GRID.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Plugins.SolarEdge.Dtos.CloudApi;

public class Grid
{
public string Status { get; set; }
public double CurrentPower { get; set; }
}
7 changes: 7 additions & 0 deletions Plugins.SolarEdge/Dtos/CloudApi/LOAD.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Plugins.SolarEdge.Dtos.CloudApi;

public class Load
{
public string Status { get; set; }
public double CurrentPower { get; set; }
}
7 changes: 7 additions & 0 deletions Plugins.SolarEdge/Dtos/CloudApi/PV.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Plugins.SolarEdge.Dtos.CloudApi;

public class Pv
{
public string Status { get; set; }
public double CurrentPower { get; set; }
}
9 changes: 9 additions & 0 deletions Plugins.SolarEdge/Dtos/CloudApi/STORAGE.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Plugins.SolarEdge.Dtos.CloudApi;

public class Storage
{
public string Status { get; set; }
public double CurrentPower { get; set; }
public int ChargeLevel { get; set; }
public bool Critical { get; set; }
}
12 changes: 12 additions & 0 deletions Plugins.SolarEdge/Dtos/CloudApi/SiteCurrentPowerFlow.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace Plugins.SolarEdge.Dtos.CloudApi;

public class SiteCurrentPowerFlow
{
public int UpdateRefreshRate { get; set; }
public string Unit { get; set; }
public List<Connection> Connections { get; set; }
public Grid Grid { get; set; }
public Load Load { get; set; }
public Pv Pv { get; set; }
public Storage Storage { get; set; }
}
23 changes: 23 additions & 0 deletions Plugins.SolarEdge/Plugins.SolarEdge.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.15.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Serilog.AspNetCore" Version="5.0.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="3.3.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
</ItemGroup>

<ItemGroup>
<Folder Include="Controllers\" />
</ItemGroup>

</Project>
45 changes: 45 additions & 0 deletions Plugins.SolarEdge/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using Plugins.SolarEdge;
using Plugins.SolarEdge.Contracts;
using Plugins.SolarEdge.Services;
using Serilog;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.

builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

builder.Services.AddSingleton<SharedValues>();
builder.Services.AddTransient<ICurrentValuesService, CurrentValuesService>()
;

builder.Host.UseSerilog((context, configuration) => configuration
.ReadFrom.Configuration(context.Configuration));

builder.Configuration
.AddJsonFile("appsettings.json")
.AddEnvironmentVariables();

var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
if (environment == "Development")
{
builder.Configuration.AddJsonFile("appsettings.Development.json");
}

var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}

app.UseAuthorization();

app.MapControllers();

app.Run();
Loading

0 comments on commit 2500926

Please sign in to comment.