Giter Club home page Giter Club logo

Comments (5)

brandond avatar brandond commented on August 21, 2024 1

Yeah, I was just looking at the filter code and realizing that it only worked for full sensors, not binary sensors. Bummer.

I was going to try to plug in some automation that took action on motion detection, and was hoping to avoid as much noise as possible, but I can probably live with it for now.

from esphome-core.

brandond avatar brandond commented on August 21, 2024 1

I can't think of much use case for doing a lot of math on binary outputs either; for most of what I want with binaries the filters would just be used to suppress undesired changes to the value.

from esphome-core.

OttoWinter avatar OttoWinter commented on August 21, 2024

I mean I've used those sensors without any initial waiting period for quite a while without issues.

For the uptime filter: Honestly, it feels like quite a limited use case. It would be easy enough to add, but I think esphomelib already probably has too many filters - having this many just confuses people.

If you find another use case, or if you can convince me that this use-case is quite common, please do say so. In the meantime, this should work fine:

main.cpp:

using namespace esphomelib;

class UptimeFilter : public sensor::Filter {
 public:
  UptimeFilter(uint32_t uptime) : uptime_(uptime) {}
  
  optional<float> new_value(float value) override {
    if (millis() >= uptime_)
      return value;
    return {};
  }
  
  uint32_t uptime_;
};

void setup() {
  // ...
  // =========== AUTO GENERATED CODE END ============
  pir_sensor.add_filter(new UptimeSensor(60*1000));
  App.setup();
}

(assuming your PIR sensor is a sensor, not a binary sensor; filters for binary sensors do not exist yet, but will exist soon-ish)

from esphome-core.

OttoWinter avatar OttoWinter commented on August 21, 2024

Okay. Regarding binary sensor filters: Do you happen to know if there are popular filters apart from the basic "debounce" filter

I was going to make my life easy and just add that one filter (and potentially a "debounce-last" or whatever it's called), but now with this feature request I'm thinking if I should just create a full modular binary sensor filter engine like with the sensors.

from esphome-core.

OttoWinter avatar OttoWinter commented on August 21, 2024

Should be really easy now with the uptime sensor. A simple lambda filter should do the trick :)

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.