ESPHome  2024.4.1
binary_sensor_map.h
Go to the documentation of this file.
1 #pragma once
2 
6 
7 #include <vector>
8 
9 namespace esphome {
10 namespace binary_sensor_map {
11 
16 };
17 
20  union {
21  float sensor_value;
22  struct {
23  float given_true;
24  float given_false;
25  } probabilities;
26  } parameters;
27 };
28 
33 class BinarySensorMap : public sensor::Sensor, public Component {
34  public:
35  void dump_config() override;
36 
43  void loop() override;
44 
51  void add_channel(binary_sensor::BinarySensor *sensor, float value);
52 
60  void add_channel(binary_sensor::BinarySensor *sensor, float prob_given_true, float prob_given_false);
61 
62  void set_sensor_type(BinarySensorMapType sensor_type) { this->sensor_type_ = sensor_type; }
63 
64  void set_bayesian_prior(float prior) { this->bayesian_prior_ = prior; };
65 
66  protected:
67  std::vector<BinarySensorMapChannel> channels_{};
69 
70  // this allows a max of 64 channels/observations in order to keep track of binary_sensor states
71  uint64_t last_mask_{0x00};
72 
73  // Bayesian event prior probability before taking into account any observations
74  float bayesian_prior_{};
75 
83  void process_group_();
84  void process_sum_();
85  void process_bayesian_();
86 
96  float bayesian_predicate_(bool sensor_state, float prior, float prob_given_true, float prob_given_false);
97 };
98 
99 } // namespace binary_sensor_map
100 } // namespace esphome
void loop()
void set_sensor_type(BinarySensorMapType sensor_type)
Class to map one or more binary_sensors to one Sensor.
This is a workaround until we can figure out a way to get the tflite-micro idf component code availab...
Definition: a01nyub.cpp:7
struct esphome::binary_sensor_map::BinarySensorMapChannel::@12::@13 probabilities
Base class for all binary_sensor-type classes.
Definition: binary_sensor.h:37
Base-class for all sensors.
Definition: sensor.h:57
union esphome::binary_sensor_map::BinarySensorMapChannel::@12 parameters