diff --git a/esphome/components/mcp23008/mcp23008.cpp b/esphome/components/mcp23008/mcp23008.cpp index 351360fe1c..24b9a63f48 100644 --- a/esphome/components/mcp23008/mcp23008.cpp +++ b/esphome/components/mcp23008/mcp23008.cpp @@ -14,6 +14,9 @@ void MCP23008::setup() { return; } + // Read current output register state + this->read_reg(mcp23x08_base::MCP23X08_OLAT, &this->olat_); + if (this->open_drain_ints_) { // enable open-drain interrupt pins, 3.3V-safe this->write_reg(mcp23x08_base::MCP23X08_IOCON, 0x04); diff --git a/esphome/components/mcp23016/mcp23016.cpp b/esphome/components/mcp23016/mcp23016.cpp index 9787da6faa..70df0dfb7b 100644 --- a/esphome/components/mcp23016/mcp23016.cpp +++ b/esphome/components/mcp23016/mcp23016.cpp @@ -15,6 +15,10 @@ void MCP23016::setup() { return; } + // Read current output register state + this->read_reg_(MCP23016_OLAT0, &this->olat_0_); + this->read_reg_(MCP23016_OLAT1, &this->olat_1_); + // all pins input this->write_reg_(MCP23016_IODIR0, 0xFF); this->write_reg_(MCP23016_IODIR1, 0xFF); diff --git a/esphome/components/mcp23017/mcp23017.cpp b/esphome/components/mcp23017/mcp23017.cpp index 7344f482e0..b82e750eaf 100644 --- a/esphome/components/mcp23017/mcp23017.cpp +++ b/esphome/components/mcp23017/mcp23017.cpp @@ -14,6 +14,10 @@ void MCP23017::setup() { return; } + // Read current output register state + this->read_reg(mcp23x17_base::MCP23X17_OLATA, &this->olat_a_); + this->read_reg(mcp23x17_base::MCP23X17_OLATB, &this->olat_b_); + if (this->open_drain_ints_) { // enable open-drain interrupt pins, 3.3V-safe this->write_reg(mcp23x17_base::MCP23X17_IOCONA, 0x04); diff --git a/esphome/components/mcp23s08/mcp23s08.cpp b/esphome/components/mcp23s08/mcp23s08.cpp index af834b4c40..2f885743de 100644 --- a/esphome/components/mcp23s08/mcp23s08.cpp +++ b/esphome/components/mcp23s08/mcp23s08.cpp @@ -23,6 +23,9 @@ void MCP23S08::setup() { this->transfer_byte(0b00011000); // Enable HAEN pins for addressing this->disable(); + // Read current output register state + this->read_reg(mcp23x08_base::MCP23X08_OLAT, &this->olat_); + if (this->open_drain_ints_) { // enable open-drain interrupt pins, 3.3V-safe this->write_reg(mcp23x08_base::MCP23X08_IOCON, 0x04); diff --git a/esphome/components/mcp23s17/mcp23s17.cpp b/esphome/components/mcp23s17/mcp23s17.cpp index 8e3d5213f8..2fc9c74634 100644 --- a/esphome/components/mcp23s17/mcp23s17.cpp +++ b/esphome/components/mcp23s17/mcp23s17.cpp @@ -23,6 +23,10 @@ void MCP23S17::setup() { this->transfer_byte(0b00011000); // Enable HAEN pins for addressing this->disable(); + // Read current output register state + this->read_reg(mcp23x17_base::MCP23X17_OLATA, &this->olat_a_); + this->read_reg(mcp23x17_base::MCP23X17_OLATB, &this->olat_b_); + if (this->open_drain_ints_) { // enable open-drain interrupt pins, 3.3V-safe this->write_reg(mcp23x17_base::MCP23X17_IOCONA, 0x04);