From e2ad6fe3d8d99859c2b0f99ffd5ed8ca3067a142 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=B6sch?= Date: Mon, 18 Jan 2021 13:35:35 +0100 Subject: [PATCH] rename read/write to read/time/write_time (#1468) --- esphome/components/ds1307/ds1307.cpp | 6 +++--- esphome/components/ds1307/ds1307.h | 8 ++++---- esphome/components/ds1307/time.py | 8 ++++---- tests/test1.yaml | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/esphome/components/ds1307/ds1307.cpp b/esphome/components/ds1307/ds1307.cpp index 599ec16e4f..2f33768132 100644 --- a/esphome/components/ds1307/ds1307.cpp +++ b/esphome/components/ds1307/ds1307.cpp @@ -16,7 +16,7 @@ void DS1307Component::setup() { } } -void DS1307Component::update() { this->read(); } +void DS1307Component::update() { this->read_time(); } void DS1307Component::dump_config() { ESP_LOGCONFIG(TAG, "DS1307:"); @@ -29,7 +29,7 @@ void DS1307Component::dump_config() { float DS1307Component::get_setup_priority() const { return setup_priority::DATA; } -void DS1307Component::read() { +void DS1307Component::read_time() { if (!this->read_rtc_()) { return; } @@ -53,7 +53,7 @@ void DS1307Component::read() { time::RealTimeClock::synchronize_epoch_(rtc_time.timestamp); } -void DS1307Component::write() { +void DS1307Component::write_time() { auto now = time::RealTimeClock::utcnow(); if (!now.is_valid()) { ESP_LOGE(TAG, "Invalid system time, not syncing to RTC."); diff --git a/esphome/components/ds1307/ds1307.h b/esphome/components/ds1307/ds1307.h index 8e318bf395..2e9ac2275c 100644 --- a/esphome/components/ds1307/ds1307.h +++ b/esphome/components/ds1307/ds1307.h @@ -13,8 +13,8 @@ class DS1307Component : public time::RealTimeClock, public i2c::I2CDevice { void update() override; void dump_config() override; float get_setup_priority() const override; - void read(); - void write(); + void read_time(); + void write_time(); protected: bool read_rtc_(); @@ -59,12 +59,12 @@ class DS1307Component : public time::RealTimeClock, public i2c::I2CDevice { template class WriteAction : public Action, public Parented { public: - void play(Ts... x) override { this->parent_->write(); } + void play(Ts... x) override { this->parent_->write_time(); } }; template class ReadAction : public Action, public Parented { public: - void play(Ts... x) override { this->parent_->read(); } + void play(Ts... x) override { this->parent_->read_time(); } }; } // namespace ds1307 } // namespace esphome diff --git a/esphome/components/ds1307/time.py b/esphome/components/ds1307/time.py index c381fb7b2a..371dc85be8 100644 --- a/esphome/components/ds1307/time.py +++ b/esphome/components/ds1307/time.py @@ -18,19 +18,19 @@ CONFIG_SCHEMA = time.TIME_SCHEMA.extend({ }).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), })) -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) yield cg.register_parented(var, config[CONF_ID]) 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), })) -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) yield cg.register_parented(var, config[CONF_ID]) yield var diff --git a/tests/test1.yaml b/tests/test1.yaml index ae10e0e0c7..5aed1dac44 100644 --- a/tests/test1.yaml +++ b/tests/test1.yaml @@ -1856,7 +1856,7 @@ time: - platform: gps on_time_sync: then: - ds1307.write: + ds1307.write_time: id: ds1307_time - platform: ds1307 id: ds1307_time @@ -1864,7 +1864,7 @@ time: on_time: seconds: 0 then: - ds1307.read + ds1307.read_time cover: - platform: template