I’m using cameras for motion detection, and they are able to send a request to a server when a motion is detected. The problem is that there is no way to change the protocol: always use HTTP (not HTTPS) to make the request, so I can’t use Home Assistant API.
I think my options are:
Allow Home Assistant to accept HTTP requests
Add an HTML file accesible through HTTP, so the camera will request this file, and this file will request Home Assistant API using javascript, over HTTPS. But, where can I put this file in Hassbian to serve over HTTP?
I don’t have a solution but I face the same issue. There is talk of enabling NGINX and/or Apache to enable both http and https traffic. Sadly, I have read the Home Assistant documentation for both and can’t figure out how to do this.
I have NGINX installed and have tried multiple configurations of it with no joy.
Maybe you might have more luck. Or maybe even if enough of us face the issue it’ll get more attention.
I know it’s possible by using NGINX proxy, but I want to keep it simple, so I didn’t do it. I’m waiting for a camera firmware update, so it can connect to https instead of http
The following code will server both HTTP and HTTPS on the same port (Thanks ChatGPT). I just tested it, and it worked fine after installing the necessary libraries
from twisted.internet import reactor
from twisted.web import server, resource
from twisted.web.static import File
from twisted.web.server import Site
from twisted.internet import ssl
class MyResource(resource.Resource):
def render_GET(self, request):
return b"Hello, world!"
root = resource.Resource()
root.putChild(b"", MyResource())
# HTTP
site = server.Site(root)
reactor.listenTCP(8000, site)
# HTTPS
ssl_context = ssl.DefaultOpenSSLContextFactory(
'path_to_private_key_file',
'path_to_certificate_file'
)
secure_site = Site(root)
reactor.listenSSL(8000, secure_site, ssl_context)
reactor.run()
This would be very very helpful so I can maintain HTTP as a fallback even as I use HTTPS for web apps and external accesss