# Batch payload reporting is not updating device state

**URL:** <https://forums.losant.com/t/batch-payload-reporting-is-not-updating-device-state/5527>\
**Category:** Help\
**Tags:** mqtt, device\
**Created:** [July 17, 2024, 8:44pm UTC](https://forums.losant.com/t/batch-payload-reporting-is-not-updating-device-state/5527 "2024-07-17T20:44:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Logan\_Parker](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/logan_parker/32/4860_2.png) [@Logan\_Parker](https://forums.losant.com/u/Logan_Parker)\
**Post date:** [July 17, 2024, 8:44pm UTC](https://forums.losant.com/t/batch-payload-reporting-is-not-updating-device-state/5527/1 "2024-07-17T20:44:55Z")

</div>

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

 ![Screenshot 2024-07-17 at 2.31.59 PM](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/6/662b598f8a5d372eb5277c287d83048fce6fd9de.png)

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:

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

```

---

<div class="post-metadata">

**Author:** ![Dylan\_Schuster](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/dylan_schuster/32/2850_2.png) [@Dylan\_Schuster](https://forums.losant.com/u/Dylan_Schuster)\
**Post date:** [July 18, 2024, 12:00pm UTC](https://forums.losant.com/t/batch-payload-reporting-is-not-updating-device-state/5527/2 "2024-07-18T12:00:00Z")

</div>

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](https://docs.losant.com/devices/state/#batch-reporting) 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](https://docs.losant.com/devices/state/#overwriting-previous-states)?

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.

---

<div class="post-metadata">

**Author:** ![Logan\_Parker](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/logan_parker/32/4860_2.png) [@Logan\_Parker](https://forums.losant.com/u/Logan_Parker)\
**Post date:** [July 18, 2024, 2:44pm UTC](https://forums.losant.com/t/batch-payload-reporting-is-not-updating-device-state/5527/3 "2024-07-18T14:44:29Z")

</div>

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:

```auto
{'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?

---

<div class="post-metadata">

**Author:** ![Dylan\_Schuster](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/dylan_schuster/32/2850_2.png) [@Dylan\_Schuster](https://forums.losant.com/u/Dylan_Schuster)\
**Post date:** [July 18, 2024, 2:51pm UTC](https://forums.losant.com/t/batch-payload-reporting-is-not-updating-device-state/5527/4 "2024-07-18T14:51:37Z")

</div>

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:

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

```

---

<div class="post-metadata">

**Author:** ![Logan\_Parker](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/logan_parker/32/4860_2.png) [@Logan\_Parker](https://forums.losant.com/u/Logan_Parker)\
**Post date:** [July 18, 2024, 3:09pm UTC](https://forums.losant.com/t/batch-payload-reporting-is-not-updating-device-state/5527/5 "2024-07-18T15:09:08Z")

</div>

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!
