Hi,
I am trying to pull an array from a home assistant sensors attribute, what I want to do is just pass along the last array entry, the issue is the array naming structure is different every time:
[{"id":"8617395361a98887","type":"inject","z":"4fbb0f02.0e5f6","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":1240,"wires":[["2da2ba8af5dd5e7a"]]},{"id":"2da2ba8af5dd5e7a","type":"api-current-state","z":"4fbb0f02.0e5f6","name":"Rates","server":"b3a3253e.d12568","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"octopusagile.rates","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":290,"y":1240,"wires":[["2f73f4624b193e82","5f25a119a3c6af29","edeb3970e07530dc"]]},{"id":"f805ddc9be792893","type":"debug","z":"4fbb0f02.0e5f6","name":"Rates","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":750,"y":1200,"wires":[]},{"id":"5f25a119a3c6af29","type":"function","z":"4fbb0f02.0e5f6","name":"function 11","func":"\n\nconst x = msg.data.attributes[-1]\nmsg.payload = x\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":470,"y":1240,"wires":[["f805ddc9be792893"]]},{"id":"edeb3970e07530dc","type":"debug","z":"4fbb0f02.0e5f6","name":"Rates","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":750,"y":1240,"wires":[]},{"id":"b3a3253e.d12568","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30,"areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true}]
My ideal solution is read the last attribute entry and write it to an input helper, at the moment I am just parsing to a debug node before I start sending the entry elsewhere for use, I've had a nosie and found a few similar things, but none of them have worked and/or were unrelated just enough to not be what I am after.
Can anyone point me in a general direction at all please?