Skip to content

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

@twenzel

Description

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions