Allow overwriting of hostname from config (#170)
This commit is contained in:
@@ -35,6 +35,10 @@ display_control = False
|
||||
# user for which display_control is enabled
|
||||
os_user = 'os_user_to_be_replaced'
|
||||
|
||||
# By default, the 'hostname' will be used as device name in home assistant.
|
||||
# To set a custom device name, uncomment the following line and set the custom name.
|
||||
# ha_device_name = 'device_name_to_use'
|
||||
|
||||
# Binary sensor that displays when there are updates
|
||||
git_update = True
|
||||
|
||||
|
||||
@@ -982,6 +982,9 @@ stop_event = threading.Event()
|
||||
script_dir = os.path.dirname(os.path.realpath(__file__))
|
||||
# get device host name - used in mqtt topic
|
||||
# and adhere to the allowed character set
|
||||
if hasattr(config, 'ha_device_name') and config.ha_device_name:
|
||||
hostname = re.sub(r'[^a-zA-Z0-9_-]', '_', config.ha_device_name)
|
||||
else:
|
||||
hostname = re.sub(r'[^a-zA-Z0-9_-]', '_', socket.gethostname())
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user