Esphomelib - library to greatly simplify Home Assistant integration with ESP32

Tags: #<Tag:0x00007f2052065850> #<Tag:0x00007f20520651c0>


Yes that is correct.


nop, doesn´t work for me…


What is the hostname of your device?

Fing (android app) is a good way of discovering this)


ok i read this:

To do this, first plug in the USB cable of the ESP into a USB port of the device esphomeyaml is running on and wait until you see a “Discovered new serial port” message (in some cases you need to restart the add-on). Select the upload port in the top navigation bar and press the big “UPLOAD” button

so, i disconnect my nodemcu of my PC, and connect it again on USB of my RPI… and…

now works


This is a great easy to understand project… I’ve got the basics working… however I am running into a problem that should be easy to solve but I can’t seem to get this working…

I am trying to control an active low relay. With the default GPIO switch config I have everything working… however on is off and off is on… and a reboot of the ESP8266 NodeMCU V2 defaults the relay to an on state…
This is my config…

  - platform: gpio
    name: "Pool Light"
    pin: D1

I have also tried to use the inverted option

  - platform: gpio
    name: "Pool Light"
    pin: D1
    inverted: True

With that config… homeassistant seems to keep the switch always on (i.e. if I toggle to off in UI, it just toggles back on")

I think I need to use the following config to set the mode of the D1 pin on startup, but I can’t figure out where to do this in the YAML to have it default the pin to high (i.e. relay off) on startup?

Any help in getting this working properly with active low relays would be very appreciated!



I managed to fix this myself… not sure which of the two things solved it…

  1. upgraded to the bleeding version of Esphomelib (since I read an issue report hinting that this may be a defect in the GA release)
  2. Changed my Yaml from
  - platform: gpio
    name: "Pool Light"
    pin: D1
    inverted: True


  - platform: gpio
    name: "Pool Light"
      number: D1
      inverted: True

And I am back in business with Active Low relays!


Hello, great software here !

Have you considered using the WifiManager lib by tzapu ?

Whenever the wifi connection fails (ie. I’m changing my wifi password or I’m moving to another place), it falls back to an access point providing a little web server to enter the new credentials. It has a quite low memory footprint even for a ESP8266 and it’s really convenient for hard-to-flash devices such as Sonoff.


hello again , i am trying to delete my retain topics off my mqtt…and i saw this;

To fix this, esphomeyaml has a simple helper script that purges stale retained messages for you:

esphomeyaml configuration.yaml clean-mqtt
This will remove all retained messages with the topic <DISCOVERY_PREFIX>/+/NODE_NAME/#. If you want to purge on another topic, simply add --topic <your_topic> to the command.

But i dont understad how to use that…anyone explain me?


Using the following config seems to make my active low relay behave as expected during normal operation… however the relays seem to click on/off at arduino reboot or reset…

  - platform: gpio
    name: "Pool Light"
      number: D1
      inverted: True

I found the following article which seems to be describing what I am seeing. Is there a different config in esphomeyaml to set the pin high before setting it to output… Or is this an issue that I should open under this library?

Reference from

IMPORTANT NOTE: There is a issue with start-up of Arduino programs that control these relays. All of these 2,4, or 8 relay boards input controls are Active LOW, meaning that setting a pin LOW turns them ON. To assure that no relays activate at Reset or Power-On until you want them to, the initialization sequence in SETUP should be:
digitalWrite(Relay, HIGH);
pinMode(Relay, OUTPUT);

This design is intentional, so that it is possible to guarantee that at power-on of a system, or system reset, that no relays activate except when expected under program control. There may be pumps, lights etc attached and chaos could ensue if this was not controlled definitively for each output port being used.


I have been looking through your code for the lights trying to figure out how to incorporate this, but its above me :pensive: any chance of you including it for more effects?


@br0nd Yeah the problem is that between the time that the ESP boots up and esphomelib’s code runs there’s still a significant amount of time. esphomelib already has a “setup priority” model that makes high-priority things like relays/switches be initialized very early on, but unfortunately that can also be a while. One way I’m using to solve this problem is by adding the code even before esphomelib is initialized. In <NODE_NAME>/src/main.cpp:

using namespace esphomelib;

void setup() {
  pinMode(D1, OUTPUT);
  digitalWrite(LOW); // Inverted
  // ========== AUTO GENERATED CODE BEGIN ===========
  auto *logger = App.init_log();
  // ...

@sparkydave You mean the lights? See - I don’t have too many effects in the library yet, but I’m hoping to change that in the future

  - platform: fastled_clockless
    chipset: WS2811
    pin: GPIO23
    num_leds: 60
    rgb_order: BRG
    name: "FastLED WS2811 Light"


Yep, I was wondering if it’s possible to use Brah’s code for all of his effects in your package?


The pseudocode didn’t work, here is what I had to do (above the “do not edit anything below this line”)

  digitalWrite(D1, HIGH); // Set D1 pin high
  pinMode(D1, OUTPUT); // Then set to output


Not directly no, sorry.


Firstly i’d like to say thank you for putting this piece together; with i was able to get some binary sensors for my doors. But I’m having a little issue with the door status, where in HA it always shows open. I’m guessing the reason for that is because in the software the pin status is set to NO(normal open). Is there a way to set that where it can be NC(normal close).


wow this is great. I might try to use this for my dimmer. I guess what would be needed to make it a dimmer though is a way to set the rotary encoder to a specific value reflecting the dimmer state (in case the brightness was changed through some other means) I guess some mutt automation can be used for that?


Great work on this! Would love to try it out for my blinds control. As far as I could find servos are not yet part of this. Is it still on the wanted list?

I’m using a Positional Rotation Servo for tilting my blinds


@OttoWinter, you’re awesome!!!

The hook up guy made a YouTube video and he tell’s about your project at 6:43


for me the OTA is not working. esphomlib can’t find the host. However it is showing up in bonjour browser so it is defiantly there. Is there any way of using the IP for OTA?


@Try2Fly Nopes, servors are not supported (yet) - I’ll maybe work on it soon, but it’s going to need some core architecture changes and that always takes some time…

@snizzleorg Yes, just put a manual_ip here: