Nest Automatic Humidity Control

Super - thanks Joe. I imagine the kitchen hvac sensor you reference is your nest?

That’s correct

Hi everyone,

Sorry… newbie questions…

So far, I have done the following:

  1. setup darksky API & added to configuration.yaml -> working!

  2. downloaded the ’ nest.class.php nest API into director -> done

  3. created a ’ update_nest_target_humidity.php’ file
    a) updated the nest.class.php file location
    b) updated my login information

  4. added configuration.yaml changes -> not sure if I did this correctly…

some questions:

  1. does the name of darksky need to match b/t what is called in the config & your trigger?
    i.e. my configuration file states:
sensor:
  - platform: darksky

…whereas your configuration.yaml calls out

entity_id: sensor.dark_sky_temperature
  1. Where do I add the start of your configuration update…? …the ‘configurator’ is flagging this
- alias: "Nest auto target humidity control"
end of the stream or a document separator is expected at line 69, column 1:
    - alias: "Nest auto target humid ... 
    ^
  1. how do I tell HA that my nest is a sensor… do I need to add ad section in configuration.yaml for my nest?

THANKS!

  1. Dark Sky will add sensors with names like sensor.dark_sky_xxx for all monitored_conditions you have in your config. You’ll need to add at least ‘temperature’ and ‘humidity’ to your monitored_conditions list in your config.
  2. Sorry this wasn’t more clear. This goes under your automations, so it should look like:
automation:
- alias: "Nest auto target humidity control"
...
  1. Yes, you need to add the Nest integration to your configuration by following the instructions here

I think I have everything setup… but getting an error. My guess is that my Nest is not setup correctly in my configuration.yaml file. Could you please provide an example?

I think this might be the case since I cannot find a nest sensor similar as what you show in your example above:

 - platform: state
      entity_id: sensor.kitchen_thermostat_hvac_state
Error while executing automation automation.nest_auto_target_humidity_control. Unknown error for call_service at pos 1: 
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/automation/__init__.py", line 437, in action
    await script_obj.async_run(variables, context)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 190, in async_run
    await self._handle_action(action, variables, context)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 274, in _handle_action
    await self._actions[_determine_action(action)](action, variables, context)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 357, in _async_call_service
    context=context,
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 97, in async_call_from_config
    domain, service_name, service_data, blocking=blocking, context=context
  File "/usr/src/homeassistant/homeassistant/core.py", line 1236, in async_call
    await asyncio.shield(self._execute_service(handler, service_call))
  File "/usr/src/homeassistant/homeassistant/core.py", line 1261, in _execute_service
    await handler.func(service_call)
  File "/usr/src/homeassistant/homeassistant/components/shell_command/__init__.py", line 78, in async_service_handler
    process = await create_process
  File "/usr/local/lib/python3.7/asyncio/subprocess.py", line 217, in create_subprocess_exec
    stderr=stderr, **kwds)
  File "/usr/local/lib/python3.7/asyncio/base_events.py", line 1529, in subprocess_exec
    bufsize, **kwargs)
  File "/usr/local/lib/python3.7/asyncio/unix_events.py", line 190, in _make_subprocess_transport
    **kwargs)

It sounds like you don’t have a Nest developer account so you won’t be able to use the official Home Assistant Nest integration. However, you shouldn’t need it to use my script. Just remove the two automation triggers related to the thermostat and keep the outside temperature trigger.

thank you! I will try that today.

By the way, have you found your nest to report a fairly accurate humidity reading? Mine seems to report high (~15% higher than a handheld device). So, I was thinking of using a ‘DHT22’ sensor for reading the current humidity.

Thanks @joe248. I tried removing the nest triggers.

looking at the error log some more, I think the issue is calling php. Since I am using hassio and not raspbian , i don’t find php in that directory either in bash… is there a way to check if php is indeed installed & determine the location?


FileNotFoundError: [Errno 2] No such file or directory: '/usr/bin/php': '/usr/bin/php'

I find my Nest to be within about 5% or so of other humidity sensors.

If you have PHP installed, running the command which php should tell you where it is located.

thanks - I re-installed home assistant on top of raspbian. I think I finally configured it… but i keep seeing these errors:

humidity.log


11-28-2019 13:12:11 Setting Nest target humidity to 40% for outside temp 37.4 (current humidity inside = %, outside = 65.0%)
11-28-2019 13:12:12 ERROR: Nest returned:

sudo /usr/bin/php update_nest_target_humidity.php
PHP Notice:  Undefined offset: 0 in /home/homeassistant/.homeassistant/nest.class.php on line 895
PHP Notice:  Undefined property: stdClass::$link in /home/homeassistant/.homeassistant/nest.class.php on line 345
PHP Notice:  Trying to get property '' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 345
PHP Notice:  Trying to get property 'structure' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 345
PHP Notice:  Undefined offset: 1 in /home/homeassistant/.homeassistant/nest.class.php on line 345
PHP Notice:  Undefined property: stdClass::$ in /home/homeassistant/.homeassistant/nest.class.php on line 346
PHP Notice:  Trying to get property 'away' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 346
PHP Notice:  Undefined property: stdClass::$device in /home/homeassistant/.homeassistant/nest.class.php on line 347
PHP Notice:  Trying to get property '' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 347
PHP Notice:  Trying to get property 'current_schedule_mode' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 347
PHP Notice:  Undefined property: stdClass::$shared in /home/homeassistant/.homeassistant/nest.class.php on line 348
PHP Notice:  Trying to get property '' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 348
PHP Notice:  Trying to get property 'target_temperature_type' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 348
PHP Notice:  Undefined property: stdClass::$device in /home/homeassistant/.homeassistant/nest.class.php on line 349
PHP Notice:  Trying to get property '' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 349
PHP Notice:  Trying to get property 'eco' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 349
PHP Notice:  Trying to get property 'mode' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 349
PHP Notice:  Undefined property: stdClass::$device in /home/homeassistant/.homeassistant/nest.class.php on line 357
PHP Notice:  Trying to get property '' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 357
PHP Notice:  Trying to get property 'away_temperature_low_enabled' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 357
PHP Notice:  Undefined property: stdClass::$device in /home/homeassistant/.homeassistant/nest.class.php on line 364
PHP Notice:  Trying to get property '' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 364
PHP Notice:  Trying to get property 'away_temperature_low_enabled' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 364
PHP Notice:  Undefined property: stdClass::$device in /home/homeassistant/.homeassistant/nest.class.php on line 368
PHP Notice:  Trying to get property '' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 368
PHP Notice:  Trying to get property 'away_temperature_high_enabled' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 368
PHP Notice:  Undefined property: stdClass::$shared in /home/homeassistant/.homeassistant/nest.class.php on line 399
PHP Notice:  Trying to get property '' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 399
PHP Notice:  Trying to get property 'current_temperature' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 399
PHP Notice:  Undefined offset: 0 in /home/homeassistant/.homeassistant/nest.class.php on line 895
PHP Notice:  Undefined offset: 0 in /home/homeassistant/.homeassistant/nest.class.php on line 895
PHP Notice:  Undefined property: stdClass::$device in /home/homeassistant/.homeassistant/nest.class.php on line 851
PHP Notice:  Trying to get property '' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 851
PHP Notice:  Trying to get property 'temperature_scale' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 851
PHP Notice:  Undefined property: stdClass::$device in /home/homeassistant/.homeassistant/nest.class.php on line 400
PHP Notice:  Trying to get property '' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 400
PHP Notice:  Trying to get property 'current_humidity' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 400
PHP Notice:  Undefined property: stdClass::$shared in /home/homeassistant/.homeassistant/nest.class.php on line 401
PHP Notice:  Trying to get property '' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 401
PHP Notice:  Trying to get property 'hvac_ac_state' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 401
PHP Notice:  Undefined property: stdClass::$shared in /home/homeassistant/.homeassistant/nest.class.php on line 402
PHP Notice:  Trying to get property '' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 402
PHP Notice:  Trying to get property 'hvac_heater_state' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 402
PHP Notice:  Undefined property: stdClass::$shared in /home/homeassistant/.homeassistant/nest.class.php on line 403
PHP Notice:  Trying to get property '' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 403
PHP Notice:  Trying to get property 'hvac_alt_heat_state' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 403
PHP Notice:  Undefined property: stdClass::$shared in /home/homeassistant/.homeassistant/nest.class.php on line 404
PHP Notice:  Trying to get property '' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 404
PHP Notice:  Trying to get property 'hvac_fan_state' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 404
PHP Notice:  Undefined property: stdClass::$shared in /home/homeassistant/.homeassistant/nest.class.php on line 405
PHP Notice:  Trying to get property '' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 405
PHP Notice:  Trying to get property 'auto_away' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 405
PHP Notice:  Undefined property: stdClass::$device in /home/homeassistant/.homeassistant/nest.class.php on line 408
PHP Notice:  Trying to get property '' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 408
PHP Notice:  Trying to get property 'leaf' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 408
PHP Notice:  Undefined property: stdClass::$device in /home/homeassistant/.homeassistant/nest.class.php on line 409
PHP Notice:  Trying to get property '' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 409
PHP Notice:  Trying to get property 'battery_level' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 409
PHP Notice:  Undefined property: stdClass::$shared in /home/homeassistant/.homeassistant/nest.class.php on line 412
PHP Notice:  Trying to get property '' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 412
PHP Notice:  Trying to get property 'hvac_heater_state' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 412
PHP Notice:  Undefined property: stdClass::$shared in /home/homeassistant/.homeassistant/nest.class.php on line 413
PHP Notice:  Trying to get property '' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 413
PHP Notice:  Trying to get property 'hvac_heat_x2_state' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 413
PHP Notice:  Undefined property: stdClass::$shared in /home/homeassistant/.homeassistant/nest.class.php on line 414
PHP Notice:  Trying to get property '' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 414
PHP Notice:  Trying to get property 'hvac_heat_x3_state' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 414
PHP Notice:  Undefined property: stdClass::$shared in /home/homeassistant/.homeassistant/nest.class.php on line 415
PHP Notice:  Trying to get property '' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 415
PHP Notice:  Trying to get property 'hvac_alt_heat_state' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 415
PHP Notice:  Undefined property: stdClass::$shared in /home/homeassistant/.homeassistant/nest.class.php on line 416
PHP Notice:  Trying to get property '' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 416
PHP Notice:  Trying to get property 'hvac_alt_heat_x2_state' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 416
PHP Notice:  Undefined property: stdClass::$shared in /home/homeassistant/.homeassistant/nest.class.php on line 417
PHP Notice:  Trying to get property '' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 417
PHP Notice:  Trying to get property 'hvac_aux_heater_state' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 417
PHP Notice:  Undefined property: stdClass::$shared in /home/homeassistant/.homeassistant/nest.class.php on line 418
PHP Notice:  Trying to get property '' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 418
PHP Notice:  Trying to get property 'hvac_emer_heat_state' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 418
PHP Notice:  Undefined property: stdClass::$shared in /home/homeassistant/.homeassistant/nest.class.php on line 421
PHP Notice:  Trying to get property '' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 421
PHP Notice:  Trying to get property 'hvac_ac_state' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 421
PHP Notice:  Undefined property: stdClass::$shared in /home/homeassistant/.homeassistant/nest.class.php on line 422
PHP Notice:  Trying to get property '' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 422
PHP Notice:  Trying to get property 'hvac_cool_x2_state' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 422
PHP Notice:  Undefined property: stdClass::$shared in /home/homeassistant/.homeassistant/nest.class.php on line 423
PHP Notice:  Trying to get property '' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 423
PHP Notice:  Trying to get property 'hvac_cool_x3_state' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 423
PHP Notice:  Undefined property: stdClass::$device in /home/homeassistant/.homeassistant/nest.class.php on line 427
PHP Notice:  Trying to get property '' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 427
PHP Notice:  Trying to get property 'auto_away_enable' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 427
PHP Notice:  Undefined property: stdClass::$device in /home/homeassistant/.homeassistant/nest.class.php on line 429
PHP Notice:  Trying to get property '' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 429
PHP Notice:  Trying to get property 'away_temperature_low_enabled' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 429
PHP Notice:  Undefined property: stdClass::$device in /home/homeassistant/.homeassistant/nest.class.php on line 430
PHP Notice:  Trying to get property '' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 430
PHP Notice:  Trying to get property 'away_temperature_high_enabled' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 430
PHP Notice:  Undefined property: stdClass::$device in /home/homeassistant/.homeassistant/nest.class.php on line 436
PHP Notice:  Trying to get property '' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 436
PHP Notice:  Trying to get property 'time_to_target' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 436
PHP Notice:  Undefined property: stdClass::$device in /home/homeassistant/.homeassistant/nest.class.php on line 438
PHP Notice:  Trying to get property '' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 438
PHP Notice:  Trying to get property 'serial_number' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 438
PHP Notice:  Undefined property: stdClass::$device in /home/homeassistant/.homeassistant/nest.class.php on line 439
PHP Notice:  Trying to get property '' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 439
PHP Notice:  Trying to get property 'temperature_scale' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 439
PHP Notice:  Undefined offset: 0 in /home/homeassistant/.homeassistant/nest.class.php on line 895
PHP Notice:  Undefined property: stdClass::$track in /home/homeassistant/.homeassistant/nest.class.php on line 920
PHP Notice:  Trying to get property '' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 920
PHP Notice:  Trying to get property 'online' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 922
PHP Notice:  Trying to get property 'last_connection' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 923
PHP Notice:  Trying to get property 'last_connection' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 924
PHP Notice:  Undefined property: stdClass::$device in /home/homeassistant/.homeassistant/nest.class.php on line 926
PHP Notice:  Trying to get property '' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 926
PHP Notice:  Trying to get property 'local_ip' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 926
PHP Notice:  Undefined property: stdClass::$device in /home/homeassistant/.homeassistant/nest.class.php on line 927
PHP Notice:  Trying to get property '' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 927
PHP Notice:  Trying to get property 'mac_address' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 927
PHP Notice:  Undefined property: stdClass::$device in /home/homeassistant/.homeassistant/nest.class.php on line 443
PHP Notice:  Trying to get property '' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 443
PHP Notice:  Trying to get property 'leaf_threshold_cool' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 443
PHP Notice:  Undefined property: stdClass::$device in /home/homeassistant/.homeassistant/nest.class.php on line 444
PHP Notice:  Trying to get property '' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 444
PHP Notice:  Trying to get property 'leaf_threshold_heat' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 444
PHP Notice:  Undefined property: stdClass::$device in /home/homeassistant/.homeassistant/nest.class.php on line 444
PHP Notice:  Trying to get property '' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 444
PHP Notice:  Trying to get property 'leaf_threshold_heat' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 444
PHP Notice:  Undefined offset: 0 in /home/homeassistant/.homeassistant/nest.class.php on line 895
PHP Notice:  Undefined offset: 0 in /home/homeassistant/.homeassistant/nest.class.php on line 895
PHP Notice:  Undefined property: stdClass::$device in /home/homeassistant/.homeassistant/nest.class.php on line 851
PHP Notice:  Trying to get property '' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 851
PHP Notice:  Trying to get property 'temperature_scale' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 851
PHP Notice:  Undefined property: stdClass::$device in /home/homeassistant/.homeassistant/nest.class.php on line 447
PHP Notice:  Trying to get property '' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 447
PHP Notice:  Trying to get property 'has_humidifier' of non-object in /home/homeassistant/.homeassistant/nest.class.php on line 447
PHP Notice:  Undefined property: stdClass::$humidity in /home/homeassistant/.homeassistant/update_nest_target_humidity.php on line 16
PHP Fatal error:  Uncaught Exception: Missing input for outside temperature in /home/homeassistant/.homeassistant/update_nest_target_humidity.php:24
Stack trace:
#0 {main}
  thrown in /home/homeassistant/.homeassistant/update_nest_target_humidity.php on line 24

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?