Esphomelib - library to greatly simplify Home Assistant integration with ESP32

mqtt
esp8266
Tags: #<Tag:0x00007f20583d1f10> #<Tag:0x00007f20583d1d08>

#163

Thanks Petrica,

I’m using one of these modules:-

What i’m unclear about is how I do the calculation of power when using the library, looking at the docs I think I’d be doing:-

App.make_adc_sensor(“Analog Voltage”, 13);

Which presumably updates MQTT each time the voltage has changed high/low for pin 13 ?
I’d like to do some calculations between the readings so that MQTT recieves the Watts consumed instead, but I’m not sure how that would be done when using the library.


#164

Digital pins read high/low depending on the threshold set while ADC pin will read a value between 0 and 1023. Regardless of digital/analog input the magic will begin on HA.

You only count the pulses per minute with the LDR. You need HA to convert this frequency to watts.

I had that exact module however it doesn’t work with the ADC as it is. I had to solder a 1 k resistor as mentioned in the schematic above.

If you use ADC, then you need to calibrate it in order to see what is the exact readout when the pulse is triggered.


#165

Please see https://esphomelib.com/esphomeyaml/cookbook/power_meter.html

(the note about only esp32 being supported is incorrect, it does work with esp8266s now)


#166

Thank you both… i think I was confusing myself by thinking the ESP should be calculating the watts too, instead of just sending the pulse count


#167

Hi all, I’ve tried 2 esp8266 boards now and on both occasions get ERROR [esphomeyaml.espota] Host node1.local Not Found. What’s the recommended troubleshooting? Using HASSIO addon


#168

@robmarkcole It sounds like you are trying to program them OTA (Over The Air) using WiFi? If this is the first time you have done it you will need to connect them directly to the Hassio machine first to allow to install the OTA code. Also I believe that the .local address requires everything to support mDNS to work correctly.


#169

Please see the note here: https://esphomelib.com/esphomeyaml/components/ota.html#configuration-variables :wink:

Usually, the host not found error is because of weird network configurations that stop mDNS from working correctly. I still don’t really have a solution for that yet, except for having people specify a static IP.


#170

Hi @allan ok I just noticed this was an option…!


#171

@robmarkcole did you manage to get it working using that?


#172

Hmm I’m getting the following, although i have check the broker config and status:

[04:40:03][I][mqtt.client:101]: Connecting to MQTT...
[04:40:03][W][mqtt.client:071]: MQTT Disconnected: Unknown.
[04:40:03][W][mqtt.client:071]: MQTT Disconnected: Unknown.
[04:40:03][W][mqtt.client:071]: MQTT Disconnected: Unknown.
[04:40:03][W][mqtt.client:071]: MQTT Disconnected: TCP disconnected.

#173

Is it possible, in similar way, to use the analog pin a0 to read data from a homemade soil moisture sensor? (the one made with two nails)
Cause I keep getting always the same volt value in the log, even with nothing connected to it.

The circuit should be something like…?

3.3 (from wemos)-----> Nail Nail------>a0

Or should I connect even to ground?

Thanks


#174

Hi,

Yes, it should work; however, you definitely need to calibrate it (might need to try several cycles of watering/drying to get reasonable values).

Without having connected the GND sensor on the ESP module there won’t be any reading. In my post above the moisture sensor would replace the LDR.


#175

Hi all.
Is it possible with esphomelib to set a delay on a pin setted as GPIO output?
I would like to give power to a sensor only every few hours.

Thanks


#176

Ok I found some sort of workaround, but it’s not working as expected.
I’ve setted pin d4 as output and connected vcc from soil sensors to this pin.

output:
  - platform: gpio
    pin: D4
    id: sm_pow

Then I’ve set up an action, triggered by an Mqtt topic; to turn on d4 and then turn it off again after a delay of 10 seconds.

mqtt:
  broker: XXX
  username: XXX
  password: XXX
  on_message:
    topic: wemosgarden/soilsensor/toggle
    then:
     - output.turn_on:
         id: sm_pow
     - delay: 10s
     - output.turn_off:
         id: sm_pow

and this is working fine: sensors turn on and in HomeAssistant I can see the right state (wet or dry).

The problem is that when the pin d4 is turned off in HomeAssistant all the sensors show always wet state.
I would expect to see the last state or an unavailable state that I could control with retain or payload messages or whatsoever.

Do you guys think there’s something I can try?
An alternative solution would be to use deep sleep but in that case I’ll loose even the state of the other sensors connected to the board.

Any hint is really appreciated. thanks


#177

Hi all,

I’m building a scale using the HX-711 Load Cell Amplifier, but couldn’t figure out how to transform the output to kg. The load cells + HX-711 is working right and I was able to use/calibrate it using a arduino and the hx711 library sketches. How should I use the “gain” option from hx-711?


#178

Is there a way to force re-publishing of the discovery messages?

When I upload to my node, I see the debug messages say “Publish failed!” when attempting to set up some of my sensors (wifi_signal seems to be a consistent culprit). So the discovery messages don’t get published.

It then goes on to publish the sensor information just fine, but HA doesn’t create the entity.

I’m migrating from Tasmota and I really do not want to define all these sensors manually… I can re-upload over and over again until it takes but that’s kind of PITA and inconsistent.


#179

I have just tried to flash my first ESP32 using the HassIO add-on (after awesome success with a 8266) but I get the below error. Any idea what I can do to get this to work? I tried a few times with the same error and have restarted the add-on a few times as well

INFO [esphomeyaml.config] Reading configuration... INFO [esphomeyaml.__main__] Generating C++ source... INFO [esphomeyaml.__main__] Compiling app... INFO [esphomeyaml.__main__] Running: platformio run -d /config/esphomeyaml/bog_arum_plant_sensor Processing bog_arum_plant_sensor (platform: [email protected]&gt;=1.4.0; board: esp32doit-devkit-v1; framework: arduino) -------------------------------------------------------------------------------- Verbose mode can be enabled via-v, --verboseoption PLATFORM: Espressif 32 &gt; DOIT ESP32 DEVKIT V1 SYSTEM: ESP32 240MHz 320KB RAM (4MB Flash) DEBUG: CURRENT(esp-prog) EXTERNAL(esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa) Library Dependency Finder -&gt; http://bit.ly/configure-pio-ldf LDF MODES: FINDER(chain) COMPATIBILITY(soft) Collected 30 compatible libraries Scanning dependencies... Dependency Graph |-- &lt;ArduinoOTA&gt; 1.0 | |-- &lt;ESPmDNS&gt; 1.0 | | |-- &lt;WiFi&gt; 1.0 | |-- &lt;WiFi&gt; 1.0 | |-- &lt;Update&gt; 1.0 |-- &lt;ESPmDNS&gt; 1.0 | |-- &lt;WiFi&gt; 1.0 |-- &lt;Preferences&gt; 1.0 |-- &lt;Update&gt; 1.0 |-- &lt;esphomelib&gt; 1.8.2 #c954c39 | |-- &lt;AsyncMqttClient&gt; 0.8.2 | | |-- &lt;AsyncTCP&gt; 1.0.1 | |-- &lt;ArduinoJson-esphomelib&gt; 5.13.3 | |-- &lt;ESP Async WebServer&gt; 1.1.1 | | |-- &lt;AsyncTCP&gt; 1.0.1 | | |-- &lt;FS&gt; 1.0 | | |-- &lt;WiFi&gt; 1.0 | | |-- &lt;ArduinoJson-esphomelib&gt; 5.13.3 | |-- &lt;FastLED&gt; 3.2.0 #d27bac9 | |-- &lt;WiFi&gt; 1.0 | |-- &lt;Wire&gt; 1.0 | |-- &lt;ESPmDNS&gt; 1.0 | | |-- &lt;WiFi&gt; 1.0 | |-- &lt;ArduinoOTA&gt; 1.0 | | |-- &lt;ESPmDNS&gt; 1.0 | | | |-- &lt;WiFi&gt; 1.0 | | |-- &lt;WiFi&gt; 1.0 | | |-- &lt;Update&gt; 1.0 | |-- &lt;Preferences&gt; 1.0 Compiling .pioenvs/bog_arum_plant_sensor/libd86/FastLED/FastLED.cpp.o Compiling .pioenvs/bog_arum_plant_sensor/libd86/FastLED/bitswap.cpp.o Compiling .pioenvs/bog_arum_plant_sensor/libd86/FastLED/colorpalettes.cpp.o Compiling .pioenvs/bog_arum_plant_sensor/libd86/FastLED/colorutils.cpp.o Error relocating /root/.platformio/packages/toolchain-xtensa32/bin/xtensa-esp32-elf-g++: _obstack_memory_used: symbol not found Error relocating /root/.platformio/packages/toolchain-xtensa32/bin/xtensa-esp32-elf-g++: _obstack_newchunk: symbol not found Error relocating /root/.platformio/packages/toolchain-xtensa32/bin/xtensa-esp32-elf-g++: obstack_free: symbol not found Error relocating /root/.platformio/packages/toolchain-xtensa32/bin/xtensa-esp32-elf-g++: _obstack_begin: symbol not found *** [.pioenvs/bog_arum_plant_sensor/libd86/FastLED/FastLED.cpp.o] Error 127 Error relocating /root/.platformio/packages/toolchain-xtensa32/bin/xtensa-esp32-elf-g++: _obstack_memory_used: symbol not found Error relocating /root/.platformio/packages/toolchain-xtensa32/bin/xtensa-esp32-elf-g++: _obstack_newchunk: symbol not found Error relocating /root/.platformio/packages/toolchain-xtensa32/bin/xtensa-esp32-elf-g++: obstack_free: symbol not found Error relocating /root/.platformio/packages/toolchain-xtensa32/bin/xtensa-esp32-elf-g++: _obstack_begin: symbol not found *** [.pioenvs/bog_arum_plant_sensor/libd86/FastLED/bitswap.cpp.o] Error 127 Error relocating /root/.platformio/packages/toolchain-xtensa32/bin/xtensa-esp32-elf-g++: _obstack_memory_used: symbol not found Error relocating /root/.platformio/packages/toolchain-xtensa32/bin/xtensa-esp32-elf-g++: _obstack_newchunk: symbol not found Error relocating /root/.platformio/packages/toolchain-xtensa32/bin/xtensa-esp32-elf-g++: obstack_free: symbol not found Error relocating /root/.platformio/packages/toolchain-xtensa32/bin/xtensa-esp32-elf-g++: _obstack_begin: symbol not found *** [.pioenvs/bog_arum_plant_sensor/libd86/FastLED/colorpalettes.cpp.o] Error 127 Error relocating /root/.platformio/packages/toolchain-xtensa32/bin/xtensa-esp32-elf-g++: _obstack_memory_used: symbol not found Error relocating /root/.platformio/packages/toolchain-xtensa32/bin/xtensa-esp32-elf-g++: _obstack_newchunk: symbol not found Error relocating /root/.platformio/packages/toolchain-xtensa32/bin/xtensa-esp32-elf-g++: obstack_free: symbol not found Error relocating /root/.platformio/packages/toolchain-xtensa32/bin/xtensa-esp32-elf-g++: _obstack_begin: symbol not found *** [.pioenvs/bog_arum_plant_sensor/libd86/FastLED/colorutils.cpp.o] Error 127 ========================== [ERROR] Took 12.15 seconds ==========================


#180

@clyra Added a section about it here: https://beta.esphomelib.com/esphomeyaml/components/sensor/hx711.html#converting-units

@oakbrad Try with the latest beta (https://beta.esphomelib.com/esphomeyaml/guides/faq.html#how-do-i-update-to-the-latest-beta-release) which a) improves the MQTT client a bit to have less failed publish packets (due to the TCP buffer filling up too quickly) and b) has a script that auto-generates the Home Assistant config.

@sparkydave See the last note here: https://esphomelib.com/esphomeyaml/guides/getting_started_hassio.html#dashboard-interface - it’s not supported in the current stable version. However, it is supported in the latest beta.


#181

@OttoWinter I noticed from your comment above that you are now supporting the esp32 on the Pi, so I switched to the latest beta, it all seems to compile OK however wont connect to wifi. I have tried adding the esphomelib_version: dev line to my config. I have double checked the Wifi information,

I am using board: wemosbat do you have any other suggestions I might be able to try?


#182

I’m a bit confused on how your setup works, and I’m assuming you want the state to be the last read state of the sensor. I would consider using a lambda call inside your turn_on and turn_off after the delay to change the state of a sensor that is exposed to MQTT, but doesn’t get updated directly by the actual sensor.