Convert agnetic flux density (µT) into heading?

Right now, my weather stations is giving reading measured in µT for the wind direction. This changes when I move the wind vane.

How can I convert these values into a heading in homeassistant using esphome?

Thanks!

This looks like detailed but long explanation. You have to create a template for this calculation.