Need help with p1 smart meter

Fighting to read the results of the p1readernode. The gas gives value the actual electricity stay zero.
The function i use

var payload=msg.payload;
var msg1 = {};
var msg2 = {};
var msg3 = {};
var msg4 = {};
msg1.payload = payload.electricity.delivered.tariff1.reading;
msg2.payload = payload.electricity.delivered.tariff2.reading;
msg3.payload = payload.electricity.delivered.actual.reading;
msg4.payload = payload.gas.reading;

return [ msg1, msg2, msg3, msg4 ];

The path i get from the debug node, so no idea why it does not work.

This is just a hunch, actual is in bold for some reason.
try

payload.electricity.delivered["actual"].reading

Add a debug node to the output of the node feeding the function node and run it. Then in the sidebar, expand all of the message and copy and past it into a reply so we can see what the data going into the function node is.

"{"meterType":"ISK5\\2M550E-1012","version":"50","timestamp":"2021-12-19T10:01:24.000Z","equipmentId":"4530303433303036393938303836303137","textMessage":{"codes":null,"message":""},"electricity":{"received":{"tariff1":{"reading":5677.072,"unit":"kWh"},"tariff2":{"reading":5932.27,"unit":"kWh"},"actual":{"reading":0.269,"unit":"kW"}},"delivered":{"tariff1":{"reading":0,"unit":"kWh"},"tariff2":{"reading":0,"unit":"kWh"},"actual":{"reading":0,"unit":"kW"}},"tariffIndicator":1,"threshold":null,"fuseThreshold":null,"switchPosition":null,"numberOfPowerFailures":9,"numberOfLongPowerFailures":2,"longPowerFailureLog":{"count":0,"log":[]},"voltageSags":{"L1":8,"L2":null,"L3":null},"voltageSwell":{"L1":1,"L2":null,"L3":null},"instantaneous":{"current":{"L1":{"reading":1,"unit":"A"},"L2":{"reading":null,"unit":null},"L3":{"reading":null,"unit":null}},"voltage":{"L1":{"reading":228,"unit":"V"},"L2":{"reading":null,"unit":null},"L3":{"reading":null,"unit":null}},"power":{"positive":{"L1":{"reading":0..."
12/19/2021, 10:00:37 AMnode: json-node
msg.payload : string[1371]



The reading event returns the following data structure:

{
    "meterType": "ISk5\2MT382-1000",
    "version": "42",
    "timestamp": "2010-12-09T10:30:20.000Z",
    "equipmentId": "4B384547303034303436333935353037",
    "textMessage": {
        "codes": "3031203631203831",
        "message": "0123456789:;<=>?0123456789:;<=>?0123456789:;<=>?0123456789:;<=>?0123456789:;<=>?"
    },
    "electricity": {
        "received": {
            "tariff1": {
                "reading": 123456.789,
                "unit": "kWh"
            },
            "tariff2": {
                "reading": 123456.789,
                "unit": "kWh"
            },
            "actual": {
                "reading": 1.193,
                "unit": "kW"
            }
        },
        "delivered": {
            "tariff1": {
                "reading": 123456.789,
                "unit": "kWh"
            },
            "tariff2": {
                "reading": 123456.789,
                "unit": "kWh"
            },
            "actual": {
                "reading": 0,
                "unit": "kW"
            }
        },
        "tariffIndicator": 2,
        "threshold": {
            "value": 16.1,
            "unit": "kW"
        },
        "fuseThreshold": {
            "value": 10,
            "unit": "A"
        },
        "switchPosition": "1",
        "numberOfPowerFailures": 4,
        "numberOfLongPowerFailures": 2,
        "longPowerFailureLog": {
            "count": 2,
            "log": [
                {
                    "startOfFailure": "2010-12-08T14:20:15.000Z",
                    "endOfFailure": "2010-12-08T14:24:15.000Z",
                    "duration": 240,
                    "unit": "s"
                },
                {
                    "startOfFailure": "2010-12-08T14:05:03.000Z",
                    "endOfFailure": "2010-12-08T14:10:04.000Z",
                    "duration": 301,
                    "unit": "s"
                }
            ]
        },
        "voltageSags": {
            "L1": 2,
            "L2": 1,
            "L3": 0
        },
        "voltageSwell": {
            "L1": 0,
            "L2": 3,
            "L3": 0
        },
        "instantaneous": {
            "current": {
                "L1": {
                    "reading": 1,
                    "unit": "A"
                },
                "L2": {
                    "reading": 2,
                    "unit": "A"
                },
                "L3": {
                    "reading": 3,
                    "unit": "A"
                }
            },
            "voltage": {
                "L1": {
                    "reading": 231,
                    "unit": "V"
                },
                "L2": {
                    "reading": 232,
                    "unit": "V"
                },
                "L3": {
                    "reading": 233,
                    "unit": "V"
                }
            },
            "power": {
                "positive": {
                    "L1": {
                        "reading": 1.111,
                        "unit": "kW"
                    },
                    "L2": {
                        "reading": 2.222,
                        "unit": "kW"
                    },
                    "L3": {
                        "reading": 3.333,
                        "unit": "kW"
                    }
                },
                "negative": {
                    "L1": {
                        "reading": 4.444,
                        "unit": "kW"
                    },
                    "L2": {
                        "reading": 5.555,
                        "unit": "kW"
                    },
                    "L3": {
                        "reading": 6.666,
                        "unit": "kW"
                    }
                }
            }
        }
    },
    "gas": {
        "deviceType": "003",
        "equipmentId": "3232323241424344313233343536373839",
        "timestamp": "2010-12-09T10:00:00.000Z",
        "reading": 12785.123,
        "unit": "m3",
        "valvePosition": "1"
    }
}

@ E1cid i got the path from a debug node,that why i am confused, in the dbug it give the value.

That is the copy paste its payload.electricity.delivered.actual.reading; in the code.

I am thinking actual has a meaning in JS , I think JQuery (again a hunch). Have you tried my suggestion? That will eliminate my hunch at least.
re-reading your initial question I think i have miss read, It would seem the reading is payload.electricity.delivered.actual.reading is always 0. Is the electricty use over 1kw? Maybe the value is below 1kw and not being parse correctly.

what is
payload.electricity.received.actual.reading?

It is < 1kw mostly ,in the debugnode it read "actual":{"reading":0.269,"unit":"kW"
now i have more trouble lol "Connection to P1 meter failed. Error details: Error: Error Resource temporarily unavailable Cannot lock port" rebooted the pi no help.

Received is if you give back,like having solar panels.

Scratch that

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