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
90 changes: 45 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,51 +38,51 @@ gateways and a higher-level MQTT integration that can be directly used with home

The following Legrand and BTicino products are partially or fully supported by OpenNetty:

| Product series | Product collection | Legrand reference | BTicino reference | Remarks |
|-------------------|--------------------|-------------------|-------------------|-----------------------------------|
| In One by Legrand | Lexic | 03600 | | |
| In One by Legrand | Lexic | 03648 | | |
| In One by Legrand | Lexic | 03809 | | |
| In One by Legrand | | 43214 | | |
| In One by Legrand | Céliane | 67201 | | |
| In One by Legrand | Céliane | 67202 | | |
| In One by Legrand | Céliane | 67203 | | |
| In One by Legrand | Céliane | 67204 | | |
| In One by Legrand | Céliane | 67208 | | |
| In One by Legrand | Céliane | 67210 | | |
| In One by Legrand | Céliane | 67212 | | |
| In One by Legrand | Céliane | 67214 | | |
| In One by Legrand | Céliane | 67215 | | |
| In One by Legrand | Céliane | 67220 | | |
| In One by Legrand | Céliane | 67222 | | |
| In One by Legrand | Céliane | 67280 | | |
| In One by Legrand | Céliane | 67290 | | |
| In One by Legrand | Céliane | 67445 | | |
| In One by Legrand | Céliane | 67448 | | |
| In One by Legrand | Plexo | 69510 | | |
| In One by Legrand | Sagane | 84520 | | |
| In One by Legrand | Sagane | 84522 | | |
| In One by Legrand | Sagane | 84523 | | |
| In One by Legrand | Sagane | 84524 | | |
| In One by Legrand | Sagane | 84525 | | |
| In One by Legrand | Sagane | 84529 | | |
| In One by Legrand | Sagane | 84530 | | |
| In One by Legrand | Sagane | 84531 | | |
| In One by Legrand | Sagane | 84542 | | |
| In One by Legrand | | 88205 | | |
| In One by Legrand | | 88213 | | |
| | | | | |
| MyHome Up | | 03535 | MH202 | |
| MyHome Up | | 03598 | F454 | |
| MyHome Up | | 03651 | F418U2 | |
| MyHome Up | | 03847 | F411U1 | |
| MyHome Up | | 03848 | F411U2 | |
| MyHome Up | Céliane | 67557 | | |
| MyHome Up | Céliane | 67561 | | |
| | | | | |
| MyHome Play | Céliane | 67223 | | |
| MyHome Play | | 88328 | 3578 | |
| MyHome Play | | 88337 | | |
| Product series | Product collection | Legrand reference | BTicino reference | Description |
|-------------------|--------------------|-------------------|-------------------|----------------------------------------|
| In One by Legrand | Lexic | 03600 | | 2-gang DIN rail switch |
| In One by Legrand | Lexic | 03648 | | SCS/Nitoo gateway |
| In One by Legrand | Lexic | 03809 | | DIN rail energy meter |
| In One by Legrand | | 43214 | | Wireless burglar alarm |
| In One by Legrand | Céliane | 67201 | | 1-gang switch |
| In One by Legrand | Céliane | 67202 | | 2-gang switch |
| In One by Legrand | Céliane | 67203 | | 1-gang switch with indicator light |
| In One by Legrand | Céliane | 67204 | | 2-gang switch with indicator light |
| In One by Legrand | Céliane | 67208 | | Light control switch |
| In One by Legrand | Céliane | 67210 | | Dimmer switch |
| In One by Legrand | Céliane | 67212 | | Dimmer switch with indicator light |
| In One by Legrand | Céliane | 67214 | | Dimmer switch with indicator light |
| In One by Legrand | Céliane | 67215 | | Motion sensor switch |
| In One by Legrand | Céliane | 67220 | | Switched outlet |
| In One by Legrand | Céliane | 67222 | | Dimmable switched outlet |
| In One by Legrand | Céliane | 67280 | | Multipurpose scenario switch |
| In One by Legrand | Céliane | 67290 | | Multipurpose scenario switch |
| In One by Legrand | Céliane | 67445 | | Pilot wire cable outlet |
| In One by Legrand | Céliane | 67448 | | Pilot wire derogation command |
| In One by Legrand | Plexo | 69510 | | 1-gang outdoor switch |
| In One by Legrand | Sagane | 84520 | | 2-gang switch |
| In One by Legrand | Sagane | 84522 | | Motion sensor switch |
| In One by Legrand | Sagane | 84523 | | Switched outlet |
| In One by Legrand | Sagane | 84524 | | Dimmable switched outlet |
| In One by Legrand | Sagane | 84525 | | Multipurpose scenario switch |
| In One by Legrand | Sagane | 84529 | | Pilot wire derogation command |
| In One by Legrand | Sagane | 84530 | | Pilot wire cable outlet |
| In One by Legrand | Sagane | 84531 | | 1-gang switch |
| In One by Legrand | Sagane | 84542 | | Multipurpose scenario switch |
| In One by Legrand | | 88205 | | Pocket scenario remote control |
| In One by Legrand | | 88213 | | PLC/USB gateway |
| | | | | |
| MyHome Up | | 03535 | MH202 | SCS scenario scheduler |
| MyHome Up | | 03598 | F454 | SCS/Ethernet gateway |
| MyHome Up | | 03651 | F418U2 | 2-gang DIN rail dimmer switch |
| MyHome Up | | 03847 | F411U1 | 1-gang DIN rail switch |
| MyHome Up | | 03848 | F411U2 | 2-gang DIN rail switch |
| MyHome Up | Céliane | 67557 | | 2-channel advanced automation actuator |
| MyHome Up | Céliane | 67561 | | 2-channel lighting/automation actuator |
| | | | | |
| MyHome Play | Céliane | 67223 | | Light control switch |
| MyHome Play | | 88328 | 3578 | Zigbee/USB gateway |
| MyHome Play | | 88337 | | Switched outlet |

> [!NOTE]
> Support for additional devices will be progressively added depending on the demand.
Expand Down
22 changes: 16 additions & 6 deletions src/OpenNetty.Mqtt/OpenNettyMqttAttributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ namespace OpenNetty.Mqtt;
public static class OpenNettyMqttAttributes
{
/// <summary>
/// Battery.
/// Battery alert.
/// </summary>
public const string Battery = "battery";
public const string BatteryAlert = "battery_alert";

/// <summary>
/// Brightness.
/// Battery level.
/// </summary>
public const string Brightness = "brightness";
public const string BatteryLevel = "battery_level";

/// <summary>
/// Dimming step.
/// Brightness.
/// </summary>
public const string DimmingStep = "dimming_step";
public const string Brightness = "brightness";

/// <summary>
/// Pilot wire derogation mode.
Expand Down Expand Up @@ -66,6 +66,11 @@ public static class OpenNettyMqttAttributes
/// </summary>
public const string SmartMeterRateType = "smart_meter_rate_type";

/// <summary>
/// Startup date.
/// </summary>
public const string StartupDate = "startup_date";

/// <summary>
/// Switch state.
/// </summary>
Expand All @@ -85,4 +90,9 @@ public static class OpenNettyMqttAttributes
/// Wireless burglar alarm state.
/// </summary>
public const string WirelessBurglarAlarmState = "wireless_burglar_alarm_state";

/// <summary>
/// Zigbee binding.
/// </summary>
public const string ZigbeeBinding = "zigbee_binding";
}
6 changes: 3 additions & 3 deletions src/OpenNetty.Mqtt/OpenNettyMqttBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,11 @@ public OpenNettyMqttBuilder ImportFromXmlConfiguration(XDocument document)

return Configure(options =>
{
options.DisableDiscovery = (bool?) element.Attribute("DisableDiscovery") ?? false;
options.DisableHomeAssistantDiscovery = (bool?) element.Attribute("DisableHomeAssistantDiscovery") ?? false;

var topics = (
RootTopic: (string?) element.Attribute("RootTopic"),
DiscoveryRootTopic: (string?) element.Attribute("DiscoveryRootTopic"));
DiscoveryRootTopic: (string?) element.Attribute("HomeAssistantDiscoveryRootTopic"));

if (!string.IsNullOrEmpty(topics.RootTopic))
{
Expand All @@ -194,7 +194,7 @@ public OpenNettyMqttBuilder ImportFromXmlConfiguration(XDocument document)

if (!string.IsNullOrEmpty(topics.DiscoveryRootTopic))
{
options.DiscoveryRootTopic = topics.DiscoveryRootTopic;
options.HomeAssistantDiscoveryRootTopic = topics.DiscoveryRootTopic;
}

options.ClientOptions = builder.Build();
Expand Down
36 changes: 34 additions & 2 deletions src/OpenNetty.Mqtt/OpenNettyMqttConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,33 @@ namespace OpenNetty.Mqtt;
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public sealed class OpenNettyMqttConfiguration : IPostConfigureOptions<OpenNettyMqttOptions>,
IValidateOptions<OpenNettyOptions>,
IValidateOptions<OpenNettyMqttOptions>
{
/// <inheritdoc/>
public ValidateOptionsResult Validate(string? name, OpenNettyOptions options)
{
foreach (var endpoint in options.Endpoints)
{
if (endpoint.GetStringSetting(OpenNettySettings.MqttTopic) is string topic &&
(topic.Contains('+', StringComparison.OrdinalIgnoreCase) ||
topic.Contains('*', StringComparison.OrdinalIgnoreCase)))
{
return ValidateOptionsResult.Fail(SR.FormatID2005(topic));
}
}

return ValidateOptionsResult.Success;
}

/// <inheritdoc/>
public void PostConfigure(string? name, OpenNettyMqttOptions options)
{
ArgumentNullException.ThrowIfNull(options);

if (string.IsNullOrEmpty(options.DiscoveryRootTopic))
if (string.IsNullOrEmpty(options.HomeAssistantDiscoveryRootTopic))
{
options.DiscoveryRootTopic = "homeassistant";
options.HomeAssistantDiscoveryRootTopic = "homeassistant";
}

if (string.IsNullOrEmpty(options.RootTopic))
Expand All @@ -43,6 +60,21 @@ public ValidateOptionsResult Validate(string? name, OpenNettyMqttOptions options
return ValidateOptionsResult.Fail(SR.GetResourceString(SR.ID2001));
}

if (options.RootTopic.EndsWith("/", StringComparison.OrdinalIgnoreCase))
{
return ValidateOptionsResult.Fail(SR.GetResourceString(SR.ID2007));
}

if (options.HomeAssistantDiscoveryRootTopic.EndsWith("/", StringComparison.OrdinalIgnoreCase))
{
return ValidateOptionsResult.Fail(SR.GetResourceString(SR.ID2008));
}

if (string.Equals(options.HomeAssistantDiscoveryRootTopic, options.RootTopic, StringComparison.OrdinalIgnoreCase))
{
return ValidateOptionsResult.Fail(SR.GetResourceString(SR.ID2009));
}

return ValidateOptionsResult.Success;
}
}
3 changes: 3 additions & 0 deletions src/OpenNetty.Mqtt/OpenNettyMqttExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ public static OpenNettyMqttBuilder AddMqttIntegration(this OpenNettyBuilder buil

builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<
IOpenNettyHandler, OpenNettyMqttHostedService>());

builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<
IPostConfigureOptions<OpenNettyMqttOptions>, OpenNettyMqttConfiguration>());
builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<
IValidateOptions<OpenNettyOptions>, OpenNettyMqttConfiguration>());
builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<
IValidateOptions<OpenNettyMqttOptions>, OpenNettyMqttConfiguration>());

Expand Down
Loading
Loading