diff --git a/AppBroker.Zigbee2Mqtt/Zigbee2MqttDeviceBaseJson.cs b/AppBroker.Zigbee2Mqtt/Zigbee2MqttDeviceBaseJson.cs index 7eb2546..064857e 100644 --- a/AppBroker.Zigbee2Mqtt/Zigbee2MqttDeviceBaseJson.cs +++ b/AppBroker.Zigbee2Mqtt/Zigbee2MqttDeviceBaseJson.cs @@ -520,7 +520,7 @@ 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() { @@ -528,6 +528,19 @@ public Zigbee2MqttListFeature() } } +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")] @@ -664,6 +677,9 @@ public enum Zigbee2MqttPowerSource [EnumMember(Value = "DC Source")] DC, + + [EnumMember(Value = "Unknown")] + Unknown, } public class Coordinator1 : Zigbee2MqttDeviceBaseJson diff --git a/AppBroker.Zigbee2Mqtt/Zigbee2MqttManager.cs b/AppBroker.Zigbee2Mqtt/Zigbee2MqttManager.cs index c039350..0b32111 100644 --- a/AppBroker.Zigbee2Mqtt/Zigbee2MqttManager.cs +++ b/AppBroker.Zigbee2Mqtt/Zigbee2MqttManager.cs @@ -111,7 +111,20 @@ public async Task 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()}"); + + } + } logger.Debug("Subscribed the incomming mqtt messages"); await managedMqttClient.StartAsync(managedMqttClientOptions); logger.Debug("Started the mqtt client");