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

System.InvalidCastException: Null object cannot be converted to a value type. #402

Open
twenzel opened this issue Aug 30, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@twenzel
Copy link

twenzel commented Aug 30, 2021

fail: Zigbee2MqttAssistant.Services.MqttConnectionService[0]
      Error processing MQTT message on topic 'zigbee2mqtt/0x00158d00045ad091'
System.InvalidCastException: Null object cannot be converted to a value type.
   at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
   at Newtonsoft.Json.Linq.Extensions.Convert[T,U](T token)
   at Newtonsoft.Json.Linq.Extensions.Value[T,U](IEnumerable`1 value)
   at Newtonsoft.Json.Linq.Extensions.Value[U](IEnumerable`1 value)
   at Zigbee2MqttAssistant.Services.BridgeStateService.UpdateDevice(String friendlyName, String jsonPayload, Boolean& forceLastSeen) in d:\a\1\s\Zigbee2MqttAssistant\Services\BridgeStateService.cs:line 124
   at Zigbee2MqttAssistant.Services.MqttConnectionService.DispatchZigbee2MqttMessage(MqttApplicationMessage msg) in d:\a\1\s\Zigbee2MqttAssistant\Services\MqttConnectionService.cs:line 505
   at Zigbee2MqttAssistant.Services.MqttConnectionService.HandleApplicationMessageReceivedAsync(MqttApplicationMessageReceivedEventArgs eventArgs) in d:\a\1\s\Zigbee2MqttAssistant\Services\MqttConnectionService.cs:line 394

Payload:

'{"battery":100,"device":{"applicationVersion":3,"dateCode":"20161129","friendlyName":"0x00158d00045ad091","hardwareVersion":30,"ieeeAddr":"0x00158d00045ad091","manufacturerID":4151,"manufacturerName":"LUMI","model":"WSDCGQ11LM","networkAddress":28156,"powerSource":"Battery","softwareBuildID":"3000-0001","stackVersion":2,"type":"EndDevice","zclVersion":1},"humidity":66.73,"linkquality":null,"pressure":958,"temperature":19.44,"voltage":3215}'

This is for a Aqara temperature, humidity and pressure sensor (WSDCGQ11LM), but happens also for a Aqara door & window contact sensor (MCCGQ11LM).

Steps I took to try resolve the problem

For all payloads I checked, it seems the linkquality is null.

Installation

  • Version of Zigbee2Mqtt: 1.21.0
  • Version of Zigbee2MqttAssistant: 0.3.181
  • Installation type (HASS.IO, Docker...): docker
  • Docker version + CPU type (amd64, arm arm64...):
@twenzel twenzel added the bug Something isn't working label Aug 30, 2021
@myroad94
Copy link

myroad94 commented Feb 8, 2022

Hi, I reproduce the issue.

System.InvalidCastException: Null object cannot be converted to a value type.
   at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
   at Newtonsoft.Json.Linq.Extensions.Convert[T,U](T token)
   at Newtonsoft.Json.Linq.Extensions.Value[T,U](IEnumerable`1 value)
   at Newtonsoft.Json.Linq.Extensions.Value[U](IEnumerable`1 value)
   at Zigbee2MqttAssistant.Services.BridgeStateService.UpdateDevice(String friendlyName, String jsonPayload, Boolean& forceLastSeen) in D:\a\1\s\Zigbee2MqttAssistant\Services\BridgeStateService.cs:line 124
   at Zigbee2MqttAssistant.Services.MqttConnectionService.DispatchZigbee2MqttMessage(MqttApplicationMessage msg) in D:\a\1\s\Zigbee2MqttAssistant\Services\MqttConnectionService.cs:line 505
   at Zigbee2MqttAssistant.Services.MqttConnectionService.HandleApplicationMessageReceivedAsync(MqttApplicationMessageReceivedEventArgs eventArgs) in D:\a\1\s\Zigbee2MqttAssistant\Services\MqttConnectionService.cs:line 394
fail: Zigbee2MqttAssistant.Services.MqttConnectionService[0]
      Error processing MQTT message on topic 'zigbee2mqtt/LivarnoStrip-0x588e81fffef2c9a4'
System.InvalidCastException: Null object cannot be converted to a value type.
   at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
   at Newtonsoft.Json.Linq.Extensions.Convert[T,U](T token)
   at Newtonsoft.Json.Linq.Extensions.Value[T,U](IEnumerable`1 value)
   at Newtonsoft.Json.Linq.Extensions.Value[U](IEnumerable`1 value)
   at Zigbee2MqttAssistant.Services.BridgeStateService.UpdateDevice(String friendlyName, String jsonPayload, Boolean& forceLastSeen) in D:\a\1\s\Zigbee2MqttAssistant\Services\BridgeStateService.cs:line 124
   at Zigbee2MqttAssistant.Services.MqttConnectionService.DispatchZigbee2MqttMessage(MqttApplicationMessage msg) in D:\a\1\s\Zigbee2MqttAssistant\Services\MqttConnectionService.cs:line 505
   at Zigbee2MqttAssistant.Services.MqttConnectionService.HandleApplicationMessageReceivedAsync(MqttApplicationMessageReceivedEventArgs eventArgs) in D:\a\1\s\Zigbee2MqttAssistant\Services\MqttConnectionService.cs:line 394
fail: Zigbee2MqttAssistant.Services.MqttConnectionService[0]
      Error processing MQTT message on topic 'zigbee2mqtt/XiaomiMotionChamberSouth-0x00158d0006d41209'
System.InvalidCastException: Null object cannot be converted to a value type.
   at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
   at Newtonsoft.Json.Linq.Extensions.Convert[T,U](T token)
   at Newtonsoft.Json.Linq.Extensions.Value[T,U](IEnumerable`1 value)
   at Newtonsoft.Json.Linq.Extensions.Value[U](IEnumerable`1 value)
   at Zigbee2MqttAssistant.Services.BridgeStateService.UpdateDevice(String friendlyName, String jsonPayload, Boolean& forceLastSeen) in D:\a\1\s\Zigbee2MqttAssistant\Services\BridgeStateService.cs:line 124
   at Zigbee2MqttAssistant.Services.MqttConnectionService.DispatchZigbee2MqttMessage(MqttApplicationMessage msg) in D:\a\1\s\Zigbee2MqttAssistant\Services\MqttConnectionService.cs:line 505
   at Zigbee2MqttAssistant.Services.MqttConnectionService.HandleApplicationMessageReceivedAsync(MqttApplicationMessageReceivedEventArgs eventArgs) in D:\a\1\s\Zigbee2MqttAssistant\Services\MqttConnectionService.cs:line 394
fail: Zigbee2MqttAssistant.Services.MqttConnectionService[0]
      Error processing MQTT message on topic 'zigbee2mqtt/XiaomiMotionBed-0x00158d0006d41425'
System.InvalidCastException: Null object cannot be converted to a value type.
   at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
   at Newtonsoft.Json.Linq.Extensions.Convert[T,U](T token)
   at Newtonsoft.Json.Linq.Extensions.Value[T,U](IEnumerable`1 value)
   at Newtonsoft.Json.Linq.Extensions.Value[U](IEnumerable`1 value)
   at Zigbee2MqttAssistant.Services.BridgeStateService.UpdateDevice(String friendlyName, String jsonPayload, Boolean& forceLastSeen) in D:\a\1\s\Zigbee2MqttAssistant\Services\BridgeStateService.cs:line 124
   at Zigbee2MqttAssistant.Services.MqttConnectionService.DispatchZigbee2MqttMessage(MqttApplicationMessage msg) in D:\a\1\s\Zigbee2MqttAssistant\Services\MqttConnectionService.cs:line 505
   at Zigbee2MqttAssistant.Services.MqttConnectionService.HandleApplicationMessageReceivedAsync(MqttApplicationMessageReceivedEventArgs eventArgs) in D:\a\1\s\Zigbee2MqttAssistant\Services\MqttConnectionService.cs:line 394
fail: Zigbee2MqttAssistant.Services.MqttConnectionService[0]
      Error processing MQTT message on topic 'zigbee2mqtt/XiaomiMotion-0x00158d0006d46f30'

On a side-note, the CPU is always used at 5 or 6% by zigbee2mqtt assistant:

    PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND
   3770 root      20   0   15.5g  67968   5300 S   6.2   1.7 107:03.45 dotnet Zigbee2MqttAssistant.dll

Environment: using containers

  • koenkk/zigbee2mqtt:1.21.1
  • carldebilly/zigbee2mqttassistant:0.3.178
  • eclipse-mosquitto:2.0.10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants