mirror of
https://github.com/esphome/esphome.git
synced 2026-09-29 16:00:23 +00:00
[pcf85063] Use register_apply_action for pcf85063.write_time and pcf85063.read_time (#19659)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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()"),
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user