I’m playing with SHT31 sensor, and since it has heater i’m looking the way to temporarily enable it.
So, i wonder… is it possible to use lambda or variable (or anything except true or false) in sensor configuration variables? I mean - for my case i’d like to enable heater for, say, 5 or 10 minutes when i power-up esp module, then heater would be disabled the whole time until next power cycle. Is it possible to define something like:
heater_enabled: id(heater)
then define “heater” variable to “true” at start and change it to “false” after set time;
or something with lambda ?
heater_enabled: lambda.....
Note that it would also be a good idea to disable temperature and humidity readings during heating, so a second question would be: can i temporarily disable sensor in esphome?
You can do an automation at boot.
But what other parameter are you going to check?
What if something happens and the device restarts?
Your heater may stay on for longer than you think
Why? I would like to dry the sensor every now and then to ensure correct readings. In high humidity environments sensor can become moist, so humidity results will be wrong.
Ok, agreed, it can happen that device restarts suddenly, but i don’t think that heating for a bit longer would hurt. But, then again, i guess i could make things based on time (say, at midnight) , or manually, so that i’d create a binary sensor and i would enable it from HA, i guess. But, sadly i don’t know how to do any of these things…
Disabling measuring during heating is a good idea because while heating temperature measurements will be wrong (higher). There is also a warnign in datasheet about this.
What i don’t know how to do is enable that variable inside esphome yaml - or write anything there without error… I tried some things with “heater_enabled:”, but i always get an error that boolean is expected (true or false). I’m not that experienced in yaml (or lambda’s), so an example would be very welcome.
Thanks for explantion. In this case perhaps it’s better to replace sht31 with sht4x series, where heater can be enabled and then it’s turned on at regular intervals. I just have a couple of these sensors lying around. But, i guess i’ll just use them “as is”.
Sht4x was designed for that, by Sensirion the heater in SHT3x is “for plausibility checks only”. There is no documentation, that it could be used to remove condensation.