#pragma once

#include "esphome/core/component.h"
#include "esphome/components/i2c/i2c.h"
#include "esphome/components/time/real_time_clock.h"

namespace esphome::rx8130 {

class RX8130Component final : public time::RealTimeClock, public i2c::I2CDevice {
 public:
  void setup() override;
  void update() override;
  void dump_config() override;
  void read_time();
  void write_time();

 protected:
  void stop_(bool stop);
};

template<typename... Ts> class WriteAction final : public Action<Ts...>, public Parented<RX8130Component> {
 public:
  void play(const Ts... x) override { this->parent_->write_time(); }
};

template<typename... Ts> class ReadAction final : public Action<Ts...>, public Parented<RX8130Component> {
 public:
  void play(const Ts... x) override { this->parent_->read_time(); }
};

}  // namespace esphome::rx8130
