How to Determine if mqtt.homeassistant Thing is Online or Offline as an Item?

If it’s just this one thing you’re interested in then you can add a thing event directly in the GUI.

Maybe check the (deprecated) rule template from @rlkoshak here: template offline things. You can still use it or use a similar trigger in your code tab of your rule.