Data Property Empty Error

I am trying to connect an external mqtt server to losant. The mqtt node connects to my server. Then I have a JSON decode that converts the message from “data.message” to an “output” object and sends it to the device state node.

When the device runs I keep getting the following error:
MQTT Error 1

Here is the device state tab showing that there are 7 attributes but only one I am connecting now to test functionality.

Here is the MQTT packet info showing that there is data (even null) in the packet:
MQTT Error MQTT packet

I don’t see why even if the data is null that it would not at least show up in the first screenshot with the keys in the MQTT packet and a value of null or zero.

Hey @Jackson_Miller,

Welcome to the forums!

null is not automatically interpreted as 0 when reporting state. When null or undefined are reported as attributes, the values are ignored.

There are times when this behavior can be quite useful. You can have a single Device State Node reporting data for every attribute, even if the attributes aren’t on the payload. Any values that aren’t there are ignored. This prevents the requirement of having to check that every attribute exists before reporting them.

In your specific use case, you can use the defaultTo helper to report 0 if the value is null or undefined.

{{defaultTo outputs.uFire_Mod-Flow_1.1 0}}

More details about this helper can be found in the docs.

Potentially related is that your object key has a special character in it: 1/min. To reference this in a template, you’ll need to use square brackets:

{{ output.uFire_Mod-Flow_1.[1/min] }}
1 Like