Skip to content

Commit

Permalink
Rename "is_power_cut_active" and "rate_type" to use more specific names
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinchalet committed Dec 21, 2024
1 parent 1cad805 commit fa511c5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
20 changes: 10 additions & 10 deletions src/OpenNetty.Mqtt/OpenNettyMqttAttributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ public static class OpenNettyMqttAttributes
/// </summary>
public const string DimmingStep = "dimming_step";

/// <summary>
/// Power cut active indicator.
/// </summary>
public const string IsPowerCutActive = "is_power_cut_active";

/// <summary>
/// Pilot wire derogation mode.
/// </summary>
Expand All @@ -41,11 +36,6 @@ public static class OpenNettyMqttAttributes
/// </summary>
public const string PilotWireSetpointMode = "pilot_wire_setpoint_mode";

/// <summary>
/// Rate type.
/// </summary>
public const string RateType = "rate_type";

/// <summary>
/// Scenario.
/// </summary>
Expand All @@ -56,6 +46,16 @@ public static class OpenNettyMqttAttributes
/// </summary>
public const string SmartMeterIndexes = "smart_meter_indexes";

/// <summary>
/// Smart meter power cut mode.
/// </summary>
public const string SmartMeterPowerCutMode = "smart_meter_power_cut_mode";

/// <summary>
/// Smart meter rate type.
/// </summary>
public const string SmartMeterRateType = "smart_meter_rate_type";

/// <summary>
/// Switch state.
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions src/OpenNetty.Mqtt/OpenNettyMqttHostedService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,14 +196,14 @@ await _events.SmartMeterIndexesReported

await _events.SmartMeterPowerCutModeReported
.Where(static arguments => !string.IsNullOrEmpty(arguments.Endpoint.Name))
.Do(arguments => ReportStringAsync(arguments.Endpoint, OpenNettyMqttAttributes.IsPowerCutActive,
.Do(arguments => ReportStringAsync(arguments.Endpoint, OpenNettyMqttAttributes.SmartMeterPowerCutMode,
arguments.Active ? "1" : "0"))
.Retry()
.SubscribeAsync(static arguments => ValueTask.CompletedTask),

await _events.SmartMeterRateTypeReported
.Where(static arguments => !string.IsNullOrEmpty(arguments.Endpoint.Name))
.Do(arguments => ReportStringAsync(arguments.Endpoint, OpenNettyMqttAttributes.RateType, arguments.Type switch
.Do(arguments => ReportStringAsync(arguments.Endpoint, OpenNettyMqttAttributes.SmartMeterRateType, arguments.Type switch
{
OpenNettyModels.TemperatureControl.SmartMeterRateType.Peak => "peak",
OpenNettyModels.TemperatureControl.SmartMeterRateType.OffPeak => "off_peak",
Expand Down
2 changes: 1 addition & 1 deletion src/OpenNetty.Mqtt/OpenNettyMqttWorker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ await _controller.SetPilotWireSetpointModeAsync(endpoint,
}
break;

case OpenNettyMqttAttributes.RateType or OpenNettyMqttAttributes.IsPowerCutActive
case OpenNettyMqttAttributes.SmartMeterPowerCutMode or OpenNettyMqttAttributes.SmartMeterRateType
when operation is OpenNettyMqttOperation.Get:
_ = await _controller.GetSmartMeterInformationAsync(endpoint);
break;
Expand Down

0 comments on commit fa511c5

Please sign in to comment.