mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 07:03:55 +00:00 
			
		
		
		
	rename read/write to read/time/write_time (#1468)
This commit is contained in:
		
				
					committed by
					
						 Jesse Hills
						Jesse Hills
					
				
			
			
				
	
			
			
			
						parent
						
							6781d08c9b
						
					
				
				
					commit
					e2ad6fe3d8
				
			| @@ -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."); | ||||
|   | ||||
| @@ -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<typename... Ts> class WriteAction : public Action<Ts...>, public Parented<DS1307Component> { | ||||
|  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> { | ||||
|  public: | ||||
|   void play(Ts... x) override { this->parent_->read(); } | ||||
|   void play(Ts... x) override { this->parent_->read_time(); } | ||||
| }; | ||||
| }  // namespace ds1307 | ||||
| }  // namespace esphome | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user