9static constexpr uint8_t CMD_CHANNEL_CTRL = 0x10;
10static constexpr uint8_t CMD_SAVE_I2C_ADDR = 0x11;
11static constexpr uint8_t CMD_READ_FIRMWARE_VER = 0x13;
24 for (uint8_t channel = 0; channel != this->
switches_.size(); channel++) {
34 for (uint8_t channel = 0; channel != this->
switches_.size(); channel++) {
36 this->
switches_[channel]->publish_state((value >> channel) & 1);
46 ESP_LOGW(TAG,
"I2C address 0x%02X is reserved; not stored",
address);
52 ESP_LOGI(TAG,
"Board now answers at 0x%02X; update address: in the configuration",
address);
57 "Seeed Multi Channel Relay:\n"
58 " Firmware version: %u",
73 this->
switches_[channel]->publish_state(on);
void mark_failed()
Mark this component as failed.
bool status_comm_result(bool ok)
Clears the warning when ok, else sets it with message (default "Communication failed"); returns ok.
bool write_byte(uint8_t a_register, uint8_t data) const
bool read_byte(uint8_t a_register, uint8_t *data)
void set_i2c_address(uint8_t address)
We store the address of the device on the bus.
void change_address(uint8_t address)
Store a new I2C address in the board's EEPROM and talk to it there from now on.
std::array< switch_::Switch *, 8 > switches_
void dump_config() override
bool set_relay(uint8_t channel, bool on)
Switch relay channel (0-7) on or off; returns false when the write failed.
uint8_t firmware_version_
Base class for all switches.
optional< bool > get_initial_state_with_restore_mode()
Returns the initial state of the switch, after applying restore mode rules.
ESPHOME_LOG_TAG(TAG, "seeed_multi_channel_relay")
ESPHOME_ALWAYS_INLINE constexpr void assign_bits(T &value, std::type_identity_t< T > mask, bool on)
Set the bits of mask in value when on is true, clear them otherwise.