Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add master_id option for component config #20

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 MConfigMMemberIDcode command
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