-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add work mode support + update readme
- Loading branch information
Showing
9 changed files
with
438 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Roses.SolarAPI.Models.FoxCloud | ||
{ | ||
public partial class DeviceListRequest | ||
{ | ||
[JsonPropertyName("pageSize")] | ||
public int PageSize { get; set; } = 10; | ||
|
||
[JsonPropertyName("currentPage")] | ||
public int CurrentPage { get; set; } = 1; | ||
|
||
[JsonPropertyName("total")] | ||
public int Total { get; set; } = 0; | ||
|
||
[JsonPropertyName("condition")] | ||
public Condition Condition { get; set; } = new Condition(); | ||
} | ||
|
||
public partial class Condition | ||
{ | ||
[JsonPropertyName("queryDate")] | ||
public QueryDate QueryDate { get; set; } = new QueryDate(); | ||
} | ||
|
||
public partial class QueryDate | ||
{ | ||
[JsonPropertyName("begin")] | ||
public int Begin { get; set; } = 0; | ||
|
||
[JsonPropertyName("end")] | ||
public int End { get; set; } = 0; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Roses.SolarAPI.Models.FoxCloud | ||
{ | ||
public partial class DeviceListResponse : IFoxResponse | ||
{ | ||
[JsonPropertyName("errno")] | ||
public int Errno { get; set; } | ||
|
||
[JsonPropertyName("result")] | ||
public Result? Result { get; set; } | ||
} | ||
|
||
public partial class Result | ||
{ | ||
[JsonPropertyName("currentPage")] | ||
public int CurrentPage { get; set; } | ||
|
||
[JsonPropertyName("pageSize")] | ||
public int PageSize { get; set; } | ||
|
||
[JsonPropertyName("total")] | ||
public int Total { get; set; } | ||
|
||
[JsonPropertyName("devices")] | ||
public Device[]? Devices { get; set; } | ||
} | ||
|
||
public partial class Device | ||
{ | ||
[JsonPropertyName("deviceID")] | ||
public Guid DeviceId { get; set; } | ||
|
||
[JsonPropertyName("deviceSN")] | ||
public string? DeviceSn { get; set; } | ||
|
||
[JsonPropertyName("moduleSN")] | ||
public string? ModuleSn { get; set; } | ||
|
||
[JsonPropertyName("plantName")] | ||
public string? PlantName { get; set; } | ||
|
||
[JsonPropertyName("deviceType")] | ||
public string? DeviceType { get; set; } | ||
|
||
[JsonPropertyName("country")] | ||
public string? Country { get; set; } | ||
|
||
[JsonPropertyName("countryCode")] | ||
public string? CountryCode { get; set; } | ||
|
||
[JsonPropertyName("feedinDate")] | ||
public string? FeedinDate { get; set; } | ||
|
||
[JsonPropertyName("status")] | ||
public int Status { get; set; } | ||
|
||
[JsonPropertyName("power")] | ||
public double Power { get; set; } | ||
|
||
[JsonPropertyName("generationToday")] | ||
public double GenerationToday { get; set; } | ||
|
||
[JsonPropertyName("generationTotal")] | ||
public double GenerationTotal { get; set; } | ||
|
||
[JsonPropertyName("productType")] | ||
public string? ProductType { get; set; } | ||
|
||
[JsonPropertyName("flowType")] | ||
public int FlowType { get; set; } | ||
|
||
[JsonPropertyName("hasBattery")] | ||
public bool HasBattery { get; set; } | ||
|
||
[JsonPropertyName("hasPV")] | ||
public bool HasPv { get; set; } | ||
|
||
[JsonPropertyName("dataLatestUploadDate")] | ||
public string? DataLatestUploadDate { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Roses.SolarAPI.Models.FoxCloud | ||
{ | ||
public partial class SetWorkModeRequest : IFoxRequest | ||
{ | ||
[JsonPropertyName("id")] | ||
public Guid Id { get; set; } | ||
|
||
[JsonPropertyName("key")] | ||
public string? Key { get; set; } = "h106__02__00"; | ||
|
||
[JsonPropertyName("values")] | ||
public Values? Values { get; set; } = new Values(); | ||
|
||
public void Validate() | ||
{ | ||
if (Id == Guid.Empty) | ||
{ | ||
throw new ArgumentNullException(nameof(SetWorkModeRequest), "No cloud device ID is provided."); | ||
} | ||
|
||
if (string.IsNullOrWhiteSpace(Key)) | ||
{ | ||
throw new ArgumentOutOfRangeException(nameof(SetWorkModeRequest), "Key has been changed."); | ||
} | ||
|
||
if (!WorkModes.ALL.Any(mode => mode == Values?.Mode)) | ||
{ | ||
throw new ArgumentOutOfRangeException(nameof(SetWorkModeRequest), "A valid work mode has not been provided."); | ||
} | ||
} | ||
} | ||
|
||
public partial class Values | ||
{ | ||
[JsonPropertyName("h106__02__00")] | ||
public string? Mode { get; set; } | ||
} | ||
|
||
public class WorkModes | ||
{ | ||
public const string FEED_IN = "Feedin"; | ||
public const string SELF_USE = "SelfUse"; | ||
public const string BACKUP = "Backup"; | ||
|
||
public readonly static string[] ALL = new[] { FEED_IN, SELF_USE, BACKUP }; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using Roses.SolarAPI.Services; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Roses.SolarAPI.Models.FoxCloud | ||
{ | ||
public class SetWorkModeResponse : IFoxResponse | ||
{ | ||
/// <summary> | ||
/// 41808 means token is invalid | ||
/// 40257 means invalid request param | ||
/// 41203 means timeout | ||
/// 0 means OK | ||
/// </summary> | ||
[JsonPropertyName("errno")] | ||
public int Errno { get; set; } = (int)FoxErrorNumber.NoResponse; | ||
|
||
[JsonPropertyName("result")] | ||
public object? Result { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.