Nest Automatic Humidity Control

I just spoke with a Google representative and apparently newer Nest thermostats do support the ability to automatically adjust the humidity based on the outside temperature. He would not directly say which models support it or not, but mine is a 3rd Generation purchased in 2018.

Now, there’s no way to know what percent humidity the Nest is set to (and the app only shows you drops of water and a slider), but at least it is something. In fact, the support rep literally said that the only thing the drops indicate is that more drops means more humidity, but there is no way to know what percentage humidity any of it actually means.

Google lies constantly and cripples the nest at every corner. Run.

I was having issues with this… so I just set up an automation in HA to contorl my humidity. It worked great this winter!

I had to use the badnest HACS integration since the official google API does not allow writes to humidity values.

I hope this helps someone :slight_smile:

- alias: Set Humidity
  description: if temp @ value , humidity target = value
  trigger:
  - platform: time_pattern
    minutes: /15
  action:
  - choose:
    - conditions:
      - condition: numeric_state
        entity_id: weather.dark_sky
        attribute: temperature
        above: '40'
      sequence:
      - service: climate.set_humidity
        data:
          entity_id: climate.dining_room_thermostat
          humidity: 45
    - conditions:
      - condition: numeric_state
        entity_id: weather.dark_sky
        attribute: temperature
        above: '30'
        below: '40'
      sequence:
      - service: climate.set_humidity
        data:
          entity_id: climate.dining_room_thermostat
          humidity: 40
    - conditions:
      - condition: numeric_state
        entity_id: weather.dark_sky
        attribute: temperature
        above: '20'
        below: '30'
      sequence:
      - service: climate.set_humidity
        data:
          entity_id: climate.dining_room_thermostat
          humidity: 30
    - conditions:
      - condition: numeric_state
        entity_id: weather.dark_sky
        attribute: temperature
        above: '10'
        below: '20'
      sequence:
      - service: climate.set_humidity
        data:
          entity_id: climate.dining_room_thermostat
          humidity: 17.5
    - conditions:
      - condition: numeric_state
        entity_id: weather.dark_sky
        attribute: temperature
        above: '0'
        below: '10'
      sequence:
      - service: climate.set_humidity
        data:
          entity_id: climate.dining_room_thermostat
          humidity: 15
    - conditions:
      - condition: numeric_state
        entity_id: weather.dark_sky
        attribute: temperature
        above: '-10'
        below: '0'
      sequence:
      - service: climate.set_humidity
        data:
          entity_id: climate.dining_room_thermostat
          humidity: 15
    - conditions:
      - condition: numeric_state
        entity_id: weather.dark_sky
        attribute: temperature
        below: '-10'
      sequence:
      - service: climate.set_humidity
        data:
          entity_id: climate.dining_room_thermostat
          humidity: 15

Glad you got it figured out. I don’t think the choose action was available when I started this, but keeping everything in an automation is the way to go. Much cleaner and easier.

Hmmm … badness is not working well for me and the official API doesn’t allow write access to the humidity…

Any other suggestions for how I might automate this?
Winter is coming! :slight_smile:

I was able to get this working on hassio with extra steps:

  • First, you need to access the bash shell of the homeassistant container. Protip: How to get shell in actual homeassistant (or addon) container when using Hassio
  • Then run apk add php8 and apk add php8-curl to install php8 (with curl extension) into the homeassistant container. php8 comes with the json extension by default.
  • Download “nest.class.php”, “update_nest_target_humidity.php”, and “nest-api-php-workaround-login.php” (Manually create cache file required for nest-api to work with Nest accounts (not Google accounts). Ref: https://github.com/gboudreau/nest-api/issues/110 · GitHub) to your local machine.
  • Create “/config/custom_scripts” folder on your hassio instance
  • Edit “nest.class.php”. This fools nest to see your automation as a web browser client instead of a curl client. This also moves the temp cookie files to a persistent location “/config/custom_scripts”
    • line 1474: curl_setopt($ch, CURLOPT_USERAGENT, 'YOUR_USERAGENT_STRING');
    • line 128: $file = "/config/custom_scripts/nest_php_{$type}_{$suffix}";
    • line 137: $file = "/config/custom_scripts/nest_php_{$type}_{$unix_user}_{$suffix}";
  • Edit “update_nest_target_humidity.php”. Specifies your credentials and changes the library path to the same location as this file
    • line 6: fill in your username
    • line 7: fill in your password
    • line 3: require_once dirname(__FILE__) . '/nest.class.php';
  • Edit “nest-api-php-workaround-login.php”. This puts in your credentials so that you don’t need to enter them everytime this script is executed. This updates the cache file location to /config/custom_scripts/ instead so that it’s persistent across home assistant reboots.
    • line 11: $username = 'YOUR_USERNAME_HERE';
    • line 12: $password = 'YOUR_PASSWORD_HERE';
    • line 14: $cache_file = '/config/custom_scripts/nest_php_cache_' . md5($username . $password);
  • Upload the files to /config/custom_scripts
  • Run /usr/bin/php8 /config/custom_scripts/nest-api-php-workaround-login.php from the bash shell prompt in the homeassistant container to generate the session cookie (will need to repeat this on a monthly cadence). Follow the steps from the script prompt
  • Run /usr/bin/php8 /config/custom_scripts/update_nest_target_humidity.php -10 35 to verify that it runs without an error
  • Update the shell command to use php8 and run from /config/custom_scripts/
    • update_nest_target_humidity: '/usr/bin/php8 /config/custom_scripts/update_nest_target_humidity.php {{states.sensor.dark_sky_temperature.state}} {{states.sensor.dark_sky_humidity.state}}'

wgjhstt247 - Did you get this working using the official Nest API? Are you also using badnest in some way?

No. This uses the unofficial nest api, not bad nest nor the official nest api. The unofficial nest api does work for this purpose.

Hi @wgjhstt247, thanks for your work.

I adoped it, but I found:

  1. my php8 wont stick through a reboot of the VM
  2. my php script exits with error 127, I made it as user root, then I changed to 777 but that did not change anything.

when I rund from bash the command you refer here to:

I just get the php file as an output, no further information.

Any idea what I do wrong?

I used `/usr/bin/php8 /config/custom_scripts/update_brother_time.php’ for my purposes of course.

Were you ever able to figure this out?