Esphomelib - library to greatly simplify Home Assistant integration with ESP32

Hi Otto, are you referring to the below note?

Note

If you’re having problems with flashing over USB, you can always download the firmware using the COMPILE button and flash the firmware using esphomeflasher.

How can I install the latest beta? or is that beta going to be released as the main version soon?

Cheers for the reply

The link for the beta is literally in my reply to your comment :expressionless:

However, 1.9.0 just got released into stable the day of that comment, so now you can also use the latest stable version.

hi @OttoWinter,

Today I was wondering if it would be possible to build a sound sensor using esphomelib. A little research pointed to the KY-038 module which should do the job. There’s no support (yet? :slight_smile: ) to this module on esphomelib but it should be possible to read the analog output of this sensor using ADC, right?

I had this idea of using it to auto-adjust sound levels of different Home Theather inputs (i.e. cable tv vs netflix, etc), perhaps even be able to create some sort of tv ad detector as they are usually louder than the usual. Did anyone built something like this before?

Well I consider this module already supported since you can just use the adc sensor. This is more of a docs issue, so a cookbook entry for the KY-038 would be welcome (similar to TEMT600 entry). See https://github.com/OttoWinter/esphomeyaml/issues/244

I have not heard of someone using it for home theater lights before, but if you do get it to work, please do share your setup :smiley:

OK so after several days of trial and defeat I’m here for some help.

I have followed the set up and have flashed a nodemcu with what I think is a reed switch sensor. I have mqtt.fx reporting every state change but home assistant doesn’t have the information just unavailable.

Here’s my configs:

esphomeyaml:
  name: frontdoor
  platform: ESP8266
  board: nodemcuv2

wifi:
  ssid: 'MY SSID'
  password: 'MY PASSWORD'

mqtt:
  broker: 'hassio.local'
  username: 'MY USERNAME'
  password: 'MY PASSWORD'

# Enable logging
logger:

ota:
  password: 'MY OTA PASSWORD'

binary_sensor:
  - platform: gpio
name: "Front Door"
pin:
  number: D3
  inverted: false
  mode: INPUT_PULLUP

Home Assistant Config:

binary_sensor:
    - platform: mqtt
      name: Front Door
      state_topic: frontdoor/binary_sensor/front_door/state
      device_class: door

MQTT.fx:

Is there anything here I am missing?

Thanks

unavailable can mean one of two things:

  • Home Assistant has no connection to tge mqtt broker
  • Home Assistant can’t read the frontdoor/status topic or that topic doesn’t contain online

Try disabling mqtt discovery in the esphomeyaml config (by putting discovery: false in the config) and running the “clean mqtt” script in the esphomeyaml dashboard (in the overflow menu behind the three dots).

I believe your issue is that the binary sensor you have manually in your Hass config is not showing up as the discovery payload also creates it. Then also make sure to restart HA and seeing if the entity is there using the entity panel.

Hi,

I did a very crude first try, but didn’t get positive results. My sketch has a single sensor, like this:

sensor:
  - platform: adc
    pin: GPIO39
    name: "Sound Sensor #1"
    update_interval: 1s
    filters: []

with only room noise, i get this:

[18:57:16][D][sensor.adc:073]: 'Sound Sensor #1': Got voltage=0.06V
[18:57:16][D][sensor.mqtt:093]: 'Sound Sensor #1': Pushing out value 0.057753 with 2 decimals of accuracy
[18:57:17][D][sensor.adc:073]: 'Sound Sensor #1': Got voltage=0.05V
[18:57:17][D][sensor.mqtt:093]: 'Sound Sensor #1': Pushing out value 0.054261 with 2 decimals of accuracy

The problem is that even if I put it in front of speaker, the values are still erratic and doesn’t seem to relate to the volume of the sound. Unfortunately the documentation of the KY-038 is almost non-existent and it seems that most people uses only the digital pin output to detect clapping sounds. Perhaps I should try another kind of sensor. :frowning:

@OttoWinter Did anything change with latest HA release with respect to MQTT? My Garage Door sensors stopped working. I use nodemcu with esphomelib and reed switch for garage open vs close. It was working fine and now the state publish MQTT message is not being picked up by HA. I can see the nodemcu publishing this message using MQTT Lens but HA is not picking up.

I see one bug, but seems to be fixed in latest release to which i have already upgraded.

Latest is not a version.

Hi all,
is it possible with esphomelib to manually set the value of a sensor? (a rotary encoder in this case)
I need the sensor to have a min and a max value.

I’ve tried something like this but it doesn’t work

       ...
       on_value:
          then:
            - if:
                condition:
                  lambda: 'return id(lrdim01).state < 0.0;'
                then:
                  - lambda: 'return id(lrdim01).state = 0.0;'
            - if:
                condition:
                  lambda: 'return id(lrdim01).state > 254.0;'
                then:
                  - lambda: 'return id(lrdim01).state = 254.0;'

thanks

Hassio is 83.3 and esphomeyaml add-on is 1.9.3

Hi @OttoWinter , I have successfully created a NodeMCU relay controller using this add-on but when I tried to create a LED strip controller it isn’t being detected in HA. Any ideas what I can do to get the light to show up as an entity? (MQTT discovery was set to ‘on’ when I first set it up, hence the NodeMCU entities are detected, so I know that works)

start of my working ModeMCU yaml:

 esphomeyaml:
  name: ha_retic_controller_1
  platform: ESP8266
  board: nodemcuv2

wifi:
  ssid: 'redacted'
  password: 'redacted'
  manual_ip:
    static_ip: 192.168.0.61
    gateway: 192.168.0.1
    subnet: 255.255.255.0
mqtt:
  broker: '192.168.0.13'
  username: 'hassio_mqtt'
  password: 'redacted'

# Enable logging
logger:

ota:
  password: 'redacted'

switch:
  - platform: gpio
    name: "Retic Station 1 Valve"
    icon: mdi:water-pump
    pin: 
      number: D1
      inverted: true

non-working LED controller yaml:

esphomeyaml:
  name: arcade_table_lighting_controller
  platform: ESP8266
  board: nodemcuv2

wifi:
  ssid: 'redacted'
  password: 'redacted'
  manual_ip:
    static_ip: 192.168.0.63
    gateway: 192.168.0.1
    subnet: 255.255.255.0

mqtt:
  broker: '192.186.0.13'
  username: 'hassio_mqtt'
  password: 'redacted'

# Enable logging
logger:

ota:
  password: 'redacted'

light:
  - platform: fastled_clockless
    chipset: WS2812B
    pin: GPIO15
    num_leds: 60
#    rgb_order: BRG
    name: "Arcade Table LEDs"
    effects:
      - random:
      - strobe:
      - flicker:
      - fastled_rainbow:
      - fastled_color_wipe:
      - fastled_scan:
      - fastled_twinkle:
      - fastled_random_twinkle:
      - fastled_fireworks:
      - fastled_flicker:

I dont know what to try to get this second device detected by HA. Using Fing on my phone I can confirm that it is connecting to my wifi with the correct IP address

See https://github.com/home-assistant/home-assistant/issues/18909 - It’s an issue in HA - you need to run the 0.84.0 beta to have the fix, 0.83.4 was never released apparently.

@infiniteloop Your solution is close, but there’s one issue. The assignment operation there doesn’t do anything since the state isn’t published. However, this is a thing sensor filters should solve anyway, not automations:

sensor:
- platform: rotary_encoder
  # ...
  filters:
  - lambda: |-
      if (x  < 0.0) return 0.0;
      if (x > 254.0) return 254.0;
      return x;

@sparkydave Try power cycling the ESP a couple of times. It seems like HA discovery doesn’t like to work that in well in recent releases. Or try with the edge esphomeyaml version.

damn, I could have figured it out.
thank you so much.

However I get an error when compiling:

Compiling .pioenvs/lr_dimmer/src/main.cpp.o
src/main.cpp: In lambda function:
src/main.cpp:105:16: error: inconsistent types 'double' and 'float' deduced for lambda return type
return x;
^
src/main.cpp:105: confused by earlier errors, bailing out
*** [.pioenvs/lr_dimmer/src/main.cpp.o] Error 1

EDIT:
solved this way

- lambda: |-
     if (int(x)  < 0) return 0;
     if (int(x) > 254) return 254;
     return int(x);

however it doesn’t behave as I would expect.
For example if I manually turn the encoder up to 254 and continue turning, it keep sending 254 (as in the code) but the “real value” of x keep incrementing and is stored somewhere(?). Because if then I turn the encoder the other way it doesn’t start to decrease immediately but only after that it has reached the value of 254.
Anyway I think I’m fine for the moment.

I think I’ve rebooted the ESP about 30 times, rebooted the HA server a heap of times and still no luck. Is the edge version of esphomeyaml expected to fix this or is there something else I’m missing here to get it to work? Thanks

I like esphomelib very much, for me it is more convenient as tasmota and espurna. But there is one (but not little) feature i would like to see in esphomelib.

It is E1.31 as in https://github.com/forkineye/ESPixelStick. I am new to this topic but in the last days i saw a lot of streams like this: https://www.youtube.com/watch?v=Al8zi0tq04o.

Happy christmas to all and greetings from germany.

Ludger

While not quite what your after, there is a component to control a string of pixels.

https://esphomelib.com/esphomeyaml/components/light/fastled_clockless.html

hi @OttoWinter I have tried flashing my ESP using the edge version of the HassIO add-on but it is still not working. What I see on the logger in ESPhomeflasher is:

Connecting to MQTT…
MQTT Dissconneted: TCP disconnected

So I dont know why the ESP wont connect to my MQTT server (the HassIO mosquito addon). My other ESP is happily connected to the same MQTT server with identical settings. Any other ideas I can try?

It is usually a typo with mqtt settings.

yep, turns out I’m an idiot. I honestly thought I had done a copy/paste with that section of code… turns out there were a 6 and an 8 transposed :see_no_evil: