#include "esphome.h"
#include <SparkFun_VEML6075_Arduino_Library.h>

class VEML6075Sensor : public PollingComponent, public sensor::Sensor {
 private:
  VEML6075 _uv;

 public:
  sensor::Sensor *uva_sensor = new sensor::Sensor();
  sensor::Sensor *uvb_sensor = new sensor::Sensor();
  sensor::Sensor *uv_index_sensor = new sensor::Sensor();

  // 4294967295UL == never per sources
  VEML6075Sensor() : PollingComponent(60*60*1000) { }

  void setup() override {
       _uv.begin();
  }

  void update() override {
    double uva_value = _uv.uva();
    double uvb_value = _uv.uvb();
    double uv_index_value = _uv.index();

    uva_sensor->publish_state(uva_value);
    uvb_sensor->publish_state(uvb_value);
    uv_index_sensor->publish_state(uv_index_value);
  }
};
