Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #947

Merged
merged 39 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
20305b1
build(deps): Bump Microsoft.AspNetCore.Components.WebAssembly
dependabot[bot] Oct 25, 2023
9d9f204
build(deps): Bump Microsoft.AspNetCore.OpenApi from 7.0.12 to 7.0.13
dependabot[bot] Oct 25, 2023
89be87b
build(deps): Bump Microsoft.AspNetCore.Mvc.NewtonsoftJson
dependabot[bot] Oct 25, 2023
0877ad0
build(deps): Bump xunit from 2.5.2 to 2.6.0
dependabot[bot] Nov 1, 2023
0eda2a4
build(deps): Bump Microsoft.AspNetCore.Components.WebAssembly.Server
dependabot[bot] Nov 1, 2023
9cd77d5
build(deps): Bump Microsoft.AspNetCore.Components.WebAssembly.DevServer
dependabot[bot] Nov 1, 2023
b1d5811
build(deps): Bump xunit from 2.6.0 to 2.6.1
dependabot[bot] Nov 3, 2023
0a7b115
fix(SolarMqttService): same topic for multiple values could not be ha…
pkuehnel Nov 3, 2023
3391b86
feat(TeslaMateMqttService): do not overwrite charger phases with null
pkuehnel Nov 7, 2023
fdf5d57
feat(CICD): use chargerPhases als label instead of alpha
pkuehnel Nov 7, 2023
42633bf
build(deps): Bump Microsoft.NET.Test.Sdk from 17.7.2 to 17.8.0
dependabot[bot] Nov 9, 2023
8cd00ea
Revert "feat(CICD): use chargerPhases als label instead of alpha"
pkuehnel Nov 9, 2023
f22aaa4
build(deps): Bump Serilog.Sinks.Console from 4.1.0 to 5.0.0
dependabot[bot] Nov 10, 2023
9dfb174
feat(CICD): use chargerPhases als label instead of alpha
pkuehnel Nov 7, 2023
7175835
Revert "feat(CICD): use chargerPhases als label instead of alpha"
pkuehnel Nov 9, 2023
e4c3651
feat(GridPriceProvider): add project
pkuehnel Nov 1, 2023
9bf0783
feat(HelloController): Add Ednpoint to ask for price in timerange
pkuehnel Nov 1, 2023
efb25df
feat(FixedPriceService): fixedPriceService can be used
pkuehnel Nov 6, 2023
89a15b0
feat(ChargingCostService): can calculate charge costs NOT TESTED!!
pkuehnel Nov 9, 2023
fadd943
fix(ChargingCostService): handle Fixed hour based prices
pkuehnel Nov 10, 2023
86f1aa8
feat(ChargingCostService): can update charge prices
pkuehnel Nov 10, 2023
70b31d7
feat(FixedPriceService): remove unnecessary code
pkuehnel Nov 11, 2023
31c1dec
feat(FixedPriceService): can handle fixed Price based on days
pkuehnel Nov 11, 2023
7583315
feat(ChargePrice): make Grid Price optional as is not used for other …
pkuehnel Nov 11, 2023
0ef1137
feat(ChargeCostDetailRazor): Add dropdown to select Price type
pkuehnel Nov 11, 2023
26b1b4d
feat(ChargeCostDetail): Add option to update fixed prices
pkuehnel Nov 12, 2023
423eaff
fix(FixedPriceService): return correct datetimeoffsets
pkuehnel Nov 12, 2023
61ad51b
fix(FixedPriceService): use local day to know which week day is valid
pkuehnel Nov 12, 2023
9cba28e
feat(ChargingCostService): use default price if no fixed price found …
pkuehnel Nov 12, 2023
e4e3f25
feat(ChargeCostDetailRazor): use grid price as default for time based…
pkuehnel Nov 12, 2023
ec28ecf
feat(Tests): Add test to check if default value is used
pkuehnel Nov 12, 2023
b7f7925
Merge pull request #945 from pkuehnel/feat/integrateTeslaMateAgile
pkuehnel Nov 12, 2023
d846d68
fix(ChargeCostDetailRazor): autoselect Energyprovider on creating new…
pkuehnel Nov 13, 2023
c42d38a
Merge pull request #956 from pkuehnel/fix/ChargeCostDetail
pkuehnel Nov 13, 2023
47334dc
feat(PvValueService): add option to ignore ssl erros
pkuehnel Nov 15, 2023
d957991
Merge pull request #980 from pkuehnel/feat/ignoreSslErrors
pkuehnel Nov 15, 2023
fd67962
fix(PvValueService): Allow json tokens to be null
pkuehnel Nov 16, 2023
7816337
feat(PVValueService): add comment why null is allowed
pkuehnel Nov 16, 2023
067b642
Merge pull request #981 from pkuehnel/fix/interpretPvNullValuesAs0
pkuehnel Nov 16, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Plugins.Modbus/Plugins.Modbus.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.5" />
<PackageReference Include="Serilog.AspNetCore" Version="7.0.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="7.0.1" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Newtonsoft" Version="6.5.0" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Plugins.SmaEnergymeter/Plugins.SmaEnergymeter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<PackageReference Include="Quartz" Version="3.7.0" />
<PackageReference Include="Serilog.AspNetCore" Version="7.0.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="7.0.1" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Plugins.SolarEdge/Plugins.SolarEdge.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Serilog.AspNetCore" Version="7.0.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="7.0.1" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>

Expand Down
4 changes: 2 additions & 2 deletions Plugins.Solax/Plugins.Solax.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.12" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.13" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.5" />
<PackageReference Include="Serilog.AspNetCore" Version="7.0.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="7.0.1" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>

Expand Down
11 changes: 11 additions & 0 deletions TeslaSolarCharger.GridPriceProvider/Data/Options/AwattarOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System.ComponentModel.DataAnnotations;

namespace TeslaSolarCharger.GridPriceProvider.Data.Options;

public class AwattarOptions
{
[Required]
public string BaseUrl { get; set; }

Check warning on line 8 in TeslaSolarCharger.GridPriceProvider/Data/Options/AwattarOptions.cs

View workflow job for this annotation

GitHub Actions / Building TeslaSolarCharger image

Non-nullable property 'BaseUrl' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

public decimal VATMultiplier { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System.ComponentModel.DataAnnotations;

namespace TeslaSolarCharger.GridPriceProvider.Data.Options;

public class EnerginetOptions
{
[Required]
public string BaseUrl { get; set; }

[Required]
public EnerginetRegion Region { get; set; }

[Required]
public EnerginetCurrency Currency { get; set; }

public decimal? VAT { get; set; }

public FixedPriceOptions? FixedPrices { get; set; }
}

public enum EnerginetRegion
{
DK1,
DK2,
NO2,
SE3,
SE4
}

public enum EnerginetCurrency
{
DKK,
EUR
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using System.ComponentModel.DataAnnotations;

namespace TeslaSolarCharger.GridPriceProvider.Data.Options;

public class FixedPriceOptions
{
public List<string> Prices { get; set; } = new();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System.ComponentModel.DataAnnotations;

namespace TeslaSolarCharger.GridPriceProvider.Data.Options;

public class HomeAssistantOptions
{
[Required]
public string BaseUrl { get; set; }

Check warning on line 8 in TeslaSolarCharger.GridPriceProvider/Data/Options/HomeAssistantOptions.cs

View workflow job for this annotation

GitHub Actions / Building TeslaSolarCharger image

Non-nullable property 'BaseUrl' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

[Required]
public string AccessToken { get; set; }

Check warning on line 11 in TeslaSolarCharger.GridPriceProvider/Data/Options/HomeAssistantOptions.cs

View workflow job for this annotation

GitHub Actions / Building TeslaSolarCharger image

Non-nullable property 'AccessToken' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

[Required]
public string EntityId { get; set; }

Check warning on line 14 in TeslaSolarCharger.GridPriceProvider/Data/Options/HomeAssistantOptions.cs

View workflow job for this annotation

GitHub Actions / Building TeslaSolarCharger image

Non-nullable property 'EntityId' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
}
18 changes: 18 additions & 0 deletions TeslaSolarCharger.GridPriceProvider/Data/Options/OctopusOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System.ComponentModel.DataAnnotations;

namespace TeslaSolarCharger.GridPriceProvider.Data.Options;

public class OctopusOptions
{
[Required]
public string BaseUrl { get; set; }

Check warning on line 8 in TeslaSolarCharger.GridPriceProvider/Data/Options/OctopusOptions.cs

View workflow job for this annotation

GitHub Actions / Building TeslaSolarCharger image

Non-nullable property 'BaseUrl' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

[Required]
public string ProductCode { get; set; }

Check warning on line 11 in TeslaSolarCharger.GridPriceProvider/Data/Options/OctopusOptions.cs

View workflow job for this annotation

GitHub Actions / Building TeslaSolarCharger image

Non-nullable property 'ProductCode' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

[Required]
public string TariffCode { get; set; }

Check warning on line 14 in TeslaSolarCharger.GridPriceProvider/Data/Options/OctopusOptions.cs

View workflow job for this annotation

GitHub Actions / Building TeslaSolarCharger image

Non-nullable property 'TariffCode' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

[Required]
public string RegionCode { get; set; }

Check warning on line 17 in TeslaSolarCharger.GridPriceProvider/Data/Options/OctopusOptions.cs

View workflow job for this annotation

GitHub Actions / Building TeslaSolarCharger image

Non-nullable property 'RegionCode' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
}
12 changes: 12 additions & 0 deletions TeslaSolarCharger.GridPriceProvider/Data/Options/TibberOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System.ComponentModel.DataAnnotations;

namespace TeslaSolarCharger.GridPriceProvider.Data.Options;

public class TibberOptions
{
[Required]
public string BaseUrl { get; set; }

Check warning on line 8 in TeslaSolarCharger.GridPriceProvider/Data/Options/TibberOptions.cs

View workflow job for this annotation

GitHub Actions / Building TeslaSolarCharger image

Non-nullable property 'BaseUrl' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

[Required]
public string AccessToken { get; set; }

Check warning on line 11 in TeslaSolarCharger.GridPriceProvider/Data/Options/TibberOptions.cs

View workflow job for this annotation

GitHub Actions / Building TeslaSolarCharger image

Non-nullable property 'AccessToken' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
}
10 changes: 10 additions & 0 deletions TeslaSolarCharger.GridPriceProvider/Data/Price.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace TeslaSolarCharger.GridPriceProvider.Data;

public class Price
{
public decimal Value { get; set; }

public DateTimeOffset ValidFrom { get; set; }

public DateTimeOffset ValidTo { get; set; }
}
19 changes: 19 additions & 0 deletions TeslaSolarCharger.GridPriceProvider/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using GraphQL.Client.Abstractions;
using GraphQL.Client.Serializer.SystemTextJson;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using TeslaSolarCharger.GridPriceProvider.Services;
using TeslaSolarCharger.GridPriceProvider.Services.Interfaces;

namespace TeslaSolarCharger.GridPriceProvider;

public static class ServiceCollectionExtensions
{
public static IServiceCollection AddGridPriceProvider(this IServiceCollection services)
{
services.AddHttpClient();
services.AddTransient<IFixedPriceService, FixedPriceService>();

return services;
}
}
68 changes: 68 additions & 0 deletions TeslaSolarCharger.GridPriceProvider/Services/AwattarService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
using Microsoft.Extensions.Options;
using System.Text.Json;
using System.Text.Json.Serialization;
using TeslaSolarCharger.GridPriceProvider.Data;
using TeslaSolarCharger.GridPriceProvider.Data.Options;
using TeslaSolarCharger.GridPriceProvider.Services.Interfaces;

namespace TeslaSolarCharger.GridPriceProvider.Services;

public class AwattarService : IPriceDataService
{
private readonly HttpClient _client;
private readonly AwattarOptions _options;

public AwattarService(HttpClient client, IOptions<AwattarOptions> options)
{
_client = client;
_options = options.Value;
}

public async Task<IEnumerable<Price>> GetPriceData(DateTimeOffset from, DateTimeOffset to)
{
var url = $"marketdata?start={from.UtcDateTime.AddHours(-1):o}&end={to.UtcDateTime.AddHours(1):o}";
var resp = await _client.GetAsync(url);
resp.EnsureSuccessStatusCode();
var agileResponse = await JsonSerializer.DeserializeAsync<AwattarResponse>(await resp.Content.ReadAsStreamAsync());
if (agileResponse == null)
{
throw new Exception($"Deserialization of aWATTar API response failed");
}
if (agileResponse.Results.Any(x => x.Unit != "Eur/MWh"))
{
throw new Exception($"Unknown price unit(s) detected from aWATTar API: {string.Join(", ", agileResponse.Results.Select(x => x.Unit).Distinct())}");
}
return agileResponse.Results.Select(x => new Price
{
Value = (x.MarketPrice / 1000) * _options.VATMultiplier,
ValidFrom = DateTimeOffset.FromUnixTimeSeconds(x.StartTimestamp / 1000),
ValidTo = DateTimeOffset.FromUnixTimeSeconds(x.EndTimestamp / 1000)
});
}

public class AwattarPrice
{
[JsonPropertyName("marketprice")]
public decimal MarketPrice { get; set; }

[JsonPropertyName("unit")]
public string Unit { get; set; }

[JsonPropertyName("start_timestamp")]
public long StartTimestamp { get; set; }

[JsonPropertyName("end_timestamp")]
public long EndTimestamp { get; set; }
}

public class AwattarResponse
{
[JsonPropertyName("data")]
public List<AwattarPrice> Results { get; set; }
}

public Task<IEnumerable<Price>> GetPriceData(DateTimeOffset from, DateTimeOffset to, string? configString)
{
throw new NotImplementedException();
}
}
91 changes: 91 additions & 0 deletions TeslaSolarCharger.GridPriceProvider/Services/EnerginetService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
//using Microsoft.Extensions.Options;
//using System.Text.Json;
//using System.Text.Json.Serialization;
//using TeslaSolarCharger.GridPriceProvider.Data;
//using TeslaSolarCharger.GridPriceProvider.Data.Options;
//using TeslaSolarCharger.GridPriceProvider.Services.Interfaces;

//namespace TeslaSolarCharger.GridPriceProvider.Services;

//public class EnerginetService : IPriceDataService
//{
// private readonly HttpClient _client;
// private readonly EnerginetOptions _options;
// private readonly FixedPriceService _fixedPriceService;

// public EnerginetService(HttpClient client, IOptions<EnerginetOptions> options)
// {
// _client = client;
// _options = options.Value;

// if (_options.FixedPrices != null)
// {
// _fixedPriceService = new FixedPriceService(Options.Create(_options.FixedPrices));
// }
// }

// public async Task<IEnumerable<Price>> GetPriceData(DateTimeOffset from, DateTimeOffset to)
// {
// var url = "Elspotprices?offset=0&start=" + from.AddHours(-2).AddMinutes(-1).UtcDateTime.ToString("yyyy-MM-ddTHH:mm") + "&end=" + to.AddHours(2).AddMinutes(1).UtcDateTime.ToString("yyyy-MM-ddTHH:mm") + "&filter={\"PriceArea\":[\"" + _options.Region + "\"]}&sort=HourUTC ASC&timezone=dk".Replace(@"\", string.Empty); ;
// var resp = await _client.GetAsync(url);

// resp.EnsureSuccessStatusCode();

// var prices = new List<Price>();
// var EnerginetResponse = await JsonSerializer.DeserializeAsync<EnerginetResponse>(await resp.Content.ReadAsStreamAsync());

// if (EnerginetResponse.Records.Count > 0)
// {
// foreach (var record in EnerginetResponse.Records)
// {
// decimal fixedPrice = 0;
// if (_fixedPriceService != null)
// {
// var fixedPrices = await _fixedPriceService.GetPriceData(record.HourUTC, record.HourUTC.AddHours(1));
// fixedPrice = fixedPrices.Sum(p => p.Value);
// }

// var spotPrice = _options.Currency switch
// {
// EnerginetCurrency.DKK => record.SpotPriceDKK,
// EnerginetCurrency.EUR => record.SpotPriceEUR,
// _ => throw new ArgumentOutOfRangeException(nameof(_options.Currency)),
// };

// var price = ((spotPrice / 1000) + fixedPrice);
// if (_options.VAT.HasValue)
// {
// price *= _options.VAT.Value;
// }
// prices.Add(new Price
// {
// ValidFrom = record.HourUTC,
// ValidTo = record.HourUTC.AddHours(1),
// Value = price
// });
// }
// }

// return prices;
// }

// private class EnerginetResponse
// {
// [JsonPropertyName("records")]
// public List<EnerginetResponseRow> Records { get; set; }
// }

// private class EnerginetResponseRow
// {
// private DateTime _hourUTC;

// [JsonPropertyName("HourUTC")]
// public DateTime HourUTC { get => _hourUTC; set => _hourUTC = DateTime.SpecifyKind(value, DateTimeKind.Utc); }

// [JsonPropertyName("SpotPriceDKK")]
// public decimal SpotPriceDKK { get; set; }

// [JsonPropertyName("SpotPriceEUR")]
// public decimal SpotPriceEUR { get; set; }
// }
//}
Loading
Loading