71 SUB_SENSOR(accumulated_flow)
76#ifdef USE_BINARY_SENSOR
77 SUB_BINARY_SENSOR(ufc_chip_error)
78 SUB_BINARY_SENSOR(flow_direction_wrong)
79 SUB_BINARY_SENSOR(empty_tube)
80 SUB_BINARY_SENSOR(flow_rate_out_of_range)
83#ifdef USE_UFM01_METER_ID
84 SUB_TEXT_SENSOR(meter_id)
86#ifdef USE_UFM01_SOFTWARE_VERSION
87 SUB_TEXT_SENSOR(software_version)
91 void setup()
override;
93 void dump_config()
override;
97#ifdef USE_UFM01_CLEAR_ACCUMULATED_FLOW_ACTION
99 void request_clear_accumulated_flow();
102 float get_setup_priority()
const override;
105#ifdef USE_UFM01_CLEAR_ACCUMULATED_FLOW_ACTION
106 bool can_start_clear_action_()
const;
107 void loop_pending_clear_action_(
uint32_t now);
108 void finish_pending_clear_();
110 void send_command_no_wait_(
const std::array<uint8_t, 7> &command);
113 bool process_active_stream_(
uint32_t now);
114 void on_active_frame_(
const uint8_t data[FRAME_SIZE],
uint32_t now);
115#ifdef USE_UFM01_METER_ID
116 void publish_meter_id_from_frame_(
const uint8_t data[FRAME_SIZE]);
118 void publish_stale_flow_and_temperature_();
119#ifdef USE_UFM01_SOFTWARE_VERSION
120 void start_software_version_read_(
uint32_t now);
123 bool service_software_version_(
uint32_t now);
127 void loop_active_stream_(
uint32_t now);
128 void loop_passive_poll_(
uint32_t now);
132 void enter_active_stream_(
const LogString *reason,
uint32_t now);
133 void enter_passive_from_stale_(
uint32_t now);
134 void restart_startup_(
const LogString *reason,
uint32_t now);
135 void start_passive_read_(
uint32_t now);
137 void note_passive_poll_result_(
bool success,
uint32_t now);
145#ifdef USE_UFM01_SOFTWARE_VERSION
146 uint32_t last_software_version_attempt_ms_{0};
148#ifdef USE_UFM01_CLEAR_ACCUMULATED_FLOW_ACTION
149 uint32_t pending_clear_start_ms_{0};
154 bool reset_retried_{
false};
155 bool passive_read_pending_{
false};
156 uint8_t consecutive_passive_failures_{0};
157 uint8_t passive_index_{0};
158 uint8_t passive_expected_size_{PASSIVE_FRAME_SIZE};
159 uint8_t passive_start_byte_2_{0};
160#ifdef USE_UFM01_SOFTWARE_VERSION
161 bool software_version_published_{
false};
162 bool software_version_read_pending_{
false};
163 uint8_t software_version_failures_{0};
165#ifdef USE_UFM01_METER_ID
166 bool meter_id_published_{
false};
167 bool meter_id_invalid_logged_{
false};
169#ifdef USE_UFM01_CLEAR_ACCUMULATED_FLOW_ACTION
170 bool clear_pending_{
false};
171 bool pending_clear_sent_{
false};
174 uint8_t passive_frame_[PASSIVE_FRAME_MAX_SIZE];
177 friend class testing::TestableUFM01;