Compare commits

...
Author SHA1 Message Date
J. Nick Koston 568161d3f2 Merge remote-tracking branch 'origin/dev' into copy-follow-entities 2026-10-25 07:52:02 -10:00
J. Nick Koston 0a3993639e [copy] Keep the binary sensor copy as a component 2026-10-24 23:35:17 -10:00
J. Nick Koston b1342196c3 Merge branch 'entity-follow-helper' into copy-follow-entities 2026-10-24 23:35:02 -10:00
J. Nick Koston 9f5ff8ef6e [core] Drop the binary sensor follower 2026-10-24 23:34:51 -10:00
J. Nick Koston 79c86833ee Merge branch 'entity-follow-helper' into copy-follow-entities 2026-10-24 23:31:58 -10:00
J. Nick Koston 4ed6599b7e [binary_sensor] Copy the constructor state after the follower's automations are wired 2026-10-24 23:31:57 -10:00
J. Nick Koston de1a854266 Merge branch 'entity-follow-helper' into copy-follow-entities 2026-10-24 23:31:14 -10:00
J. Nick Koston 11b73fa6eb Merge branch 'copy-entity-state-tests' into entity-follow-helper 2026-10-24 23:31:14 -10:00
J. Nick Koston 7f5898279c [copy] Check a copy binary sensor whose source starts off 2026-10-24 23:31:14 -10:00
J. Nick Koston 916fc01a6a Merge branch 'entity-follow-helper' into copy-follow-entities 2026-10-24 22:49:11 -10:00
J. Nick Koston de49ad67fb [core] Keep the state sync out of FollowEntity and parenthesize test strings 2026-10-24 22:49:10 -10:00
J. Nick Koston 4ee6141b02 [copy] Check that the early copies follow later updates 2026-10-24 22:41:33 -10:00
J. Nick Koston 0a97ed5706 Merge branch 'entity-follow-helper' into copy-follow-entities 2026-10-24 22:41:33 -10:00
J. Nick Koston 8359b10cf8 Merge branch 'copy-entity-state-tests' into entity-follow-helper 2026-10-24 22:41:33 -10:00
J. Nick Koston f00b11a48a Merge branch 'entity-follow-helper' into copy-follow-entities
# Conflicts:
#	tests/integration/test_copy_entity_state.py
2026-10-24 22:31:38 -10:00
J. Nick Koston 9749698201 [core] Make the follow sync opt-in and pass leading callback arguments 2026-10-24 22:31:20 -10:00
J. Nick Koston 6f4bdf49fd [copy] Check the copy states from a table 2026-10-24 22:31:03 -10:00
J. Nick Koston 772acacb9e Merge branch 'copy-entity-state-tests' into entity-follow-helper 2026-10-24 22:31:03 -10:00
J. Nick Koston c1e1555918 [copy] Follow the source with plain sensors, binary sensors and text sensors 2026-10-24 22:26:31 -10:00
J. Nick Koston e647b2acc1 [core] Add follow helpers for plain sensors, binary sensors and text sensors 2026-10-24 22:25:08 -10:00
J. Nick Koston 3af8fec562 [copy] Add an integration test for the sensor, binary sensor and text sensor platforms 2026-10-24 22:23:00 -10:00
6 changed files with 10 additions and 100 deletions

No files matched your search

+5 -16
View File
@@ -13,19 +13,10 @@ from esphome.const import (
from esphome.core.entity_helpers import inherit_property_from
from esphome.types import ConfigType
from .. import copy_ns
CopySensor = copy_ns.class_("CopySensor", sensor.Sensor, cg.Component)
CONFIG_SCHEMA = (
sensor.sensor_schema(CopySensor)
.extend(
{
cv.Required(CONF_SOURCE_ID): cv.use_id(sensor.Sensor),
}
)
.extend(cv.COMPONENT_SCHEMA)
CONFIG_SCHEMA = sensor.sensor_schema(sensor.Sensor).extend(
{
cv.Required(CONF_SOURCE_ID): cv.use_id(sensor.Sensor),
}
)
FINAL_VALIDATE_SCHEMA = cv.All(
@@ -40,6 +31,4 @@ FINAL_VALIDATE_SCHEMA = cv.All(
async def to_code(config: ConfigType) -> None:
var = await sensor.new_sensor(config)
await cg.register_component(var, config)
await cg.add_variable(var.set_source, config[CONF_SOURCE_ID])
sensor.follow_sensor(var, await cg.get_variable(config[CONF_SOURCE_ID]))
@@ -1,16 +0,0 @@
#include "copy_sensor.h"
#include "esphome/core/log.h"
namespace esphome::copy {
ESPHOME_LOG_TAG(TAG, "copy.sensor");
void CopySensor::setup() {
source_->add_on_state_callback([this](float value) { this->publish_state(value); });
if (source_->has_state())
this->publish_state(source_->state);
}
void CopySensor::dump_config() { LOG_SENSOR("", "Copy Sensor", this); }
} // namespace esphome::copy
@@ -1,18 +0,0 @@
#pragma once
#include "esphome/core/component.h"
#include "esphome/components/sensor/sensor.h"
namespace esphome::copy {
class CopySensor final : public sensor::Sensor, public Component {
public:
void set_source(sensor::Sensor *source) { source_ = source; }
void setup() override;
void dump_config() override;
protected:
sensor::Sensor *source_;
};
} // namespace esphome::copy
@@ -5,19 +5,10 @@ from esphome.const import CONF_ENTITY_CATEGORY, CONF_ICON, CONF_SOURCE_ID
from esphome.core.entity_helpers import inherit_property_from
from esphome.types import ConfigType
from .. import copy_ns
CopyTextSensor = copy_ns.class_("CopyTextSensor", text_sensor.TextSensor, cg.Component)
CONFIG_SCHEMA = (
text_sensor.text_sensor_schema(CopyTextSensor)
.extend(
{
cv.Required(CONF_SOURCE_ID): cv.use_id(text_sensor.TextSensor),
}
)
.extend(cv.COMPONENT_SCHEMA)
CONFIG_SCHEMA = text_sensor.text_sensor_schema(text_sensor.TextSensor).extend(
{
cv.Required(CONF_SOURCE_ID): cv.use_id(text_sensor.TextSensor),
}
)
FINAL_VALIDATE_SCHEMA = cv.All(
@@ -28,6 +19,4 @@ FINAL_VALIDATE_SCHEMA = cv.All(
async def to_code(config: ConfigType) -> None:
var = await text_sensor.new_text_sensor(config)
await cg.register_component(var, config)
await cg.add_variable(var.set_source, config[CONF_SOURCE_ID])
text_sensor.follow_text_sensor(var, await cg.get_variable(config[CONF_SOURCE_ID]))
@@ -1,16 +0,0 @@
#include "copy_text_sensor.h"
#include "esphome/core/log.h"
namespace esphome::copy {
ESPHOME_LOG_TAG(TAG, "copy.text_sensor");
void CopyTextSensor::setup() {
source_->add_on_state_callback([this](const std::string &value) { this->publish_state(value); });
if (source_->has_state())
this->publish_state(source_->state);
}
void CopyTextSensor::dump_config() { LOG_TEXT_SENSOR("", "Copy Sensor", this); }
} // namespace esphome::copy
@@ -1,18 +0,0 @@
#pragma once
#include "esphome/core/component.h"
#include "esphome/components/text_sensor/text_sensor.h"
namespace esphome::copy {
class CopyTextSensor final : public text_sensor::TextSensor, public Component {
public:
void set_source(text_sensor::TextSensor *source) { source_ = source; }
void setup() override;
void dump_config() override;
protected:
text_sensor::TextSensor *source_;
};
} // namespace esphome::copy