Seems that this does the trick, I forgot the * at the end in the beginning…
Good read here: Data Exploration | InfluxData Documentation Archive
SELECT mean(value) AS value INTO "homeassistant"."2y_5m".:MEASUREMENT FROM "homeassistant"."autogen"./.*/ WHERE time < now()GROUP BY time(5m),*
SELECT mean(value) AS value INTO "homeassistant"."5y_15m".:MEASUREMENT FROM "homeassistant"."2y_5m"./.*/ WHERE time < now() -17520h0m0s GROUP BY time(15m),*