• Turns out the problem was not with the ESP01 or with Espruino, but with my malformed request :) The debugging methods from this thread made that clear (it showed a HTTP-400 header coming back).

    For whoever finds it useful, this is how Espruino connects to Home Assistant:

      
      var wifi   = require("Wifi");
      var entity = 'smoke_kitchen';
    
      wifi.connect("SSID", {password:"PASS"}, function (e) { 
        if( ! e )
        {
          wifi.setHostname("SmokeAlarm-"+entity+"_"+getSerial() );
          
          var http = require("http");
          var data = JSON.stringify( {state:'on'} );
          
          var options = {
            host: 'HASS-HOST',
            port: 8123,
            path: '/api/states/input_boolean.' + entity,
            method: 'POST',
            headers: {
              'Content-Type': 'application/json',
              'Content-Length': data.length,
              'x-ha-access': 'Token if needed',
            },
          };
          
          var req = http.request( options, function (res) {
            console.log('Status: ' + res.statusCode);
            console.log( res );
          });
          
          req.write( data );
          req.end();
          
        } else
        { 
          console.log("Error connecting to wifi: ", e );
        }
      });
    
About

Avatar for Thijsmans @Thijsmans started