LordMike / MBW.BlueRiiot2MQTT

Utility to map between Blue Riiots pool API, and Home Assistant MQTT
49 stars 2 forks source link

ArgumentNullException while publishing to broker #19

Closed kopierschnitte closed 4 years ago

kopierschnitte commented 4 years ago

Hi! I've recently added a 2nd pool to my BlueRiiot account and now I can't get updated values anymore. BlueRiiot2MQTT log shows the following right after starting the image:

[2020-08-08 11:41:18+00:00 INF] [MqttNet.MqttClient] Connected.
[2020-08-08 11:41:18+00:00 INF] [MBW.BlueRiiot2MQTT.Service.BlueRiiotMqttService] Forcing a sync with BlueRiiot
[2020-08-08 11:41:19+00:00 INF] [Microsoft.Hosting.Lifetime] Application started. Press Ctrl+C to shut down.
[2020-08-08 11:41:19+00:00 INF] [Microsoft.Hosting.Lifetime] Hosting environment: Production
[2020-08-08 11:41:19+00:00 INF] [Microsoft.Hosting.Lifetime] Content root path: /app
[2020-08-08 11:41:23+00:00 ERR] [MBW.BlueRiiot2MQTT.Service.BlueRiiotMqttService] An error occurred while pushing updated data to MQTT
System.ArgumentNullException: Value cannot be null. (Parameter 'o')
   at Newtonsoft.Json.Utilities.ValidationUtils.ArgumentNotNull(Object value, String parameterName)
   at Newtonsoft.Json.Linq.JToken.FromObjectInternal(Object o, JsonSerializer jsonSerializer)
   at Newtonsoft.Json.Linq.JToken.FromObject(Object o)
   at MBW.HassMQTT.HassMqttManager.SendValue(IMqttValueContainer container, Boolean resetDirty, CancellationToken token)
   at MBW.HassMQTT.HassMqttManager.FlushAll(CancellationToken token)
   at MBW.BlueRiiot2MQTT.Service.BlueRiiotMqttService.ExecuteAsync(CancellationToken stoppingToken) in /src/MBW.BlueRiiot2MQTT/Service/BlueRiiotMqttService.cs:line 152
[2020-08-08 11:41:23+00:00 INF] [MBW.BlueRiiot2MQTT.Service.BlueRiiotMqttService] New data ready at 08/08/2020 12:39:49 (interval 01:12:00). Waiting 00:58:25.5631689
LordMike commented 4 years ago

It'll be interesting to know exactly which value you've had, that could've been null.. I've added code to handle the case of a value being null in the lower levels, as it's bound to happen (like now).

I'll push an update momentarily.

LordMike commented 4 years ago

0.7.2 is out soon.

Let me know if it fixes the immediate issue, and let's see if we can find the empty/null value

LordMike commented 4 years ago

Oh btw, be aware that the automatic polling occurs when any blue device should have new data, for all devices.

So with 2 devices, it'll poll twice as often on both devices, even if just one of them is expected to have data.

I might change that to be per-device.

kopierschnitte commented 4 years ago

Okay, seems to fixed. Thanks!