2 Automation on same " Actions"

hi there.
i have 2 Automation

1 is Triggers by “humidity”
1 is Triggers by “light_level”

starting the same fan “switch.th_10_01”

Triggers by “light_level” working fine
Triggers by “humidity” is working fine but when “light_level” has been trigger then “humidity” don’t continue to activate if humidity is over 85%

can you help
grettings
tommy


id: '1563718947193'
  alias: Toilet Fan Over 85%
  trigger:
  - above: '85'
    entity_id: sensor.th_10_01_am2301_humidity
    platform: numeric_state
  condition: []
  action:
  - data:
      entity_id: switch.th_10_01
    service: switch.turn_on
- id: '1563720264146'
  alias: Toilet Fan Under 84%
  trigger:
  - above: '0'
    below: '84'
    entity_id: sensor.th_10_01_am2301_humidity
    for: 00:00:30
    platform: numeric_state
  condition: []
  action:
  - data:
      entity_id: switch.th_10_01
    service: switch.turn_off
- id: '1563727520038'
  alias: Fan Lys ON
  trigger:
  - above: '3'
    entity_id: sensor.wc_sensor_light_level
    for: 00:00:30
    platform: numeric_state
  condition: []
  action:
  - data:
      entity_id: switch.th_10_01
    service: switch.turn_on
- id: '1563727609877'
  alias: Fan Lys OFF
  trigger:
  - below: '2'
    entity_id: sensor.wc_sensor_light_level
    for: 00:05:00
    platform: numeric_state
  condition: []
  action:
  - data:
      entity_id: switch.th_10_01
    service: switch.turn_off

hint: please format your code!

Please define what you want this to do. It is hard to understand from this.

To me these seem fine as individual automations but together they are like two hands eating the same banana without knowledge over the other hand whose turn is to eat.

What are the conditions it need to run? No running during the night as you turn it off when low light? Or is that closed space?

Automations trigger on state change, so if the sequence is:

light comes on --> fan turns on
humidity goes over 85 --> fan turns on, but that does nothing 'cos it is already on
light turns off --> fan turns off

It doesn’t matter at that stage if the humidity is over 85, as the fan is only turned on when it goes from 84 (or less) to 85.

I think the solution is to put a condition on the light-off automation that it humidity is less than 85.

hi .
the ```wc_sensor_light_level

i have hue motion detector for the toilet lights and use it for turning on the toilet fan
when the lights is on an it wil run for 5 min after the lights is off " get rit of smell GG"
runs 24h and works fine

the other if for when we have taken a bath the humidity is triggering the fan for getting rit of it.
start at 85% an up
stop at lover 84

grettings
tommy

that is the rigt problem.
when the humidity trigger on over 85% on off 84% it works fine
it´s only as you describe it falling

grettings
tommy

The toilet fan is controlled by:

  • humidity level
  • light level

If the fan is turned on by high humidity, you don’t want it turned off by low light.

The simplest way to achieve this is to use a ‘flag’ to indicate that the fan was turned on by high humidity. Low light checks this flag and, if set, won’t turn off the fan.

This example uses an input_boolean to serve as the flag.

input_boolean:
  humidity_flag:
    name: Fan Humidity Flag

High humidity level turns on the fan and turns on input_boolean.humidity_flag.

- id: '1563718947193'
  alias: 'Toilet Fan Over 85%'
  trigger:
  - platform: numeric_state
    entity_id: sensor.th_10_01_am2301_humidity
    above: '85'
  action:
  - service: switch.turn_on
    entity_id: switch.th_10_01
  - service: input_boolean.turn_on
    entity_id: input_boolean.humidity_flag  

Normal humidity level turns off the fan and the humidity_flag.

- id: '1563720264146'
  alias: 'Toilet Fan Under 84%'
  trigger:
  - platform: numeric_state
    entity_id: sensor.th_10_01_am2301_humidity
    below: '84'
    for: 00:00:30
  action:
  - service: switch.turn_off
    entity_id: switch.th_10_01
  - service: input_boolean.turn_off
    entity_id: input_boolean.humidity_flag 

High light level turns on the fan.

- id: '1563727520038'
  alias: 'Fan Lys ON'
  trigger:
  - platform: numeric_state
    entity_id: sensor.wc_sensor_light_level
    above: '3'
    for: 00:00:30
  action:
  - service: switch.turn_on
    entity_id: switch.th_10_01

Low light level turns off the fan only if the humidity_flag is off.

- id: '1563727609877'
  alias: 'Fan Lys OFF'
  trigger:
  - platform: numeric_state
    entity_id: sensor.wc_sensor_light_level
    below: '2'
    for: 00:05:00
  condition:
    condition: state
    entity_id: input_boolean.humidity_flag
    state: 'off'
  action:
  - service: switch.turn_off
    entity_id: switch.th_10_01

hi there

sorry for the new-bee question :woozy_face:

input_boolean:
  humidity_flag:
    name: Fan Humidity Flag

where shall i put that ?
in configuration.yaml ?

i gets fails when i put it in automations.yaml

Yes, in configuration.yaml and then you will have to restart Home Assistant in order to have the input_boolean created as a new entity.

A 1000 Thanks for the help

now it is working like i wish for :+1::+1::+1::+1::+1::+1::+1::+1::+1:

grettings
tommy

1 Like

You’re welcome!

Please mark my post with the Solution checkmark. Only you, the author of this topic, can do that. after marking it, it will make the solution easier to find for other users. It will automatically appear as a link directly below your first post.

While the input_boolean solution works, this is the “right” answer. The input_boolean is really not needed. This can be done in two automations:

id: '1563718947193'
  alias: turn_on_fan
  trigger:
  - above: 85
    entity_id: sensor.th_10_01_am2301_humidity
    platform: numeric_state
  - above: 3
    entity_id: sensor.wc_sensor_light_level
    for: 00:00:30
    platform: numeric_state
  condition:
  - above: 85
    entity_id: sensor.th_10_01_am2301_humidity
    condition: numeric_state
  - above: 3
    entity_id: sensor.wc_sensor_light_level
    condition: numeric_state
  action:
  - data:
      entity_id: switch.th_10_01
    service: switch.turn_on

- id: '1563720264146'
  alias: turn_off_fan
  trigger:
  - above: 0
    below: 84
    entity_id: sensor.th_10_01_am2301_humidity
    for: 00:00:30
    platform: numeric_state
  - below: 2
    entity_id: sensor.wc_sensor_light_level
    for: 00:05:00
    platform: numeric_state
  condition:
  - above: 0
    below: 84
    entity_id: sensor.th_10_01_am2301_humidity
    condition: numeric_state
  - below: 2
    entity_id: sensor.wc_sensor_light_level
    condition: numeric_state
  action:
  - data:
      entity_id: switch.th_10_01
    service: switch.turn_off

(untested, may have typos)

hi. and thanks

i will test it later and see if it do it´s magic

grettings
tommy

Isn’t the requirement that either the humidity > 85 OR the light_level > 3?

By default, multiple conditions are logically ANDed. That means the first automation will turn on the fan only if both of its conditions are true (humidity > 85 AND light_level > 3).

is this ok
vi kan skrive på dansk ;o)

Please edit your post for spelling. It is damned hard to read like that.

Dont work

The:`id: ‘1563718947193’
alias: turn_on_fan
trigger:

  • above: 85
    entity_id: sensor.th_10_01_am2301_humidity
    platform: numeric_state
  • above: 3
    entity_id: sensor.wc_sensor_light_level
    for: 00:00:30
    platform: numeric_state
    condition:
  • above: 85
    entity_id: sensor.th_10_01_am2301_humidity
    condition: numeric_state
  • above: 3
    entity_id: sensor.wc_sensor_light_level
    condition: numeric_state
    action:
  • data:
    entity_id: switch.th_10_01
    service: switch.turn_on`

do not turn on fan sensor.wc_sensor_light_level

grettings
tommy