How to access the hostname of the machine running Home Assistant?

Hello steve2020
For my part, I had solved this problem in this way. Maybe you are interested.
Well it's to get the IP address of the host, but same idea to get the name of the host