Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed z2m intergration #33

Merged
merged 2 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
18 changes: 17 additions & 1 deletion AppBroker.Zigbee2Mqtt/Zigbee2MqttDeviceBaseJson.cs
Original file line number Diff line number Diff line change
Expand Up @@ -520,14 +520,27 @@ public JToken ConvertToBool(object v)
public class Zigbee2MqttListFeature : Zigbee2MqttGenericExposedFeature
{
[JsonProperty("item_type")]
public string ItemType { get; set; } = "number";
public ItemType ItemType { get; set; }

public Zigbee2MqttListFeature()
{
Type = Zigbee2MqttGenericFeatureType.List;
}
}

public class ItemType
{
[JsonProperty("access")]
public int Access { get; set; }
[JsonProperty("label")]
public string Label { get; set; }
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("type")]
public string Type { get; set; }
}


public class Zigbee2MqttNumericFeaturePreset : Zigbee2MqttDeviceBaseJson
{
[JsonProperty("name")]
Expand Down Expand Up @@ -664,6 +677,9 @@ public enum Zigbee2MqttPowerSource

[EnumMember(Value = "DC Source")]
DC,

[EnumMember(Value = "Unknown")]
Unknown,
}

public class Coordinator1 : Zigbee2MqttDeviceBaseJson
Expand Down
16 changes: 15 additions & 1 deletion AppBroker.Zigbee2Mqtt/Zigbee2MqttManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,21 @@ public async Task<IManagedMqttClient> Connect()
logger.Debug("Builded new mqtt tcp client options");

MQTTClient = managedMqttClient;
MQTTClient.ApplicationMessageReceivedAsync += Mqtt_ApplicationMessageReceivedAsync;
MQTTClient.ApplicationMessageReceivedAsync += async (e) =>
{

try
{
await Mqtt_ApplicationMessageReceivedAsync(e);
}
catch (Exception ex)
{
logger.Error(ex);
logger.Error($"{e.ApplicationMessage.Topic}{Environment.NewLine}{e.ApplicationMessage.ConvertPayloadToString()}");

}
}
;
susch19 marked this conversation as resolved.
Show resolved Hide resolved
logger.Debug("Subscribed the incomming mqtt messages");
await managedMqttClient.StartAsync(managedMqttClientOptions);
logger.Debug("Started the mqtt client");
Expand Down
Loading