Lambda to reset an AM2302 power

I’ve installed 6 of the AM2302 temperature and humidity sensors around my house, but now discover they are unreliable and lockup every day or so on my ESP8266 units. Lots of info online in arduino discussions about various timing issues and stability problems etc. It occurred to me the most simple means to just reset them would be to use a spare GPIO to power the Sensor and then use a lambda to briefly pull that pin low for 1000ms.
Not been using ESPhome long, so can anyone advise me the YAML I’d need to use for lambdas and maybe the raw_state to detect the NaN and then toggle the GPIO? Thanks

That’s just a wired version of the DHT22 isn’t it?

I have nine DHT22s spread around the house and they don’t miss a beat.

What’s your config look like?

How long are the wires connecting to the sensor?

Do you have a 4K7 pullup resistor on the Data line (or is there one built in)?

Think the DHT22 is basic the same. Mine don’t have wires attached, I just quoted the number printed on the front of the device. Seems there are various suppliers of these devices, possibly with small timing variances and hence adaptions on the libraries others have developed for arduino.

I’m using the stock configuration basically from the ESPhome DHT page. While the sensors have a built in pull-up, I’ve also tried adding a 5k pull up to some of the installations too. A couple of them I’ve tried the filter options, but doesn’t have any affect on reliability. The cable lengths vary from 15cm to 1.5m the longest run the sensor has to be connected to 5v and through a levelshifter PCB. The worse issue of reliability seems to be after power on. Sometime I need to cycle the power a couple of times to get them to actually give readings the ESP can interpret. Hence the idea to automate the power cycling of these devices.

Yep. Short leads only. 10cm or so, or you will have issues.

Also try setting the model option in your sensor config, the default “AUTO_DETECT” isn’t great.

Yep, got model set. They work for 24-48hrs generally. I can’t reduce the cable length, so occasional automated reset would be a good solution in my situation, just never done a ESPhome lambda, hence request for help on that.