Number item is not updated when null value received via mqtt

  • Platform information:
    • Hardware: rpi4
    • OS: raspberry pi OS
    • Java Runtime Environment: 11.0.9
    • openHAB version: 2.5.10
  • Issue of the topic:
    Hi!
    I am controlling heating via openHAB rules.
    I have sonoff basic (running tasmota) with actuator and temperature sensor connected to each radiator in separate rooms that communicates via MQTT with openHAB.
    My problem is that sometimes the temperature becomes NULL in tasmota for unknown reason (faulty sensor, or contact issue?) and the regular MQTT message with the sensor data is sent with NULL towards openHAB, but openHAB does not update the item’s value to NULL in this case but leaves the last set value untouched. Therefore the system and the rule does not notices that something is wrong and treates the value as valid.

I was wondering if there is a possibility to configure OH to update number item to null value as well or could you have any suggestion how to bypass this issue?

Thank you in advance!

Best regards,
Krisztián

A couple of things here:

openHAB2 should be run with Java8, not Java11. You may run into unexpected issues using Java11 with openHAB2.

This wouldn’t be that simple, because Tasmota sends the String null, but if your Channel is a Number type it will reject it because, well, it isn’t a Number. You might want to change your Channel and Item types to String.

It’ll have something to do with your MQTT channel configuration, which is a secret from us.

Nor should it, unless you tell it to in your configuration.
It would in fact be better to update your Item state to UNDEF if you want to indicate there is some problem, like missing data. It’s easy to detect change to UNDEF with a rule.
NULL within openHAB is really for “no idea yet” which isn’t quite the same as “I know the data is missing”.
This isn’t directly related to your mystery MQTT message payload text (or absence of).

Thank you for the quick response and suggestions!

I do it then with string item. This will be the best.