Closed RubenKelevra closed 1 month ago
Example from today:
that's not good. could you provide more information? the raw values of all
red_channel:
name: "TCS34725 Red Channel"
green_channel:
name: "TCS34725 Green Channel"
blue_channel:
name: "TCS34725 Blue Channel"
clear_channel:
name: "TCS34725 Clear Channel"
illuminance:
name: "TCS34725 Illuminance"
would be helpful.
@swifty99 yeah sure - sorry for the delay:
@swifty99 It looks like the negative values in illuminance trigger the negative values in color temperature.
no worries,
do you have a chance to log the Esphome logs while this happens? It will look something like this:
[21:13:10][D][tcs34725:251]: Got Red=62.5%,Green=25.0%,Blue=17.5%,Clear=0.0% Illuminance=0.1lx Color Temperature=2343.5K
[21:13:10][D][tcs34725:292]: Integration time: 614.4ms, ideal: 614.4ms regval_new 0 Gain: 60 Clear channel raw: 40 gain reg: 3
Probably the sensor ist oversaturated. The only thing that really helps would be a grey filter. I use the light from a reflected surface. Not linear perfectly but good enough.
cheers Jan
Maybe we can close this issue.
Probable take away: have a look in the logs for the overasaturation message.
Hey @swifty99,
so I can confirm issues with the latest ESPHome version as well: While there's an output of the chip reported which includes the Color temperature, HA will receive an "inf K" reporting:
The internal calculation is OK as:
[17:25:13][D][tcs34725:248]: Got Red=58.3%,Green=49.9%,Blue=48.3%,Clear=65.9% Illuminance=14722.4lx Color Temperature=3933.1K
with this code:
ESP_LOGD(TAG,
"Got Red=%.1f%%,Green=%.1f%%,Blue=%.1f%%,Clear=%.1f%% Illuminance=%.1flx Color "
"Temperature=%.1fK",
channel_r, channel_g, channel_b, channel_c, this->illuminance_, this->color_temperature_);
this value will be given to sensor properties:
if (this->color_temperature_sensor_ != nullptr)
this->color_temperature_sensor_->publish_state(this->color_temperature_);
At the moment I think I cannot do anything, as the value was calcualted correctly (3933.1K ). And it is not overexposed, none of the raw values reaches 100%. What you could try is take a different Node and give it different name and try once more. Another try would be to remove the filters temporary.
Alright, will do that.
So I think what happens is, that some calculations runs towards infinity and then the value gets stuck there...
That's what it looks like here in this HA-graph:
@swifty99 wrote:
The internal calculation is OK as:
[17:25:13][D][tcs34725:248]: Got Red=58.3%,Green=49.9%,Blue=48.3%,Clear=65.9% Illuminance=14722.4lx Color Temperature=3933.1K
At the moment I think I cannot do anything, as the value was calcualted correctly (3933.1K ). And it is not overexposed, none of the raw values reaches 100%. What you could try is take a different Node and give it different name and try once more. Another try would be to remove the filters temporary.
Well, actually the sensor does get overexposed: clear channel hits (nearly 100%). Guess the "nearly" 100% is not detected and thus the calculations runs off the rails.
This is then leading to those absurd numbers I guess:
And since the averaging filter is getting extremely large numbers, maybe even infinity, as input, the output gets stuck for longer at 'inf' even if the sensor gives new and correct values - like in the log above.
ok. the logging did not indicate that.
Overexposure shall be avoided. Use a filter or a different location. There is nothing the hard or software could fix.
@swifty99 so I dug in the code today, and I think I found the issue – and at least one other.
I'll tackle them and send PRs :)
The problem
I'm using a TCS34725 with
integration_time: auto
on a D1 mini.Around noon the color temperature is either NaN or is reported negative:
After 14:30 for the rest of the day (with obviously less intense sun hitting the sensor) the values are reported correctly:
Which version of ESPHome has the issue?
2022.8.3
What type of installation are you using?
Home Assistant Add-on
Which version of Home Assistant has the issue?
2022.9.2
What platform are you using?
ESP8266
Board
D1_mini
Component causing the issue
TCS34725
Example YAML snippet
Anything in the logs that might be useful for us?
No response
Additional information
No response