From fa511c57d225adfba02369c27d9891f10263d583 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Chalet?= Date: Sat, 21 Dec 2024 17:13:25 +0100 Subject: [PATCH] Rename "is_power_cut_active" and "rate_type" to use more specific names --- src/OpenNetty.Mqtt/OpenNettyMqttAttributes.cs | 20 +++++++++---------- .../OpenNettyMqttHostedService.cs | 4 ++-- src/OpenNetty.Mqtt/OpenNettyMqttWorker.cs | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/OpenNetty.Mqtt/OpenNettyMqttAttributes.cs b/src/OpenNetty.Mqtt/OpenNettyMqttAttributes.cs index 3181927..2c5acd4 100644 --- a/src/OpenNetty.Mqtt/OpenNettyMqttAttributes.cs +++ b/src/OpenNetty.Mqtt/OpenNettyMqttAttributes.cs @@ -26,11 +26,6 @@ public static class OpenNettyMqttAttributes /// public const string DimmingStep = "dimming_step"; - /// - /// Power cut active indicator. - /// - public const string IsPowerCutActive = "is_power_cut_active"; - /// /// Pilot wire derogation mode. /// @@ -41,11 +36,6 @@ public static class OpenNettyMqttAttributes /// public const string PilotWireSetpointMode = "pilot_wire_setpoint_mode"; - /// - /// Rate type. - /// - public const string RateType = "rate_type"; - /// /// Scenario. /// @@ -56,6 +46,16 @@ public static class OpenNettyMqttAttributes /// public const string SmartMeterIndexes = "smart_meter_indexes"; + /// + /// Smart meter power cut mode. + /// + public const string SmartMeterPowerCutMode = "smart_meter_power_cut_mode"; + + /// + /// Smart meter rate type. + /// + public const string SmartMeterRateType = "smart_meter_rate_type"; + /// /// Switch state. /// diff --git a/src/OpenNetty.Mqtt/OpenNettyMqttHostedService.cs b/src/OpenNetty.Mqtt/OpenNettyMqttHostedService.cs index fd81d42..9f8aefa 100644 --- a/src/OpenNetty.Mqtt/OpenNettyMqttHostedService.cs +++ b/src/OpenNetty.Mqtt/OpenNettyMqttHostedService.cs @@ -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", diff --git a/src/OpenNetty.Mqtt/OpenNettyMqttWorker.cs b/src/OpenNetty.Mqtt/OpenNettyMqttWorker.cs index 9eb8949..667636f 100644 --- a/src/OpenNetty.Mqtt/OpenNettyMqttWorker.cs +++ b/src/OpenNetty.Mqtt/OpenNettyMqttWorker.cs @@ -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;