From aecca5eea6056701d7de9ae079f4dc3b9e089757 Mon Sep 17 00:00:00 2001 From: KoenBreeman <121864590+KoenBreeman@users.noreply.github.com> Date: Fri, 9 Aug 2024 16:15:53 +0200 Subject: [PATCH] Created seeedmultichanelle relay --- CODEOWNERS | 1 + .../seeedmultichannelrelay/__init__.py | 38 +++++++++ .../seeedmultichannelrelay.cpp | 82 +++++++++++++++++++ .../seeedmultichannelrelay.h | 78 ++++++++++++++++++ .../seeedmultichannelrelay/switch/__init__.py | 75 +++++++++++++++++ .../switch/seeedmultichannelrelay_switch.cpp | 77 +++++++++++++++++ .../switch/seeedmultichannelrelay_switch.h | 31 +++++++ .../seeedmultichannelrelay/common.yaml | 22 +++++ .../test.esp32-ard.yaml | 22 +++++ .../test.esp32-c3-ard.yaml | 22 +++++ .../test.esp32-c3-idf.yaml | 22 +++++ .../test.esp32-idf.yaml | 22 +++++ .../test.esp8266-ard.yaml | 22 +++++ .../test.rp2040-ard.yaml | 22 +++++ 14 files changed, 536 insertions(+) create mode 100644 esphome/components/seeedmultichannelrelay/__init__.py create mode 100644 esphome/components/seeedmultichannelrelay/seeedmultichannelrelay.cpp create mode 100644 esphome/components/seeedmultichannelrelay/seeedmultichannelrelay.h create mode 100644 esphome/components/seeedmultichannelrelay/switch/__init__.py create mode 100644 esphome/components/seeedmultichannelrelay/switch/seeedmultichannelrelay_switch.cpp create mode 100644 esphome/components/seeedmultichannelrelay/switch/seeedmultichannelrelay_switch.h create mode 100644 tests/components/seeedmultichannelrelay/common.yaml create mode 100644 tests/components/seeedmultichannelrelay/test.esp32-ard.yaml create mode 100644 tests/components/seeedmultichannelrelay/test.esp32-c3-ard.yaml create mode 100644 tests/components/seeedmultichannelrelay/test.esp32-c3-idf.yaml create mode 100644 tests/components/seeedmultichannelrelay/test.esp32-idf.yaml create mode 100644 tests/components/seeedmultichannelrelay/test.esp8266-ard.yaml create mode 100644 tests/components/seeedmultichannelrelay/test.rp2040-ard.yaml diff --git a/CODEOWNERS b/CODEOWNERS index 9159f5f843..fa7489cdff 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -334,6 +334,7 @@ esphome/components/sdl/* @clydebarrow esphome/components/sdm_meter/* @jesserockz @polyfaces esphome/components/sdp3x/* @Azimath esphome/components/seeed_mr24hpc1/* @limengdu +esphome/components/seeedmultichannelrelay/* @KoenBreeman esphome/components/selec_meter/* @sourabhjaiswal esphome/components/select/* @esphome/core esphome/components/sen0321/* @notjj diff --git a/esphome/components/seeedmultichannelrelay/__init__.py b/esphome/components/seeedmultichannelrelay/__init__.py new file mode 100644 index 0000000000..52b9ba17bb --- /dev/null +++ b/esphome/components/seeedmultichannelrelay/__init__.py @@ -0,0 +1,38 @@ +import esphome.codegen as cg +import esphome.config_validation as cv +from esphome.components import i2c +from esphome.const import CONF_ID + +CODEOWNERS = ["@KoenBreeman"] +DEPENDENCIES = ["i2c"] + +MULTI_CONF = True + +CONF_I2C_ADDR = 0x11 + +CONF_SEEEDMULTICHANNELRELAY_ID = "seeedmultichannelrelay_id" +CONF_CHANGE_ADDRESS_TO = "change_address_to" + +seeedmultichannelrelay_ns = cg.esphome_ns.namespace("seeedmultichannelrelay") +SeeedMultiChannelRelay = seeedmultichannelrelay_ns.class_( + "SeeedMultiChannelRelay", cg.Component, i2c.I2CDevice +) + +CONFIG_SCHEMA = ( + cv.Schema( + { + cv.GenerateID(): cv.declare_id(SeeedMultiChannelRelay), + cv.Optional(CONF_CHANGE_ADDRESS_TO): cv.hex_int_range(min=0x00, max=0x7F), + } + ) + .extend(cv.COMPONENT_SCHEMA) + .extend(i2c.i2c_device_schema(CONF_I2C_ADDR)) +) + + +async def to_code(config): + var = cg.new_Pvariable(config[CONF_ID]) + await cg.register_component(var, config) + await i2c.register_i2c_device(var, config) + if CONF_CHANGE_ADDRESS_TO in config: + cg.add(var.change_i2c_address(config[CONF_CHANGE_ADDRESS_TO])) diff --git a/esphome/components/seeedmultichannelrelay/seeedmultichannelrelay.cpp b/esphome/components/seeedmultichannelrelay/seeedmultichannelrelay.cpp new file mode 100644 index 0000000000..fc52e6b39e --- /dev/null +++ b/esphome/components/seeedmultichannelrelay/seeedmultichannelrelay.cpp @@ -0,0 +1,82 @@ +#include "seeedmultichannelrelay.h" +#include "esphome/core/log.h" +#include "seeedmultichannelrelay.h" + +namespace esphome { +namespace seeedmultichannelrelay { + +static const char *const TAG = "SeeedMultiChannelRelay"; + +void SeeedMultiChannelRelay::channel_ctrl_(uint8_t state) { + this->channel_state_ = state; + this->write1_byte_(CMD_CHANNEL_CTRL, state); +} + +void SeeedMultiChannelRelay::turn_on_channel_(uint8_t channel) { + this->channel_state_ |= (1 << (channel - 1)); + this->channel_ctrl_(channel_state_); +} + +void SeeedMultiChannelRelay::turn_off_channel_(uint8_t channel) { + this->channel_state_ &= ~(1 << (channel - 1)); + this->channel_ctrl_(channel_state_); +} + +void SeeedMultiChannelRelay::dump_config() { + ESP_LOGCONFIG(TAG, "Seeed Multi Channel Relays:"); + LOG_I2C_DEVICE(this); +} + +/*! @brief Read a certain length of data to the specified register address. */ +uint8_t SeeedMultiChannelRelay::read1_byte_(uint8_t register_address) { + uint8_t data; + if (!this->read_byte(register_address, &data)) { + ESP_LOGW(TAG, "Read from relay failed!"); + this->status_set_warning(); + return uint8_t(0); + } + return data; +} + +/*! @brief Control the on/off of the specified relay. + * @param number Bit number of relay (0~3). + @param state OFF = 0, ON = 1 . */ +void SeeedMultiChannelRelay::relay_write(uint8_t number, bool state) { + if (state) { + this->turn_on_channel_(number); + } else { + this->turn_off_channel_(number); + } +} + +void SeeedMultiChannelRelay::setup() { + ESP_LOGCONFIG(TAG, "Setting up Seeed Multi Channel Relay..."); + ESP_LOGCONFIG(TAG, "Firmware version of the Seeed Multi Channel Relay %u", this->get_firmware_version()); + if (this->address_changed_) { + this->write1_byte_(CMD_SAVE_I2C_ADDR, this->new_addr_); + this->set_i2c_address(this->new_addr_); + ESP_LOGCONFIG(TAG, "I2C address of control changed to %u", this->new_addr_); + } +} + +void SeeedMultiChannelRelay::change_i2c_address(uint8_t new_addr) { + this->new_addr_ = new_addr; + address_changed_ = true; +} + +uint8_t SeeedMultiChannelRelay::get_firmware_version() { + uint8_t firmware_from_device = this->read1_byte_(CMD_READ_FIRMWARE_VER); + return firmware_from_device; +} + +/*! @brief Write a certain length of data to the specified register address. */ +void SeeedMultiChannelRelay::write1_byte_(uint8_t register_address, uint8_t data) { + if (!this->write_byte(register_address, data)) { + ESP_LOGW(TAG, "Write to relay failed!"); + this->status_set_warning(); + return; + } +} + +} // namespace seeedmultichannelrelay +} // namespace esphome diff --git a/esphome/components/seeedmultichannelrelay/seeedmultichannelrelay.h b/esphome/components/seeedmultichannelrelay/seeedmultichannelrelay.h new file mode 100644 index 0000000000..1e8d91fdcd --- /dev/null +++ b/esphome/components/seeedmultichannelrelay/seeedmultichannelrelay.h @@ -0,0 +1,78 @@ +#pragma once + +#include "esphome/core/component.h" +#include "esphome/components/i2c/i2c.h" + +namespace esphome { +namespace seeedmultichannelrelay { + +static constexpr uint8_t CMD_CHANNEL_CTRL = 0x10; +static constexpr uint8_t CMD_SAVE_I2C_ADDR = 0x11; +static constexpr uint8_t CMD_READ_I2C_ADDR = 0x12; +static constexpr uint8_t CMD_READ_FIRMWARE_VER = 0x13; + +enum class RelayBit : uint8_t { + RELAY1 = 1, + RELAY2 = 2, + RELAY3 = 3, + RELAY4 = 4, + RELAY5 = 5, + RELAY6 = 6, + RELAY7 = 7, + RELAY8 = 8 +}; + +class SeeedMultiChannelRelay : public Component, public i2c::I2CDevice { + public: + void relay_write(uint8_t number, bool state); + + /* + @brief Change device address from old_addr to new_addr. + @param new_addr, the address to use. + old_addr, the original address + @return None +*/ + void change_i2c_address(uint8_t new_addr); + + /* +@brief Read firmware version from on board MCU +@param +@return Firmware version in byte +*/ + uint8_t get_firmware_version(); + + protected: + void write1_byte_(uint8_t register_address, uint8_t data); + uint8_t read1_byte_(uint8_t register_address); + uint8_t channel_state_; // Value to save channel state + uint8_t new_addr_; + bool address_changed_ = false; + + /* + @brief Control relay channels + @param state, use one Byte to represent 8 channel + @return None + */ + void channel_ctrl_(uint8_t state); + + /* + @brief Turn on one of 8 channels + @param channel, channel to control with (range form 1 to 8) + @return None +*/ + void turn_on_channel_(uint8_t channel); + + /* + @brief Turn off on of 8 channels + @param channel, channel to control with (range form 1 to 8) + @return None + */ + void turn_off_channel_(uint8_t channel); + + void dump_config() override; + + void setup() override; +}; + +} // namespace seeedmultichannelrelay +} // namespace esphome diff --git a/esphome/components/seeedmultichannelrelay/switch/__init__.py b/esphome/components/seeedmultichannelrelay/switch/__init__.py new file mode 100644 index 0000000000..a52b7c86d3 --- /dev/null +++ b/esphome/components/seeedmultichannelrelay/switch/__init__.py @@ -0,0 +1,75 @@ +import esphome.codegen as cg +import esphome.config_validation as cv +from esphome.components import i2c, switch +from esphome.const import CONF_CHANNEL, CONF_INTERLOCK + +from .. import ( + seeedmultichannelrelay_ns, + SeeedMultiChannelRelay, + CONF_SEEEDMULTICHANNELRELAY_ID, +) + +DEPENDENCIES = ["seeedmultichannelrelay"] + +SeeedMultiChannelRelaySwitch = seeedmultichannelrelay_ns.class_( + "SeeedMultiChannelRelaySwitch", cg.Component, i2c.I2CDevice, switch.Switch +) + +CONF_INTERLOCK_WAIT_TIME = "interlock_wait_time" + +CONF_Relay_1 = 1 +CONF_Relay_2 = 2 +CONF_Relay_3 = 3 +CONF_Relay_4 = 4 +CONF_Relay_5 = 5 +CONF_Relay_6 = 6 +CONF_Relay_7 = 7 +CONF_Relay_8 = 8 + +RelayBit_ = seeedmultichannelrelay_ns.enum("RelayBit", is_class=True) + +SWITCH_MAP = { + CONF_Relay_1: RelayBit_.RELAY1, + CONF_Relay_2: RelayBit_.RELAY2, + CONF_Relay_3: RelayBit_.RELAY3, + CONF_Relay_4: RelayBit_.RELAY4, + CONF_Relay_5: RelayBit_.RELAY5, + CONF_Relay_6: RelayBit_.RELAY6, + CONF_Relay_7: RelayBit_.RELAY7, + CONF_Relay_8: RelayBit_.RELAY8, +} + + +CONFIG_SCHEMA = ( + switch.switch_schema(SeeedMultiChannelRelaySwitch) + .extend( + { + cv.GenerateID(): cv.declare_id(SeeedMultiChannelRelaySwitch), + cv.GenerateID(CONF_SEEEDMULTICHANNELRELAY_ID): cv.use_id( + SeeedMultiChannelRelay + ), + cv.Required(CONF_CHANNEL): cv.enum(SWITCH_MAP), + cv.Optional(CONF_INTERLOCK): cv.ensure_list(cv.use_id(switch.Switch)), + cv.Optional( + CONF_INTERLOCK_WAIT_TIME, default="0ms" + ): cv.positive_time_period_milliseconds, + } + ) + .extend(cv.COMPONENT_SCHEMA) +) + + +async def to_code(config): + var = await switch.new_switch(config) + await cg.register_component(var, config) + await cg.register_parented(var, config[CONF_SEEEDMULTICHANNELRELAY_ID]) + + cg.add(var.set_channel(config[CONF_CHANNEL])) + + if CONF_INTERLOCK in config: + interlock = [] + for it in config[CONF_INTERLOCK]: + lock = await cg.get_variable(it) + interlock.append(lock) + cg.add(var.set_interlock(interlock)) + cg.add(var.set_interlock_wait_time(config[CONF_INTERLOCK_WAIT_TIME])) diff --git a/esphome/components/seeedmultichannelrelay/switch/seeedmultichannelrelay_switch.cpp b/esphome/components/seeedmultichannelrelay/switch/seeedmultichannelrelay_switch.cpp new file mode 100644 index 0000000000..5fa1f94d38 --- /dev/null +++ b/esphome/components/seeedmultichannelrelay/switch/seeedmultichannelrelay_switch.cpp @@ -0,0 +1,77 @@ +#include "esphome/core/log.h" +#include "seeedmultichannelrelay_switch.h" + +namespace esphome { +namespace seeedmultichannelrelay { + +static const char *const TAG = "switch.SeeedMultiChannelRelay"; + +float SeeedMultiChannelRelaySwitch::get_setup_priority() const { return setup_priority::HARDWARE; } + +void SeeedMultiChannelRelaySwitch::setup() { + ESP_LOGCONFIG(TAG, "Setting up SeeedMultiChannelRelay Switch '%s'...", this->name_.c_str()); + + bool initial_state = this->get_initial_state_with_restore_mode().value_or(false); + + // write state before setup + if (initial_state) { + this->turn_on(); + } else { + this->turn_off(); + } +} + +void SeeedMultiChannelRelaySwitch::dump_config() { + LOG_SWITCH("", "SeeedMultiChannelRelay Switch", this); + + if (!this->interlock_.empty()) { + ESP_LOGCONFIG(TAG, " Interlocks:"); + for (auto *lock : this->interlock_) { + if (lock == this) + continue; + ESP_LOGCONFIG(TAG, " %s", lock->get_name().c_str()); + } + } +} + +void SeeedMultiChannelRelaySwitch::write_state(bool state) { + if (state != this->inverted_) { + // Turning ON, check interlocking + + bool found = false; + for (auto *lock : this->interlock_) { + if (lock == this) + continue; + + if (lock->state) { + lock->turn_off(); + found = true; + } + } + if (found && this->interlock_wait_time_ != 0) { + this->set_timeout("interlock", this->interlock_wait_time_, [this, state] { + // Don't write directly, call the function again + // (some other switch may have changed state while we were waiting) + this->write_state(state); + }); + return; + } + } else if (this->interlock_wait_time_ != 0) { + // If we are switched off during the interlock wait time, cancel any pending + // re-activations + this->cancel_timeout("interlock"); + } + + // This will be called every time the user requests a state change. + this->parent_->relay_write(this->channel_, state); + + // Acknowledge new state by publishing it + this->publish_state(state); +} + +void SeeedMultiChannelRelaySwitch::set_interlock(const std::vector &interlock) { + this->interlock_ = interlock; +} + +} // namespace seeedmultichannelrelay +} // namespace esphome diff --git a/esphome/components/seeedmultichannelrelay/switch/seeedmultichannelrelay_switch.h b/esphome/components/seeedmultichannelrelay/switch/seeedmultichannelrelay_switch.h new file mode 100644 index 0000000000..0111055f32 --- /dev/null +++ b/esphome/components/seeedmultichannelrelay/switch/seeedmultichannelrelay_switch.h @@ -0,0 +1,31 @@ +#pragma once + +#include "esphome/core/component.h" +#include "esphome/components/switch/switch.h" + +#include "esphome/components/seeedmultichannelrelay/seeedmultichannelrelay.h" + +namespace esphome { +namespace seeedmultichannelrelay { + +class SeeedMultiChannelRelaySwitch : public Component, public switch_::Switch, public Parented { + public: + float get_setup_priority() const override; + + void setup() override; + void dump_config() override; + void write_state(bool state) override; + + void set_channel(RelayBit channel) { this->channel_ = (uint8_t) channel; } + + void set_interlock(const std::vector &interlock); + void set_interlock_wait_time(uint32_t interlock_wait_time) { interlock_wait_time_ = interlock_wait_time; } + + protected: + uint8_t channel_; + std::vector interlock_; + uint32_t interlock_wait_time_{0}; +}; + +} // namespace seeedmultichannelrelay +} // namespace esphome diff --git a/tests/components/seeedmultichannelrelay/common.yaml b/tests/components/seeedmultichannelrelay/common.yaml new file mode 100644 index 0000000000..63cb2ccdb1 --- /dev/null +++ b/tests/components/seeedmultichannelrelay/common.yaml @@ -0,0 +1,22 @@ +seeedmultichannelrelay: + id: SeeedMultiChannelRelay_ID + change_address_to: 0x01 # changes the address of the seeedmultichannelrelay (only runs once to update into the EPROM) then you have to change the i2c_address + +switch: + - platform: seeedmultichannelrelay + id: seeedmultichannelrelay_1 + name: seeedmultichannelrelay1 + channel: 1 + seeedmultichannelrelay_id: SeeedMultiChannelRelay_ID + + - platform: seeedmultichannelrelay + id: seeedmultichannelrelay_2 + name: seeedmultichannelrelay2 + channel: 2 + seeedmultichannelrelay_id: SeeedMultiChannelRelay_ID + + - platform: seeedmultichannelrelay + id: seeedmultichannelrelay_8 + name: seeedmultichannelrelay8 + channel: 8 + seeedmultichannelrelay_id: SeeedMultiChannelRelay_ID diff --git a/tests/components/seeedmultichannelrelay/test.esp32-ard.yaml b/tests/components/seeedmultichannelrelay/test.esp32-ard.yaml new file mode 100644 index 0000000000..63cb2ccdb1 --- /dev/null +++ b/tests/components/seeedmultichannelrelay/test.esp32-ard.yaml @@ -0,0 +1,22 @@ +seeedmultichannelrelay: + id: SeeedMultiChannelRelay_ID + change_address_to: 0x01 # changes the address of the seeedmultichannelrelay (only runs once to update into the EPROM) then you have to change the i2c_address + +switch: + - platform: seeedmultichannelrelay + id: seeedmultichannelrelay_1 + name: seeedmultichannelrelay1 + channel: 1 + seeedmultichannelrelay_id: SeeedMultiChannelRelay_ID + + - platform: seeedmultichannelrelay + id: seeedmultichannelrelay_2 + name: seeedmultichannelrelay2 + channel: 2 + seeedmultichannelrelay_id: SeeedMultiChannelRelay_ID + + - platform: seeedmultichannelrelay + id: seeedmultichannelrelay_8 + name: seeedmultichannelrelay8 + channel: 8 + seeedmultichannelrelay_id: SeeedMultiChannelRelay_ID diff --git a/tests/components/seeedmultichannelrelay/test.esp32-c3-ard.yaml b/tests/components/seeedmultichannelrelay/test.esp32-c3-ard.yaml new file mode 100644 index 0000000000..63cb2ccdb1 --- /dev/null +++ b/tests/components/seeedmultichannelrelay/test.esp32-c3-ard.yaml @@ -0,0 +1,22 @@ +seeedmultichannelrelay: + id: SeeedMultiChannelRelay_ID + change_address_to: 0x01 # changes the address of the seeedmultichannelrelay (only runs once to update into the EPROM) then you have to change the i2c_address + +switch: + - platform: seeedmultichannelrelay + id: seeedmultichannelrelay_1 + name: seeedmultichannelrelay1 + channel: 1 + seeedmultichannelrelay_id: SeeedMultiChannelRelay_ID + + - platform: seeedmultichannelrelay + id: seeedmultichannelrelay_2 + name: seeedmultichannelrelay2 + channel: 2 + seeedmultichannelrelay_id: SeeedMultiChannelRelay_ID + + - platform: seeedmultichannelrelay + id: seeedmultichannelrelay_8 + name: seeedmultichannelrelay8 + channel: 8 + seeedmultichannelrelay_id: SeeedMultiChannelRelay_ID diff --git a/tests/components/seeedmultichannelrelay/test.esp32-c3-idf.yaml b/tests/components/seeedmultichannelrelay/test.esp32-c3-idf.yaml new file mode 100644 index 0000000000..63cb2ccdb1 --- /dev/null +++ b/tests/components/seeedmultichannelrelay/test.esp32-c3-idf.yaml @@ -0,0 +1,22 @@ +seeedmultichannelrelay: + id: SeeedMultiChannelRelay_ID + change_address_to: 0x01 # changes the address of the seeedmultichannelrelay (only runs once to update into the EPROM) then you have to change the i2c_address + +switch: + - platform: seeedmultichannelrelay + id: seeedmultichannelrelay_1 + name: seeedmultichannelrelay1 + channel: 1 + seeedmultichannelrelay_id: SeeedMultiChannelRelay_ID + + - platform: seeedmultichannelrelay + id: seeedmultichannelrelay_2 + name: seeedmultichannelrelay2 + channel: 2 + seeedmultichannelrelay_id: SeeedMultiChannelRelay_ID + + - platform: seeedmultichannelrelay + id: seeedmultichannelrelay_8 + name: seeedmultichannelrelay8 + channel: 8 + seeedmultichannelrelay_id: SeeedMultiChannelRelay_ID diff --git a/tests/components/seeedmultichannelrelay/test.esp32-idf.yaml b/tests/components/seeedmultichannelrelay/test.esp32-idf.yaml new file mode 100644 index 0000000000..63cb2ccdb1 --- /dev/null +++ b/tests/components/seeedmultichannelrelay/test.esp32-idf.yaml @@ -0,0 +1,22 @@ +seeedmultichannelrelay: + id: SeeedMultiChannelRelay_ID + change_address_to: 0x01 # changes the address of the seeedmultichannelrelay (only runs once to update into the EPROM) then you have to change the i2c_address + +switch: + - platform: seeedmultichannelrelay + id: seeedmultichannelrelay_1 + name: seeedmultichannelrelay1 + channel: 1 + seeedmultichannelrelay_id: SeeedMultiChannelRelay_ID + + - platform: seeedmultichannelrelay + id: seeedmultichannelrelay_2 + name: seeedmultichannelrelay2 + channel: 2 + seeedmultichannelrelay_id: SeeedMultiChannelRelay_ID + + - platform: seeedmultichannelrelay + id: seeedmultichannelrelay_8 + name: seeedmultichannelrelay8 + channel: 8 + seeedmultichannelrelay_id: SeeedMultiChannelRelay_ID diff --git a/tests/components/seeedmultichannelrelay/test.esp8266-ard.yaml b/tests/components/seeedmultichannelrelay/test.esp8266-ard.yaml new file mode 100644 index 0000000000..63cb2ccdb1 --- /dev/null +++ b/tests/components/seeedmultichannelrelay/test.esp8266-ard.yaml @@ -0,0 +1,22 @@ +seeedmultichannelrelay: + id: SeeedMultiChannelRelay_ID + change_address_to: 0x01 # changes the address of the seeedmultichannelrelay (only runs once to update into the EPROM) then you have to change the i2c_address + +switch: + - platform: seeedmultichannelrelay + id: seeedmultichannelrelay_1 + name: seeedmultichannelrelay1 + channel: 1 + seeedmultichannelrelay_id: SeeedMultiChannelRelay_ID + + - platform: seeedmultichannelrelay + id: seeedmultichannelrelay_2 + name: seeedmultichannelrelay2 + channel: 2 + seeedmultichannelrelay_id: SeeedMultiChannelRelay_ID + + - platform: seeedmultichannelrelay + id: seeedmultichannelrelay_8 + name: seeedmultichannelrelay8 + channel: 8 + seeedmultichannelrelay_id: SeeedMultiChannelRelay_ID diff --git a/tests/components/seeedmultichannelrelay/test.rp2040-ard.yaml b/tests/components/seeedmultichannelrelay/test.rp2040-ard.yaml new file mode 100644 index 0000000000..63cb2ccdb1 --- /dev/null +++ b/tests/components/seeedmultichannelrelay/test.rp2040-ard.yaml @@ -0,0 +1,22 @@ +seeedmultichannelrelay: + id: SeeedMultiChannelRelay_ID + change_address_to: 0x01 # changes the address of the seeedmultichannelrelay (only runs once to update into the EPROM) then you have to change the i2c_address + +switch: + - platform: seeedmultichannelrelay + id: seeedmultichannelrelay_1 + name: seeedmultichannelrelay1 + channel: 1 + seeedmultichannelrelay_id: SeeedMultiChannelRelay_ID + + - platform: seeedmultichannelrelay + id: seeedmultichannelrelay_2 + name: seeedmultichannelrelay2 + channel: 2 + seeedmultichannelrelay_id: SeeedMultiChannelRelay_ID + + - platform: seeedmultichannelrelay + id: seeedmultichannelrelay_8 + name: seeedmultichannelrelay8 + channel: 8 + seeedmultichannelrelay_id: SeeedMultiChannelRelay_ID