QuietCool Whole House Fan

EDIT: There is a custom_component linked toward the end of this thread that works better than the original solution I posted below.

I installed one of these in my house and integrated it into HASS. I’ll tell you about the HASS integration part. The installation part is a handyman thing so I’ll skip that.

The first issue was to determine how the electronics in the fan worked so I could determine how I’d control it. The fan has 4 wires. Hot/Neutral and two more hots (one for high and one for low). In order for the fan to turn on 3 (and only 3) of the 4 wires have to be energized, power and a high/low.

Figuring the wiring out now created a problem because most home-automated switches aren’t SPDT. They are SPST and in order to control the high/low, a SPDT switch would be the simplest solution. (Note: Standard house 3 way switches are SPDT). I considered using two SPST switches and an SPDT relay but decided against it. Researching my options and costs and how much time… Sonoff + relays would be the cheapest but if someone wanted to change the fan if I moved out, they probably wouldn’t understand. I looked at the manufacture’s Wifi controller which was the most expensive but the easiest to wire and seemed to be more future-proof for other people. So, I ordered the QuietCool Wifi controller because I found someone figured out the CoAP protocol it uses and had some code published. (There isn’t a supported API which sucks).

I took the code here: https://github.com/stabbylambda/quietcool

I couldn’t figure out what to do with the node/javascript stuff so I contacted David. He was a major help and put some code snips together that I turned into a usable script. The script has the UID if the fan and the controller IP. I’m not sure how I figured out the UID. I just added some log statements to his quietcool-cli and stumbled on it.

I then added some configs to HASS and a quick appdaemon script and I had a fan I could control from HASS!

The last step is to automate it based on temperature and what doors and windows are open but that’s the easy part. :slight_smile:

node script (quietcool.js):

// Call this like: node /opt/scripts/quietcool.js off

const fan = require('/usr/lib/node_modules/quietcool');
//const fan = require('quietcool');
const util = require('util')

const fanId = { uid: '<fan UID here>', ip: 'x.x.x.x' }

var myparam = process.argv[2].toUpperCase()

console.log(myparam);

if (myparam == "HIGH" ) {
  fan.setCurrentSpeed(fanId, "3")
    .flatMap(x => fan.turnFanOn(fanId))
    .subscribe(x => console.log(x));
}
if (myparam == "LOW" ) {
  fan.setCurrentSpeed(fanId, "1")
    .flatMap(x => fan.turnFanOn(fanId))
    .subscribe(x => console.log(x));
}
if (myparam == "OFF" ) {
  fan.turnFanOff(fanId).subscribe(x => console.log(x));
}

HASS Config:

input_select:
  house_fan:
    options:
      - "OFF"
      - "HIGH"
      - "LOW"
    icon: mdi:fan

AppDaemon script:

import appdaemon.plugins.hass.hassapi as hass
import subprocess

class QuietCool(hass.Hass):

    def initialize(self):
        self.log("QuietCool")
        self.listen_state(self.select_change, "input_select.house_fan")

    def select_change(self, entity, attribute, old, new, kwargs):
        self.log("select_change")

        self.log(new.upper())
        cmd = ['node','/opt/scripts/quietcool.js',new.upper()]
        returncode = subprocess.call(cmd)

First of all thank you for putting this project up here - I tried to get this going but i’ve hit a wall. I run HA on docker and just got AppDaemon also working on docker. I was able to run the stabbylambda/quietcool-server in a docker image to find my fan UID. Hoping for some guidance on the scripts you’ve created:

  1. In your first block of code (quietcool.js) - i see reference to /usr/lib/node_modules/quietcool . Is this where the quietcool.js script resides, are any of the stabbylambda/quietcool files also required in this directory? Just curious why this is not stored in the HA config directory, or if it can be.

  2. The app daemon script - do i just create another script here called quietcool.js? Was not sure what /opt/scripts/quietcool.js refers to in this block of code (if it’s a remote directory on HASS or within AppDaemon - since i’m running both on separate dockers).

Thanks in advance - very cool that you were able to get this working, I mainly bought my wifi controller, because I saw your project up here awhile back.

sdc, Thanks for reaching out. I hope I can help!

It’s funny you mention that you bought the controller because of this posting. I’m pretty sure I bought the controller because I saw the node libraries posted. I haven’t touched node now in a long time so I’m a bit rusty but let’s try and figure this out :slight_smile:

  1. The path /usr/lib/node_modules/quietcool I’m pretty sure is where node installed the quietcool module. I think that is done with the npm install quietcool command. The quietcool.js above can be in any directory; it imports the quietcool module and sets the fan to high/low/off.

  2. The appdaemon script just serves as an alternative to the built in HASS automatons. You can just as easily run (eg) node /opt/scripts/quietcool.js low using the shell component and skip appdaemon if you want.

As a side note - I don’t use docker. Docker might be a bit tricky because it’s going to be easiest to have node installed in your hass docker image. I suppose you could have node running outside of docker and use an ssh shell command that calls scripts outside of the hass docker. All of this complicates things and will make the initial setup more challenging.

One other possibly import tidbit. I’m running node v7.10.1. I’m not sure what versions will work but that’s what I’m using.

I hope that helps.

Thank you for the guidance, it works! Exactly what I needed to get this going (have no experience with node) - will to need to figure out how to build NPM into docker into the future, but for now I was able to test this in my existing image and it works flawlessly. Here’s what I did:

1.) npm install -g quietcool

2.) modify the script at the top of your post with my fan id and ip address (saved this to /opt/scripts) - also was able to retrieve my fan id by installing the quietcool server in docker and viewing the log output

3.) Added the input_select sensor

4.) I opted to use the shell script vs AppDaemon

input_select:
    house_fan:
       options:
           - "OFF"
           - "HIGH"
           - "LOW"
       icon: mdi:fan    

automation:
 - alias: 'QuietCool'
   initial_state: 'on' 
   trigger:
      platform: state
      entity_id: input_select.house_fan
   action:
        service: shell_command.set_qcfan

shell_command:
  set_qcfan: '/usr/bin/node /opt/scripts/quietcool.js {{ states.input_select.house_fan.state }}

Have you been able to get the timer to work? Looks like you can pass time to the quietcool module. I’m going to take a look at time, and also looks like I can easily add the 3rd speed, my fan has a medium setting also.

1 Like

Awesome. Glad you got it going. I never tried the timer in the Quietcool controller. I have all of my controls for it in HASS. Post back if you get it working… I’m sure someone would find it useful.

Do you guys have any issues with wifi connectivity with it? Mine constantly decides to not work anymore. It is connected to the network, but I can’t ping it and the regular app can’t even find it anymore. Seriously considering to roll my own SPDT module, because I love the fan!

No issues here with WiFi connectivity. I recall reading about people having wifi issues when I checked the reviews on the module but I haven’t had a problem. My WAP is a Unifi. The WiFi module and the WAP are in the attic and both clear line of sight of each-other so that might be why.

I had network issues, until i went to a static IP. Connection has been rock solid now. Have also moved to the native HA component - works great with the fan speeds.

Native HA component? Where?

Here’s the repository - https://github.com/stabbylambda/homeassistant-quietcool huge thanks to StabbyLambda.

I’m using the fan control entity row with this, and it’s working great (Lovelace Fan Control Entity Row).

1 Like

I have a stupid question, how did you import this into Home Assistant? I’m a very new user, obviously lol.

Thanks for your help!

I was going to switch to the custom_component today but I found a bug. Hopefully it gets resolved and I can update my original post. My Node method is a bit convoluted.

https://github.com/stabbylambda/homeassistant-quietcool/issues/1

I know this was posted awhile back but I’m trying to include my quietcool fan into my Home Assistant setup but do not know how and where to run the “npm install -g quietcool” command from Home Assistant. I do not run HA on docker, just a regular old RPi3b+. Any help would be much appreciated!

thanks in advance!

The dev has simplified this a bit with the new custom component - no custom node/appdaemon needed everything works natively :

Let me know if you have any issues can post my config if you run into any issues.

If you’re starting fresh I would probably just use the custom_component. It has some obvious issues but once you recognize them you can work around them.

You can also probably create a template to make the interface work properly and hide the issues.

I realize this is a really late reply, but I also had really bad wifi connectivity issues. Nowhere in the documentation did I find requirements, however, I learned that the controller I have only talks 2.4GHz and my wifi was an Eero Mesh Wifi system that ran 2.4 and 5 on the same SSIDs. I specifically switched away from Eero because of this issue so that I could broadcast a 2.4GHz SSID dedicated to IoT and my problems went away. I later found that the wifi controller specifically has issues with dual band SSIDs, so this might be something to consider if you’re still having issues.

Looks like the latest Home Assistant upgrade broke this component, i’m now seeing this in the logs:

2022-04-10 17:42:58 ERROR (MainThread) [homeassistant.config] Platform error: fan
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config.py", line 877, in async_process_component_config
    platform = p_integration.get_platform(domain)
  File "/usr/src/homeassistant/homeassistant/loader.py", line 603, in get_platform
    cache[full_name] = self._import_platform(platform_name)
  File "/usr/src/homeassistant/homeassistant/loader.py", line 620, in _import_platform
    return importlib.import_module(f"{self.pkg_path}.{platform_name}")
  File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/config/custom_components/quietcool/fan.py", line 3, in <module>
    from homeassistant.components.fan import (FanEntity,
ImportError: cannot import name 'SPEED_OFF' from 'homeassistant.components.fan' (/usr/src/homeassistant/homeassistant/components/fan/__init__.py)

You’re talking about the WiFi controller correct? I fixed some of the issues with it here but it doesn’t work yet.

Yep - WiFi controller. Looks like HA just deprecated fan.set_speed for fan.set_percentage. Let me know if you have any luck was going to try to dig into it this week.

@sdc I think I fixed it. Well, at least it seems to be working for me.