[pcf85063] Use register_apply_action for pcf85063.write_time and pcf85063.read_time (#19659)

This commit is contained in:
J. Nick Koston
2026-09-25 18:51:41 +00:00
committed by GitHub
parent 432cae58ae
commit c16f75f0e2
2 changed files with 4 additions and 18 deletions
-9
View File
@@ -81,13 +81,4 @@ class PCF85063Component final : public time::RealTimeClock, public i2c::I2CDevic
} pcf85063_;
};
template<typename... Ts> class WriteAction final : public Action<Ts...>, public Parented<PCF85063Component> {
public:
void play(const Ts &...x) override { this->parent_->write_time(); }
};
template<typename... Ts> class ReadAction final : public Action<Ts...>, public Parented<PCF85063Component> {
public:
void play(const Ts &...x) override { this->parent_->read_time(); }
};
} // namespace esphome::pcf85063
+4 -9
View File
@@ -11,8 +11,6 @@ pcf85063_ns = cg.esphome_ns.namespace("pcf85063")
PCF85063Component = pcf85063_ns.class_(
"PCF85063Component", time.RealTimeClock, i2c.I2CDevice
)
WriteAction = pcf85063_ns.class_("WriteAction", automation.Action)
ReadAction = pcf85063_ns.class_("ReadAction", automation.Action)
CONFIG_SCHEMA = time.TIME_SCHEMA.extend(
@@ -22,27 +20,24 @@ CONFIG_SCHEMA = time.TIME_SCHEMA.extend(
).extend(i2c.i2c_device_schema(0x51))
automation.register_parented_action(
automation.register_apply_action(
"pcf85063.write_time",
WriteAction,
cv.Schema(
{
cv.GenerateID(): cv.use_id(PCF85063Component),
}
),
synchronous=True,
automation.ApplyCall("write_time()"),
)
automation.register_parented_action(
automation.register_apply_action(
"pcf85063.read_time",
ReadAction,
automation.maybe_simple_id(
{
cv.GenerateID(): cv.use_id(PCF85063Component),
}
),
synchronous=True,
automation.ApplyCall("read_time()"),
)