mirror of
https://github.com/esphome/esphome.git
synced 2026-09-29 07:50:21 +00:00
[mk2pvrouter] Add binary_sensor platform (#19719)
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
72ac32a2c4
commit
499ce56c2b
@@ -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
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user