patrickcollins12 / esphome-fan-controller

ESPHome Fan Controller

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Request] Possible to use two temperature sensors?

martijn-brant opened this issue · comments

Thanks for this repo.. the code and schematics work great for me. My prototype is working great however I have a question.. is it possible to add another DHT temperature probe? My AV cabinets have two zones and I've added a fan in each. One is for the AV Receiver (always on when using TV) and the other is for gaming consoles (only on sometimes). I'd rather not build two separate fan controllers for two compartments. I don't mind both sides spinning faster when only one zone is needing more cooling (e.g. the gaming side being cooled even if there are no consoles active).

I had to reassign the DHT to GPIO23 on my nodemcu-32s board else it wouldn't work. PWM is on GPIO15. I've looking at the code as to what would be needed to support a 2nd DHT but the code is a bit too advanced for me. Ideally it would report two temperature values to Home Assistant as well and act on the worst one. But I would be more than pleased to get the worst value of the two as well. (one being 29c and the other 35c.. having it act like it's 35c and adjust fan accordingly).

Could you help with this? Many thanks.

glad it worked for you!

Well you could easily run two separate systems off the one esp32: two pids, two dht, two fans. You would just copy all of those sections in the yaml file and give each a different name.

However, to answer your question directly. Yes you can take the max of two sensors to create a 3rd ”template” sensor. All three sensors will be visible to home assistant.

I’m not at my computer at the moment, so I can’t provide direct code.

This example creates a 3rd template sensor which is an average.

https://community.home-assistant.io/t/average-temperature-based-on-multiple-sensors/220781/3

to create a max instead the lambda is something like:

lambda: |-
      return max(id(dht_temp_1).state, id(dht_temp_2).state);

let me know how you go.

Ah yes, great idea just to duplicate the YAML values for the sensors/outputs. I added an additional GPIO for extra PWM (Fan 2) and extra DHT11. Works like a charm. This gives me dual-zone option on a single Nodemcu. Thanks for your code and your reply.