Parsing Node_Red payload

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

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"}}'

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

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)


Then pass it through a json parser node.
Hopefully the payload will now show like this

And you can then use a change node to move the required bit of msg.payload.data into msg.payload.

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.

using the HASS rather than MQTT. Thanks so much

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