# Parsing Node\_Red payload

**URL:** https://discourse.nodered.org/t/parsing-node-red-payload/96200
**Category:** General
**Tags:** home-assistant
**Created:** [23 March 2025 17:35 UTC](https://discourse.nodered.org/t/parsing-node-red-payload/96200 "2025-03-23T17:35:18Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![whlatimer](https://avatars.discourse-cdn.com/v4/letter/w/b5e925/32.png) [@whlatimer](https://discourse.nodered.org/u/whlatimer)
#### Post date: [23 March 2025 17:35 UTC](https://discourse.nodered.org/t/parsing-node-red-payload/96200/1 "2025-03-23T17:35:18Z")

</div>

I'm using a Node-Red flow written by someone else to read my electric meter (Smart Meter) hourly; the flow executes an api from SmartMeter and is intended to return a single value that updates a sensor. Based on the error below, it seems the API is executing properly but the return value (payload) is a string that contains several values.

I am new to both Node Red and MQTT, so I'm stumbling in the dark so to speak.

My theory is that the API was changed to return multiple instead of a single value. Can anyone suggest a solution on how to parse the payload in order to extract one or more of the values. TIA

Exception raised while updating state of sensor.smt\_current\_reading, topic: 'smt/reading' with

```auto
payload: b'{"data":{"odrstatus":"COMPLETED","odrread":56972.21,"odrusage":42.556,"odrdate":"03/22/2025 10:06:00","responseMessage":"SUCCESS"}}'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/sensor/ **init**.py", line 640, in state
numerical_value = float(value) # type:ignore[arg-type]
ValueError: could not convert string to float: '{"data":{"odrstatus":"COMPLETED","odrread":56972.21,"odrusage":42.556,"odrdate":"03/22/2025 10:06:00","responseMessage":"SUCCESS"}}'

```

---

<div class="post-metadata">

### Author: ![hardillb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hardillb/32/12373_2.png) [@hardillb](https://discourse.nodered.org/u/hardillb)
#### Post date: [23 March 2025 18:05 UTC](https://discourse.nodered.org/t/parsing-node-red-payload/96200/2 "2025-03-23T18:05:14Z")

</div>

The exception appears to be coming from some Home Assistant Python, not Node-RED.

The exception is complaining that a JSON string is being passed and not a single floating point number, I suspect it is expecting to only receive the value of `odrusage` or `odread`.

Assuming the JSON is in a `msg.payload` then you should be able to use the change node to move the required value to being just the payload before sending it on

---

<div class="post-metadata">

### Author: ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)
#### Post date: [23 March 2025 18:22 UTC](https://discourse.nodered.org/t/parsing-node-red-payload/96200/3 "2025-03-23T18:22:51Z")

</div>

> [@whlatimer](#):
>
> `payload: b'{"data":{"odrstatus":"COMPLETED","odrread":56972.21,"odrusage":42.556,"odrdate":"03/22/2025 10:06:00","responseMessage":"SUCCESS"}}'`

If this was _just_ Node-red I would approach the problem this way:

Use a debug node to show you the msg.payload.  
If it looks like this (the datatype is "string" and there is no 'b' at the beginning)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/d/0da2c85130f86d04b89f449a0baab27969369cf8.png)  
Then pass it through a json parser node.  
Hopefully the payload will now show like this  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/a/0a9e2e5fc2989ceabbf614973cc11d8e1f8a9d2c.png)  
And you can then use a change node to move the required bit of msg.payload.data into msg.payload.

---

<div class="post-metadata">

### Author: ![mikefila](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mikefila/32/95223_2.png) [@mikefila](https://discourse.nodered.org/u/mikefila)
#### Post date: [23 March 2025 19:41 UTC](https://discourse.nodered.org/t/parsing-node-red-payload/96200/4 "2025-03-23T19:41:56Z")

</div>

If you are still confused about how to fix this error, please export and post your flow. Or at least link to the code you copied. It will make it easier to explain how to correct the error.

---

<div class="post-metadata">

### Author: ![whlatimer](https://avatars.discourse-cdn.com/v4/letter/w/b5e925/32.png) [@whlatimer](https://discourse.nodered.org/u/whlatimer)
#### Post date: [23 March 2025 21:07 UTC](https://discourse.nodered.org/t/parsing-node-red-payload/96200/5 "2025-03-23T21:07:32Z")

</div>

> **[GitHub - stmrocket/ha-smartmetertexas: Smart Meter Texas API Implementation for Node-Red...](https://github.com/stmrocket/ha-smartmetertexas)**
>
> Smart Meter Texas API Implementation for Node-Red and Home Assistant

using the HASS rather than MQTT. Thanks so much

---

<div class="post-metadata">

### Author: ![mikefila](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mikefila/32/95223_2.png) [@mikefila](https://discourse.nodered.org/u/mikefila)
#### Post date: [24 March 2025 14:15 UTC](https://discourse.nodered.org/t/parsing-node-red-payload/96200/6 "2025-03-24T14:15:17Z")

</div>

Could you turn on this debug, click on the translucent tab and deploy. Execute the flow and post the message from the debug.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/2/a2916dfe1e956973729f781de0594c52ff76cd8c.png)

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [22 June 2025 14:15 UTC](https://discourse.nodered.org/t/parsing-node-red-payload/96200/7 "2025-06-22T14:15:48Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
