Get hostname from HASSOS installation

Hey folks,

What is the proper way to get the hostname of the machine running home assistant?

I am currently using Python’s socket.gethostname() function to read the, well, host name (see: https://github.com/legrego/homeassistant-elasticsearch/blob/4c40844fc936f0b7bb69c967efcd6bbac1600fa5/custom_components/elastic/es_doc_publisher.py#L44)

I got a report that a user running my custom component within HASSOS is getting the wrong hostname (see: https://github.com/legrego/homeassistant-elasticsearch/issues/101). socket.gethostname() appears to always return homeassistant for them, even though the configured hostname appears to be something else:

image

1 Like