Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 0 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ jobs:
os_name: windows

steps:
- name: Select Xcode version
if: ${{ runner.os == 'macOS' }}
run: sudo xcode-select -s "/Applications/Xcode_15.4.app"

- name: Checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

Expand Down
6 changes: 3 additions & 3 deletions src/OpenNetty.Mqtt/OpenNettyMqttHostedService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ await _events.ProgressiveScenarioReported
.Where(static arguments => !string.IsNullOrEmpty(arguments.Endpoint.Name))
.Do(arguments => ReportAsync(arguments.Endpoint, OpenNettyMqttAttributes.Scenario, builder =>
{
var node = new JsonObject()
var node = new JsonObject
{
["scenario_type"] = "progressive",
["duration"] = arguments.Duration.TotalSeconds
Expand Down Expand Up @@ -273,7 +273,7 @@ await _events.SmartMeterIndexesReported
.Where(static arguments => !string.IsNullOrEmpty(arguments.Endpoint.Name))
.Do(arguments => ReportAsync(arguments.Endpoint, OpenNettyMqttAttributes.SmartMeterIndexes, builder =>
{
var node = new JsonObject()
var node = new JsonObject
{
["base_index"] = arguments.Indexes.BaseIndex,
["blue_index"] = arguments.Indexes.BlueIndex,
Expand Down Expand Up @@ -341,7 +341,7 @@ await _events.TimedScenarioReported
.Where(static arguments => !string.IsNullOrEmpty(arguments.Endpoint.Name))
.Do(arguments => ReportAsync(arguments.Endpoint, OpenNettyMqttAttributes.Scenario, builder =>
{
var node = new JsonObject()
var node = new JsonObject
{
["scenario_type"] = "timed",
["duration"] = arguments.Duration.TotalSeconds
Expand Down
7 changes: 3 additions & 4 deletions src/OpenNetty.Mqtt/OpenNettyMqttWorker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,6 @@ where endpoint.GetBooleanSetting(OpenNettySettings.MqttDiscovery) is not false
};

await foreach (var (endpoint, name) in from endpoint in endpoints
where endpoint.GetBooleanSetting(OpenNettySettings.MqttDiscovery) is not false
let name = options.EndpointNameProvider(endpoint)
where !string.IsNullOrEmpty(name)
orderby name
Expand Down Expand Up @@ -596,7 +595,7 @@ orderby name
["state_topic"] = $"{options.RootTopic}/{name}/{OpenNettyMqttAttributes.PilotWireDerogationMode}",
["options"] = new JsonArray(
[
"None",
"No derogation",
"Comfort, until the next setpoint change",
"Comfort, for at least 4 hours",
"Comfort, for at least 8 hours",
Expand All @@ -615,7 +614,7 @@ orderby name
]),
["value_template"] = """
{% set map = {
'none': 'None',
'none': 'No derogation',
'comfort': 'Comfort, until the next setpoint change',
'comfort:4h': 'Comfort, for at least 4 hours',
'comfort:8h': 'Comfort, for at least 8 hours',
Expand All @@ -636,7 +635,7 @@ orderby name
""",
["command_template"] = """
{% set map = {
'None': 'none',
'No derogation': 'none',
'Comfort, until the next setpoint change': 'comfort',
'Comfort, for at least 4 hours': 'comfort:4h',
'Comfort, for at least 8 hours': 'comfort:8h',
Expand Down
8 changes: 4 additions & 4 deletions src/OpenNetty/OpenNettyController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1187,9 +1187,9 @@ public virtual async ValueTask<byte> GetMemoryDepthAsync(
}

var description = await GetUnitDescriptionAsync(endpoint, cancellationToken);
if (description is not { FunctionCode: 6, Values: [{ Length: > 0 }] values })
if (description is not { FunctionCode: 6 or 132, Values: [{ Length: > 0 }] values })
{
throw new InvalidOperationException(SR.GetResourceString(SR.ID0076));
throw new InvalidOperationException(SR.GetResourceString(SR.ID0075));
}

return OpenNettyModels.TemperatureControl.PilotWireConfiguration.CreateFromUnitDescription(values);
Expand Down Expand Up @@ -1399,7 +1399,7 @@ public virtual async ValueTask<byte> GetMemoryDepthAsync(
var description = await GetUnitDescriptionAsync(endpoint, cancellationToken);
if (description is not { FunctionCode: 7, Values: [{ Length: > 0 }] values })
{
throw new InvalidOperationException(SR.GetResourceString(SR.ID0076));
throw new InvalidOperationException(SR.GetResourceString(SR.ID0075));
}

return OpenNettyModels.TemperatureControl.SmartMeterInformation.CreateFromUnitDescription(values);
Expand Down Expand Up @@ -1565,7 +1565,7 @@ public virtual async ValueTask<TimeSpan> GetUptimeAsync(
var description = await GetUnitDescriptionAsync(endpoint, cancellationToken);
if (description is not { FunctionCode: 133, Values: [{ Length: > 0 }] values })
{
throw new InvalidOperationException(SR.GetResourceString(SR.ID0076));
throw new InvalidOperationException(SR.GetResourceString(SR.ID0075));
}

return values[0] switch
Expand Down
24 changes: 9 additions & 15 deletions src/OpenNetty/OpenNettyCoordinator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,7 @@ async ValueTask ReportSetpointModeAsync(OpenNettyEndpoint endpoint, Cancellation
Type : OpenNettyMessageType.DimensionRead,
Address : OpenNettyAddress address,
Dimension: OpenNettyDimension dimension,
Values : ["6", { Length: > 0 } value] })
Values : ["6" or "132", { Length: > 0 } value] })
when dimension == OpenNettyDimensions.Diagnostics.UnitDescription:
{
// Ignore the message if the corresponding endpoint couldn't be resolved or if it
Expand Down Expand Up @@ -991,7 +991,7 @@ async ValueTask ReportSetpointModeAsync(OpenNettyEndpoint endpoint, Cancellation

if (endpoint.HasCapability(OpenNettyCapabilities.PilotWireHeating))
{
tasks.Add(ReportDerogationAndSetpointModesAsync(endpoint, CancellationToken.None).AsTask());
tasks.Add(ReportSetpointModeAsync(endpoint, CancellationToken.None).AsTask());
}

if (endpoint is { Unit.Definition.AssociatedUnitId: byte unit })
Expand All @@ -1003,7 +1003,7 @@ async ValueTask ReportSetpointModeAsync(OpenNettyEndpoint endpoint, Cancellation

if (endpoint is not null && endpoint.HasCapability(OpenNettyCapabilities.PilotWireHeating))
{
await ReportDerogationAndSetpointModesAsync(endpoint, CancellationToken.None);
await ReportSetpointModeAsync(endpoint, CancellationToken.None);
}
}));
}
Expand All @@ -1017,13 +1017,16 @@ async ValueTask ReportSetpointModeAsync(OpenNettyEndpoint endpoint, Cancellation
.OfType<OpenNettyEndpoint>()
.Where(static endpoint => endpoint.HasCapability(OpenNettyCapabilities.PilotWireHeating));

tasks.Add(Parallel.ForEachAsync(endpoints, ReportDerogationAndSetpointModesAsync));
tasks.Add(Parallel.ForEachAsync(endpoints, ReportSetpointModeAsync));
}

await Task.WhenAll(tasks);

async ValueTask ReportDerogationAndSetpointModesAsync(OpenNettyEndpoint endpoint, CancellationToken cancellationToken)
{
// Note: setting the setpoint mode may not have an immediate effect on the device (e.g if a
// derogation mode was set with a minimal duration during which setpoint commands are ignored).
//
// As such, the derogation mode cannot be reported here, as it may still be active on the device.
async ValueTask ReportSetpointModeAsync(OpenNettyEndpoint endpoint, CancellationToken cancellationToken) =>
await _events.PublishAsync(new PilotWireSetpointModeReportedEventArgs(endpoint, value switch
{
"0" => OpenNettyModels.TemperatureControl.PilotWireMode.Comfort,
Expand All @@ -1034,15 +1037,6 @@ async ValueTask ReportDerogationAndSetpointModesAsync(OpenNettyEndpoint endpoint

_ => throw new InvalidDataException(SR.GetResourceString(SR.ID0075))
}), cancellationToken);

// Note: setting the setpoint mode may not have an immediate effect on the device (e.g if a
// derogation mode was set with a minimal duration during which setpoint commands are ignored).
// As such, the derogation mode cannot be reported here, as it may still be active on the device.
if (notification is OpenNettyNotifications.MessageSent)
{
await _events.PublishAsync(new PilotWireDerogationModeReportedEventArgs(endpoint, null, null), cancellationToken);
}
}
break;
}

Expand Down
Loading