Giter Club home page Giter Club logo

Comments (3)

OttoWinter avatar OttoWinter commented on July 20, 2024

That's exactly what sensor filters are for in esphomelib πŸ’ͺ. They pre-process sensor values in order to decrease network traffic and put less pressure on Home Assistant's state machine.

I don't know the exact thresholds for your setup, but something like this might work:

auto o = App.make_ultrasonic_sensor(...);
o.mqtt->clear_filters();
o.mqtt->add_lambda_filter([&](float value) -> Optional<float> {
  if (value > 2.0f || isnan(value))
    // Returning an empty optional stops the value from ebing published.
    return Optional<float>();
  β€Žreturn value;
});

(writing this on my phone, as my laptop doesn't have any power; might not compile as-is)

Sensor filters are only supposed to do some basic pre-processing though, and more sophisticated stuff should be done with template (binary) sensors in Home Assistant. Home Assistant's template engine is amazing and it would be very difficult to create a similar, complete system for esphomelib.

from esphome-core.

OttoWinter avatar OttoWinter commented on July 20, 2024

And with esphomeyaml this has just gotten a lot easier: https://esphomelib.com/esphomeyaml/components/sensor/index.html#sensor-filters πŸ˜€

from esphome-core.

OttoWinter avatar OttoWinter commented on July 20, 2024

Should be possible with the Template Binary Sensor now :) Closing ...

from esphome-core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.