mirror of
https://github.com/esphome/esphome.git
synced 2024-11-23 23:48:11 +01:00
cct
This commit is contained in:
parent
db1e641fcb
commit
e4e4a7aeef
3 changed files with 19 additions and 0 deletions
|
@ -269,6 +269,10 @@ void AS7343Component::calculate_and_publish() {
|
|||
ESP_LOGD(TAG, " ,Lux(XYZ) , %f, lx", lux2);
|
||||
ESP_LOGD(TAG, " ,Color temp(XYZ) , %f, K", cct);
|
||||
|
||||
if (this->ct_ != nullptr) {
|
||||
this->ct_->publish_state(cct);
|
||||
}
|
||||
|
||||
if (this->illuminance_ != nullptr) {
|
||||
this->illuminance_->publish_state(lux2);
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ class AS7343Component : public PollingComponent, public i2c::I2CDevice {
|
|||
void set_irradiance_photopic_sensor(sensor::Sensor *sensor) { irradiance_photopic_ = sensor; }
|
||||
void set_ppfd_sensor(sensor::Sensor *sensor) { ppfd_ = sensor; }
|
||||
void set_saturation_sensor(sensor::Sensor *sensor) { this->saturated_ = sensor; }
|
||||
void set_color_temperature_sensor(sensor::Sensor *sensor) { ct_ = sensor; }
|
||||
|
||||
void set_gain(AS7343Gain gain) { gain_ = gain; }
|
||||
void set_atime(uint8_t atime) { atime_ = atime; }
|
||||
|
@ -114,6 +115,7 @@ class AS7343Component : public PollingComponent, public i2c::I2CDevice {
|
|||
sensor::Sensor *irradiance_{nullptr};
|
||||
sensor::Sensor *irradiance_photopic_{nullptr};
|
||||
sensor::Sensor *ppfd_{nullptr};
|
||||
sensor::Sensor *ct_{nullptr};
|
||||
|
||||
sensor::Sensor *saturated_{nullptr};
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ import esphome.codegen as cg
|
|||
import esphome.config_validation as cv
|
||||
from esphome.components import i2c, sensor
|
||||
from esphome.const import (
|
||||
CONF_COLOR_TEMPERATURE,
|
||||
CONF_GAIN,
|
||||
CONF_ID,
|
||||
CONF_NAME,
|
||||
|
@ -10,8 +11,10 @@ from esphome.const import (
|
|||
CONF_GLASS_ATTENUATION_FACTOR,
|
||||
ICON_BRIGHTNESS_5,
|
||||
STATE_CLASS_MEASUREMENT,
|
||||
UNIT_KELVIN,
|
||||
UNIT_LUX,
|
||||
UNIT_PERCENT,
|
||||
ICON_THERMOMETER,
|
||||
)
|
||||
|
||||
|
||||
|
@ -163,6 +166,15 @@ CONFIG_SCHEMA = (
|
|||
),
|
||||
key=CONF_NAME,
|
||||
),
|
||||
cv.Optional(CONF_COLOR_TEMPERATURE): cv.maybe_simple_value(
|
||||
sensor.sensor_schema(
|
||||
unit_of_measurement=UNIT_KELVIN,
|
||||
icon=ICON_THERMOMETER,
|
||||
accuracy_decimals=0,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
),
|
||||
key=CONF_NAME,
|
||||
),
|
||||
}
|
||||
)
|
||||
.extend(cv.polling_component_schema("60s"))
|
||||
|
@ -188,6 +200,7 @@ SENSORS = {
|
|||
CONF_IRRADIANCE_PHOTOPIC: "set_irradiance_photopic_sensor",
|
||||
CONF_PPFD: "set_ppfd_sensor",
|
||||
CONF_SATURATION: "set_saturation_sensor",
|
||||
CONF_COLOR_TEMPERATURE: "set_color_temperature_sensor",
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue