MQTT: How to set UNDEF when invalid data returned from Zigbee2MQTT?

A better work around is to:

  1. create a .persist file and exclude these Items from being saved.
  2. create a rule that triggers when this Item changes
  3. if and only if it’s a valid state, call .persist() on the Item to save the value

That will only store valid values to the database.