LordMike / MBW.BlueRiiot2MQTT

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

Version 0.12.0 bug on deserialization #44

Closed LordMike closed 3 years ago

LordMike commented 3 years ago

i have this error with version 12

[09:54:10 INF] Loading extra config file at /data/options.json
[2021-04-13 09:54:10+00:00 INF] [MqttNet.ManagedMqttClient] Started
[2021-04-13 09:54:11+00:00 INF] [MqttNet.MqttClient] Connected.
[2021-04-13 09:54:11+00:00 INF] [Microsoft.Hosting.Lifetime] Application started. Press Ctrl+C to shut down.
[2021-04-13 09:54:11+00:00 INF] [Microsoft.Hosting.Lifetime] Hosting environment: Production
[2021-04-13 09:54:11+00:00 INF] [Microsoft.Hosting.Lifetime] Content root path: /app
[2021-04-13 09:54:12+00:00 ERR] [MBW.BlueRiiot2MQTT.Service.BlueRiiotMqttService] An error occurred while performing the update
System.InvalidCastException: Unable to cast object of type 'System.String' to type 'System.Nullable`1[System.DateTime]'.
   at MBW.Client.BlueRiiotApi.Converters.TimeSpanDatedConverter.ReadJson(JsonReader reader, Type objectType, TimeSpan existingValue, Boolean hasExistingValue, JsonSerializer serializer)
   at Newtonsoft.Json.JsonConverter`1.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType)
   at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType, JsonSerializer jsonSerializer)
   at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType)
   at Newtonsoft.Json.Linq.JToken.ToObject[T]()
   at MBW.Client.BlueRiiotApi.BlueClient.PerformHttp[TRequest,TResponse](String path, HttpMethod method, TRequest requestBody, CancellationToken token)
   at MBW.Client.BlueRiiotApi.BlueClient.GetSwimmingPools(Boolean deleted, CancellationToken token)
   at MBW.BlueRiiot2MQTT.Service.BlueRiiotMqttService.PerformUpdate(CancellationToken stoppingToken) in /src/MBW.BlueRiiot2MQTT/Service/BlueRiiotMqttService.cs:line 130
   at MBW.BlueRiiot2MQTT.Service.BlueRiiotMqttService.ExecuteAsync(CancellationToken stoppingToken) in /src/MBW.BlueRiiot2MQTT/Service/BlueRiiotMqttService.cs:line 75

Originally posted by @olivierjag2 in https://github.com/LordMike/MBW.BlueRiiot2MQTT/issues/40#issuecomment-818610703

olivierjag2 commented 3 years ago

Do you have idea what is the issue?

dodg3r commented 3 years ago

Its working for me.

Do you have the blue extender?

olivierjag2 commented 3 years ago

Yes

olivierjag2 commented 3 years ago

Works fine before update

LordMike commented 3 years ago

Do you have idea what is the issue?

I'm not sure yet... It's an API thing, likely.. maybe a new format of something. Haven't looked into it.

dodg3r commented 3 years ago

It still works for me

olivierjag2 commented 3 years ago

I try to remove and rinstall and I receive same error

ggggh commented 3 years ago

I was actually about to ask on a separate thread - have any of you installed the latest official app update? Worried it is a significant change and might change integration and "break" things? Haven't tried.. Have any of you?

dodg3r commented 3 years ago

I´m using the last app update. I´m using blue connect with premium and blue extender. I don´t have any sigfox reception in my location in sweden.

Everything works.

olivierjag2 commented 3 years ago

for me

I´m using the last iOS app update. I´m using blue connect with premium and blue extender. I don´t have any sigfox reception in my location in Canada.

don't works for me

ggggh commented 3 years ago

Ok, good to hear! Was worried it might do a firmware update on the back of one of the bluetooth readings after the last major app update (there was one on Android very recently).

ggggh commented 3 years ago

Seems to be failing on a date string? could it be some timezone in the string which isn't casting well, Mike?

olivierjag2 commented 3 years ago

can I return to .11 version?

olivierjag2 commented 3 years ago

I try with docker with version 11, I have the same error message. very weird. It work fine yesterday...

dodg3r commented 3 years ago

Really strange..

Its working like a charm for me :)

Have you tried to restart the hole server and not just hass?

If you compare to my setup. Is there anything that differs?

image

MQTT:
  Server: ip_adress
  Port: *
  Username: *
  Password: *
  ClientId: blueriiot2mqtt
BlueRiiot:
  Username: *
  Password: *
  Language: en
  DiscoveryInterval: '12:00:00'
  UpdateInterval: '01:00:00'
  UpdateIntervalWhenAllDevicesAsleep: '08:00:00'
  ReportUnchangedValues: false
HASS:
  DiscoveryPrefix: homeassistant
  TopicPrefix: blueriiot
  EnableHASSDiscovery: true
olivierjag2 commented 3 years ago

you can close the ticket...I created a new bluerioot account and I fix the problem, v12 works fine

LordMike commented 3 years ago

Seems to be failing on a date string? could it be some timezone in the string which isn't casting well, Mike?

This is definitely a borked JSON response. For some reason, newtonsoft did not interpret the datetime as a datetime - but as something else.. Perhaps an error code (in string format) or something.. ... or an invalid format.

The new account fixing it makes me think that it's more akin to an error code within the value.

Acutally.. It could perhaps be something like 23:59:60.. maybe it's a DST or leap second thing. I've just tested, and that value definitely leads to this error. I'll improve the exception, so the next time it occurs, I can see what happens.

LordMike commented 3 years ago

I'm closing this for now. @olivierjag2 I hope the new account isn't causing too much trouble.

If possible, you could try running 0.12.1 when it's out and report back if the exception still occurs? I'm very curious as to what the offending value was.

smooglemoolegs commented 3 years ago

LordMike, I can confirm that this is still happening on 0.12.1. I’ve had this issue since 0.11 and haven’t been able to get this add on to work at all. With the new debugging in 0.12.1 I get this:

[08:26:14 INF] Loading extra config file at /data/options.json
[2021-04-16 08:26:14+00:00 INF] [MqttNet.ManagedMqttClient] Started
[2021-04-16 08:26:14+00:00 INF] [MqttNet.MqttClient] Connected.
[2021-04-16 08:26:14+00:00 INF] [Microsoft.Hosting.Lifetime] Application started. Press Ctrl+C to shut down.
[2021-04-16 08:26:14+00:00 INF] [Microsoft.Hosting.Lifetime] Hosting environment: Production
[2021-04-16 08:26:14+00:00 INF] [Microsoft.Hosting.Lifetime] Content root path: /app
[2021-04-16 08:26:15+00:00 ERR] [MBW.BlueRiiot2MQTT.Service.BlueRiiotMqttService] An error occurred while performing the update
System.Exception: Unable to parse value as TimeSpan. Received: '0000-01-01T08:00:00.000'
   at MBW.Client.BlueRiiotApi.Converters.TimeSpanDatedConverter.ReadJson(JsonReader reader, Type objectType, TimeSpan existingValue, Boolean hasExistingValue, JsonSerializer serializer)
   at Newtonsoft.Json.JsonConverter`1.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType)
   at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType, JsonSerializer jsonSerializer)
   at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType)
   at Newtonsoft.Json.Linq.JToken.ToObject[T]()
   at MBW.Client.BlueRiiotApi.BlueClient.PerformHttp[TRequest,TResponse](String path, HttpMethod method, TRequest requestBody, CancellationToken token)
   at MBW.Client.BlueRiiotApi.BlueClient.GetSwimmingPools(Boolean deleted, CancellationToken token)
   at MBW.BlueRiiot2MQTT.Service.BlueRiiotMqttService.PerformUpdate(CancellationToken stoppingToken) in /src/MBW.BlueRiiot2MQTT/Service/BlueRiiotMqttService.cs:line 130
   at MBW.BlueRiiot2MQTT.Service.BlueRiiotMqttService.ExecuteAsync(CancellationToken stoppingToken) in /src/MBW.BlueRiiot2MQTT/Service/BlueRiiotMqttService.cs:line 75
LordMike commented 3 years ago

Nice. I'll make that work.

LordMike commented 3 years ago

@smooglemoolegs try 0.12.2. :)

smooglemoolegs commented 3 years ago

Thanks for the quick fix, @LordMike. I can confirm that 0.12.2 fixed this issue.

olivierjag2 commented 3 years ago

can I make the update?

LordMike commented 3 years ago

I believe you can perform the update, yes.. ?

smooglemoolegs commented 3 years ago

You should see the update on HASS add on store. It didn’t show for me straight away but I waited overnight then it showed up.