Esphomelib - library to greatly simplify Home Assistant integration with ESP32

Ok, I understand :see_no_evil: Code can seem like a lot of garbled characters.

As such a delta filter would be relatively easy for me to implement, I think I can easily add. Only thing I would be interested in would be the exact use case (it helps a lot if you know what you’re actually try solve). Thanks!

Hi,

For the ADC I’ve managed to use, until now, LDR (both as general light sensor to be able to trigger automations when bulbs need to be turned on/off using sun light as condition or as a feedback for a light command being sent by HA to bulbs - that is for bulbs that do not send acknowledgment to the commands received; I know that there are digital sensors for luminescence but it is easier, and more fun to put a LDR and a resistor to an ADC pin :slight_smile: ), load cell (for building a weighting device or as bed occupancy sensor), MQ-9 for carbon monoxide (at least I think it works as when placed near a glass of beer it immediately reacts :wink: ) and sound sensor. Obviously, there are many more different types of analog sensors but at least for these I found an immediate, effective use.

Each of these would require readings being sent to HA both when changes occur (by comparison to the previous stored value) and over a certain schedule (at 1/2/5/10 minutes, etc) - this would also serve as a heartbeat signal.

Hi this is a great project! Do you have any intention to support rotary encoders?
I’m currently using espeasy for an mqtt “dimmer” using rotary encoder. I’d love to move to your solution.

Yes that seems like a fun use-case. I’ve now tried to make a generic “send if … or …” with a special “send if delta or time” filter. I’ll see if I can get it into 1.6.0 :+1:

Absolute rotary encoders (the ones using a voltage divider circuit) should already be supported by the ADC Sensor :slight_smile: (I think I’ll create a “cookbook” for 2nd order components sometime).

Basically, with absolute rotary encoders, you just measure the voltage on the pin between GND and VCC. That voltage you measure will be proportional to the angle. Something like this:

sensor:
  - platform: adc
    pin: A0
    name: "Living Room Dimmer"
    filters:
      # Convert voltage to angle, depends on input voltage and encoder.
      - lambda: (x / 3.3) * 360.0
    # Tell Home Assistant the output value is in degrees
    unit_of_measurement: "°"

Continuous rotary encoder (with digital signals) are currently not supported, but I’ll try to get it into the automation engine release as it makes most sense there.

Thanks for the info, and for looking into rotary encoder support - meant the digital continuous rotary encoders rather than pot.
These are useful because analogue input on a sonoff basic is not easy.

BTW this is my project - Analogue style rotary dimmer switch - Sonoff + ESPEasy + MQTT

@hijinx Rotary encoders are now supported with v1.5.3 :slight_smile: https://esphomelib.com/esphomeyaml/components/sensor/rotary_encoder.html

sensor:
  - platform: rotary_encoder
    name: "Rotary Encoder"
    pin_a: D1
    pin_b: D2

@Petrica I’ve now also added support for heartbeat and delta sensor filters https://esphomelib.com/esphomeyaml/components/sensor/index.html#base-sensor-configuration Your use-case should be possible like this now:

sensor:
  - platform: some_platform
    # ...
    filters:
      - or:
        - heartbeat: 5min
        - delta: 5.0

This configuration will publish new states if either the absolute difference to the last reported value is at least 5.0 or if the last sent value is 5 minutes old.

1 Like

I’ll give it a try ASAP!

@OttoWinter I have 2 magnetic reed switches connected to 2 pins and set up sensors using esphomeyaml in HA for garage door open or closed. I see that the sensors go unavailable frequently and come back online. See pic below. Is there a way to resolve this?

Jep, that’s a known problem - and I don’t know a “real” solution to it. Somehow some ESP8266 like randomly loosing the WiFi connection and not being able to recover from it.

A few work-arounds that can help:

  • Use the latest arduino framework version (see this) - something in the low level IP stack (short lwip) seems to be quite broken in older version.
  • Play around with the MQTT keepalive option. For me, on some nodes reducing this value has helped, on others increasing it helped. I have no idea why :confused:
  • (Apparently, the “cheap” ESP8266/NodeMCU boards are much worse at this. Probably something related to them having a worse WiFi antenna.)

@OttoWinter Ok thanks will try those option.

Do you have any idea of adding RF devices? Here is a link to a program.

Yes I will support RF signals quite soon. The sending part is now more or less done with the IR Transmitter component (RF signals are really nothing else than a modulated signal like IR). I only need to add support for all the protocols now and create a RF receiver to sniff the codes.

Looks very good so far. I saw your note in the docs “In the future, this integration will be expanded to support reading RSSI values and hopefully support lots more devices like tracking smartphones and reading temperature values from BLE sensors.”

I’d love to put an ESP32 outside to drive a drip irrigation valve and be able to read (Bluetooth) miflora values and publish it on MQTT for HA to use.

Any idea when reading BLE sensors will come in?

Yeah sure it’s on my list, but that list is quite long… :wink: The problem is that I don’t own any BLE sensors (which send temperature values) and they seem quite expensive. Do you know of any cheap BLE-enabled sensors (~10$)? I’m thinking of maybe buying one as BLE is an interesting standard

The Miflora is a good device to use as an example. It’s fairly cheap also ~10-15USD.

1 Like

Close enough to 10 (if measured in euros :slight_smile: )
http://s.aliexpress.com/IZJVNfUB

1 Like

As @Landrash said, Miflora is very popular among the Home Assistant crowd, and runs about 13 USD.

Thank you! Just ordered one from eBay (I’m not a big fan of AliExpress) and will try to add support for it when it arrives - Gotta say that one @Petrica posted really looks quite dope (from a design perspective). So I’m already excited to have it arrive :slight_smile:

@OttoWinter is there any chance of including control for digital LED’s? I found this earlier today as linked from another thread on this forum and thought it would be a nice addition to your awesome work to have digital LED control since the NodeMCU’s make such a neat little controller for this type of thing

You mean individually addressabld lights like WS2811 or neopixel rings? See the FastLED lights https://esphomelib.com/esphomeyaml/index.html#light-components