Nest/ Node Red help needed

I’m using a thermostat (Nest) and I am new to node red myself and I’m completely lost as to how and where to begin. I’m not sure how to make a flow for what I’m trying to achieve. I am trying to setup a flow that does this If any of the doors or windows are open for more than 5 minutes then turn off the HVAC. If the HVAC is off and a door or window closes and all doors and windows are closed then resume HVAC.

What I have tried and failed with is connecting a state changed to a stop timer and lastly the call service.

Another issue i am having is when I enter {“entity_id”:“climate.downstairs”,“auto_away”: ‘on’} the box remains red

Forgot to mention Im using Homeassistant /Hassio

Is there a reason why you want to use Node Red instead of an automation in Home Assistant?

I’m not able to access my NR currently to try it for real, but I think I can point you in the right direction

If any of the doors or windows are open for more than 5 minutes then turn off the HVAC.

Use a state change node for each window/door, and connect each to a switch. The switch routes for on/off:

  • On -> stoptimer node (starts the timer)
  • Off -> change node, set payload to “STOP” -> same stoptimer as above (cancels timer)

Connect each stoptimer to one current state node for the HVAC. Connect that to a switch (if on, continue) -> call service to torn off HVAC.

So you will have a bunch of inputs, each with their own timer. If one of the timers successfully completes, it checks the state of the HVAC, and then if necessary turns it off.

If the HVAC is off and a door or window closes and all doors and windows are closed then resume HVAC.

I think this could be easier if you put all your doors and windows in a group in home assistant, then use a state change node to monitor the group

state change node (halt if on) -> current state of HVAC -> switch node - if off -> call service to turn on HVAC

I’m new to HA and am struggling at writing at yamls. Noone has offered to help me out except point me towards Node-Red saying it’s easier. Now I’m stuck in-between trying to learn a little of both and failing on both ends

Thanks I will try this in the a.m. hopefully I can pull it off. Your detailed post should hopefully walk me down the path to success​:crossed_fingers:t2::crossed_fingers:t2::crossed_fingers:t2:

I hear ya. Well, let’s get you up and running in HA with this automation. I use Node-Red too but honestly, I find the more you use 2 systems, the more chances of failure.

Since I don’t know the names of your entities, you’ll have to modify it a bit, but here’s what you’d need to do in yaml. You can then decide, which you’d like to use.

Let’s assume you have 4 sensors (add more as needed) and start by creating a template binary sensor. This will report “on” if any one of your sensors are reporting open or off if they are all closed.

binary_sensor:
  - platform: template
    sensors:
      windows_doors_open:
        friendly_name: 'Open Windows or Doors'
        entity_id:
          - sensor.front_door
          - sensor.window
          - sensor.upstairs_window
          - sensor.basment_window
        value_template: >
           {% if is_state("sensor.front_door", "open")%}on
           {% elif is_state("sensor.window", "open")%}on
           {% elif is_state("sensor.upstairs_window", "open")%}on
           {% elif is_state("sensor.basement_window", "open")%}on
           {% else %}off
           {% endif %}

Next we need two automations, one for turning your Nest on and the other for turning it off:

automation:
  - alias: "Nest - Turn Off with Open Windows"
    id: "Nest_Off_With_Open_Window"
    initial_state: on
    trigger:
      - platform: state
        entity_id: binary_sensor.windows_doors_open
        to: 'on'
        for:
          minutes: 5
    action:
      - service: climate.turn_off
        entity_id: climate.downstairs

  - alias: "Nest - Turn On with Windows Closed"
    id: "Nest_On_With_Closed_Windows"
    initial_state: on
    trigger:
      - platform: state
        entity_id: binary_sensor.windows_doors_open
        to: 'off'
    condition:
      condition: and
      conditions:
          - condition: template
            value_template: '{{ is_state("climate.downstairs", "off") }}'
    action:
      - service: climate.turn_on
        entity_id: climate.downstairs
1 Like

It’s easier if you know what you’re doing! Node-Red may be easier then but yaml is easier to get your head around to start with, it’s all there in front of you so you can follow it through easily, make tweaks as you go and learn for next time. Node-red looks easy with it’s pretty building block UI but it’s what’s inside those little boxes which is the important part and the programming like speak inside those isn’t as obvious until you understand it.

Using yaml you can often find some existing code that is close to what you want, or a kind soul like @Jer78 will produce a starting point for you like he has, and away you go.

I don’t have any programming knowledge and tried node-red but after doing a few simple on/offs went back to yaml for all the reasons above.

2 Likes

Thank you!!! So I tried the node red way step by step and nothing happened. Then I inserted your code into my automations yaml made sure it passed the config test and it was invalid. Theres no doubt in my mind that I am the issue and I am doing something terribly wrong. I’m a bit embarrassed since you guys are really being helpful.

@Matt112 Don’t worry, it’s bound to happen. If I had a nickel for every invalid config I’d be rich! lol
I tested the code in my setup and works, so I think it’s a spacing issue, can you post your entire automations.yaml and use the </> in the toolbar above so I can help figure where the problem is? Thanks