[pcf8563] Use register_apply_action for pcf8563.write_time and pcf8563.read_time (#19639)

This commit is contained in:
J. Nick Koston
2026-09-25 18:43:10 +01:00
committed by GitHub
parent 11e016be59
commit 23c317f163
2 changed files with 9 additions and 30 deletions
-9
View File
@@ -109,13 +109,4 @@ class PCF8563Component final : public time::RealTimeClock, public i2c::I2CDevice
} pcf8563_;
};
template<typename... Ts> class WriteAction final : public Action<Ts...>, public Parented<PCF8563Component> {
public:
void play(const Ts &...x) override { this->parent_->write_time(); }
};
template<typename... Ts> class ReadAction final : public Action<Ts...>, public Parented<PCF8563Component> {
public:
void play(const Ts &...x) override { this->parent_->read_time(); }
};
} // namespace esphome::pcf8563
+9 -21
View File
@@ -14,8 +14,6 @@ pcf8563_ns = cg.esphome_ns.namespace("pcf8563")
pcf8563Component = pcf8563_ns.class_(
"PCF8563Component", time.RealTimeClock, i2c.I2CDevice
)
WriteAction = pcf8563_ns.class_("WriteAction", automation.Action)
ReadAction = pcf8563_ns.class_("ReadAction", automation.Action)
CONFIG_SCHEMA = time.TIME_SCHEMA.extend(
@@ -25,27 +23,17 @@ CONFIG_SCHEMA = time.TIME_SCHEMA.extend(
).extend(i2c.i2c_device_schema(0x51))
automation.register_parented_action(
"pcf8563.write_time",
WriteAction,
automation.maybe_simple_id(
{
cv.GenerateID(): cv.use_id(pcf8563Component),
}
),
synchronous=True,
PCF8563_ACTION_SCHEMA = automation.maybe_simple_id(
{
cv.GenerateID(): cv.use_id(pcf8563Component),
}
)
automation.register_parented_action(
"pcf8563.read_time",
ReadAction,
automation.maybe_simple_id(
{
cv.GenerateID(): cv.use_id(pcf8563Component),
}
),
synchronous=True,
automation.register_apply_action(
"pcf8563.write_time", PCF8563_ACTION_SCHEMA, automation.ApplyCall("write_time()")
)
automation.register_apply_action(
"pcf8563.read_time", PCF8563_ACTION_SCHEMA, automation.ApplyCall("read_time()")
)