openhab / openhab-addons

Add-ons for openHAB
https://www.openhab.org/
Eclipse Public License 2.0
1.88k stars 3.59k forks source link

[mqtt] not reliable after upgrade to 4.2.0 "Command 'NULL' from channel [...] not supported" #17533

Open MaTr74 opened 1 week ago

MaTr74 commented 1 week ago

Expected Behavior

MQTT plugin isn't treat a message/field/command as NULL.

Current Behavior

I have the following MQTT thing configured:

    Thing topic test "Test" {
         Channels:
             Type switch: Status [ stateTopic="tele/wp-zigbee-coordinator-01/SENSOR", transformationPattern="REGEX:(.*ZbReceived.*test.*ZoneStatusChange.*)∩JSONPATH:$..*.ZoneStatusChange", on="1", off="0" ]
             Type number: LinkQuality [ stateTopic="tele/wp-zigbee-coordinator-01/SENSOR", transformationPattern="REGEX:(.*ZbReceived.*test.*LinkQuality.*)∩JSONPATH:$..*.LinkQuality" ]
             Type number: BatteryVoltage [ stateTopic="tele/wp-zigbee-coordinator-01/SENSOR", transformationPattern="REGEX:(.*ZbReceived.*test.*BatteryVoltage.*)∩JSONPATH:$..*.BatteryVoltage", unit="V" ]
             Type number: BatteryPercentage [ stateTopic="tele/wp-zigbee-coordinator-01/SENSOR", transformationPattern="REGEX:(.*ZbReceived.*test.*BatteryPercentage.*)∩JSONPATH:$..*.BatteryPercentage", unit="%" ]
             Type datetime: LastSeen [ stateTopic="tele/wp-zigbee-coordinator-01/SENSOR", transformationPattern="REGEX:(.*ZbReceived.*test.*)∩JS:currentDateTime.js" ]
     }

When I send the following message a second time:

{"ZbReceived":{"0xA7E2":{"Device":"0xA7E2","Name":"test","Cluster":10,"Read":[7],"ReadNames":{"LocalTime":true},"Endpoint":1,"LinkQuality":76}}}

... the following WARN messages appear in the log:

2024-10-12 09:29:52.535 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Command 'NULL' from channel 'mqtt:topic:mosquitto:test:LinkQuality' not supported by type 'NumberValue': Character N is neither a decimal digit number, decimal point, nor "e" notation exponential mark.

Steps to Reproduce (for Bugs)

  1. Create docker network sudo docker network create openhab-test
  2. Install docker Mosquitto image (see attached mosquitto-docker-compose.yml)
  3. Install docker openHAB image (see attached openhab-docker-compose.yml)
  4. Install the following openHAB addons:
    • MQTT Binding
    • JSONPATH transformation
    • Regex transformation
  5. Add mqtt.things file to conf/things (file attached)
  6. Send the message above twice to topic tele/wp-zigbee-coordinator-01/SENSOR

Your Environment

files.zip

lsiepel commented 1 week ago

Not really sure what is going on there, might be related to the chaining, might be something different. I suspect it is rather introduced into 4.2.0 and not in in 4.2.2 as the changelog does not show something i can tie to this. Maybe @jimtng has some thoughts on this issue?

MaTr74 commented 1 week ago

I went back step by step through the releases and can confirm that the warnings occur with 4.2.0. On 4.1.3 everything is working well. I will fix the title.

MaTr74 commented 1 week ago

I've just created a minimal example and updated the report with which you can reproduce the behaviour.