Sort node not working with split node

I am getting a collection of entities from Home Assistant and i am trying to sort the entities by name

The sort function just wont sort the incoming data... any idea why?

Here is the code:

Here is one of the entities im trying to sort:

{"entity_id":"light.step01","state":"off","attributes":{"effect_list":["None","Random Color"],"friendly_name":"step01","supported_features":61},"last_changed":"2020-08-12T08:43:02.604431+00:00","last_updated":"2020-08-12T08:43:02.604431+00:00","context":{"id":"7a980f57efd04ff09e8226f51c78b13a","parent_id":null,"user_id":null},"timeSinceChangedMs":5400231}

The flow:

[{"id":"a7111d80.930cf","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"a8ecd3f.0c2a33","type":"debug","z":"a7111d80.930cf","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":870,"y":740,"wires":[]},{"id":"c95583cb.6a5b5","type":"sort","z":"a7111d80.930cf","name":"","order":"ascending","as_num":false,"target":"","targetType":"seq","msgKey":"","msgKeyType":"elem","seqKey":"payload","seqKeyType":"msg","x":730,"y":640,"wires":[["a8ecd3f.0c2a33"]]},{"id":"41115106.53eb","type":"split","z":"a7111d80.930cf","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":550,"y":580,"wires":[["54ba328b.32e36c","c95583cb.6a5b5"]]},{"id":"50e8a5b2.077dec","type":"ha-get-entities","z":"a7111d80.930cf","server":"aa148f9e.e5c97","name":"","rules":[{"property":"entity_id","logic":"is","value":"light\\.step[^a-z][^a-z]","valueType":"re"}],"output_type":"array","output_empty_results":true,"output_location_type":"msg","output_location":"payload","output_results_count":1,"x":500,"y":740,"wires":[["41115106.53eb"]]},{"id":"54ba328b.32e36c","type":"debug","z":"a7111d80.930cf","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":720,"y":860,"wires":[]},{"id":"95e62f23.d38e1","type":"inject","z":"a7111d80.930cf","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":340,"y":740,"wires":[["50e8a5b2.077dec"]]},{"id":"aa148f9e.e5c97","type":"server","z":"","name":"Home Assistant","addon":true}]

The entity you posted does not appear to have an attribute called "name", so what are you trying to sort on? If you mean freindly_name then you need to sort on something like payload.attributes.friendly_name. Read the node red docs page Working with Messages which will provide useful help with identifying attributes in a complex object.

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