Skip to content

Commit

Permalink
Add master_id option for component config
Browse files Browse the repository at this point in the history
  • Loading branch information
vfrc2 committed Sep 9, 2023
1 parent f3dbd12 commit 28c0790
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions components/opentherm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
cv.GenerateID(): cv.declare_id(generate.OpenthermHub),
cv.Optional("in_pin", 4): cv.int_,
cv.Optional("out_pin", 5): cv.int_,
cv.Optional("master_id", 5): cv.int_,
cv.Optional("ch_enable", True): cv.boolean,
cv.Optional("dhw_enable", True): cv.boolean,
cv.Optional("cooling_enable", False): cv.boolean,
Expand Down
5 changes: 5 additions & 0 deletions components/opentherm/hub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ namespace message_data {
#define OPENTHERM_IGNORE_2(x, y)

unsigned int OpenthermHub::build_request(OpenThermMessageID request_id) {
if (request_id == OpenThermMessageID::MConfigMMemberIDcode) {
ESP_LOGD(TAG, "Building Member Config request with id %d", this->master_id);
return ot->buildRequest(OpenThermMessageType::WRITE_DATA, OpenThermMessageID::MConfigMMemberIDcode, this->master_id);
}
// First, handle the status request. This requires special logic, because we
// wouldn't want to inadvertently disable domestic hot water, for example.
// It is also included in the macro-generated code below, but that will
Expand Down Expand Up @@ -225,6 +229,7 @@ void OpenthermHub::setup() {
this->ot = new OpenTherm(this->in_pin, this->out_pin, false);
this->ot->begin(this->handle_interrupt_callback, this->process_response_callback);

this->add_initial_message(OpenThermMessageID::MConfigMMemberIDcode);
// Ensure that there is at least one request, as we are required to
// communicate at least once every second. Sending the status request is
// good practice anyway.
Expand Down
3 changes: 3 additions & 0 deletions components/opentherm/hub.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ class OpenthermHub : public Component {
protected:
// Communication pins for the OpenTherm interface
int in_pin, out_pin;
// Master id for
int master_id = 0;
// The OpenTherm interface from @ihormelnyk's library
OpenTherm* ot;

Expand Down Expand Up @@ -114,6 +116,7 @@ class OpenthermHub : public Component {
// Setters for the input and output OpenTherm interface pins
void set_in_pin(int in_pin) { this->in_pin = in_pin; }
void set_out_pin(int out_pin) { this->out_pin = out_pin; }
void set_master_id(int master_id) { this->master_id = master_id; }

#define OPENTHERM_SET_SENSOR(entity) void set_ ## entity(sensor::Sensor* sensor) { this->entity = sensor; }
OPENTHERM_SENSOR_LIST(OPENTHERM_SET_SENSOR, )
Expand Down
1 change: 1 addition & 0 deletions examples/thermostat-pid-complete.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ captive_portal:
opentherm:
in_pin: 4
out_pin: 5
# master_id: 4 # default 0, baxi 4
ch_enable: true
dhw_enable: false
cooling_enable: false
Expand Down

0 comments on commit 28c0790

Please sign in to comment.