Hi
I'm trying to sort an string of dates and then split the string and send the first date as payload.
The business case is that i got a json file from my renovation company that contains pickup dates for my different types of trash, and i want to use the dates for showing an notifying in Home assistant
My flow that ends in the string of dates (containing the json data) is like this:
[{"id":"8f4c55dc.520918","type":"inject","z":"a318c51d.29a138","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"name\":\"Restavfall\",\"date\":\"2021-12-17\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-05-04\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-05-20\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-06-04\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-06-18\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-07-02\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-07-16\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-07-30\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-08-13\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-08-27\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-09-10\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-09-24\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-10-08\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-10-22\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-11-05\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-11-19\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-04-20\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-12-03\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-04-20\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-06-18\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-11-05\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-11-19\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-12-03\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-09-24\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-09-10\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-08-27\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-08-13\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-07-30\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-07-16\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-07-02\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-10-22\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-10-08\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-05-20\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-12-17\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-05-04\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-06-04\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-12-17\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-11-19\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-10-22\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-05-04\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-09-24\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-08-27\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-07-30\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-07-02\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-06-04\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Glass- og metallemballasje\",\"date\":\"2021-07-30\",\"fractionId\":2612,\"fractionGuid\":\"2627574c-db98-4d6b-94fd-dfb47a64007d\",\"route\":161408,\"routeName\":\"1614\",\"frequency\":8,\"startDay\":4},{\"name\":\"Glass- og metallemballasje\",\"date\":\"2021-11-19\",\"fractionId\":2612,\"fractionGuid\":\"2627574c-db98-4d6b-94fd-dfb47a64007d\",\"route\":161408,\"routeName\":\"1614\",\"frequency\":8,\"startDay\":4},{\"name\":\"Glass- og metallemballasje\",\"date\":\"2021-09-24\",\"fractionId\":2612,\"fractionGuid\":\"2627574c-db98-4d6b-94fd-dfb47a64007d\",\"route\":161408,\"routeName\":\"1614\",\"frequency\":8,\"startDay\":4},{\"name\":\"Glass- og metallemballasje\",\"date\":\"2021-06-04\",\"fractionId\":2612,\"fractionGuid\":\"2627574c-db98-4d6b-94fd-dfb47a64007d\",\"route\":161408,\"routeName\":\"1614\",\"frequency\":8,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-10-22\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-09-24\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-08-27\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-07-30\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-07-02\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-06-04\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-05-04\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-12-17\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-11-19\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4}]","payloadType":"json","x":180,"y":580,"wires":[["386ee4ad.4e547c"]]},{"id":"386ee4ad.4e547c","type":"split","z":"a318c51d.29a138","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":true,"addname":"","x":480,"y":640,"wires":[["13dd80cc.14bebf"]]},{"id":"13dd80cc.14bebf","type":"switch","z":"a318c51d.29a138","name":"","property":"payload.name","propertyType":"msg","rules":[{"t":"eq","v":"Restavfall","vt":"str"},{"t":"eq","v":"Matavfall","vt":"str"},{"t":"eq","v":"Plast","vt":"str"},{"t":"eq","v":"Papir, papp og kartong","vt":"str"},{"t":"eq","v":"Glass- og metallemballasje","vt":"str"}],"checkall":"true","repair":false,"outputs":5,"x":700,"y":640,"wires":[["53054a07.e52f64"],["d9f3cbcb.d29178"],["b984f0b3.ef20c"],["ff99496c.aa1d08"],["bc01472.69bcab8"]]},{"id":"53054a07.e52f64","type":"change","z":"a318c51d.29a138","name":"","rules":[{"t":"move","p":"payload.name","pt":"msg","to":"topic","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":930,"y":380,"wires":[["61eafcbd.d01db4"]]},{"id":"61eafcbd.d01db4","type":"change","z":"a318c51d.29a138","name":"","rules":[{"t":"move","p":"payload.date","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":930,"y":420,"wires":[["317384a6.4c7dec"]]},{"id":"317384a6.4c7dec","type":"batch","z":"a318c51d.29a138","name":"","mode":"interval","count":10,"overlap":0,"interval":10,"allowEmptySequence":false,"topics":[],"x":870,"y":460,"wires":[["ca031751.21ce98"]]},{"id":"ca031751.21ce98","type":"join","z":"a318c51d.29a138","name":"","mode":"custom","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":",","joinerType":"str","accumulate":false,"timeout":"10","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":990,"y":460,"wires":[["7085436e.78c62c"]]},{"id":"7085436e.78c62c","type":"debug","z":"a318c51d.29a138","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1270,"y":360,"wires":[]},{"id":"1befde2.864f922","type":"api-call-service","z":"a318c51d.29a138","name":"Restaavfall","server":"ec6b4330.077a3","version":1,"debugenabled":false,"service_domain":"input_datetime","service":"set_datetime","entityId":"input_datetime.hra_restavfall","data":"{\"date\": {{payload}}}","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":true,"x":1170,"y":460,"wires":[[]]},{"id":"ec6b4330.077a3","type":"server","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]
The result is:
2021-12-17,2021-05-04,2021-05-20,2021-06-04,2021-06-18,2021-07-02,2021-07-16,2021-07-30,2021-08-13,2021-08-27,2021-09-10,2021-09-24,2021-10-08,2021-10-22,2021-11-05,2021-11-19,2021-04-20,2021-12-03
The output/ next steps i want is an payload with the first date from time.now, so that i can use the service "set_datetime" for setting a date in Home assistant.
My flow can probably be easier, (and i'm doing 5 equal set dates from the switch, only listed one), but i got the string of dates as an output, and are happy with that. Now i'm just struggling to handle the result.
Hopefully someone can guide an help me towards the goal, and my coding skills is on an noob level.
Regards
Mons