• I am trying to hook up an ESP01 to my smoke alarm like in this video

    and making it report to home-assistant, running on my pi. Home-assistant has an API which should make it possible for the ESP01 to alter a variable (input_boolean) and trigger other alarms.

    However, the http-request only seems to be able to reach the pi on port 80. Which is a problem, since home-assistant listens to port 8123 (in my case, pihole listens to port 80).

      var wifi = require("Wifi");
    
      wifi.connect("SSID", {password:"PASS"}, function(e) { 
        if( ! e )
        {
          wifi.setHostname("SmokeAlarm-"+getSerial­() );
          wifi.stopAP();
          
          var options = {
            host: 'xd-1',
            port: 80,
            path: '/api/',
            method: 'GET'
          };
          
          require("http").request( options, function (res) {
            res.on('data', function (data) { console.log(data); });
          }).end();
        }
      });
    

    The path "/api/" does not exist on port 80 (pihole only uses /admin/*) and the ESP01 outputs the right error page, served by pihole. The script functions as it should.

    The path "/api/" DOES exist on port 8123 - I can see it in any browser on any device in my network. When changing the port from 80 to 8123, the ESP01 shows nothing, except "=undefined".

    I'm starting to lose it. Why is the request not coming through? Any thoughts?

About

Avatar for Thijsmans @Thijsmans started