Skip to content

Commit

Permalink
Fix errros during state set, when single property doesn't work
Browse files Browse the repository at this point in the history
* since if conversion fails for a single property, the rest should still be set
  • Loading branch information
susch19 committed Nov 27, 2024
1 parent e0982eb commit 63d1123
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions AppBroker.Zigbee2Mqtt/Zigbee2MqttManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public async Task<IManagedMqttClient> Connect()
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");
Expand Down Expand Up @@ -283,7 +283,14 @@ private Dictionary<string, JToken> ReplaceCustomStates(long id, Dictionary<strin
{
if (customStates.TryGetValue(item.Property, out var token))
{
customStates[item.Name] = item.ConvertToBool(token.ToOObject());
try
{
customStates[item.Name] = item.ConvertToBool(token.ToOObject());
}
catch (Exception e)
{
logger.Warn("Could not convert {0}. \r\n Reson: {1}", item.Name, e.ToString());
}
}
}
return customStates;
Expand Down

0 comments on commit 63d1123

Please sign in to comment.