Just a follow up on this in case others experience similar issues. After changing the DNS in the modem and router I had fast 5Ghz speeds for three days, until I shut down the computer. When I started it again it was slow, so I put back the power lines and they seem to work well, as long as we don't turn on the dishwasher or oven in the kitchen, which shaves off roughly 40% of the download speed.
Seeing that the DNS seems to be at play here in messing with wi-fi speeds I just flushed the DNS in the terminal and that fixed the 5 Ghz wi-fi speeds again.
In the terminal type:
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
Then add your password and hit the return key to flush the DNS cache and see if that works. For me this all points to a bug in Sonoma and having to work around it until Apple issues a fix, but I have a far better understanding now than I did a week ago.