rename read/write to read/time/write_time (#1468)

This commit is contained in:
Florian Mösch 2021-01-18 13:35:35 +01:00 committed by GitHub
parent 4c105398f7
commit b28735d63b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 13 deletions

View File

@ -16,7 +16,7 @@ void DS1307Component::setup() {
} }
} }
void DS1307Component::update() { this->read(); } void DS1307Component::update() { this->read_time(); }
void DS1307Component::dump_config() { void DS1307Component::dump_config() {
ESP_LOGCONFIG(TAG, "DS1307:"); ESP_LOGCONFIG(TAG, "DS1307:");
@ -29,7 +29,7 @@ void DS1307Component::dump_config() {
float DS1307Component::get_setup_priority() const { return setup_priority::DATA; } float DS1307Component::get_setup_priority() const { return setup_priority::DATA; }
void DS1307Component::read() { void DS1307Component::read_time() {
if (!this->read_rtc_()) { if (!this->read_rtc_()) {
return; return;
} }
@ -53,7 +53,7 @@ void DS1307Component::read() {
time::RealTimeClock::synchronize_epoch_(rtc_time.timestamp); time::RealTimeClock::synchronize_epoch_(rtc_time.timestamp);
} }
void DS1307Component::write() { void DS1307Component::write_time() {
auto now = time::RealTimeClock::utcnow(); auto now = time::RealTimeClock::utcnow();
if (!now.is_valid()) { if (!now.is_valid()) {
ESP_LOGE(TAG, "Invalid system time, not syncing to RTC."); ESP_LOGE(TAG, "Invalid system time, not syncing to RTC.");

View File

@ -13,8 +13,8 @@ class DS1307Component : public time::RealTimeClock, public i2c::I2CDevice {
void update() override; void update() override;
void dump_config() override; void dump_config() override;
float get_setup_priority() const override; float get_setup_priority() const override;
void read(); void read_time();
void write(); void write_time();
protected: protected:
bool read_rtc_(); bool read_rtc_();
@ -59,12 +59,12 @@ class DS1307Component : public time::RealTimeClock, public i2c::I2CDevice {
template<typename... Ts> class WriteAction : public Action<Ts...>, public Parented<DS1307Component> { template<typename... Ts> class WriteAction : public Action<Ts...>, public Parented<DS1307Component> {
public: public:
void play(Ts... x) override { this->parent_->write(); } void play(Ts... x) override { this->parent_->write_time(); }
}; };
template<typename... Ts> class ReadAction : public Action<Ts...>, public Parented<DS1307Component> { template<typename... Ts> class ReadAction : public Action<Ts...>, public Parented<DS1307Component> {
public: public:
void play(Ts... x) override { this->parent_->read(); } void play(Ts... x) override { this->parent_->read_time(); }
}; };
} // namespace ds1307 } // namespace ds1307
} // namespace esphome } // namespace esphome

View File

@ -18,19 +18,19 @@ CONFIG_SCHEMA = time.TIME_SCHEMA.extend({
}).extend(i2c.i2c_device_schema(0x68)) }).extend(i2c.i2c_device_schema(0x68))
@automation.register_action('ds1307.write', WriteAction, cv.Schema({ @automation.register_action('ds1307.write_time', WriteAction, cv.Schema({
cv.GenerateID(): cv.use_id(DS1307Component), cv.GenerateID(): cv.use_id(DS1307Component),
})) }))
def ds1307_write_to_code(config, action_id, template_arg, args): def ds1307_write_time_to_code(config, action_id, template_arg, args):
var = cg.new_Pvariable(action_id, template_arg) var = cg.new_Pvariable(action_id, template_arg)
yield cg.register_parented(var, config[CONF_ID]) yield cg.register_parented(var, config[CONF_ID])
yield var yield var
@automation.register_action('ds1307.read', ReadAction, automation.maybe_simple_id({ @automation.register_action('ds1307.read_time', ReadAction, automation.maybe_simple_id({
cv.GenerateID(): cv.use_id(DS1307Component), cv.GenerateID(): cv.use_id(DS1307Component),
})) }))
def ds1307_read_to_code(config, action_id, template_arg, args): def ds1307_read_time_to_code(config, action_id, template_arg, args):
var = cg.new_Pvariable(action_id, template_arg) var = cg.new_Pvariable(action_id, template_arg)
yield cg.register_parented(var, config[CONF_ID]) yield cg.register_parented(var, config[CONF_ID])
yield var yield var

View File

@ -1856,7 +1856,7 @@ time:
- platform: gps - platform: gps
on_time_sync: on_time_sync:
then: then:
ds1307.write: ds1307.write_time:
id: ds1307_time id: ds1307_time
- platform: ds1307 - platform: ds1307
id: ds1307_time id: ds1307_time
@ -1864,7 +1864,7 @@ time:
on_time: on_time:
seconds: 0 seconds: 0
then: then:
ds1307.read ds1307.read_time
cover: cover:
- platform: template - platform: template