11 #ifdef OPENTHERM_USE_SENSOR 15 #ifdef OPENTHERM_USE_BINARY_SENSOR 19 #ifdef OPENTHERM_USE_SWITCH 23 #ifdef OPENTHERM_USE_OUTPUT 27 #ifdef OPENTHERM_USE_NUMBER 32 #include <unordered_map> 33 #include <unordered_set> 41 static const uint8_t REPEATING_MESSAGE_ORDER = 255;
42 static const uint8_t INITIAL_UNORDERED_MESSAGE_ORDER = 254;
54 OPENTHERM_BINARY_SENSOR_LIST(OPENTHERM_DECLARE_BINARY_SENSOR, )
58 OPENTHERM_NUMBER_LIST(OPENTHERM_DECLARE_NUMBER, )
62 OPENTHERM_INPUT_SENSOR_LIST(OPENTHERM_DECLARE_INPUT_SENSOR, )
66 bool sending_initial_ = true;
100 template<typename F>
bool spin_wait_(uint32_t timeout, F func) {
101 auto start_time =
millis();
105 if (cur_time - start_time >= timeout) {
125 OPENTHERM_BINARY_SENSOR_LIST(OPENTHERM_SET_BINARY_SENSOR, )
129 OPENTHERM_NUMBER_LIST(OPENTHERM_SET_NUMBER, )
133 OPENTHERM_INPUT_SENSOR_LIST(OPENTHERM_SET_INPUT_SENSOR, )
172 void setup()
override;
174 void loop()
override;
void add_on_before_process_response_callback(std::function< void(OpenthermData &)> &&callback)
bool should_skip_loop_(uint32_t cur_time) const
void set_dhw_block(bool value)
void check_timings_(uint32_t cur_time)
uint32_t last_conversation_start_
std::vector< MessageId >::const_iterator message_iterator_
void handle_protocol_error_()
void process_response(OpenthermData &data)
std::unordered_map< MessageId, uint8_t > configured_messages_
InternalGPIOPin * in_pin_
OPENTHERM_OUTPUT_LIST(OPENTHERM_DECLARE_OUTPUT,) OPENTHERM_INPUT_SENSOR_LIST(OPENTHERM_DECLARE_INPUT_SENSOR
void set_out_pin(InternalGPIOPin *out_pin)
std::unique_ptr< OpenTherm > opentherm_
uint32_t IRAM_ATTR HOT millis()
bool spin_wait_(uint32_t timeout, F func)
CallbackManager< void(OpenthermData &)> before_process_response_callback_
void set_sync_mode(bool sync_mode)
void start_conversation_()
BedjetMode mode
BedJet operating mode.
uint32_t last_conversation_end_
InternalGPIOPin * out_pin_
CallbackManager< void(OpenthermData &)> before_send_callback_
void set_in_pin(InternalGPIOPin *in_pin)
void set_cooling_enable(bool value)
void handle_timer_error_()
void write_initial_messages_(std::vector< MessageId > &target)
void add_on_before_send_callback(std::function< void(OpenthermData &)> &&callback)
void dump_config() override
const float HARDWARE
For components that deal with hardware and are very important like GPIO switch.
float get_setup_priority() const override
void IRAM_ATTR HOT yield()
void set_dhw_enable(bool value)
void set_otc_active(bool value)
OPENTHERM_SWITCH_LIST(OPENTHERM_DECLARE_SWITCH,) OPENTHERM_NUMBER_LIST(OPENTHERM_DECLARE_NUMBER
Implementation of SPI Controller mode.
std::vector< MessageId > messages_
void write_repeating_messages_(std::vector< MessageId > &target)
OPENTHERM_SETTING_LIST(OPENTHERM_DECLARE_SETTING,) bool sending_initial_
void set_ch_enable(bool value)
void add_repeating_message(MessageId message_id)
Structure to hold Opentherm data packet content.
void handle_timeout_error_()
void set_summer_mode_active(bool value)
OPENTHERM_SENSOR_LIST(OPENTHERM_DECLARE_SENSOR,) OPENTHERM_BINARY_SENSOR_LIST(OPENTHERM_DECLARE_BINARY_SENSOR
void on_shutdown() override
OpenthermData build_request_(MessageId request_id) const
void set_ch2_active(bool value)
OpenthermData last_request_
void add_initial_message(MessageId message_id, uint8_t order)
bool handle_error_(OperationMode mode)