i8beef / HomeAutio.Mqtt.GoogleHome

MIT License
215 stars 29 forks source link

How to connect to WEMOS D1 with PubSubClient? + Reverse proxy issues #81

Closed Weissnix4711 closed 4 years ago

Weissnix4711 commented 4 years ago

I have set up the software as following the wiki, however I'm still confused how to connect it to a WEMOS D1 mini with PubSubClient.

I would like to subscribe to a topic using the WEMOS, so I can turn on / off my boiler. As far as the hardware goes, I have everything sorted. I've built a DIY Opentherm adaptor, and have tested it.

I don't know much about MQTT. I've tried setting the MQTT server to the IP address of the computer running your software, and I am not using a username or password. I have also set the brokerIp to that of the WEMOS, in appsettings.Production.json.

PubSubClient tries to connect, but can't, and vice versa. Your software gives the following error:

[11:33:58 ERR] Error while connecting with server.
[11:33:58 INF] Disconnected.
[11:33:58 INF] MQTT Connection closed unexpectedly, reconnecting...

What have I done wrong? What must I do for them to be able to communicate?

Also, I cannot get the reverse proxy to work. nginx keeps giving me 404 error when trying to add the test app in the Google Home app.

My ngnix config file:

http {
  server {
    listen 443 ssl;
    access_log /var/log/nginx/reverse-access.log;
    error_log /var/log/nginx/reverse-error.log;

    location /google/home/ {
      allow all;
      proxy_pass http://192.168.1.5:5000;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection $http_connection;
    }
  }
}

Have I done this right? I have never before made / used a reverse proxy, and don't have much experience with nginx.

Thanks.

Weissnix4711 commented 4 years ago

Never mind. I've figured it out. As reference to anyone else:

Firstly, it seems I need to use mosquitto or some other MQTT broker.

As for the proxy issue, you need to make a config file inside of /etc/nginx/sites-available. Also, use certbot to get a certificate, and add it manually to that config file. It fails if you try and do it automatically.