[mk2pvrouter] Add binary_sensor platform (#19719)

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Frédéric Metrich
2026-09-26 14:49:47 +01:00
committed by GitHub
co-authored by Claude Opus 5.5
parent 72ac32a2c4
commit 499ce56c2b
5 changed files with 91 additions and 0 deletions
@@ -0,0 +1,21 @@
#include <gtest/gtest.h>
#include "esphome/components/mk2pvrouter/binary_sensor/mk2pvrouter_binary_sensor.h"
namespace esphome::mk2pvrouter::testing {
TEST(Mk2PVRouterBinarySensorTest, ZeroPublishesOff) {
Mk2PVRouterBinarySensor sensor("R1");
sensor.publish_val("0");
ASSERT_TRUE(sensor.has_state());
EXPECT_FALSE(sensor.state);
}
TEST(Mk2PVRouterBinarySensorTest, OnePublishesOn) {
Mk2PVRouterBinarySensor sensor("R1");
sensor.publish_val("1");
ASSERT_TRUE(sensor.has_state());
EXPECT_TRUE(sensor.state);
}
} // namespace esphome::mk2pvrouter::testing
+7
View File
@@ -59,3 +59,10 @@ sensor:
name: Relay 10 State
tag: R10
mk2pvrouter_id: test_mk2pvrouter
binary_sensor:
# Test relay as binary sensor
- platform: mk2pvrouter
name: Relay 2 Binary
tag: R2
mk2pvrouter_id: test_mk2pvrouter