logo elektroda
logo elektroda
X
logo elektroda

Simple HTTP server/file hosting for Home Assistant (useful for OTA)

p.kaczmarek2 
Home Assistant logo with WWW text on a blue background.
Home Assistant offers a built-in, very simple way to host files on its own HTTP server. This can be very useful when we want to perform OTA (remote firmware update) on some device that expects to give it a URL with a file and only supports HTTP. An example of such a situation may be Tasmota (when we want to upload our own build) or Sonoff NSPanel (the FlashNextion command to change the display firmware also requires the file URL).
The situation is complicated by the fact that often newer hosting solutions available on the web force HTTPS, which makes it impossible, for example, to download this Nextion via ordinary HTTP. For the same reason, for example, it is not possible to download binaries directly from Github.
You can easily set up an HTTP server at your place, for example using Visual Code, or Node.JS, or other Python tools, but why? Just use HA...
Here I will briefly show how this can be done.

HTTP hosting in HA
I wrote quite a lot about HA itself in this topic:
Tutorial Home Assistant - configuration, WiFi, MQTT, Zigbee, Tasmota
Some convenient access to it will be useful, I mapped the config folder via SMB:
Window for adding network location in Windows
Network location addition dialog with Home Assistant configuration.
This allows you to conveniently operate on the Assistant's files:
View of the Home Assistant configuration folder with its contents.
We upload the files we want to host to config/www :
Screenshot of a Windows folder with TFT files.
For me, there are ripples for the Sonoff panel, which I will describe soon.
You can get to them from a web address like:

http://192.168.0.113:8123/local/ns-panel.tft

The subdirectory is very important local We can't get to them without him!
Just opening this URL will download the file - without logging in:
Screenshot of Microsoft Edge browser with the Downloads pane open, showing the file ns-panel (10).tft.
And it is this URL that can be given to devices that need to download our update via HTTP GET...

Summary
I have the impression that few people know about this option, and it is most useful. It is worth knowing about it, the more that no one will guess that these files are available in the subdirectory local and as we know, users often skip reading the documentation...
It turns out that hosting files on HA itself is very simple - just right for OTA.
PS: Of course, remember that if our HA is only in the local network, these files will only be visible in the local network. But we rather know that, don't we? Same as other servers.

About Author
p.kaczmarek2
p.kaczmarek2 wrote 12224 posts with rating 10162 , helped 580 times. Been with us since 2014 year.

Comments

morgan_flint 16 Apr 2024 19:53

Hello, @pkaczmarek2 I'm trying to do this without success... I have Home Assistant installed via Docker in a local server with Ubuntu Server as OS. Could this be the cause? Thanks! [Read more]

p.kaczmarek2 16 Apr 2024 20:40

I've been testing the HASS HTTP server on my dedicated HASS VM, made with official (?) image downloaded from web. I am not sure about Docker, but maybe first you should try whether the HTTP port is open... [Read more]

miegapele 17 Apr 2024 07:44

This seems way too complicated for such small task. Python has build in server, just run python -m http.server [Read more]

p.kaczmarek2 17 Apr 2024 09:04

It depends, some people may have blocked incoming connections to their machine for security purposes. Still, the Python http server is very useful, I am also sometimes using it as a base for my custom... [Read more]

morgan_flint 17 Apr 2024 12:43

Progress so far, after reading this : - Added "http:" to configuration.yaml file in HA /config directory - Created "www" under /config - Files stored in "www" are accessible via http://192.168.1.249:8123/local/filename.ext... [Read more]

p.kaczmarek2 17 Apr 2024 14:11

I do not remember well but I check this and it seems that you need to first install SMB Samba Share addon for HA. I think I did that, but it was a year ago or so... https://obrazki.elektroda.pl/2047092300_1713355856_thumb.jpg... [Read more]

morgan_flint 17 Apr 2024 18:51

I'm afraid I can't access the add-on store because of my docker-compose install of HA... I remember I read some (most) of the add-ons also have a docker version, but I still haven't found this one. What... [Read more]

p.kaczmarek2 18 Apr 2024 07:14

Good job! So, everything is working now? [Read more]

morgan_flint 18 Apr 2024 12:49

Yes, but still trying to figure out how to host Webapp in there... Copied the contents of https://github.com/OpenBekenIOT/webapp/tree/gh-pages to config/www and then changed the URL of the app in the... [Read more]

morgan_flint 27 Jul 2024 14:32

I tried again after re-reading this thread and related ones but with no luck... This is the error I get: https://obrazki.elektroda.pl/7647758800_1722083473_thumb.jpg Maybe I have to configure... [Read more]

p.kaczmarek2 27 Jul 2024 14:34

So currently you're not able to host any files on HA? Any web page, not just OBK Web App [Read more]

morgan_flint 27 Jul 2024 18:32

I've tried with a simple txt and can read it from the browser. Also, if I put 192.168.1.249:8123/local/startup.js in the browser it lists the script there so yes, files are hosted there, but the webapp... [Read more]

p.kaczmarek2 27 Jul 2024 23:09

This is not the correct way to run web app. Do you change Web App URL In the OBK device setting to point to your self-hosted app? [Read more]

morgan_flint 28 Jul 2024 10:50

That was just a test to check that the files are accessible but, as I said here , I also changed the app's URL to http://192.168.1.249:8123/local/ in OBK's configuration. EDIT: Another test, devicesList.html... [Read more]

morgan_flint 20 Aug 2024 13:56

Problem solved! With a "little help" from ChatGPT . I just had to add the following to configuration.yaml in Home Assistant: http: cors_allowed_origins: - http://localhost:8123 ... [Read more]

donaldwaters434 30 Aug 2024 22:26

It’s great to see Home Assistant being used for file hosting! This built-in HTTP server feature is a lifesaver when devices need to access files via HTTP, like with Tasmota or Sonoff NSPanel. It’s a real... [Read more]

sjjduesndheh 30 Aug 2024 23:34

If you're looking for a straightforward HTTP server or file hosting, they offer reliable offshore server options that could be perfect for your needs. [Read more]

%}