Batch payload reporting is not updating device state

I am currently attempting to record data in relatively frequent intervals, and then use batch reporting to update the device state.

as shown in the device log, the MQTT broker is receiving each of the payloads that i have sent to the device state topic (approx. 24 payloads over 2 minutes), and it correctly shows my payloads back to me. However, i expect a device state update for each of these payloads, and currently it is only registering one state update for each set of 24 payloads.

Is this expected behaviour? And if so, what happens to the additional data packets I am sending / am I able to access them in some way? Can I adjust this behaviour?

For some background, I am using the losant python mqtt library, and sending data using the line:

self._mqtt_client.publish(self._state_topic(), json.dumps(self.data))

Sorry, but I’m having trouble following along …

as shown in the device log, the MQTT broker is receiving each of the payloads that i have sent to the device state topic (approx. 24 payloads over 2 minutes)

In the screenshot you provided, it appears that you are reporting once every two minutes per both the device log and the attribute data table; I’m not seeing ~24 separate payloads over a two-minute period. And the timestamps seem to correspond between the two.

I do see a bulk state report above those entries; are you expecting the values in that report to overwrite values that were previously reported? If so, are you including a timestamp per object in the array you are sending? And do those timestamps match existing state report timestamps down to the millisecond?

If I’m off track with what the issue is here, I may need you to PM me more information - an example device ID, the objects / arrays you are reporting up from the device, and more details on what the expected end result is.

Hey Dylan,

Sorry for the confusion - that screenshot is slightly unclear. I am reporting once every two minutes, however, each of those reports is a bulk state report with 24 payloads collected over the 2 minute period between transmissions. In the screenshot, each of those individual reports are the same as the bulk state report above those entries, I had just collapsed them so I could show that they are there.

The behaviour I’m expecting is less about overriding previously reported payloads, and more just sending a bunch of state reports at once. It would effectively be the same as sending a state update every 5 seconds, but just saves on the total number of requests we’re sending.

Each payload object in the array looks more or less like the following:

{'data': {'timestamp': '2024-07-17T14:46:00', 'loc': '51.057811,-113.9960727', 'airTemp': 24.566, 'airHum': 38.89, 'airPres': 89370.0, 'min_wind_dir': 330.6, 'max_wind_dir': 330.6, 'average_wind_dir': 330.6, 'min_wind_speed': 0.0, 'max_wind_speed': 0.0, 'average_wind_speed': 0.0, 'heating_temp': 26.75, 'dump_state': 0.0, 'pm2_5': 37.0, 'pm10': 43.0, 'noise_intensity': 46.1, 'cpu_temp': 32.0, 'board_temp': 31.25}}

I was reading into the metadata object of a payload - is that required here?

I think i see the issue - you are including a timestamp property in the data object, where it is being treated as another device attribute.

Instead, you need to pass a time property as a sibling of the data object for each entry in the array, like so:

[
  {
    "time": "2024-07-17T14:46:00",
    "data": {
      "loc": "51.057811,-113.9960727",
      "airTemp": 24.566,
      ...
    }
  },
  ...
]

That seemed to have worked! I’m now running into a time zone issue, but that’s just on my end.

Thank you for all your help!