9static constexpr uint8_t REG_MODE = 0x10;
10static constexpr uint8_t REG_RELAY = 0x11;
11static constexpr uint8_t MODE_SYNC = 1;
19 for (
size_t channel = 0; channel < this->
switches_.size(); channel++) {
31 ESP_LOGCONFIG(TAG,
"M5Stack 4 Relay:");
45 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)
std::array< switch_::Switch *, 4 > switches_
void dump_config() override
bool set_relay(uint8_t channel, bool on)
Switch relay channel (0-3) on or off; returns false when the write failed.
Base class for all switches.
void restore()
Drive the switch to the state its restore mode yields, through control(), so inversion and write_stat...
ESPHOME_LOG_TAG(TAG, "m5stack_4relay")
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.