68 SUB_SENSOR(accumulated_flow)
73#ifdef USE_BINARY_SENSOR
74 SUB_BINARY_SENSOR(ufc_chip_error)
75 SUB_BINARY_SENSOR(flow_direction_wrong)
76 SUB_BINARY_SENSOR(empty_tube)
77 SUB_BINARY_SENSOR(flow_rate_out_of_range)
80#ifdef USE_UFM01_METER_ID
81 SUB_TEXT_SENSOR(meter_id)
83#ifdef USE_UFM01_SOFTWARE_VERSION
84 SUB_TEXT_SENSOR(software_version)
88 void setup()
override;
90 void dump_config()
override;
94#ifdef USE_UFM01_CLEAR_ACCUMULATED_FLOW_ACTION
96 void request_clear_accumulated_flow();
99 float get_setup_priority()
const override;
102#ifdef USE_UFM01_CLEAR_ACCUMULATED_FLOW_ACTION
103 bool can_start_clear_action_()
const;
104 void loop_pending_clear_action_(
uint32_t now);
105 void finish_pending_clear_();
107 void send_command_no_wait_(
const std::array<uint8_t, 7> &command);
110 bool process_active_stream_(
uint32_t now);
111 void on_active_frame_(uint8_t data[FRAME_SIZE],
uint32_t now);
112#ifdef USE_UFM01_METER_ID
113 void publish_meter_id_from_frame_(
const uint8_t data[FRAME_SIZE]);
115 void publish_stale_flow_and_temperature_();
116#ifdef USE_UFM01_SOFTWARE_VERSION
117 void start_software_version_read_(
uint32_t now);
120 bool service_software_version_(
uint32_t now);
124 void loop_active_stream_(
uint32_t now);
125 void loop_passive_poll_(
uint32_t now);
129 void enter_active_stream_(
const LogString *reason,
uint32_t now);
130 void enter_passive_from_stale_(
uint32_t now);
131 void restart_startup_(
const LogString *reason,
uint32_t now);
132 void start_passive_read_(
uint32_t now);
134 void note_passive_poll_result_(
bool success,
uint32_t now);
142#ifdef USE_UFM01_SOFTWARE_VERSION
143 uint32_t last_software_version_attempt_ms_{0};
145#ifdef USE_UFM01_CLEAR_ACCUMULATED_FLOW_ACTION
146 uint32_t pending_clear_start_ms_{0};
148 int32_t read_index_{0};
152 bool reset_retried_{
false};
153 bool passive_read_pending_{
false};
154 uint8_t consecutive_passive_failures_{0};
155 uint8_t passive_index_{0};
156 uint8_t passive_expected_size_{PASSIVE_FRAME_SIZE};
157 uint8_t passive_start_byte_2_{0};
158#ifdef USE_UFM01_SOFTWARE_VERSION
159 bool software_version_published_{
false};
160 bool software_version_read_pending_{
false};
161 uint8_t software_version_failures_{0};
163#ifdef USE_UFM01_METER_ID
164 bool meter_id_published_{
false};
165 bool meter_id_invalid_logged_{
false};
167#ifdef USE_UFM01_CLEAR_ACCUMULATED_FLOW_ACTION
168 bool clear_pending_{
false};
169 bool pending_clear_sent_{
false};
172 uint8_t passive_frame_[PASSIVE_FRAME_MAX_SIZE];
173 uint8_t data_[FRAME_SIZE];
175 friend class testing::TestableUFM01;