Numeric_state automation with Ambient Weather Integration Not Triggering

Tags: #<Tag:0x00007f32525d4220>

I am really struggling with getting an automation to trigger for turning a relay off when a target humidity and temperature are reached. Essentially I want to turn off the relay when a temperature AND relative humidity are in a certain range.

In the most basic case I have the following in the states under developer tools:

{{ states.sensor.liberty_hill_humidity_in.state }} 
34
{{ states.sensor.liberty_hill_temp.state }} 
24.6

{{ states.sensor.liberty_hill_humidity_in }}
<template TemplateState(<state sensor.liberty_hill_humidity_in=34; unit_of_measurement=%, friendly_name=Main Floor RH, device_class=humidity @ 2021-02-21T08:59:51.097616-05:00>)>

{{ states.sensor.liberty_hill_temp }} 
<template TemplateState(<state sensor.liberty_hill_temp=25.2; unit_of_measurement=°F, friendly_name=Outside Temp., device_class=temperature @ 2021-02-21T10:16:52.888312-05:00>)>

My automation is currently stripped down to:

  trigger:
  - platform: time_pattern
    minutes: /1
  condition:
  - condition: device
    type: is_on
    device_id: 0bc7fc57176e25715459e733d2f31b89
    entity_id: switch.flush_1d_relay_current_value_2
    domain: switch
  - condition: numeric_state
    entity_id: sensor.liberty_hill_temp
    value_template: '{{ float(states.sensor.liberty_hill_temp.state) }}'
    above: '20'
    below: '50'
  - condition: numeric_state
    entity_id: sensor.liberty_hill_humidity_in
    above: '35'
    below: '40'
    value_template: '{{ float(states.sensor.liberty_hill_humidity_in.state) }}'
  action:
  - type: turn_off
    device_id: 0bc7fc57176e25715459e733d2f31b89
    entity_id: switch.flush_1d_relay_current_value_2
    domain: switch

It never triggers and when I manually execute it always shuts off the relay even though not all conditions are met. This is driving me crazy at the moment and am not sure how to go about fixing it.

Thank you in advance!

Manually triggering an automation ignores the conditions and jumps straight to the actions.

If you manually trigger it using the Developer Tools / Services UI you have the option to include the conditions.

Also rather than triggering every minute (inefficient) try it like this

  trigger:
  - platform: numeric_state
    entity_id: sensor.liberty_hill_temp
    above: 20
    below: 50
  - platform: numeric_state
    entity_id: sensor.liberty_hill_humidity_in
    above: 35
    below: 40
  condition:
  - condition: state
    entity_id: switch.flush_1d_relay_current_value_2
    state: 'on'
  - condition: numeric_state
    entity_id: sensor.liberty_hill_temp
    above: 20
    below: 50
  - condition: numeric_state
    entity_id: sensor.liberty_hill_humidity_in
    above: 35
    below: 40
  action:
  - service: switch.turn_off
    entity_id: switch.flush_1d_relay_current_value_2

Thank you, I had no idea it worked like that…my ignorance. Toggling it the way you said it works correctly, I think. However it still doesn’t trigger every minute. I assume that means something is still incorrect.

See the example I just edited into my post above.

This will only switch the switch off if it is on and the two sensors are in the ranges specified.

Interesting, I will give that a shot. Quick question on that. Is there a way to do AND/OR on those triggers or should I do an automation per range? Essentially I would like to turn it off like (I think):

 - condition: or
      conditions:
        - condition: state
          entity_id: sensor.liberty_hill_humidity_in
          above: 35
          below: 40
        - condition: state
          entity_id: sensor.liberty_hill_temp
          above: 20
          below: 50
    - condition: or
      conditions:
        - condition: state
          entity_id: sensor.liberty_hill_humidity_in
          above: 30
          below: 35
        - condition: state
          entity_id: sensor.liberty_hill_temp
          above: 10
          below: 20
    - condition: or
      conditions:
        - condition: state
          entity_id: sensor.liberty_hill_humidity_in
          above: 25
          below: 30
        - condition: state
          entity_id: sensor.liberty_hill_temp
          above: 0
          below: 10
    - condition: or
      conditions:
        - condition: state
          entity_id: sensor.liberty_hill_humidity_in
          above: 20
          below: 25
        - condition: state
          entity_id: sensor.liberty_hill_temp
          above: -10
          below: 0
    - condition: or
      conditions:
        - condition: state
          entity_id: sensor.liberty_hill_humidity_in
          above: 15
          below: 20
        - condition: state
          entity_id: sensor.liberty_hill_temp
          above: -20
          below: -10

Triggers are OR (any one can trigger).

Conditions are AND by default.

So the net effect of including your triggers as conditions as well is to have AND logic for the triggers.

As to your new conditions you would be better off using these triggers with them:

  trigger:
  - platform: numeric_state
    entity_id: sensor.liberty_hill_temp
  - platform: numeric_state
    entity_id: sensor.liberty_hill_humidity_in

That way any change in either sensor will then be checked against your multiple sets of conditions.

So I ran into an issue where the trigger needs to have an above or below defined. I tried to set it to Above -100 and Above 0 thinking it will be triggered each time it changes but this still fails to trigger. Any other ideas how to get it to trigger on each temperature or humidity change?

  trigger:
  - platform: numeric_state
    entity_id: sensor.liberty_hill_humidity_in
    above: '0'
  - platform: numeric_state
    entity_id: sensor.liberty_hill_temp
    above: '-100'
  condition:
  - condition: device
    type: is_on
    device_id: 0bc7fc57176e25715459e733d2f31b89
    entity_id: switch.flush_1d_relay_current_value_2
    domain: switch
  - condition: or
    conditions:
    - condition: and
      conditions:
      - condition: numeric_state
        entity_id: sensor.liberty_hill_humidity_in
        above: '35'
        below: '40'
      - condition: numeric_state
        entity_id: sensor.liberty_hill_temp
        above: '20'
        below: '50'
    - condition: and
      conditions:
      - condition: numeric_state
        entity_id: sensor.liberty_hill_humidity_in
        above: '30'
        below: '35'
      - condition: numeric_state
        entity_id: sensor.liberty_hill_temp
        above: '10'
        below: '20'
    - condition: and
      conditions:
      - condition: numeric_state
        entity_id: sensor.liberty_hill_humidity_in
        above: '25'
        below: '30'
      - condition: numeric_state
        entity_id: sensor.liberty_hill_temp
        above: '0'
        below: '10'
    - condition: and
      conditions:
      - condition: numeric_state
        entity_id: sensor.liberty_hill_humidity_in
        above: '20'
        below: '25'
      - condition: numeric_state
        entity_id: sensor.liberty_hill_temp
        above: '-10'
        below: '0'
    - condition: and
      conditions:
      - condition: numeric_state
        entity_id: sensor.liberty_hill_humidity_in
        above: '15'
        below: '20'
      - condition: numeric_state
        entity_id: sensor.liberty_hill_temp
        above: '-20'
        below: '-10'
    - condition: and
      conditions:
      - condition: numeric_state
        entity_id: sensor.liberty_hill_humidity_in
        above: '15'
      - condition: numeric_state
        entity_id: sensor.liberty_hill_temp
        below: '-20'
    - condition: and
      conditions:
      - condition: numeric_state
        entity_id: sensor.liberty_hill_humidity_in
        above: '50'
      - condition: numeric_state
        entity_id: sensor.liberty_hill_temp
        above: '50'

Above 0 is above -100. All you need is above -100.

Well its two different sensors. A humidity and a temperature. So I set humidity above 0% (always trigger) and temperature about -100 (should never be that cold here. Is there a way to tell if it was triggered? Maybe its an issue with my conditionals…I would expect the first AND under the OR to be valid. Since its 38 degrees outside and 37% humidity.

When I run it from developer tools like this:

entity_id: automation.maintain_humidity_off
skip_condition: false

It shuts off the humidifier. It just doesn’t appear to trigger by itself ever.

Running the corresponding on automation the same way automatically turns it on too:

  trigger:
  - platform: numeric_state
    entity_id: sensor.liberty_hill_humidity_in
    below: '30'
  condition:
  - condition: device
    type: is_off
    device_id: 0bc7fc57176e25715459e733d2f31b89
    entity_id: switch.flush_1d_relay_current_value_2
    domain: switch
  - condition: state
    entity_id: climate.z_wave_thermostat_thermostat_mode
    state: heat
  action:
  - type: turn_on
    device_id: 0bc7fc57176e25715459e733d2f31b89
    entity_id: switch.flush_1d_relay_current_value_2
    domain: switch

I suspect this is an issue with the conditions not parsing correctly.

Sorry. Missed that. On tiny screen mobile. Will have a look when I get to my desk later.

No worries, I am just really stuck. I am not sure where to go next.

That’s not how numeric state triggers work.

They trigger when crossing the above or below threshold. By setting the limits so wide your triggers will never occur because they will never cross these values.

Use these triggers to trigger on every change of state:

  trigger:
  - platform: state
    entity_id: sensor.liberty_hill_temp
  - platform: state
    entity_id: sensor.liberty_hill_humidity_in