yllibed / Zigbee2MqttAssistant

GUI for Zigbee2Mqtt running in docker and HASS.IO

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

twenzel opened this issue · comments

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...):

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